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 change link of some wordpress pages

Create a blank page and name it panel then go to your created signup template and select parent page panel. Its just below Publish->Page Attributes. /*Add noindex to this page (Add to functions.php)*/ function add_noindex_tags(){ # Add noindex to page. if( is_page(‘panel’) ) echo ‘<meta name=”robots” content=”noindex,nofollow”>’; } add_action(‘wp_head’,’add_noindex_tags’, 4 );

add_filter() function misunderstanding

add_filter ( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 ) Hook a function or method to a specific filter action. WordPress offers filter hooks to allow plugins to modify various types of internal data at runtime. A plugin can modify data by binding a callback to a filter hook. When … 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

Stuck in redirect loop after using wp_login action

After a lot of messing around it turned out that the culprit was the plugin WPML. I’m sketchy on the exact reasons as to why it caused the redirect loop, but it had to do with some unusual settings I was using because I was trying to work around another WPML problem. In other words … Read more