激活时添加插件设置链接

时间:2011-08-05 作者:idontknowhow

这里我想在我的wordpress插件激活后

激活前

Activate | Edit | Delete
激活后

Settings | Edit | Delete
如何在代码中添加此菜单

2 个回复
SO网友:brasofilo

从我的插件中提取的代码,根据需要进行调整。

add_filter( \'plugin_action_links\', \'wpse_25030_settings_plugin_link\', 10, 2 );

function wpse_25030_settings_plugin_link( $links, $file ) 
{
    if ( $file == plugin_basename(dirname(__FILE__) . \'/many-tips-together.php\') ) 
    {
        /*
         * Insert the link at the beginning
         */
        $in = \'<a href="options-general.php?page=many-tips-together">\' . __(\'Settings\',\'mtt\') . \'</a>\';
        array_unshift($links, $in);

        /*
         * Insert at the end
         */
        // $links[] = \'<a href="options-general.php?page=many-tips-together">\'.__(\'Settings\',\'mtt\').\'</a>\';
    }
    return $links;
}

SO网友:Jorge Rodríguez Trías

    public function my_plugin_action_links( $links ) {
       $mylinks[] = \'<a href="\'. get_admin_url(null, \'admin.php?page=settings\') .\'">\'.__(\'Settings\', \'woocommerce\').\'</a>\';

       return $mylinks + $links;
    }       
正在添加return $mylinks + $links;, 它命令阵列

结束

相关推荐