2014-01-05, 01:01:27
I've come up with this:
So if there are two actions like those:
that need to be visible and active on pages tab and plugins tab accordingly, the register_plugin() would look like this:
Maybe GS should have something like that natively?
PHP Code:
function dynamic_page_type( array $pairs )
{
foreach( $pairs as $page_type => $action )
{
if( isset( $_GET[ $action ] ) ){
return $page_type;
}
}
}
So if there are two actions like those:
PHP Code:
add_action( 'pages-sidebar', 'createSideMenu', array( $thisfile, 'Pages Option', 'pages_opt' ) );
add_action( 'plugins-sidebar', 'createSideMenu', array( $thisfile, 'Plugins Option', 'plugins_opt' ) );
PHP Code:
register_plugin(
$thisfile, # Plugin id
'MyPlugin', # Plugin name
'1.0.0', # Plugin version
'John Hancock', # Plugin author
'http://website.com', # author website
'A plugin that does things.', # Plugin description
# page type - on which admin tab to display
dynamic_page_type( array( 'pages' => 'pages_opt', 'plugins' => 'plugins_opt' ) ),
'run_MyPlugin' # main function (administration)
);
Maybe GS should have something like that natively?