variable created in page.php is null inside of header.php

Generally said, there should nothing be happening before the get_header() call. So initiate your class if is_page() is true via wp_head action hook. Example: add_action( ‘wp_head’, ‘initiate_my_class’ ); function initiate_my_class() { if ( is_page() ) { //code } } Edit: As @AndrewBartel in his comment said you can globalize your variable or implement some kind … Read more

Refresh or redirect page after activate my plugin

You should be able to do something like this: register_activation_hook(__FILE__, ‘my_plugin_activate’); add_action(‘admin_init’, ‘my_plugin_redirect’); function my_plugin_activate() { add_option(‘my_plugin_do_activation_redirect’, true); } function my_plugin_redirect() { if (get_option(‘my_plugin_do_activation_redirect’, false)) { delete_option(‘my_plugin_do_activation_redirect’); wp_redirect(MY_PLUGIN_SETTINGS_URL); } }

Merge custom plugins in one folder

Choose one file to be the main file of the plugin. From it, use require_once( plugin_dir_path( __FILE__ ) . ‘another-file.php’ ); for each of the other files you want to include. This means the rest of the files no longer need the plugin comment header, just the actual code that does whatever you need it … Read more

Plugin as custom page

If your plugin have to completely control the output of the page, i.e. not taking into account the active theme or other installed plugins, than you can simply prevent WordPress handle that url. For example: add_action(‘init’, function() { if (trim(add_query_arg(array()), “https://wordpress.stackexchange.com/”) === ‘book-search’) { require_once plugin_dir_path( __FILE__ ) . “pages/book-search.php”; exit(); } }); add_query_arg() is … Read more