Skip to content

Instantly share code, notes, and snippets.

@bradyvercher
Created February 2, 2013 05:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save bradyvercher/4696210 to your computer and use it in GitHub Desktop.
Save bradyvercher/4696210 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.
<?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 <brady@blazersix.com>
* @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&amp;plugin=' . $slug . '&amp;TB_iframe=true&amp;width=600&amp;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