static function updateOption($name, $value, $blogID = 1) { if (wpsIsMultisite()) { return update_blog_option($blogID, $name, $value); } return update_option($name, $value); }
/** * Updates flag url for given blog. * * @param int $blog_id * @param string $flag_url * * @return bool */ public static function update_flag($blog_id, $flag_url) { $flag_url = empty($flag_url) ? '' : $flag_url; if ($blog_id > 0) { return update_blog_option($blog_id, 'inpsyde_multilingual_flag_url', $flag_url); } return FALSE; }
/** * Validate and save user input * * @param array $data User input * @return bool */ public function save(array $data) { if (!$this->nonce->is_valid()) { return false; } $id = $this->get_current_blog_id($data, get_current_blog_id()); $value = $this->get_sent_value($data); return update_blog_option($id, $this->option_name, $value); }
function popmake_update_site_option($key, $value) { global $blog_id; if (function_exists('is_multisite') && is_multisite() && $blog_id) { return update_blog_option($blog_id, $key, $value); } else { return update_site_option($key, $value); } }
/** * Update Blog Option * * @param string $option * @param mixed $data * @param int $blog_id * * @return bool * * @access public * @static */ public static function updateOption($option, $data, $blog_id = null) { if (is_multisite()) { $blog = is_null($blog_id) ? get_current_blog_id() : $blog_id; $response = update_blog_option($blog, $option, $data); } else { $response = update_option($option, $data); } return $response; }
/** * @param array $options * @param int $blog ID of the blog to be set in multisite env. */ public static function setOptions($options, $blog = null) { if (is_null($blog)) { global $dg_options; update_option(DG_OPTION_NAME, $options); $dg_options = $options; } else { update_blog_option($blog, DG_OPTION_NAME, $options); } }
/** * A wrapper for updating theme options on the test install * * @param string $option_name The option name * @param array The options array to update * @return bool True on success, false on failure. */ function update_test_options($option_name, $options_array) { if (defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE) { global $blog_id; $options = update_blog_option($blog_id, $option_name, $options_array); } else { $options = update_option($option_name, $options_array); } return $options; }
function mytheme_add_admin() { global $themename, $shortname, $options, $blog_id; $page = ''; if (isset($_GET["page"]) && !empty($_GET["page"])) { $page = $_GET["page"]; } if ($page == basename(__FILE__)) { $action = ''; if (isset($_REQUEST["action"]) && !empty($_REQUEST["action"])) { $action = $_REQUEST["action"]; } if ('save' == $action) { check_admin_referer('thematic-theme-options'); foreach ($options as $value) { if (THEMATIC_MB) { if (isset($_REQUEST[$value['id']])) { update_blog_option($blog_id, $value['id'], $_REQUEST[$value['id']]); } else { update_blog_option($blog_id, $value['id'], $value['std']); } } else { if (isset($_REQUEST[$value['id']])) { update_option($value['id'], $_REQUEST[$value['id']]); } else { update_option($value['id'], $value['std']); } } } header("Location: themes.php?page=theme-options.php&saved=true"); die; } else { if ('reset' == $action) { check_admin_referer('thematic-reset'); foreach ($options as $value) { if (THEMATIC_MB) { delete_blog_option($blog_id, $value['id']); } else { delete_option($value['id']); } } header("Location: themes.php?page=theme-options.php&reset=true"); die; } else { if ('resetwidgets' == $action) { check_admin_referer('thematic-reset-widgets'); update_option('sidebars_widgets', NULL); header("Location: themes.php?page=theme-options.php&resetwidgets=true"); die; } } } } add_theme_page($themename . " Options", "Thematic Options", 'edit_themes', basename(__FILE__), 'mytheme_admin'); }
/** * Set 'mucd_duplicable' option to "yes" for the list of blogs, other to "no" * @since 0.2.0 * @param array $blogs list of blogs we want the option set to "yes" */ public static function set_duplicable_option($blogs) { $network_blogs = wp_get_sites(array('limit' => MUCD_MAX_NUMBER_OF_SITE)); foreach ($network_blogs as $blog) { if (in_array($blog['blog_id'], $blogs)) { update_blog_option($blog['blog_id'], 'mucd_duplicable', "yes"); } else { update_blog_option($blog['blog_id'], 'mucd_duplicable', "no"); } } }
public function login_radius_update_old_blogs($oldConfig) { global $loginradius_api_settings; if (isset($loginradius_api_settings['multisite_config']) && $loginradius_api_settings['multisite_config'] == '1') { $settings = get_option('LoginRadius_share_settings'); $blogs = wp_get_sites(); foreach ($blogs as $blog) { update_blog_option($blog['blog_id'], 'LoginRadius_share_settings', $settings); } } }
public function oss_update_old_blogs($oldConfig) { global $oss_api_settings; if (isset($oss_api_settings['multisite_config']) && $oss_api_settings['multisite_config'] == '1') { $settings = get_option('OpenSocialShare_share_settings'); $blogs = wp_get_sites(); foreach ($blogs as $blog) { update_blog_option($blog['blog_id'], 'OpenSocialShare_share_settings', $settings); } } }
public static function updateAddress($optionsToUpdate) { $countAddress = 1; while (isset($optionsToUpdate['_gmsites_address' . $countAddress])) { if ($countAddress <= GMSITES_PERSISTENCE_LIMIT) { $key = '_gmsites_address' . $countAddress; $value = $optionsToUpdate['_gmsites_address' . $countAddress]; update_blog_option(self::getBlogID(), $key, $value); $countAddress++; } } }
function _archivesCalendar_activate() { global $wpdb; $default_options = array("css" => 1, "theme" => "calendrier", "js" => 1, "show_settings" => 1, "filter" => 0, "javascript" => "jQuery(document).ready(function(\$){\n\t\$('.calendar-archives').archivesCW();\n});"); $default_custom_css = file_get_contents(plugins_url('/admin/default_custom.css', __FILE__)); $default_themer_options = array("arw-theme1" => $default_custom_css, "arw-theme2" => ''); if (!($options = get_option('archivesCalendar'))) { // if new installation copy default options into the DB $options = $default_options; } else { // if reactivation or after update: merge existing settings with the defaults in case if new options were added in the update array_merge($default_options, $options); } if (!($themer_options = get_option('archivesCalendarThemer'))) { $themer_options = $default_themer_options; } foreach ($themer_options as $ctheme => $css) { if ($css) { if (is_writable('../wp-content/plugins/' . dirname(plugin_basename(__FILE__)) . '/themes/')) { if (isMU()) { $old_blog = $wpdb->blogid; $blogids = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}"); foreach ($blogids as $blogid) { $blog_id = $blogid->blog_id; switch_to_blog($blog_id); $filename = '../wp-content/plugins/' . dirname(plugin_basename(__FILE__)) . '/themes/' . $ctheme . '-' . $wpdb->blogid . '.css'; $themefile = fopen($filename, "w") or die("Unable to open file!"); fwrite($themefile, $css); fclose($themefile); } switch_to_blog($old_blog); } else { $filename = '../wp-content/plugins/' . dirname(plugin_basename(__FILE__)) . '/themes/' . $ctheme . '.css'; $themefile = fopen($filename, "w") or die("Unable to open file!"); fwrite($themefile, $css); fclose($themefile); } } else { echo "<p>Can't write in `/wp-content/plugins/" . dirname(plugin_basename(__FILE__)) . "/themes/" . " </p>"; } } } if (isMU()) { update_blog_option($wpdb->blogid, 'archivesCalendar', $options); add_blog_option($wpdb->blogid, 'archivesCalendar', $options); add_blog_option($wpdb->blogid, 'archivesCalendarThemer', $themer_options); } else { update_option('archivesCalendar', $options); add_option('archivesCalendar', $options); add_option('archivesCalendarThemer', $themer_options); } }
/** * Activation hook * * @see register_activation_hook() */ function registerActivationHook() { // Prevent overwriting customizations if Pressbooks has been disabled if (!get_site_option('pressbooks-activated')) { // Insert Pressbooks description on root blog update_blog_option(1, 'blogdescription', 'Simple Book Publishing'); // Configure theme and remove widgets from root blog update_blog_option(1, 'template', 'pressbooks-publisher'); update_blog_option(1, 'stylesheet', 'pressbooks-publisher'); delete_blog_option(1, 'sidebars_widgets'); // Add "activated" key to enable check above add_site_option('pressbooks-activated', true); } }
/** * Sanitize the BP options * * We don't want to save BP options to any blog other than the BP_ROOT_BLOG * * @param string $new_value * @param mixed $option * @return string $new_value */ function bfox_bp_option_sanitize($new_value, $option = '') { global $blog_id; // We don't want to save BP options to any blog other than the BP_ROOT_BLOG if (BP_ROOT_BLOG != $blog_id) { if (!$option) { $option = substr(current_filter(), strlen('sanitize_option_')); } // Save the option to the BP_ROOT_BLOG update_blog_option(BP_ROOT_BLOG, $option, $new_value); // Since we really want to save to the BP_ROOT_BLOG, let's not change the value in this blog $new_value = get_option($option); } return $new_value; }
public static function set($_options) { if (is_multisite()) { if (!@get_blog_option(BLOG_ID_CURRENT_SITE, self::$_optionName)) { add_blog_option(BLOG_ID_CURRENT_SITE, self::$_optionName, $_options); } else { update_blog_option(BLOG_ID_CURRENT_SITE, self::$_optionName, $_options + @get_blog_option(BLOG_ID_CURRENT_SITE, self::$_optionName)); } self::$_arrSettings = @get_blog_option(BLOG_ID_CURRENT_SITE, self::$_optionName); } else { if (!@get_option(self::$_optionName)) { add_option(self::$_optionName, $_options); } else { update_option(self::$_optionName, $_options + @get_option(self::$_optionName)); } self::$_arrSettings = @get_option(self::$_optionName); } }
/** * Add new option when registering a site (back and front end) * * URI: http://stackoverflow.com/a/10372861/1287812 */ public function add_new_blog_field($blog_id, $user_id, $domain, $path, $site_id, $meta) { $new_field_value = ''; # Site added in the back end if (!empty($_POST['blog']['input_site_cat'])) { switch_to_blog($blog_id); $cat_id = $_POST['blog']['input_site_cat']; # TODO: if Sign-up is to be enabled, change this to a method $val = B5F_Multisite_Categories::get_instance()->do_mature_to_name($cat_id); update_blog_option($blog_id, 'site_category', $val); update_blog_status($blog_id, 'mature', $cat_id); get_blog_status($blog_id, 'mature'); restore_current_blog(); } elseif (!empty($meta['input_site_cat'])) { $new_field_value = $meta['input_site_cat']; update_option('site_category', $new_field_value); } }
function psu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta) { $activated = wpmu_activate_signup($key); if (is_array($activated) && $activated['blog_id'] && $activated['user_id']) { // successfully created blog update_blog_option($activated['blog_id'], 'stylesheet', 'pressrow'); update_blog_option($activated['blog_id'], 'template', 'pressrow'); // they're already CAS authenticated, // so set the WP authentication cookie for them wp_set_auth_cookie($activated['user_id']); ?> <h2>Yay! We made a blog for you</h2> <p>Click this link to access your dashboard:</p> <ul><li><a href="http://<?php echo $domain . $path; ?> wp-admin/"><?php echo $domain . $path; ?> wp-admin/</a></li></ul> <p>Go ahead and bookmark it once you get there, we hope you come back.</p><?php } else { // error will robinson ?> <h2>hrrm...</h2> <p>There seems to have been an error.</p> <p>You may already have a blog at this address: <a href="http://<?php echo $domain . $path; ?> " target="_blank"><?php echo $domain . $path; ?> </a>.</p> <p>Please call the <a href="http://url.path.to/your/helpdesk" target="_blank">Help Desk</a> with the following:</p> <p><pre><?php print_r($activated->errors); ?> </pre></p><?php } return FALSE; }
/** * bp_zoneideas_widget_cool_widget_control() * * This function will enable a "edit" menu on your widget. This lets site admins click * the edit link on the widget to set options. The options you can then use in the display of * your widget. * * For zoneideas, in the groups component widget there is a setting called "max-groups" where * a user can define how many groups they would like to display. */ function bp_zoneideas_widget_cool_widget_control() { global $current_blog; $options = $newoptions = get_blog_option($current_blog->blog_id, 'bp_zoneideas_widget_cool_widget'); if ($_POST['bp-zoneideas-widget-cool-widget']) { $newoptions['option_name'] = strip_tags(stripslashes($_POST['bp-zoneideas-widget-cool-widget-option'])); } if ($options != $newoptions) { $options = $newoptions; update_blog_option($current_blog->blog_id, 'bp_zoneideas_widget_cool_widget', $options); } $option_name = attribute_escape($options['option_name']); ?> <p><label for="bp-zoneideas-widget-cool-widget-option"><?php _e('Some Option', 'bp-zoneideas'); ?> <br /> <input class="widefat" id="bp-zoneideas-widget-cool-widget-option" name="bp-zoneideas-widget-cool-widget-option" type="text" value="<?php echo $option_name; ?> " style="width: 30%" /></label></p> <input type="hidden" id="bp-zoneideas-widget-cool-widget" name="bp-zoneideas-widget-cool-widget" value="1" /> <?php }
function affiliate_supporter_paid($bid, $amount, $supporterperiod) { if (function_exists('get_site_option')) { $getoption = 'get_site_option'; } else { $getoption = 'get_option'; } // Check if the blog is from an affiliate if (function_exists('get_blog_option')) { $aff = get_blog_option($bid, 'affiliate_referred_by', false); $paid = get_blog_option($bid, 'affiliate_paid', 'no'); } else { $aff = false; } if ($aff && $paid != 'yes') { switch ($supporterperiod) { case '1': $amount = $getoption("supporter_1_whole_payment", 0) . '.' . $getoption("supporter_1_partial_payment", 0); break; case '3': $amount = $getoption("supporter_3_whole_payment", 0) . '.' . $getoption("supporter_3_partial_payment", 0); break; case '12': $amount = $getoption("supporter_12_whole_payment", 0) . '.' . $getoption("supporter_12_partial_payment", 0); break; default: $amount = 0; break; } do_action('affiliate_purchase', $aff, $amount); if (defined('AFFILIATE_PAYONCE') && AFFILIATE_PAYONCE == 'yes') { if (function_exists('update_blog_option')) { update_blog_option($bid, 'affiliate_paid', 'yes'); } } } }
function rt_wp_nginx_helper_install() { global $wp_roles, $rt_wp_nginx_helper; if (!current_user_can('activate_plugins')) { return; } $role = get_role('administrator'); if (empty($role)) { update_site_option("rt_wp_nginx_helper_init_check", __('Sorry, you need to be an administrator to use Nginx Helper', "rt_wp_nginx_helper")); return; } $role->add_cap('Nginx Helper | Config'); $role->add_cap('Nginx Helper | Purge cache'); $rt_wp_nginx_helper_get_options = get_site_option('rt_wp_nginx_helper_global_options'); if (empty($rt_wp_nginx_helper_get_options)) { $rt_wp_nginx_helper_get_options = rt_wp_nginx_helper_get_options(); update_site_option("rt_wp_nginx_helper_global_options", $rt_wp_nginx_helper_get_options); } if (is_multisite()) { $blogs = get_blogs_of_user(true); foreach ($blogs as $b) { $rt_wp_nginx_helper_options = get_blog_option($b->userblog_id, 'rt_wp_nginx_helper_options'); if (empty($rt_wp_nginx_helper_options)) { $rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options(); update_blog_option($b->userblog_id, "rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options); } } } else { $rt_wp_nginx_helper_options = get_option('rt_wp_nginx_helper_options'); if (empty($rt_wp_nginx_helper_options)) { $rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options(); update_option("rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options); } } wp_schedule_event(time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily'); }
function network_config_page() { $options = get_site_option('wpseo_ms'); if (isset($_POST['wpseo_submit'])) { foreach (array('access', 'defaultblog') as $opt) { $options[$opt] = $_POST['wpseo_ms'][$opt]; } update_site_option('wpseo_ms', $options); echo '<div id="message" class="updated">' . __('Settings Updated.') . '</div>'; } if (isset($_POST['wpseo_restore_blog'])) { if (isset($_POST['wpseo_ms']['restoreblog']) && is_numeric($_POST['wpseo_ms']['restoreblog'])) { $blog = get_blog_details($_POST['wpseo_ms']['restoreblog']); if ($blog) { foreach (get_wpseo_options_arr() as $option) { $new_options = get_blog_option($options['defaultblog'], $option); if (count($new_options) > 0) { update_blog_option($_POST['wpseo_ms']['restoreblog'], $option, $new_options); } } echo '<div id="message" class="updated"><p>' . $blog->blogname . ' ' . __('restored to default SEO settings.') . '</p></div>'; } } } $this->admin_header('MultiSite Settings', false, false); $content = '<form method="post">'; $content .= $this->select('access', __('Who should have access to the WordPress SEO settings'), array('admin' => 'Site Admins (default)', 'superadmin' => 'Super Admins only'), 'wpseo_ms'); $content .= $this->textinput('defaultblog', __('New blogs get the SEO settings from this blog'), 'wpseo_ms'); $content .= '<p>' . __('Enter the Blog ID for the site whose settings you want to use as default for all sites that are added to your network. Leave empty for none.') . '</p>'; $content .= '<input type="submit" name="wpseo_submit" class="button-primary" value="' . __('Save MultiSite Settings') . '"/>'; $content .= '</form>'; $this->postbox('wpseo_export', __('MultiSite Settings', 'yoast-wpseo'), $content); $content = '<form method="post">'; $content .= '<p>' . __('Using this form you can reset a site to the default SEO settings.') . '</p>'; $content .= $this->textinput('restoreblog', __('Blog ID'), 'wpseo_ms'); $content .= '<input type="submit" name="wpseo_restore_blog" value="' . __('Restore site to defaults') . '" class="button"/>'; $content .= '</form>'; $this->postbox('wpseo_export', __('Restore site to default settings', 'yoast-wpseo'), $content); $this->admin_footer('Restore to Default', false); }
/** * * @ignore * @param string $key * @param mixed $value */ public function update($key, $value) { $value = apply_filters('timber_site_set_meta', $value, $key, $this->ID, $this); if (is_multisite()) { update_blog_option($this->ID, $key, $value); } else { update_option($key, $value); } $this->{$key} = $value; }
function M_update_option($key, $value) { if (defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { if (function_exists('update_blog_option')) { return update_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, $key, $value); } else { return update_option($key, $value); } } else { return update_option($key, $value); } }
function mycred_update_option($option_id, $value = '') { if (is_multisite()) { if (mycred_override_settings()) { return update_blog_option(1, $option_id, $value); } else { return update_blog_option($GLOBALS['blog_id'], $option_id, $value); } } else { return update_option($option_id, $value); } }
/** * update the social login options in all the old blogs */ function the_champ_update_old_blogs($oldConfig) { $optionParts = explode('_', current_filter()); $option = $optionParts[2] . '_' . $optionParts[3] . '_' . $optionParts[4]; $newConfig = get_option($option); if (isset($newConfig['config_multisite']) && $newConfig['config_multisite'] == 1) { $blogs = get_blog_list(0, 'all'); foreach ($blogs as $blog) { update_blog_option($blog['blog_id'], $option, $newConfig); } } }
/** * Update the details for a blog. Updates the blogs table for a given blog id. * * @since 3.0.0 * * @param int $blog_id Blog ID * @param array $details Array of details keyed by blogs table field names. * @return bool True if update succeeds, false otherwise. */ function update_blog_details($blog_id, $details = array()) { global $wpdb; if (empty($details)) { return false; } if (is_object($details)) { $details = get_object_vars($details); } $current_details = get_blog_details($blog_id, false); if (empty($current_details)) { return false; } $current_details = get_object_vars($current_details); $details = array_merge($current_details, $details); $details['last_updated'] = current_time('mysql', true); $update_details = array(); $fields = array('site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'); foreach (array_intersect(array_keys($details), $fields) as $field) { $update_details[$field] = $details[$field]; } $wpdb->update($wpdb->blogs, $update_details, array('blog_id' => $blog_id)); // If spam status changed, issue actions. if ($details['spam'] != $current_details['spam']) { if ($details['spam'] == 1) { do_action("make_spam_blog", $blog_id); } else { do_action("make_ham_blog", $blog_id); } } if (isset($details['public'])) { update_blog_option($blog_id, 'blog_public', $details['public'], false); } refresh_blog_details($blog_id); return true; }
$successTextEnd = '</strong></font><br>'; $network_ids = wp_get_sites(); foreach ($network_ids as $key => $value) { $net_id = $value['blog_id']; $bps_Net_lsm = 'bulletproof_security_options_login_security'; $BPS_Net_LSM_Options = array('bps_max_logins' => '3', 'bps_lockout_duration' => '60', 'bps_manual_lockout_duration' => '60', 'bps_max_db_rows_display' => '', 'bps_login_security_OnOff' => 'On', 'bps_login_security_logging' => 'logLockouts', 'bps_login_security_errors' => 'wpErrors', 'bps_login_security_remaining' => 'On', 'bps_login_security_pw_reset' => 'enable', 'bps_login_security_sort' => 'ascending'); if (!get_blog_option($net_id, $bps_Net_lsm)) { foreach ($BPS_Net_LSM_Options as $key => $value) { update_blog_option($net_id, 'bulletproof_security_options_login_security', $BPS_Net_LSM_Options); } echo $successTextBegin . 'Site: ' . $net_id . $successMessage . $successTextEnd; } else { $BPS_LSM_Options_Net = get_blog_option($net_id, 'bulletproof_security_options_login_security'); $BPS_Net_Options_lsm = array('bps_max_logins' => $BPS_LSM_Options_Net['bps_max_logins'], 'bps_lockout_duration' => $BPS_LSM_Options_Net['bps_lockout_duration'], 'bps_manual_lockout_duration' => $BPS_LSM_Options_Net['bps_manual_lockout_duration'], 'bps_max_db_rows_display' => $BPS_LSM_Options_Net['bps_max_db_rows_display'], 'bps_login_security_OnOff' => $BPS_LSM_Options_Net['bps_login_security_OnOff'], 'bps_login_security_logging' => $BPS_LSM_Options_Net['bps_login_security_logging'], 'bps_login_security_errors' => $BPS_LSM_Options_Net['bps_login_security_errors'], 'bps_login_security_remaining' => $BPS_LSM_Options_Net['bps_login_security_remaining'], 'bps_login_security_pw_reset' => $BPS_LSM_Options_Net['bps_login_security_pw_reset'], 'bps_login_security_sort' => $BPS_LSM_Options_Net['bps_login_security_sort']); foreach ($BPS_Net_Options_lsm as $key => $value) { update_blog_option($net_id, 'bulletproof_security_options_login_security', $BPS_Net_Options_lsm); } echo $successTextBegin . 'Site: ' . $net_id . $successMessage . $successTextEnd; } } } } ?> </td> </tr> <tr> <td class="bps-table_cell_bottom"> </td> </tr> </table>
/** * Returns array of stylesheet names of themes allowed on the site. * * @since 3.4.0 * @access public * * @param int $blog_id Optional. Defaults to current blog. * @return array Array of stylesheet names. */ public static function get_allowed_on_site($blog_id = null) { static $allowed_themes = array(); if (!$blog_id) { $blog_id = get_current_blog_id(); } if (isset($allowed_themes[$blog_id])) { return $allowed_themes[$blog_id]; } $current = $blog_id == get_current_blog_id(); if ($current) { $allowed_themes[$blog_id] = get_option('allowedthemes'); } else { $allowed_themes[$blog_id] = get_blog_option($blog_id, 'allowedthemes'); } // This is all super old MU back compat joy. // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. if (false === $allowed_themes[$blog_id]) { if ($current) { $allowed_themes[$blog_id] = get_option('allowed_themes'); } else { $allowed_themes[$blog_id] = get_blog_option($blog_id, 'allowed_themes'); } if (!is_array($allowed_themes[$blog_id]) || empty($allowed_themes[$blog_id])) { $allowed_themes[$blog_id] = array(); } else { $converted = array(); $themes = wp_get_themes(); foreach ($themes as $stylesheet => $theme_data) { if (isset($allowed_themes[$blog_id][$theme_data->get('Name')])) { $converted[$stylesheet] = true; } } $allowed_themes[$blog_id] = $converted; } // Set the option so we never have to go through this pain again. if (is_admin() && $allowed_themes[$blog_id]) { if ($current) { update_option('allowedthemes', $allowed_themes[$blog_id]); delete_option('allowed_themes'); } else { update_blog_option($blog_id, 'allowedthemes', $allowed_themes[$blog_id]); delete_blog_option($blog_id, 'allowed_themes'); } } } return $allowed_themes[$blog_id]; }
function create_defaults() { // Function to create some defaults if they are not set if (defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { if (function_exists('get_blog_option')) { if (function_exists('switch_to_blog')) { switch_to_blog(MEMBERSHIP_GLOBAL_MAINSITE); } $M_options = get_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', array()); } else { $M_options = get_option('membership_options', array()); } } else { $M_options = get_option('membership_options', array()); } // Make registration and associated pages if (empty($M_options['registration_page'])) { // Check if the buddypress registration page is created or not if (defined('BP_VERSION') && version_compare(preg_replace('/-.*$/', '', BP_VERSION), "1.5", '>=')) { // Get the BP pages $bppages = get_option('bp-pages', array()); } $pagedetails = array('post_title' => __('Register', 'membership'), 'post_name' => 'register', 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => ''); $id = wp_insert_post($pagedetails); $M_options['registration_page'] = $id; $pagedetails = array('post_title' => __('Account', 'membership'), 'post_name' => 'account', 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => ''); $id = wp_insert_post($pagedetails); $M_options['account_page'] = $id; $content = '<p>' . __('The content you are trying to access is only available to members. Sorry.', 'membership') . '</p>'; $pagedetails = array('post_title' => __('Protected Content', 'membership'), 'post_name' => 'protected', 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => $content); $id = wp_insert_post($pagedetails); $M_options['nocontent_page'] = $id; } // Create relevant admin side shortcodes if (empty($M_options['membershipadminshortcodes'])) { if (!is_array($M_options['membershipadminshortcodes'])) { $M_options['membershipadminshortcodes'] = array(); } if (class_exists('RGForms')) { // Gravity Forms exists $M_options['membershipadminshortcodes'][] = 'gravityform'; } if (defined('WPCF7_VERSION')) { // Contact Form 7 exists $M_options['membershipadminshortcodes'][] = 'contact-form'; } if (defined('WPAUDIO_URL')) { // WPAudio exists $M_options['membershipadminshortcodes'][] = 'wpaudio'; } } // Create a default download group if (empty($M_options['membershipdownloadgroups'])) { if (!is_array($M_options['membershipdownloadgroups'])) { $M_options['membershipdownloadgroups'] = array(); } $M_options['membershipdownloadgroups'][] = __('default', 'membership'); } // Create a hashed downloads url if (empty($M_options['masked_url'])) { $M_options['masked_url'] = __('downloads', 'membership'); } // Update the options if (defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { if (function_exists('update_blog_option')) { update_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', $M_options); } else { update_option('membership_options', $M_options); } } else { update_option('membership_options', $M_options); } }