remove_action on after_setup_theme not working from child theme

I am trying to remove a theme action for an elegant-themes theme using a child theme.. This works when I remove action after add_action code anywhere in the parent theme functions.php. However, it does not work when I add it from child theme functions.php. remove_action (‘after_setup_theme’, ‘et_pb_setup_theme’ , 10); Remove action has same priority 10 … Read more

How to override existing plugin action with new action

I’m using a plugin. It has an action like this. add_action(‘publish_post’, ‘old_action’); function old_action($pid) { “code goes here” } } I’m writing a module for this plugin. So i need to override that old action function with my new action function. This is my new function. function new_action($pid) { “code goes here” } } I … Read more

How to create an API for my plugin?

I have been developing plugins for WordPress, most plugins I have developed use two or three classes, hence not as huge as Buddypress or WooCommerce. I am planning to develop two open source plugins to deliver some sort of complex system (can’t share details at the moment but later during development) where other developers can … Read more

add_action(), add_filter() before or after function

When looking through WordPress snippets/tutorials/plugins I often see add_action() and add_filter() being placed before the function is declared: add_action( ‘publish_post’, ’email_friends’ ); function email_friends( $post_ID ) { $friends=”[email protected], [email protected]”; mail( $friends, “sally’s blog updated” , ‘I just put something on my blog: http://blog.example.com’ ); return $post_ID; } From a logic standpoint this just doesn’t make … Read more

How to enqueue scripts on custom post add/edit pages?

I’m trying to enqueue a JS script only when someone is adding or editing a custom post type I created called “recipes”. Currently the script works ok when I do this: if (is_admin()){ wp_enqueue_script( ‘my-script’ ); } But this loads it in every admin page, I’m assuming I need to hook it to a function … Read more

How to test wp_cron?

This is kind of a stupid question… I scheduled a action to run every hour: if(!wp_next_scheduled(‘my_hourly_events’)) wp_schedule_event(time(), ‘hourly’, ‘my_hourly_events’); add_action(‘my_hourly_events’, ‘the_function_to_run’); function the_function_to_run(){ echo ‘it works!’; } How can I test if this works without waiting an hour? 🙂 I tried adding wp_clear_scheduled_hook(‘my_hourly_events’); before this code and adding wp_cron() after, but I don’t see my … Read more