/**
  *    update_post_shortcodes
  *
  * @access    public
  * @param $page_for_posts
  * @return    void
  */
 public function update_post_shortcodes($page_for_posts = '')
 {
     // make sure page_for_posts is set
     $page_for_posts = !empty($page_for_posts) ? $page_for_posts : EE_Config::get_page_for_posts();
     // critical page shortcodes that we do NOT want added to the Posts page (blog)
     $critical_shortcodes = $this->core->get_critical_pages_shortcodes_array();
     // allow others to mess stuff up :D
     do_action('AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts);
     // verify that post_shortcodes is set
     $this->core->post_shortcodes = isset($this->core->post_shortcodes) && is_array($this->core->post_shortcodes) ? $this->core->post_shortcodes : array();
     // cycle thru post_shortcodes
     foreach ($this->core->post_shortcodes as $post_name => $shortcodes) {
         // are there any shortcodes to track ?
         if (!empty($shortcodes)) {
             // loop thru list of tracked shortcodes
             foreach ($shortcodes as $shortcode => $post_id) {
                 // if shortcode is for a critical page, BUT this is NOT the corresponding critical page for that shortcode
                 if (isset($critical_shortcodes[$post_id]) && $post_name == $page_for_posts) {
                     // then remove this shortcode, because we don't want critical page shortcodes like ESPRESSO_TXN_PAGE running on the "Posts Page" (blog)
                     unset($this->core->post_shortcodes[$post_name][$shortcode]);
                 }
                 // skip the posts page, because we want all shortcodes registered for it
                 if ($post_name == $page_for_posts) {
                     continue;
                 }
                 // make sure post still exists
                 $post = get_post($post_id);
                 if ($post) {
                     // check that the post name matches what we have saved
                     if ($post->post_name == $post_name) {
                         // if so, then break before hitting the unset below
                         continue;
                     }
                 }
                 // we don't like missing posts around here >:(
                 unset($this->core->post_shortcodes[$post_name]);
             }
         } else {
             // you got no shortcodes to keep track of !
             unset($this->core->post_shortcodes[$post_name]);
         }
     }
     //only show errors
     $this->update_espresso_config();
 }
 /**
  * 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;
 }