本文整理汇总了PHP中GADWP_Tools::check_roles方法的典型用法代码示例。如果您正苦于以下问题:PHP GADWP_Tools::check_roles方法的具体用法?PHP GADWP_Tools::check_roles怎么用?PHP GADWP_Tools::check_roles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GADWP_Tools
的用法示例。
在下文中一共展示了GADWP_Tools::check_roles方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_styles_scripts
/**
* Styles & Scripts conditional loading
*
* @param
* $hook
*/
public function load_styles_scripts()
{
$lang = get_bloginfo('language');
$lang = explode('-', $lang);
$lang = $lang[0];
/*
* Item reports Styles & Scripts
*/
if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_front']) && $this->gadwp->config->options['frontend_item_reports']) {
wp_enqueue_style('gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION);
wp_enqueue_style('gadwp-frontend-item-reports', GADWP_URL . 'front/css/item-reports.css', null, GADWP_CURRENT_VERSION);
$country_codes = GADWP_Tools::get_countrycodes();
if ($this->gadwp->config->options['ga_target_geomap'] && isset($country_codes[$this->gadwp->config->options['ga_target_geomap']])) {
$region = $this->gadwp->config->options['ga_target_geomap'];
} else {
$region = false;
}
wp_enqueue_style("wp-jquery-ui-dialog");
if (!wp_script_is('googlejsapi')) {
wp_register_script('googlejsapi', 'https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22language%22%3A%22' . $lang . '%22%2C%22packages%22%3A%5B%22corechart%22%2C%20%22table%22%2C%20%22orgchart%22%2C%20%22geochart%22%5D%7D%5D%7D%27', array(), null);
}
wp_enqueue_script('gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array('jquery'), GADWP_CURRENT_VERSION);
wp_enqueue_script('gadwp-frontend-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-frontend-item-reports', 'gadwpItemData', array('ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('gadwp_frontend_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", 'google-analytics-dashboard-for-wp'), 'technologydetails' => __("Technology", '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'), __("Search Engines", 'google-analytics-dashboard-for-wp'), __("Social Networks", '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') . ' <strong>' . __("authorize the plugin", 'google-analytics-dashboard-for-wp') . '</strong>!', __("Browser", 'google-analytics-dashboard-for-wp'), __("Operating System", 'google-analytics-dashboard-for-wp'), __("Screen Resolution", 'google-analytics-dashboard-for-wp'), __("Mobile Brand", 'google-analytics-dashboard-for-wp')), 'colorVariations' => GADWP_Tools::variations($this->gadwp->config->options['ga_dash_style']), 'region' => $region, 'language' => get_bloginfo('language'), 'filter' => $_SERVER["REQUEST_URI"], 'viewList' => false, 'scope' => 'front-item'));
/* @formatter:on */
}
}
示例2: load_styles_scripts
/**
* Styles & Scripts conditional loading
*
* @param
* $hook
*/
public function load_styles_scripts()
{
/*
* GADWP main stylesheet
*/
wp_enqueue_style('ga_dash-front', GADWP_URL . 'front/css/item-reports.css', null, GADWP_CURRENT_VERSION);
/*
* Item reports Styles & Scripts
*/
if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_front']) && $this->gadwp->config->options['frontend_item_reports']) {
wp_enqueue_style('gadwp-nprogress', GADWP_URL . 'tools/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION);
wp_enqueue_style('gadwp_frontend_item_reports', GADWP_URL . 'front/css/item-reports.css', null, GADWP_CURRENT_VERSION);
$country_codes = GADWP_Tools::get_countrycodes();
if ($this->gadwp->config->options['ga_target_geomap'] && isset($country_codes[$this->gadwp->config->options['ga_target_geomap']])) {
$region = $this->gadwp->config->options['ga_target_geomap'];
} else {
$region = false;
}
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 . 'tools/nprogress/nprogress.js', array('jquery'), GADWP_CURRENT_VERSION);
wp_enqueue_script('gadwp_frontend_item_reports', plugins_url('js/item-reports.js', __FILE__), array('gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog'), GADWP_CURRENT_VERSION);
/* @formatter:off */
wp_localize_script('gadwp_frontend_item_reports', 'gadwp_item_data', array('ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('gadwp_frontend_item_reports'), 'dateList' => array('today' => __("Today", 'ga-dash'), 'yesterday' => __("Yesterday", 'ga-dash'), '7daysAgo' => __("Last 7 Days", 'ga-dash'), '30daysAgo' => __("Last 30 Days", 'ga-dash'), '90daysAgo' => __("Last 90 Days", 'ga-dash')), 'reportList' => array('uniquePageviews' => __("Unique Views", 'ga-dash'), 'users' => __("Users", 'ga-dash'), 'organicSearches' => __("Organic", 'ga-dash'), 'pageviews' => __("Page Views", 'ga-dash'), 'visitBounceRate' => __("Bounce Rate", 'ga-dash'), 'locations' => __("Location", 'ga-dash'), 'referrers' => __("Referrers", 'ga-dash'), 'searches' => __("Searches", 'ga-dash'), 'trafficdetails' => __("Traffic Details", 'ga-dash')), 'i18n' => array(__("A JavaScript Error is blocking plugin resources!", 'ga-dash'), __("Traffic Mediums", 'ga-dash'), __("Visitor Type", 'ga-dash'), __("Social Networks", 'ga-dash'), __("Search Engines", 'ga-dash'), __("Unique Views", 'ga-dash'), __("Users", 'ga-dash'), __("Page Views", 'ga-dash'), __("Bounce Rate", 'ga-dash'), __("Organic Search", 'ga-dash'), __("Pages/Session", 'ga-dash'), __("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'), __("Not enough data collected", 'ga-dash'), __("This report is unavailable", 'ga-dash'), __("report generated by", 'ga-dash')), 'colorVariations' => GADWP_Tools::variations($this->gadwp->config->options['ga_dash_style']), 'region' => $region));
/* @formatter:on */
}
}
示例3: tracking_code
public function tracking_code()
{
if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_track_exclude'], true) || $this->gadwp->config->options['ga_dash_excludesa'] && current_user_can('manage_network')) {
return;
}
$traking_mode = $this->gadwp->config->options['ga_dash_tracking'];
$traking_type = $this->gadwp->config->options['ga_dash_tracking_type'];
if ($traking_mode > 0) {
if (!$this->gadwp->config->options['ga_dash_tableid_jail']) {
return;
}
if ($traking_type == "classic") {
echo "\n<!-- BEGIN GADWP v" . GADWP_CURRENT_VERSION . " Classic Tracking - https://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
if ($this->gadwp->config->options['ga_event_tracking']) {
require_once 'tracking/events-classic.php';
}
require_once 'tracking/code-classic.php';
echo "\n<!-- END GADWP Classic Tracking -->\n\n";
} else {
echo "\n<!-- BEGIN GADWP v" . GADWP_CURRENT_VERSION . " Universal Tracking - https://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
if ($this->gadwp->config->options['ga_event_tracking'] || $this->gadwp->config->options['ga_aff_tracking'] || $this->gadwp->config->options['ga_hash_tracking']) {
require_once 'tracking/events-universal.php';
}
require_once 'tracking/code-universal.php';
echo "\n<!-- END GADWP Universal Tracking -->\n\n";
}
}
}
示例4: __construct
public function __construct()
{
$this->gadwp = GADWP();
if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) && 1 == $this->gadwp->config->options['dashboard_widget']) {
add_action('wp_dashboard_setup', array($this, 'add_widget'));
}
}
示例5: __construct
public function __construct()
{
$this->gadwp = GADWP();
if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) || GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_front'])) {
add_action('wp_ajax_gadwp_set_error', array($this, 'ajax_set_error'));
}
}
示例6: custom_adminbar_node
function custom_adminbar_node($wp_admin_bar)
{
if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_front']) && $this->gadwp->config->options['frontend_item_reports']) {
/* @formatter:off */
$args = array('id' => 'gadwp-1', 'title' => '<span class="ab-icon"></span><span class="">' . __("Analytics", 'ga-dash') . '</span>', 'href' => '#1');
/* @formatter:on */
$wp_admin_bar->add_node($args);
}
}
示例7: ajax_item_reports
/**
* Ajax handler for Item Reports
*
* @return json|int
*/
public function ajax_item_reports()
{
if (!isset($_REQUEST['gadwp_security_backend_item_reports']) || !wp_verify_nonce($_REQUEST['gadwp_security_backend_item_reports'], 'gadwp_backend_item_reports')) {
wp_die(-30);
}
$from = $_REQUEST['from'];
$to = $_REQUEST['to'];
$query = $_REQUEST['query'];
if (isset($_REQUEST['filter'])) {
$filter_id = $_REQUEST['filter'];
} else {
$filter_id = false;
}
if (ob_get_length()) {
ob_clean();
}
if (!GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) || 0 == $this->gadwp->config->options['backend_item_reports']) {
wp_die(-31);
}
if ($this->gadwp->config->options['ga_dash_token'] && $this->gadwp->config->options['ga_dash_tableid_jail'] && $from && $to) {
if (null === $this->gadwp->gapi_controller) {
$this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
}
} else {
wp_die(-24);
}
$projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
$profile_info = GADWP_Tools::get_selected_profile($this->gadwp->config->options['ga_dash_profile_list'], $projectId);
if (isset($profile_info[4])) {
$this->gadwp->gapi_controller->timeshift = $profile_info[4];
} else {
$this->gadwp->gapi_controller->timeshift = (int) current_time('timestamp') - time();
}
if ($filter_id) {
$uri_parts = explode('/', get_permalink($filter_id), 4);
if (isset($uri_parts[3])) {
$uri = '/' . $uri_parts[3];
} else {
wp_die(-25);
}
// allow URL correction before sending an API request
$filter = apply_filters('gadwp_backenditem_uri', $uri);
$lastchar = substr($filter, -1);
if (isset($profile_info[6]) && $profile_info[6] && $lastchar == '/') {
$filter = $filter . $profile_info[6];
}
// Encode URL
$filter = rawurlencode(rawurldecode($filter));
}
$queries = explode(',', $query);
$results = array();
foreach ($queries as $value) {
$results[] = $this->gadwp->gapi_controller->get($projectId, $value, $from, $to, $filter);
}
wp_send_json($results);
}
示例8: __construct
public function __construct()
{
$this->gadwp = GADWP();
if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) && 1 == $this->gadwp->config->options['backend_item_reports']) {
// Add custom column in Posts List
add_filter('manage_posts_columns', array($this, 'add_columns'));
// Populate custom column in Posts List
add_action('manage_posts_custom_column', array($this, 'add_icons'), 10, 2);
// Add custom column in Pages List
add_filter('manage_pages_columns', array($this, 'add_columns'));
// Populate custom column in Pages List
add_action('manage_pages_custom_column', array($this, 'add_icons'), 10, 2);
}
}
示例9: ajax_afterpost_reports
/**
* Ajax handler for getting analytics data for frontend Views vs UniqueViews
*
* @return string|int
*/
public function ajax_afterpost_reports()
{
if (!isset($_REQUEST['gadash_security_pagereports']) || !wp_verify_nonce($_REQUEST['gadash_security_pagereports'], 'gadash_get_frontend_pagereports')) {
wp_die(-30);
}
$page_url = $_REQUEST['gadash_pageurl'];
$query = $_REQUEST['query'];
if (ob_get_length()) {
ob_clean();
}
if (!GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_front']) || !($this->gadwp->config->options['ga_dash_frontend_stats'] || $this->gadwp->config->options['ga_dash_frontend_keywords'])) {
wp_die(-31);
}
if ($this->gadwp->config->options['ga_dash_token'] && $this->gadwp->config->options['ga_dash_tableid_jail']) {
if (null === $this->gadwp->gapi_controller) {
$this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
}
} else {
wp_die(-24);
}
if ($this->gadwp->config->options['ga_dash_tableid_jail']) {
$projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
} else {
wp_die(-25);
}
$profile_info = GADWP_Tools::get_selected_profile($this->gadwp->config->options['ga_dash_profile_list'], $projectId);
if (isset($profile_info[4])) {
$this->gadwp->gapi_controller->timeshift = $profile_info[4];
} else {
$this->gadwp->gapi_controller->timeshift = (int) current_time('timestamp') - time();
}
switch ($query) {
case 'pageviews':
wp_send_json($this->gadwp->gapi_controller->frontend_afterpost_pageviews($projectId, $page_url));
break;
default:
wp_send_json($this->gadwp->gapi_controller->frontend_afterpost_searches($projectId, $page_url));
break;
}
}
示例10: load
/**
* Conditional load
*/
public function load()
{
if (is_admin()) {
if (defined('DOING_AJAX') && DOING_AJAX) {
if (GADWP_Tools::check_roles(self::$instance->config->options['ga_dash_access_back'])) {
/*
* Load Backend ajax actions
*/
include_once GADWP_DIR . 'admin/ajax-actions.php';
self::$instance->backend_actions = new GADWP_Backend_Ajax();
}
/*
* Load Frontend ajax actions
*/
include_once GADWP_DIR . 'front/ajax-actions.php';
self::$instance->frontend_actions = new GADWP_Frontend_Ajax();
/*
* Load Common ajax actions
*/
include_once GADWP_DIR . 'common/ajax-actions.php';
self::$instance->common_actions = new GADWP_Common_Ajax();
} else {
if (GADWP_Tools::check_roles(self::$instance->config->options['ga_dash_access_back'])) {
/*
* Load Backend Setup
*/
include_once GADWP_DIR . 'admin/setup.php';
self::$instance->backend_setup = new GADWP_Backend_Setup();
if (self::$instance->config->options['dashboard_widget']) {
/*
* Load Backend Widget
*/
include_once GADWP_DIR . 'admin/widgets.php';
self::$instance->backend_widgets = new GADWP_Backend_Widgets();
}
if (self::$instance->config->options['backend_item_reports']) {
/*
* Load Backend Item Reports
*/
include_once GADWP_DIR . 'admin/item-reports.php';
self::$instance->backend_item_reports = new GADWP_Backend_Item_Reports();
}
}
}
} else {
if (GADWP_Tools::check_roles(self::$instance->config->options['ga_dash_access_front'])) {
/*
* Load Frontend Setup
*/
include_once GADWP_DIR . 'front/setup.php';
self::$instance->frontend_setup = new GADWP_Frontend_Setup();
if (self::$instance->config->options['frontend_item_reports']) {
/*
* Load Frontend Item Reports
*/
include_once GADWP_DIR . 'front/item-reports.php';
self::$instance->frontend_item_reports = new GADWP_Frontend_Item_Reports();
}
}
if (!GADWP_Tools::check_roles(self::$instance->config->options['ga_track_exclude'], true) && self::$instance->config->options['ga_dash_tracking']) {
/*
* Load tracking class
*/
include_once GADWP_DIR . 'front/tracking.php';
self::$instance->tracking = new GADWP_Tracking();
}
}
}
示例11: load_styles_scripts
/**
* Styles & Scripts conditional loading (based on current URI)
*
* @param
* $hook
*/
public function load_styles_scripts($hook)
{
/*
* GADWP main stylesheet
*/
wp_enqueue_style('gadwp', GADWP_URL . 'admin/css/gadwp.css', null, GADWP_CURRENT_VERSION);
/*
* Dashboard Widgets Styles & Scripts
*/
$widgets_hooks = array('index.php');
if (in_array($hook, $widgets_hooks)) {
if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) && $this->gadwp->config->options['dashboard_widget']) {
wp_enqueue_style('gadwp-nprogress', GADWP_URL . 'tools/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION);
wp_enqueue_script('gadwp-admin-widgets', plugins_url('js/widgets.js', __FILE__), array('jquery'), GADWP_CURRENT_VERSION);
if (!wp_script_is('googlejsapi')) {
wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
wp_enqueue_script('googlejsapi');
}
wp_enqueue_script('gadwp-nprogress', GADWP_URL . 'tools/nprogress/nprogress.js', array('jquery'), GADWP_CURRENT_VERSION);
}
}
/*
* 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['item_reports']) {
wp_enqueue_style('gadwp-nprogress', GADWP_URL . 'tools/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION);
wp_enqueue_style('gadwp_itemreports', GADWP_URL . 'admin/css/item-reports.css', null, GADWP_CURRENT_VERSION);
$country_codes = GADWP_Tools::get_countrycodes();
if ($this->gadwp->config->options['ga_target_geomap'] && isset($country_codes[$this->gadwp->config->options['ga_target_geomap']])) {
$region = $this->gadwp->config->options['ga_target_geomap'];
} else {
$region = false;
}
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 . 'tools/nprogress/nprogress.js', array('jquery'), GADWP_CURRENT_VERSION);
wp_enqueue_script('gadwp_itemreports', plugins_url('js/item-reports.js', __FILE__), array('gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog'), GADWP_CURRENT_VERSION);
wp_localize_script('gadwp_itemreports', 'gadwp_item_data', array('ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('gadwp_get_itemreports'), 'dateList' => array('today' => __("Today", 'ga-dash'), 'yesterday' => __("Yesterday", 'ga-dash'), '7daysAgo' => __("Last 7 Days", 'ga-dash'), '30daysAgo' => __("Last 30 Days", 'ga-dash'), '90daysAgo' => __("Last 90 Days", 'ga-dash')), 'reportList' => array('uniquePageviews' => __("Unique Views", 'ga-dash'), 'users' => __("Users", 'ga-dash'), 'organicSearches' => __("Organic", 'ga-dash'), 'pageviews' => __("Page Views", 'ga-dash'), 'visitBounceRate' => __("Bounce Rate", 'ga-dash'), 'locations' => __("Location", 'ga-dash'), 'referrers' => __("Referrers", 'ga-dash'), 'searches' => __("Searches", 'ga-dash'), 'trafficdetails' => __("Traffic Details", 'ga-dash')), 'i18n' => array(__("A JavaScript Error is blocking plugin resources!", 'ga-dash'), __("Traffic Mediums", 'ga-dash'), __("Visitor Type", 'ga-dash'), __("Social Networks", 'ga-dash'), __("Search Engines", 'ga-dash'), __("Unique Views", 'ga-dash'), __("Users", 'ga-dash'), __("Page Views", 'ga-dash'), __("Bounce Rate", 'ga-dash'), __("Organic Search", 'ga-dash'), __("Pages/Session", 'ga-dash'), __("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'), __("Not enough data collected", 'ga-dash'), __("This report is unavailable", 'ga-dash'), __("report generated by", 'ga-dash')), 'colorVariations' => GADWP_Tools::variations($this->gadwp->config->options['ga_dash_style']), 'region' => $region));
}
}
/*
* Settings Styles & Scripts
*/
$settings_hooks = array('toplevel_page_gadash_settings', 'google-analytics_page_gadash_backend_settings', 'google-analytics_page_gadash_frontend_settings', 'google-analytics_page_gadash_tracking_settings', 'google-analytics_page_gadash_errors_debugging');
if (in_array($hook, $settings_hooks)) {
wp_enqueue_style('wp-color-picker');
wp_enqueue_script('wp-color-picker');
wp_enqueue_script('wp-color-picker-script-handle', plugins_url('js/wp-color-picker-script.js', __FILE__), array('wp-color-picker'), false, true);
wp_enqueue_script('gadwp-settings', plugins_url('js/settings.js', __FILE__), array('jquery'), GADWP_CURRENT_VERSION);
}
}
示例12: add_content
public function add_content($content)
{
if (!GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_front']) || !($this->gadwp->config->options['ga_dash_frontend_stats'] || $this->gadwp->config->options['ga_dash_frontend_keywords'])) {
return $content;
}
if ($this->gadwp->config->options['ga_dash_frontend_stats'] && $this->gadwp->config->options['ga_dash_frontend_keywords']) {
$npcounter = 1;
} else {
$npcounter = 0;
}
if ((is_page() || is_single()) && !is_preview()) {
$page_url = $_SERVER["REQUEST_URI"];
//Encode URL
$page_url = rawurlencode($page_url);
$content .= '<script type="text/javascript">
gadash_firstclick = true;
function checknpcounter(max) {
try {
if (npcounter == max) {
NProgress.done();
} else {
npcounter++;
NProgress.set((1/(max+1))*npcounter);
}
} catch(e) {}
}
npcounter = 0;
jQuery(document).ready(function(){
jQuery("#gadwp-title").click(function(){
if (gadash_firstclick){
try {
NProgress.configure({ parent: "#gadwp-progressbar" });
NProgress.configure({ showSpinner: false });
NProgress.start();
} catch(e) {
jQuery("#gadwp-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red","font-size":"13px"});
jQuery("#gadwp-progressbar").html("' . __("A JavaScript Error is blocking plugin resources!", 'ga-dash') . '");
}
if(typeof ga_dash_drawpagesessions == "function"){
jQuery.post("' . admin_url('admin-ajax.php') . '", {action: "gadash_get_frontend_pagereports",gadash_pageurl: "' . $page_url . '",query: "pageviews",gadash_security_pagereports: "' . wp_create_nonce('gadash_get_frontend_pagereports') . '"}, function(response){
if (!jQuery.isNumeric(response)){
if (jQuery.isArray(response)){
gadash_pagesessions = response;
google.setOnLoadCallback(ga_dash_drawpagesessions(gadash_pagesessions));
} else {
checknpcounter(0);
jQuery("#gadwp-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red","font-size":"13px"});
jQuery("#gadwp-progressbar").html("' . __("Invalid response, more details in JavaScript Console (F12).", 'ga-dash') . '");
console.log("\\n********************* GADWP Log ********************* \\n\\n"+response);
}
}else{
jQuery("#gadwp-sessions").css({"background-color":"#F7F7F7","height":"auto","padding-top":"30px","padding-bottom":"30px","color":"#000","text-align":"center"});
jQuery("#gadwp-sessions").html("' . __("This report is unavailable", 'ga-dash') . ' ("+response+")");
checknpcounter(' . $npcounter . ');
}
});
}
if(typeof ga_dash_drawpagesearches == "function"){
jQuery.post("' . admin_url('admin-ajax.php') . '", {action: "gadash_get_frontend_pagereports",gadash_pageurl: "' . $page_url . '",query: "searches",gadash_security_pagereports: "' . wp_create_nonce('gadash_get_frontend_pagereports') . '"}, function(response){
if (!jQuery.isNumeric(response)){
if (jQuery.isArray(response)){
gadash_pagesearches = response;
google.setOnLoadCallback(ga_dash_drawpagesearches(gadash_pagesearches));
} else {
checknpcounter(0);
jQuery("#gadwp-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red","font-size":"13px"});
jQuery("#gadwp-progressbar").html("' . __("Invalid response, more details in JavaScript Console (F12).", 'ga-dash') . '");
console.log("\\n********************* GADWP Log ********************* \\n\\n"+response);
}
}else{
jQuery("#gadwp-searches").css({"background-color":"#F7F7F7","height":"auto","padding-top":"30px","padding-bottom":"30px","color":"#000","text-align":"center"});
jQuery("#gadwp-searches").html("' . __("This report is unavailable", 'ga-dash') . ' ("+response+")");
checknpcounter(' . $npcounter . ');
}
});
}
gadash_firstclick = false;
}
});
});';
if ($this->gadwp->config->options['ga_dash_frontend_stats']) {
$title = __("Views vs UniqueViews", 'ga-dash');
if (isset($this->gadwp->config->options['ga_dash_style'])) {
$css = "colors:['" . $this->gadwp->config->options['ga_dash_style'] . "','" . GADWP_Tools::colourVariator($this->gadwp->config->options['ga_dash_style'], -20) . "'],";
$color = $this->gadwp->config->options['ga_dash_style'];
} else {
$css = "";
$color = "#3366CC";
}
$content .= '
google.load("visualization", "1", {packages:["corechart"]});
function ga_dash_drawpagesessions(gadash_pagesessions) {
var data = google.visualization.arrayToDataTable(gadash_pagesessions);
//.........这里部分代码省略.........
示例13: 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]));
// . ' ⇒ ' . $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 */
}
//.........这里部分代码省略.........
示例14: ajax_widget_reports
/**
* Ajax handler for Admin Widget
*
* @return json|int
*/
public function ajax_widget_reports()
{
if (!isset($_REQUEST['gadash_security_widget_reports']) || !wp_verify_nonce($_REQUEST['gadash_security_widget_reports'], 'gadash_get_widgetreports')) {
wp_die(-30);
}
$projectId = $_REQUEST['projectId'];
$from = $_REQUEST['from'];
$to = $_REQUEST['to'];
$query = $_REQUEST['query'];
if (ob_get_length()) {
ob_clean();
}
if (!GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) || 0 == $this->gadwp->config->options['dashboard_widget']) {
wp_die(-31);
}
if ($this->gadwp->config->options['ga_dash_token'] && $projectId && $from && $to) {
if (null === $this->gadwp->gapi_controller) {
$this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
}
} else {
wp_die(-24);
}
$profile_info = GADWP_Tools::get_selected_profile($this->gadwp->config->options['ga_dash_profile_list'], $projectId);
if (isset($profile_info[4])) {
$this->gadwp->gapi_controller->timeshift = $profile_info[4];
} else {
$this->gadwp->gapi_controller->timeshift = (int) current_time('timestamp') - time();
}
$queries = explode(',', $query);
$results = array();
foreach ($queries as $value) {
$results[] = $this->gadwp->gapi_controller->get($projectId, $value, $from, $to);
}
wp_send_json($results);
}