How to trigger function on theme delete?

As long as you don’t delete your theme by ftp, but use the regular way of switching to another theme in the admin, there is a hook to use, switch_theme. It works like this: add_action(‘switch_theme’, ‘mytheme_setup_options’); function mytheme_setup_options () { delete_option(‘mytheme_option1’); delete_option(‘mytheme_option2′); } There’s a sister hook called after_switch_theme, which you could use, for instance, … Read more

How to use do_action_ref_array?

I haven’t tested this yet but somebody suggested this: add_action( ‘bookly_validate_custom_field’, function ( \stdClass $field, &$errors, $cart_key, \stdClass $field_info ) { // Validation by custom_field id switch ( $field->id ) { case ‘id_value’: if ( /*$invalid == */ true ) { $errors[‘custom_fields’][ $cart_key ][ $field->id ] = __( ‘Invalid’, ‘bookly’ ); } break; } }, … Read more

What is the action hook for an order that fails on frontend checkout in WooCommerce?

You can catch specific status change by using this action hook ‘woocommerce_order_status_{status}’. It is defined in the WC_Order class. This is how you define it: /** * Executed when the status is changed to failed. * @param int $order_id * @param \WC_Order $order */ function wpdg_9291_woocommerce_order_status_failed( $order_id, $order ) { // Do something here } … Read more