Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: My Plugin
- Plugin URI: https://stackoverflow.com/q/48890836/9217760
- Description: Just a simple test plugin.
- Version: 20180221.1
- */
- // Either of these worked for me.
- /*global $my_vars;
- $my_vars = '1';*/
- $GLOBALS['my_vars'] = '1';
- // THIS IS REALLY JUST A TEST. =)
- function my_plugin_option( $name ) {
- if ( 'my_vars' === $name ) {
- return '1';
- }
- }
- // You'll need to turn on WP_DEBUG and WP_DEBUG_LOG; then see wp-content/debug.log
- // after plugin activation.
- register_activation_hook( __FILE__, 'my_plugin_activation' );
- function my_plugin_activation() {
- global $my_vars;
- error_log( var_export( $my_vars, true ) ); // NULL if $my_vars wasn't defined with "global" or $GLOBALS
- error_log( my_plugin_option( 'my_vars' ) ); // 1
- error_log( '"My Plugin" has been activated.' );
- }
- // You'll need to turn on WP_DEBUG and WP_DEBUG_LOG; then see wp-content/debug.log
- // after plugin deactivation.
- register_deactivation_hook( __FILE__, 'my_plugin_deactivation' );
- function my_plugin_deactivation() {
- error_log( '"My Plugin" has been deactivated.' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement