-
Notifications
You must be signed in to change notification settings - Fork 15
Extending with child plugins
Kaiser edited this page Jan 23, 2015
·
3 revisions
It's pretty easy, as you can read in the brief guide below.
Write a normal plugin with a plugin header.
Then write a simple class that extends the WCM\CurrentAdminInfo\AbstractScreenData
class.
Hook that with a callback into plugins_loaded
. There will automatically be a new tab added
to the help screen tabs that is named like your class.
Your class needs only one method:
- Named
collect()
and does nothing than collecting data to output in your help tab - you can optionally add a second method named
markup()
if you don't want a list. It has one argument: your collected data.
The same again, but as an example. The Bootstrap.php
main class:
<?php
/** Plugin Name: (WCM) CAI Extension */
add_action( 'plugins_loaded', function()
{
if ( ! is_admin() )
return;
$extension = new YourVendorName\YourExtension;
$extension->setup();
} );
The actual class collecting and formatting data
<?php
namespace YourVendorName;
class YourExtension extends WCM\CurrentAdminInfo\AbstractScreenData;
{
public function collect()
{
// Your data collecting logic goes here
}
// This method is optional and formats your output
protected function markup( $set )
{
sort( $set );
// Custom formatting goes here
}
}