Is there a way to define wp_blogs domains in wp-config?

When WordPress loads multisite, it includes the relevant MS specific files in wp-settings.php The relevant lines: <?php // Initialize multisite if enabled. if ( is_multisite() ) { require( ABSPATH . WPINC . ‘/ms-blogs.php’ ); require( ABSPATH . WPINC . ‘/ms-settings.php’ ); } elseif ( ! defined( ‘MULTISITE’ ) ) { define( ‘MULTISITE’, false ); } … Read more

Listing of all site options in dashboard

There is no function for that. But you can use a custom SQL query like this … SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE site_id = $wpdb->siteid AND `meta_key` NOT LIKE ‘_site_transient%’ ORDER BY meta_key … to get all non-transient options. Basic example: /** * Plugin Name: T5 Multi-Site Options * Description: Add a page to … Read more

domain mapping confused about sunrise

Apparantly this happens with the newer version of domain mapping because sunrise.php itself needs to be updated. To solve it I: Copy the new sunrise.php file from wp-content/plugins/wordpress-mu-domain-mapping/sunrise.php to wp-content/sunrise.php and you’ll be fine. And it works now.

Turn off ms-files.php after network setup

In theory: Move images from blogs.dir/SITENUM/files/ to /uploads/SITENUM/ (or make an alias) Edit all sites so they don’t look in /files/ but in /uploads/SITENUM/ .htaccess, remove the ms-files.php line Search/replace each posts table for each site, changing /files/ to /uploads/SITENUM/ A walk-through can be found here (dumping ms-files), this is not a trivial hack! It … Read more

Fatal error: Call to undefined function wp_get_current_user()

wp_get_current_user() is a pluggable function and not yet available when your plugin is included. You have to wait for the action plugins_loaded: Example: add_action( ‘plugins_loaded’, ‘wpse_92517_init’ ); function wpse_92517_init() { if(!is_super_admin()) add_action(‘widgets_init’,’my_unregister_widget’); } function my_unregister_widgets() { unregister_widget( ‘WP_Widget_Pages’ ); unregister_widget( ‘WP_Widget_Calendar’ ); } Or move the check into the widget function: add_action( ‘widgets_init’, ‘my_unregister_widget’ ); … Read more

How to cache a shortcode functions output?

You might have a look at the WordPress Transient API. You should be able to store your shortcode output $total_network with set_transient( ‘my_shortcode_cache’, $total_network, WEEK_IN_SECONDS ); where WEEK_IN_SECONDS is a built in constant equal to 604800. You can then fetch it with: get_transient( ‘my_shortcode_cache’ ); If you need it to work network wide there exists … Read more

REST API for Multisite

I’m using the REST API to pull data about one multisite installation and feed it to sites in another multisite installation. Here’s some of the code in use: class WPSE205354_Demo { function __construct() { add_filter( ‘json_endpoints’, array( $this, ‘register_routes’ ) ); } /** * Register the additional API routes * @param array $routes The routes … Read more

Multisite with 2 different themes

KongA, Yes, you can use multiple themes when using WordPress multisite. In the Network Admin you can install themes and activate them for the network. You can activate Theme A and Theme B both. Once activated, you would visit Site A’s wp-admin and choose Theme A under Appearance. Then repeat the process for Site B. … Read more