Auto Load Plugin Hooks inside Must Use Plugin
With Multisite, you need to use add_site_option/get_site_option instead of add_option/get_option. https://codex.wordpress.org/Function_Reference/get_site_option
With Multisite, you need to use add_site_option/get_site_option instead of add_option/get_option. https://codex.wordpress.org/Function_Reference/get_site_option
Use get_current_blog_id() to check the current site. To run on site 2 only, use this: function new_meta_values($order_id) { if ( 2 !== get_current_blog_id() ) return; /* the rest of the function code */ }
The function checks your version of WP for possible updates. It appears that there is a transient in the database named ‘update_core’, so it’s stored in the $wpdb->options table as ‘_site_transient_update_core’. The value of that transient is a serialized object that has information, I’m not an expert on wp_version_check, but it uses that transient to … Read more
I think the answer to this Disable plugin / plugin action via theme is good for base knowledge on how to disable plugins from code. Adapting that knowledge to your needs will leave us with this: add_action(‘admin_init’, ‘my_filter_the_plugins’); function my_filter_the_plugins() { global $current_user; if (in_array(‘media_manager’, $current_user->roles)) { deactivate_plugins( // deactivate for media_manager array( ‘/advanced-page-manager/advanced_page_manager.php’ ), … Read more
wp_insert_post was introduced in changeset 2887, and was to fix bug #1681. I couldn’t find the save_post hook’s original provenance, but it was most recently added to core in changeset 3291, related to ticket #2063. Evidently it had existed in 1.5.2 (although version control does not support this theory) and needed to be added back … Read more
In my projects I do it like that PHP function foo() { echo ‘bar’; } add_action(‘wp_ajax_foo’, ‘foo’ ); // executed when logged in add_action(‘wp_ajax_nopriv_foo’, ‘foo’ ); // executed when logged out Javascript data = { action: ‘foo’, avalue: ‘some value’, ‘anothervalue’: ‘another value’ }; jQuery.post(ajaxurl, data, function(response){ alert(response); });
If you take a look at the Codex page about add_shortcode() you won’t see anything about the need of an add_action() before you can use add_shortcode(). So, you can just put your add_shortcode() directly into your functions.php. This is what I do too. See this article – WordPress Shortcodes: A Complete Guide about the use … Read more
It looks like the xmlrpc_prepare_post filter is only applied to the output of the wp_getPost and wp_getRevision methods of the wp_xmlrpc_server class. It would be great if this code line: do_action( ‘xmlrpc_call’, ‘wp.newPost’ ); would be replaced with extra input arguments, for example: do_action( ‘xmlrpc_call’, ‘wp.newPost’, …, $content_struct ); but that’s not going to happen … Read more
function pj_time () { echo current_filter(); } Easier than I thought 😉 http://codex.wordpress.org/Function_Reference/current_filter
add_filter(‘wpseo_robots’, ‘yoast_no_home_noindex’, 999); function yoast_no_home_noindex($string= “”) { if (is_home() || is_front_page()) { $string= “index,follow”; } return $string; } this should be fine i think.. somewhere in your theme functions.php and should do the trick.