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


PHP GADWP_Tools::get_cache方法代码示例

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


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

示例1: get_realtime

 /**
  * Analytics data for backend reports (Real-Time)
  *
  * @param
  *            $projectId
  * @return array|int
  */
 private function get_realtime($projectId)
 {
     $metrics = 'rt:activeUsers';
     $dimensions = 'rt:pagePath,rt:source,rt:keyword,rt:trafficType,rt:visitorType,rt:pageTitle';
     try {
         $serial = 'qr_realtimecache_' . $this->get_serial($projectId);
         $transient = GADWP_Tools::get_cache($serial);
         if ($transient === false) {
             if ($this->gapi_errors_handler()) {
                 return -23;
             }
             $data = $this->service->data_realtime->get('ga:' . $projectId, $metrics, array('dimensions' => $dimensions, 'quotaUser' => $this->managequota . 'p' . $projectId));
             GADWP_Tools::set_cache($serial, $data, 55);
             $this->gadwp->config->options['api_backoff'] = 0;
             $this->gadwp->config->set_plugin_options();
         } else {
             $data = $transient;
         }
     } catch (Google_Service_Exception $e) {
         GADWP_Tools::set_cache('last_error', date('Y-m-d H:i:s') . ': ' . esc_html("(" . $e->getCode() . ") " . $e->getMessage()), $this->error_timeout);
         GADWP_Tools::set_cache('gapi_errors', array($e->getCode(), (array) $e->getErrors()), $this->error_timeout);
         return $e->getCode();
     } catch (Exception $e) {
         GADWP_Tools::set_cache('last_error', date('Y-m-d H:i:s') . ': ' . esc_html($e), $this->error_timeout);
         return $e->getCode();
     }
     if ($data->getRows() < 1) {
         return -21;
     }
     $i = 0;
     $gadwp_data = $data;
     foreach ($data->getRows() as $row) {
         $gadwp_data->rows[$i] = array_map('esc_html', $row);
         $i++;
     }
     return $gadwp_data;
 }
开发者ID:RagnarDanneskjold,项目名称:goodbyeloans.com,代码行数:44,代码来源:gapi.php

示例2: general_settings_network


