Multisite: How to store global options vs. site options?
There are functions for saving and retrieving network-wide options: add_network_option(); update_network_option(); get_network_option(); The values of these options are stored in wp_sitemeta.
There are functions for saving and retrieving network-wide options: add_network_option(); update_network_option(); get_network_option(); The values of these options are stored in wp_sitemeta.
You can use one installation to serve three or more single-site setups (just switch on $_SERVER[‘HTTP_HOST’] in your wp-config.php) or one multi-site installation. But running three updates for the same software on one host doesn’t make sense. Just a waste of time. Unless you plan to install hundreds of different themes and plugins on each … Read more
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
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
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.
You can use is_plugin_active_for_network( $plugin )
The capabilities are stored as user meta data in a serialized array for each site. The key as a regular expression would look like that: ‘~’ . $GLOBALS[‘wpdb’]->base_prefix . ‘(\d+)_capabilities~’ So … get the user meta data, find the capability strings (they hold the roles), and compare the unserialized result with the role you want … Read more
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
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
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