How to set the default options on an existing plugin in a WP MU new user install

At the top of the api.php page before the class JSON_API line add the following code: add_action( ‘wpmu_new_blog’, ‘wpse_set_defaults’ ); function wpse_set_defaults( $blog_id ) { global $json_api; switch_to_blog( $blog_id ); // set the default controllers here $required_controllers = explode(“,”, “categories,posts,user,attachments”); $id = ‘json_api_controllers’; $available_controllers = $json_api->get_controllers(); $active_controllers = explode(‘,’, get_option($id, ‘core’)); $action = “activate”; foreach … Read more

Disable Please visit the Update Network page to update all your sites. Notice from Dashboard

This message was fired on two hooks. add_action( ‘admin_notices’, ‘site_admin_notice’ ); add_action( ‘network_admin_notices’, ‘site_admin_notice’ ); Remove this and you remove the message, use remove_action. To remove this function use a function, like the follow example. add_action( ‘admin_menu’,’fb_hide_site_notice’ ); function fb_hide_site_notice() { remove_action( ‘admin_notices’, ‘site_admin_notice’ ); } Now for the network ares: add_action( ‘network_admin_menu’, ‘fb_hide_network_notice’ ); … Read more

Sorting Posts by Date – get_blogs_of_user_id()

You can build an array of all post items, and then sort them by date at the end of your querying: $blogs = get_blogs_of_user( get_current_user_id() ); if ( $blogs ) { $items = array(); foreach ( $blogs as $blog ) { switch_to_blog( $blog->userblog_id ); $posts = get_posts( ‘posts_per_page=2’ ); foreach ( $posts as $post ) … Read more

Problem with paging on Multisite

If you’re using the category archive template you do not need to create a new WP_Query instance. Just filter the main query using pre_get_posts(). Put this in functions php or a plugin: add_action( ‘pre_get_posts’, wp_se_pre_get_posts’ ); function wp_se_pre_get_posts( $query ) { if ( is_admin() || ! $query->is_main_query || ! is_category( ‘pressmeddelande’ ) return $query; $query->set( … Read more