How to display message (with switch_theme hook) after deactivating My theme?

It’s impossible, because after deactivation your theme isn’t even loaded! It’s possible, but hacky. Essentially, we unset the action param, load in the themes admin page & then exit before the redirect-on-success occurs. add_action( ‘switch_theme’, ‘wpse_60972_theme_deactivate_message’ ); function wpse_60972_theme_deactivate_message() { $msg = ‘ <div class=”error”> <p>Your theme has been DEACTIVATED</p> </div>’; add_action( ‘admin_notices’, create_function( ”, … Read more

need help looping add_action in wp

You can try something like this: $dynValue=5;//loop this many times //start of my loop for ($num=1; $num <= $dynValue; $num++){ add_action(‘add_meta_boxes’, create_function(”, ‘//some content’)); // Write the php code as if it was to put it in an echo/print instruction. // More details: http://php.net/manual/en/function.create-function.php }//end of my loop

Add/remove action on jQuery toggle

I ended up not adding/removing the action at all, but rather writing an option to the database and having a second plugin check if the option is set: function av_maintenance_mode_check() { if( !wp_verify_nonce( $_GET[‘nonce’], ‘av-maintenance-mode-nonce’ )) die( ‘Go away!’); if( get_option( ‘av_maintenance_mode’ ) == ‘on’ ) { echo ‘<span style=”color:green”>On</span>’; }else{ echo ‘<span style=”color:red”>Off</span>’; } … Read more