WP action is not triggering a do_action() call within?

I’ve taken you example and reduced it to this functioning test case: class ClassOne { public static function do_something() { do_action( ‘my_action_1’ ); do_action( ‘my_action_2’ ); } } class ClassTwo { function __construct() { add_action( ‘my_action_2’, [ $this, ‘my_action_2’ ] ); add_action( ‘my_action_1’, [ $this, ‘my_action_1’ ] ); } public function my_action_2() { print “My … Read more

Is there a Woocommerce hook that fires when applying a coupon but before checking if it’s valid?

Its the woocommerce_get_shop_coupon_data filter, example code: add_filter ( ‘woocommerce_get_shop_coupon_data’, ‘mp_create_coupon’, 10, 2 ); function mp_create_coupon( $data, $code ) { // Check if the coupon has already been created in the database global $wpdb; $sql = $wpdb->prepare( “SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type=”shop_coupon” AND post_status=”publish” ORDER BY post_date DESC LIMIT 1;”, $code … Read more

How to redirect to action on custom page within admin section

Get the url of a specific admin page (e.g. the settings page (options-general.php)): admin_url( ‘options-general.php’ ) Codex admin_url() Adding query arguments to an url: $params = array( ‘page’ => $_REQUEST[‘page’], ‘action’ => ‘edit’, ‘rls_element’ => $item[‘rls_name’] ); $url = add_query_arg( $params, $org_url ); Codex add_query_arg() Put a and b together: $params = array( ‘page’ => … Read more

What is the purpose of $merged_filters?

For those of you who may be wondering what this does – I have figured it out. When a new function is added to an action/filter hook, it is added at the end of the array. However, WordPress specifies that those functions are to be executed by priority. When a function is added, merged_filters is … Read more