How to show phpinfo() only in a new tab?

If you are displaying the info in the front-end, hook into wp or init, otherwise init or admin_init will work on admin: add_action(‘wp’, function() { if( current_user_can(“manage_options”) && ! is_feed() && isset( $_GET[“my_plugin_show_phpinfo”] ) ) { ?> <!– Output things –> <?php phpinfo(); ?> <?php exit; } }); Now if you go to http://example.com/?my_plugin_show_phpinfo=1 it … Read more

Plugin Development Output

It appears you are missing your plugin folder when enqueueing your scripts. plugins_url outputs the URL to your wp plugins folder it does not include your custom plugin folder. wp_register_script( ‘script_js’, plugins_url(‘/YOUR_FOLDER/js/script.js’)); // Add your plugin folder wp_register_script( ‘script_js’, plugins_url(‘/js/script.js’,__FILE__)); // Let php add your folder Also you don’t need to register your scripts / … Read more

Global State During an Admin Post

When using admin-post.php, no loaded menus on an admin-post.php request is standard wordpress behavior. Standard practise to redirect after processing done on post action hook is to use: wp_redirect( admin_url( ‘admin.php?page=YOUR_PAGE’ ) ); When using admin-post.php, wordpress will include wp-admin/includes/wp-admin.php instead of wp-admin/wp-admin.php ( WordPress Admin Bootstrap ) to skip some setup. One of the … Read more