当前位置: 首页>>代码示例>>PHP>>正文


PHP GADWP_Tools::get_sites方法代码示例

本文整理汇总了PHP中GADWP_Tools::get_sites方法的典型用法代码示例。如果您正苦于以下问题:PHP GADWP_Tools::get_sites方法的具体用法?PHP GADWP_Tools::get_sites怎么用?PHP GADWP_Tools::get_sites使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GADWP_Tools的用法示例。


在下文中一共展示了GADWP_Tools::get_sites方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: uninstall

 public static function uninstall()
 {
     global $wpdb;
     if (is_multisite()) {
         // Cleanup Network install
         foreach (GADWP_Tools::get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) {
             switch_to_blog($blog['blog_id']);
             $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'gadwp_cache_%%'");
             delete_option('gadash_options');
             restore_current_blog();
         }
         delete_site_option('gadash_network_options');
     } else {
         // Cleanup Single install
         $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'gadwp_cache_%%'");
         delete_option('gadash_options');
     }
     GADWP_Tools::unset_cookie('default_metric');
     GADWP_Tools::unset_cookie('default_dimension');
     GADWP_Tools::unset_cookie('default_view');
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:21,代码来源:uninstall.php

示例2: general_settings_network

    public static function general_settings_network()
    {
        $gadwp = GADWP();
        global $wp_version;
        if (!current_user_can('manage_network_options')) {
            return;
        }
        $options = self::update_options('network');
        /*
         * Include GAPI
         */
        echo '<div id="gapi-warning" class="updated"><p>' . __('Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', 'google-analytics-dashboard-for-wp') . ' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=general_screen&utm_campaign=gadwp">Library conflicts between WordPress plugins</a></p></div>';
        if (null === $gadwp->gapi_controller) {
            $gadwp->gapi_controller = new GADWP_GAPI_Controller();
        }
        echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
        if (isset($_POST['ga_dash_code'])) {
            if (!stripos('x' . $_POST['ga_dash_code'], 'UA-', 1) == 1) {
                try {
                    $gadwp->gapi_controller->client->authenticate($_POST['ga_dash_code']);
                    $gadwp->config->options['ga_dash_token'] = $gadwp->gapi_controller->client->getAccessToken();
                    $gadwp->config->options['automatic_updates_minorversion'] = 1;
                    $gadwp->config->set_plugin_options(true);
                    $options = self::update_options('network');
                    $message = "<div class='updated'><p>" . __("Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp') . "</p></div>";
                    if (is_multisite()) {
                        // Cleanup errors on the entire network
                        foreach (GADWP_Tools::get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) {
                            switch_to_blog($blog['blog_id']);
                            GADWP_Tools::delete_cache('gapi_errors');
                            restore_current_blog();
                        }
                    } else {
                        GADWP_Tools::delete_cache('gapi_errors');
                    }
                    if ($gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken()) {
                        if (!empty($gadwp->config->options['ga_dash_profile_list'])) {
                            $profiles = $gadwp->config->options['ga_dash_profile_list'];
                        } else {
                            $profiles = $gadwp->gapi_controller->refresh_profiles();
                        }
                        if ($profiles) {
                            $gadwp->config->options['ga_dash_profile_list'] = $profiles;
                            if (isset($gadwp->config->options['ga_dash_tableid_jail']) && !$gadwp->config->options['ga_dash_tableid_jail']) {
                                $profile = GADWP_Tools::guess_default_domain($profiles);
                                $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
                                // $gadwp->config->options['ga_dash_tableid'] = $profile;
                            }
                            $gadwp->config->set_plugin_options(true);
                            $options = self::update_options('network');
                        }
                    }
                } catch (Google_IO_Exception $e) {
                    GADWP_Tools::set_cache('last_error', date('Y-m-d H:i:s') . ': ' . esc_html($e), $gadwp->gapi_controller->error_timeout);
                    return false;
                } catch (Google_Service_Exception $e) {
                    GADWP_Tools::set_cache('last_error', date('Y-m-d H:i:s') . ': ' . esc_html("(" . $e->getCode() . ") " . $e->getMessage()), $gadwp->gapi_controller->error_timeout);
                    GADWP_Tools::set_cache('gapi_errors', $e->getErrors(), $gadwp->gapi_controller->error_timeout);
                    return $e->getCode();
                } catch (Exception $e) {
                    GADWP_Tools::set_cache('last_error', date('Y-m-d H:i:s') . ': ' . esc_html($e) . "\nResponseHttpCode:" . $e->getCode(), $gadwp->gapi_controller->error_timeout);
                    $gadwp->gapi_controller->reset_token(false);
                }
            } else {
                $message = "<div class='error'><p>" . __("The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp') . ".</p></div>";
            }
        }
        if (isset($_POST['Refresh'])) {
            if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
                $gadwp->config->options['ga_dash_profile_list'] = array();
                $message = "<div class='updated'><p>" . __("Properties refreshed.", 'google-analytics-dashboard-for-wp') . "</p></div>";
                $options = self::update_options('network');
                if ($gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken()) {
                    if (!empty($gadwp->config->options['ga_dash_profile_list'])) {
                        $profiles = $gadwp->config->options['ga_dash_profile_list'];
                    } else {
                        $profiles = $gadwp->gapi_controller->refresh_profiles();
                    }
                    if ($profiles) {
                        $gadwp->config->options['ga_dash_profile_list'] = $profiles;
                        if (isset($gadwp->config->options['ga_dash_tableid_jail']) && !$gadwp->config->options['ga_dash_tableid_jail']) {
                            $profile = GADWP_Tools::guess_default_domain($profiles);
                            $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
                            // $gadwp->config->options['ga_dash_tableid'] = $profile;
                        }
                        $gadwp->config->set_plugin_options(true);
                        $options = self::update_options('network');
                    }
                }
            } else {
                $message = "<div class='error'><p>" . __("Cheating Huh?", 'google-analytics-dashboard-for-wp') . "</p></div>";
            }
        }
        if (isset($_POST['Clear'])) {
            if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
                GADWP_Tools::clear_cache();
                $message = "<div class='updated'><p>" . __("Cleared Cache.", 'google-analytics-dashboard-for-wp') . "</p></div>";
            } else {
                $message = "<div class='error'><p>" . __("Cheating Huh?", 'google-analytics-dashboard-for-wp') . "</p></div>";
            }
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:settings.php

示例3: maintain_compatibility

 private function maintain_compatibility()
 {
     $flag = false;
     if (GADWP_CURRENT_VERSION != get_option('gadwp_version')) {
         $flag = true;
         update_option('gadwp_version', GADWP_CURRENT_VERSION);
         update_option('gadwp_got_updated', true);
         $rebuild_token = json_decode($this->options['ga_dash_token']);
         // v4.8.2
         if (is_object($rebuild_token) && !isset($rebuild_token->token_type)) {
             if (isset($this->options['ga_dash_refresh_token'])) {
                 $rebuild_token->refresh_token = $this->options['ga_dash_refresh_token'];
             }
             $rebuild_token->token_type = "Bearer";
             $this->options['ga_dash_token'] = json_encode($rebuild_token);
             unset($this->options['ga_dash_refresh_token']);
             $this->set_plugin_options(true);
         } else {
             unset($this->options['ga_dash_refresh_token']);
         }
         GADWP_Tools::clear_cache();
         GADWP_Tools::delete_cache('last_error');
         if (is_multisite()) {
             // Cleanup errors and cookies on the entire network
             foreach (GADWP_Tools::get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) {
                 switch_to_blog($blog['blog_id']);
                 GADWP_Tools::delete_cache('gapi_errors');
                 restore_current_blog();
             }
         } else {
             GADWP_Tools::delete_cache('gapi_errors');
         }
         GADWP_Tools::unset_cookie('default_metric');
         GADWP_Tools::unset_cookie('default_dimension');
         GADWP_Tools::unset_cookie('default_view');
     }
     if (!isset($this->options['ga_enhanced_links'])) {
         $this->options['ga_enhanced_links'] = 0;
         $flag = true;
     }
     if (!isset($this->options['ga_dash_network'])) {
         $this->options['ga_dash_network'] = 0;
         $flag = true;
     }
     if (!isset($this->options['ga_enhanced_excludesa'])) {
         $this->options['ga_dash_excludesa'] = 0;
         $flag = true;
     }
     if (!isset($this->options['ga_dash_remarketing'])) {
         $this->options['ga_dash_remarketing'] = 0;
         $flag = true;
     }
     if (!isset($this->options['ga_dash_adsense'])) {
         $this->options['ga_dash_adsense'] = 0;
         $flag = true;
     }
     if (!isset($this->options['ga_speed_samplerate'])) {
         $this->options['ga_speed_samplerate'] = 1;
         $flag = true;
     }
     if (!isset($this->options['automatic_updates_minorversion'])) {
         $this->options['automatic_updates_minorversion'] = 1;
         $flag = true;
     }
     if (!isset($this->options['ga_event_bouncerate'])) {
         $this->options['ga_event_bouncerate'] = 0;
         $flag = true;
     }
     if (!is_array($this->options['ga_dash_access_front']) || empty($this->options['ga_dash_access_front'])) {
         $this->options['ga_dash_access_front'] = array();
         $this->options['ga_dash_access_front'][] = 'administrator';
         $flag = true;
     }
     if (!is_array($this->options['ga_dash_profile_list'])) {
         $this->options['ga_dash_profile_list'] = array();
         $flag = true;
     }
     if (!is_array($this->options['ga_dash_access_back']) || empty($this->options['ga_dash_access_back'])) {
         $this->options['ga_dash_access_back'] = array();
         $this->options['ga_dash_access_back'][] = 'administrator';
         $flag = true;
     }
     if (!is_array($this->options['ga_track_exclude'])) {
         $this->options['ga_track_exclude'] = array();
         $flag = true;
     }
     if (!isset($this->options['ga_crossdomain_tracking'])) {
         $this->options['ga_crossdomain_tracking'] = 0;
         $flag = true;
     }
     if (!isset($this->options['ga_crossdomain_list'])) {
         $this->options['ga_crossdomain_list'] = '';
         $flag = true;
     }
     if (!isset($this->options['ga_author_dimindex'])) {
         $this->options['ga_author_dimindex'] = 0;
         $flag = true;
     }
     if (!isset($this->options['ga_tag_dimindex'])) {
         $this->options['ga_tag_dimindex'] = 0;
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:config.php


注:本文中的GADWP_Tools::get_sites方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。