Forked from bradyvercher/installed-plugin-details.php
Created
April 29, 2019 17:11
-
-
Save cavearr/6ea2d4aaab2cb5cf2cf962cf031ac413 to your computer and use it in GitHub Desktop.
WordPress Plugin: Show a "Details" link for installed plugins to view information from the WordPress.org plugin directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Installed Plugin Details | |
* Description: Show a "Details" link for installed plugins to view information from the WordPress.org plugin directory. | |
* Version: 1.0.0 | |
* Author: Blazer Six | |
* Author URI: http://www.blazersix.com/ | |
* License: GPL-2.0+ | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
* | |
* @package BlazerSix\InstalledPluginDetails | |
* @author Brady Vercher <[email protected]> | |
* @copyright Copyright (c) 2012, Blazer Six, Inc. | |
* @license GPL-2.0+ | |
*/ | |
/** | |
* Main plugin class. | |
*/ | |
class Installed_Plugin_Details { | |
/** | |
* Set up the plugin. | |
* | |
* @since 1.0.0 | |
*/ | |
public function setup() { | |
if ( is_admin() ) { | |
// Display the link with the plugin action links. | |
add_filter( 'plugin_action_links', array( $this, 'plugin_links' ), 10, 3 ); | |
// Display the link with the plugin meta. | |
add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 4 ); | |
} | |
} | |
/** | |
* Add a "details" link to open a thickbox popup with information about | |
* the plugin from the public directory. | |
* | |
* @since 1.0.0 | |
* | |
* @param array $links List of links. | |
* @param string $plugin_file Relative path to the main plugin file from the plugins directory. | |
* @param array $plugin_data Data from the plugin headers. | |
* @return array | |
*/ | |
public function plugin_links( $links, $plugin_file, $plugin_data ) { | |
if ( isset( $plugin_data['PluginURI'] ) && false !== strpos( $plugin_data['PluginURI'], 'http://wordpress.org/extend/plugins/' ) ) { | |
$slug = basename( $plugin_data['PluginURI'] ); | |
$links[] = sprintf( '<a href="%s" class="thickbox" title="%s">%s</a>', | |
self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $slug . '&TB_iframe=true&width=600&height=550' ), | |
esc_attr( sprintf( __( 'More information about %s' ), $plugin_data['Name'] ) ), | |
__( 'Details' ) | |
); | |
} | |
return $links; | |
} | |
} | |
// Initialize the plugin. | |
$installed_plugin_details = new Installed_Plugin_Details; | |
$installed_plugin_details->setup(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment