Prevent Deletion of Blogs

You can not stop anything which do not have an explicit option to be stopped. In this case, actions are a mean to execute some additional code in the context of a specific execution path, and not to alter it. If there is no way to signal to the process to stop, than the only … Read more

WordPress admin notice in plugin function

Your problem is pretty simple. Your callback for this hook is not a simple function but some method of a class. If you add action like this: add_action(‘admin_notices’, ‘simple_notice’); you tell WP that there is some simple function called simple_notice and it should be called when hook admin_notices is processed. But… There is no such … Read more

Store source permalink on XMLRPC calls

From look at source metaWeblog.newPost seems to be processed in wp_xmlrpc_server->mw_newPost() method. At the end of this method there is following hook call: do_action( ‘xmlrpc_call_success_mw_newPost’, $post_ID, $args ); which seems to be very fitting to process and save any additional information for post that have just been created by its ID provided.

What’s the earliest point I can get the queried object ID?

A more compact and WordPress-ish way, using url_to_postid(): function wpmp_switcher_exclusions_init() { $pid = url_to_postid( home_url( add_query_arg( array() ) ) ); if ( (int) $pid > 0 && get_post_meta( $pid, ‘_wp_page_template’, TRUE ) === ‘my-responsive-template.php’ ) { remove_action(‘init’, ‘wpmp_switcher_init’); remove_action(‘admin_menu’, ‘wpmp_switcher_admin_menu’); remove_action(‘wp_footer’, ‘wpmp_switcher_wp_footer’); remove_filter(‘stylesheet’, ‘wpmp_switcher_stylesheet’); remove_filter(‘template’, ‘wpmp_switcher_template’); remove_filter(‘option_home’, ‘wpmp_switcher_option_home_siteurl’); remove_filter(‘option_siteurl’, ‘wpmp_switcher_option_home_siteurl’); } } add_action( ‘setup_theme’, ‘wpmp_switcher_exclusions_init’ … Read more

Autogenerate wordpress shortcodes using array?

Auto-generate shortcodes from an array: You can try the following Shortcode Automat: /** * Setup the Shortcode Automat * */ function shortcode_automat_setup() { $settings = array( “get_address” => “mg_admin_address”, “get_phone” => “mg_admin_phone”, “get_fax” => “mg_admin_fax”, “get_email” => “mg_admin_email”, “get_hrs_mon” => “mg_work_hrs_mon_frd”, “get_hrs_sat” => “mg_work_hrs_sat” ); $sc = new ShortCodeAutomat( $settings ); $sc->generate(); } add_action( ‘wp_loaded’, … Read more

Action hook ‘wp’ firing twice… why?

It can happen if one of the files you include in the theme is returning 404 Not Found error. Like, if you’re linking to a .js or .css or an image which does not exist on that location. Use the Inspector in your browser to see if you get any 404 errors, anywhere. Fix them … Read more