@MWP\WordPress\Plugin( on="activation|deactivation", file="plugin.php" )
Using this annotation will register your function as a callback for when the plugin is activacted or deactivated on the site.
@Params
on="activation|deactivation"
(required) – Must be one of (‘activation’,’deactivation’)
file="plugin.php"
(required) – The filename of your base plugin file.
@Example Code
/**
* Create a default page on first activation
*
* @MWP\WordPress\Plugin( on="activation", file="plugin.php" )
*
* @return void
*/
public function pluginActivated()
{
if ( ! $this->getSetting( 'plugin_page' ) )
{
$page_id = wp_insert_post( array
(
'post_title' => 'My Plugin Page',
'post_content' => '',
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'post_type' => 'page',
)
);
$this->setSetting( 'plugin_page', $page_id )->saveSettings();
}
}