/** * Used to return what the optin value is set for the EE User Experience Program. * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set * on the main site only. * * @return mixed|void */ protected function _get_main_ee_ueip_optin() { //if this is the main site then we can just bypass our direct query. if (is_main_site()) { return get_option('ee_ueip_optin', false); } //is this already cached for this request? If so use it. if (!empty(EE_Core_Config::$ee_ueip_option)) { return EE_Core_Config::$ee_ueip_option; } global $wpdb; $current_network_main_site = is_multisite() ? get_current_site() : null; $current_main_site_id = !empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; $option = 'ee_ueip_optin'; //set correct table for query $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog //for the purpose of caching. $pre = apply_filters('pre_option_' . $option, false, $option); if (false !== $pre) { EE_Core_Config::$ee_ueip_option = $pre; return EE_Core_Config::$ee_ueip_option; } $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM {$table_name} WHERE option_name = %s LIMIT 1", $option)); if (is_object($row)) { $value = $row->option_value; } else { //option does not exist so use default. return apply_filters('default_option_' . $option, false, $option); } EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); return EE_Core_Config::$ee_ueip_option; }