4

I would like to add some external content to the plugin information displayed on the /wp-admin/plugin-install.php admin screens.

/wp-admin/plugin-install.php calls the following:

$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');

And if I hack this core file as a test, I can add the content, I want, OK.

However as a new WP developer I am really struggling to see how I can add this content via a plugin.

class WP_Plugin_Install_List_Table extends WP_List_Table so I don't think I can extend this any further.

Is there a way to add content via a plugin to these screens?

2
  • 2
    You can extend an already extended class. What content do you want to add and where?
    – s_ha_dum
    Oct 17 '13 at 17:55
  • @s_ha_dum I would like to add a couple of rows of text pulled from the external site below each plugins Description in the /wp-admin/plugin-install.php?tab=new or wp-admin/plugin-install.php?tab=popular screens
    – dbm44
    Oct 17 '13 at 19:31
4

Without extending the class, what can be done is adding a Custom Action Link:

add_filter( 'plugin_install_action_links', 'action_links_wpse_119218', 10, 2 );

function action_links_wpse_119218( $links, $plugin )
{
    if( isset( $_GET['tab'] ) )
    {
        switch( $_GET['tab'] )
        {
            case 'featured':                                         
                $links['my-action'] = "Tested up to <a href='#'>{$plugin['tested']}</a>";
            break;                                                   
            case 'popular':                                          
                $links['my-action'] = "Requires <a href='#'>{$plugin['requires']}</a>";
            break;                                                   
            case 'new':                                              
                $links['my-action'] = "Slug <a href='#'>{$plugin['slug']}</a>";
            break;                                                   
        }
    }
    return $links;
}

enter image description here

And then, you can proceed to move the element around with jQuery:

$('.move-me').each(function(){ /* your_magic(); */ });

That custom link, My view, is added with:

add_filter( 'views_plugin-install', 'views_wpse_119218' );

function views_wpse_119218( $views ){
    $views['my-view'] = '<a href="#">My view</a>';
    return $views;
}

This would be used to create your own custom screen/table with add_action( 'load-plugin-install.php', 'callback' ).

3
  • Thank you very much, that is really helpful, it does however trigger a 'Warning call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'callback()' was given on line 406 in file /home/mysite/public_html/wp-includes/plugin.php' Any ideas how to get rid of this?
    – dbm44
    Oct 18 '13 at 11:15
  • I've updated the answer with PHP5.2 compatible code.
    – brasofilo
    Oct 18 '13 at 11:32
  • Thanks again, you have been really helpful. The solution works very well
    – dbm44
    Oct 18 '13 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.