Add code inside specific wordpress standard function

It depends what you want to do. If you look into the function definition, you’ll notice some do_action(): For example: do_action( ‘delete_attachment’, $post_id ); do_action( ‘delete_post’, $post_id ); do_action( ‘deleted_post’, $post_id ); These are points, called hooks in WordPress, where you can actually run your stuff. Hooks will help you to modify the core behaviour … 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