Why does my wp_safe_redirect output the ERR_TOO_MANY_REDIRECTS error?

Because you’re in an infinite loop. When the user visits the site, init fires, and they get redirected to themes.php?page=theme_setup Then they arrive on themes.php?page=theme_setup and the init hook fires and redirects them to themes.php?page=theme_setup So then they arrive on themes.php?page=theme_setup and the init hook fires and redirects them to themes.php?page=theme_setup So then they arrive … Read more

Payment before publishing post

Use below code add_action(‘transition_post_status’, ‘send_new_post’, 10, 3); // Listen for publishing of a new post function send_new_post($new_status, $old_status, $post) { if(‘publish’ === $new_status && ‘publish’ !== $old_status && $post->post_type === ‘post’) { // Do something! } }

WooCommerce Hook: Content get’s displayed twice and not AFTER the order total

In case it helps anyone, the do_action(‘woocommerce_review_order_after_order_total’) is called in the middle of a table in the template and expects a table row to be echoed by the add_action hook. If you just echo text or, as in the question, an input, it falls outside the table, appears before not after the table and presumably … Read more

Error call_user_func_array() expects parameter 1 to be a valid callback when using image_size_names_choose

You can’t define a hook callback function inside another function. You’ve defined my_custom_sizes() inside setup(), which means that my_custom_sizes() cannot be called outside of the scope of setup(). This is a problem because the hook, image_size_names_choose, is not run inside your setup() function. You need to define your callback in the global scope: function setup() … Read more

What is @Action in WordPress?

This is called php annotations. Many of them are built-in via a standard called phpdoc (like @var), and they are used by the interpreter or the static tools (also by humans for a more structured comment). There is another usecase for these annotations, and it’s to run some code – probably using reflections (which usually … Read more

register_activation_hook in oop approach

It doesn’t really matter. If you simply must have it inside a class, I would use a constant and a static method. // in the main plugin file define( ‘MYPLUGIN_FILE’, __FILE__ ); // include another file with this class in class MyPlugin { public static function init() { register_activation_hook( MYPLUGIN_FILE, array( ‘MyPlugin’, ‘install’ )); } … Read more