//.........这里部分代码省略.........
            } else {
                $message = "<div class='error'><p>" . __("Cheating Huh?", 'google-analytics-dashboard-for-wp') . "</p></div>";
            }
        }
        if (isset($_POST['options']['ga_dash_hidden']) && !isset($_POST['Clear']) && !isset($_POST['Reset']) && !isset($_POST['Refresh'])) {
            $message = "<div class='updated'><p>" . __("Settings saved.", 'google-analytics-dashboard-for-wp') . "</p></div>";
            if (!(isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
                $message = "<div class='error'><p>" . __("Cheating Huh?", 'google-analytics-dashboard-for-wp') . "</p></div>";
            }
        }
        if (isset($_POST['Hide'])) {
            if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
                $message = "<div class='updated'><p>" . __("All other domains/properties were removed.", 'google-analytics-dashboard-for-wp') . "</p></div>";
                $lock_profile = GADWP_Tools::get_selected_profile($gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail']);
                $gadwp->config->options['ga_dash_profile_list'] = array($lock_profile);
                $options = self::update_options('network');
            } else {
                $message = "<div class='error'><p>" . __("Cheating Huh?", 'google-analytics-dashboard-for-wp') . "</p></div>";
            }
        }
        ?>
	<div class="wrap">
		<?php 
        echo "<h2>" . __("Google Analytics Settings", 'google-analytics-dashboard-for-wp') . "</h2>";
        ?>
<hr>
                                        </div>
                                        <div id="poststuff" class="gadwp">
                                            <div id="post-body" class="metabox-holder columns-2">
                                                <div id="post-body-content">
                                                    <div class="settings-wrapper">
                                                        <div class="inside">
						<?php 
        if ($gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache('last_error')) {
            $message = sprintf('<div class="error"><p>%s</p></div>', sprintf(__('Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s">%2$s</a>', menu_page_url('gadash_errors_debugging', false), __('Errors & Debug', 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s">%2$s</a>', menu_page_url('gadash_settings', false), __('authorize the plugin', 'google-analytics-dashboard-for-wp'))));
        }
        if (isset($_POST['Authorize'])) {
            GADWP_Tools::clear_cache();
            $gadwp->gapi_controller->token_request();
            echo "<div class='updated'><p>" . __("Use the red link (see below) to generate and get your access code!", 'google-analytics-dashboard-for-wp') . "</p></div>";
        } else {
            if (isset($message)) {
                echo $message;
            }
            ?>
						<form name="ga_dash_form" method="post" action="<?php 
            echo esc_url($_SERVER['REQUEST_URI']);
            ?>
">
                                                                <input type="hidden" name="options[ga_dash_hidden]" value="Y">
							<?php 
            wp_nonce_field('gadash_form', 'gadash_security');
            ?>
							<table class="gadwp-settings-options">
                                                                    <tr>
                                                                        <td colspan="2"><?php 
            echo "<h2>" . __("Network Setup", 'google-analytics-dashboard-for-wp') . "</h2>";
            ?>
</td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="2" class="gadwp-settings-title">
                                                                            <div class="button-primary gadwp-settings-switchoo">
                                                                                <input type="checkbox" name="options[ga_dash_network]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_network" <?php 
            checked($options['ga_dash_network'], 1);
            ?>
开发者ID:RagnarDanneskjold,项目名称:goodbyeloans.com,代码行数:67,代码来源:settings.php

示例3: load_styles_scripts

 /**
  * Styles & Scripts conditional loading (based on current URI)
  *
  * @param
  *            $hook
  */
 public function load_styles_scripts($hook)
 {
     $new_hook = explode('_page_', $hook);
     if (isset($new_hook[1])) {
         $new_hook = '_page_' . $new_hook[1];
     } else {
         $new_hook = $hook;
     }
     /*
      * GADWP main stylesheet
      */
     wp_enqueue_style('gadwp', GADWP_URL . 'admin/css/gadwp.css', null, GADWP_CURRENT_VERSION);
     /*
      * GADWP UI
      */
     if (GADWP_Tools::get_cache('gapi_errors')) {
         $ed_bubble = '!';
     } else {
         $ed_bubble = '';
     }
     wp_enqueue_script('gadwp-backend-ui', plugins_url('js/ui.js', __FILE__), array('jquery'), GADWP_CURRENT_VERSION, true);
     /* @formatter:off */
     wp_localize_script('gadwp-backend-ui', 'gadwp_ui_data', array('ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('gadwp_dismiss_notices'), 'ed_bubble' => $ed_bubble));
     /* @formatter:on */
     if ($this->gadwp->config->options['switch_profile'] && count($this->gadwp->config->options['ga_dash_profile_list']) > 1) {
         $views = array();
         foreach ($this->gadwp->config->options['ga_dash_profile_list'] as $items) {
             if ($items[3]) {
                 $views[$items[1]] = esc_js(GADWP_Tools::strip_protocol($items[3]));
                 //  . ' &#8658; ' . $items[0] );
             }
         }
     } else {
         $views = false;
     }
     /*
      * Main Dashboard Widgets Styles & Scripts
      */
     $widgets_hooks = array('index.php');
     if (in_array($new_hook, $widgets_hooks)) {
         if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) && $this->gadwp->config->options['dashboard_widget']) {
             if ($this->gadwp->config->options['ga_target_geomap']) {
                 $country_codes = GADWP_Tools::get_countrycodes();
                 if (isset($country_codes[$this->gadwp->config->options['ga_target_geomap']])) {
                     $region = $this->gadwp->config->options['ga_target_geomap'];
                 } else {
                     $region = false;
                 }
             } else {
                 $region = false;
             }
             wp_enqueue_style('gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION);
             wp_enqueue_style('gadwp-backend-item-reports', GADWP_URL . 'admin/css/admin-widgets.css', null, GADWP_CURRENT_VERSION);
             wp_register_style('jquery-ui-tooltip-html', GADWP_URL . 'common/realtime/jquery.ui.tooltip.html.css');
             wp_enqueue_style('jquery-ui-tooltip-html');
             wp_register_script('jquery-ui-tooltip-html', GADWP_URL . 'common/realtime/jquery.ui.tooltip.html.js');
             if (!wp_script_is('googlejsapi')) {
                 wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
             }
             wp_enqueue_script('gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array('jquery'), GADWP_CURRENT_VERSION);
             wp_enqueue_script('gadwp-backend-dashboard-reports', GADWP_URL . 'common/js/reports.js', array('jquery', 'googlejsapi', 'gadwp-nprogress', 'jquery-ui-tooltip', 'jquery-ui-core', 'jquery-ui-position', 'jquery-ui-tooltip-html'), GADWP_CURRENT_VERSION);
             /* @formatter:off */
             wp_localize_script('gadwp-backend-dashboard-reports', 'gadwp_item_data', array('ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('gadwp_backend_item_reports'), 'dateList' => array('realtime' => __("Real-Time", 'google-analytics-dashboard-for-wp'), 'today' => __("Today", 'google-analytics-dashboard-for-wp'), 'yesterday' => __("Yesterday", 'google-analytics-dashboard-for-wp'), '7daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 7), '14daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 14), '30daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 30), '90daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 90), '365daysAgo' => sprintf(_n("%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp'), __('One', 'google-analytics-dashboard-for-wp')), '1095daysAgo' => sprintf(_n("%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp'), __('Three', 'google-analytics-dashboard-for-wp'))), 'reportList' => array('sessions' => __("Sessions", 'google-analytics-dashboard-for-wp'), 'users' => __("Users", 'google-analytics-dashboard-for-wp'), 'organicSearches' => __("Organic", 'google-analytics-dashboard-for-wp'), 'pageviews' => __("Page Views", 'google-analytics-dashboard-for-wp'), 'visitBounceRate' => __("Bounce Rate", 'google-analytics-dashboard-for-wp'), 'locations' => __("Location", 'google-analytics-dashboard-for-wp'), 'contentpages' => __("Pages", 'google-analytics-dashboard-for-wp'), 'referrers' => __("Referrers", 'google-analytics-dashboard-for-wp'), 'searches' => __("Searches", 'google-analytics-dashboard-for-wp'), 'trafficdetails' => __("Traffic Details", 'google-analytics-dashboard-for-wp')), 'i18n' => array(__("A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp'), __("Traffic Mediums", 'google-analytics-dashboard-for-wp'), __("Visitor Type", 'google-analytics-dashboard-for-wp'), __("Social Networks", 'google-analytics-dashboard-for-wp'), __("Search Engines", 'google-analytics-dashboard-for-wp'), __("Sessions", 'google-analytics-dashboard-for-wp'), __("Users", 'google-analytics-dashboard-for-wp'), __("Page Views", 'google-analytics-dashboard-for-wp'), __("Bounce Rate", 'google-analytics-dashboard-for-wp'), __("Organic Search", 'google-analytics-dashboard-for-wp'), __("Pages/Session", 'google-analytics-dashboard-for-wp'), __("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'), __("Not enough data collected", 'google-analytics-dashboard-for-wp'), __("This report is unavailable", 'google-analytics-dashboard-for-wp'), __("report generated by", 'google-analytics-dashboard-for-wp'), __("This plugin needs an authorization:", 'google-analytics-dashboard-for-wp') . ' <a href="' . menu_page_url('gadash_settings', false) . '">' . __("authorize the plugin", 'google-analytics-dashboard-for-wp') . '</a>.'), 'i18n_realtime' => array(__("REFERRALS", 'google-analytics-dashboard-for-wp'), __("KEYWORDS", 'google-analytics-dashboard-for-wp'), __("SOCIAL", 'google-analytics-dashboard-for-wp'), __("CAMPAIGN", 'google-analytics-dashboard-for-wp'), __("DIRECT", 'google-analytics-dashboard-for-wp'), __("NEW", 'google-analytics-dashboard-for-wp')), 'realtime_maxpages' => $this->gadwp->config->options['ga_realtime_pages'], 'colorVariations' => GADWP_Tools::variations($this->gadwp->config->options['ga_dash_style']), 'region' => $region, 'language' => get_bloginfo('language'), 'viewList' => $views, 'scope' => 'admin-widgets'));
             /* @formatter:on */
         }
     }
     /*
      * Posts/Pages List Styles & Scripts
      */
     $contentstats_hooks = array('edit.php');
     if (in_array($hook, $contentstats_hooks)) {
         if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) && $this->gadwp->config->options['backend_item_reports']) {
             if ($this->gadwp->config->options['ga_target_geomap']) {
                 $country_codes = GADWP_Tools::get_countrycodes();
                 if (isset($country_codes[$this->gadwp->config->options['ga_target_geomap']])) {
                     $region = $this->gadwp->config->options['ga_target_geomap'];
                 } else {
                     $region = false;
                 }
             } else {
                 $region = false;
             }
             wp_enqueue_style('gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION);
             wp_enqueue_style('gadwp-backend-item-reports', GADWP_URL . 'admin/css/item-reports.css', null, GADWP_CURRENT_VERSION);
             wp_enqueue_style("wp-jquery-ui-dialog");
             if (!wp_script_is('googlejsapi')) {
                 wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
             }
             wp_enqueue_script('gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array('jquery'), GADWP_CURRENT_VERSION);
             wp_enqueue_script('gadwp-backend-item-reports', GADWP_URL . 'common/js/reports.js', array('gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog'), GADWP_CURRENT_VERSION);
             /* @formatter:off */
             wp_localize_script('gadwp-backend-item-reports', 'gadwp_item_data', array('ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('gadwp_backend_item_reports'), 'dateList' => array('today' => __("Today", 'google-analytics-dashboard-for-wp'), 'yesterday' => __("Yesterday", 'google-analytics-dashboard-for-wp'), '7daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 7), '14daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 14), '30daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 30), '90daysAgo' => sprintf(__("Last %d Days", 'google-analytics-dashboard-for-wp'), 90), '365daysAgo' => sprintf(_n("%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp'), __('One', 'google-analytics-dashboard-for-wp')), '1095daysAgo' => sprintf(_n("%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp'), __('Three', 'google-analytics-dashboard-for-wp'))), 'reportList' => array('uniquePageviews' => __("Unique Views", 'google-analytics-dashboard-for-wp'), 'users' => __("Users", 'google-analytics-dashboard-for-wp'), 'organicSearches' => __("Organic", 'google-analytics-dashboard-for-wp'), 'pageviews' => __("Page Views", 'google-analytics-dashboard-for-wp'), 'visitBounceRate' => __("Bounce Rate", 'google-analytics-dashboard-for-wp'), 'locations' => __("Location", 'google-analytics-dashboard-for-wp'), 'referrers' => __("Referrers", 'google-analytics-dashboard-for-wp'), 'searches' => __("Searches", 'google-analytics-dashboard-for-wp'), 'trafficdetails' => __("Traffic Details", 'google-analytics-dashboard-for-wp')), 'i18n' => array(__("A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp'), __("Traffic Mediums", 'google-analytics-dashboard-for-wp'), __("Visitor Type", 'google-analytics-dashboard-for-wp'), __("Social Networks", 'google-analytics-dashboard-for-wp'), __("Search Engines", 'google-analytics-dashboard-for-wp'), __("Unique Views", 'google-analytics-dashboard-for-wp'), __("Users", 'google-analytics-dashboard-for-wp'), __("Page Views", 'google-analytics-dashboard-for-wp'), __("Bounce Rate", 'google-analytics-dashboard-for-wp'), __("Organic Search", 'google-analytics-dashboard-for-wp'), __("Pages/Session", 'google-analytics-dashboard-for-wp'), __("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'), __("Not enough data collected", 'google-analytics-dashboard-for-wp'), __("This report is unavailable", 'google-analytics-dashboard-for-wp'), __("report generated by", 'google-analytics-dashboard-for-wp'), __("This plugin needs an authorization:", 'google-analytics-dashboard-for-wp') . ' <a href="' . menu_page_url('gadash_settings', false) . '">' . __("authorize the plugin", 'google-analytics-dashboard-for-wp') . '</a>.'), 'colorVariations' => GADWP_Tools::variations($this->gadwp->config->options['ga_dash_style']), 'region' => $region, 'language' => get_bloginfo('language'), 'viewList' => false, 'scope' => 'admin-item'));
             /* @formatter:on */
         }
//.........这里部分代码省略.........
开发者ID:zakaria340,项目名称:critique,代码行数:101,代码来源:setup.php


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