setup.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * Author: ExactMetrics team
  4. * Author URI: https://exactmetrics.com
  5. * Copyright 2018 ExactMetrics team
  6. * License: GPLv2 or later
  7. * License URI: http://www.gnu.org/licenses/gpl-2.0.html
  8. */
  9. // Exit if accessed directly
  10. if ( ! defined( 'ABSPATH' ) )
  11. exit();
  12. if ( ! class_exists( 'GADWP_Frontend_Setup' ) ) {
  13. final class GADWP_Frontend_Setup {
  14. private $gadwp;
  15. public function __construct() {
  16. $this->gadwp = GADWP();
  17. // Styles & Scripts
  18. add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
  19. }
  20. /**
  21. * Styles & Scripts conditional loading
  22. *
  23. * @param
  24. * $hook
  25. */
  26. public function load_styles_scripts() {
  27. $lang = get_bloginfo( 'language' );
  28. $lang = explode( '-', $lang );
  29. $lang = $lang[0];
  30. /*
  31. * Item reports Styles & Scripts
  32. */
  33. if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_front'] ) && $this->gadwp->config->options['frontend_item_reports'] ) {
  34. wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
  35. wp_enqueue_style( 'gadwp-frontend-item-reports', GADWP_URL . 'front/css/item-reports.css', null, GADWP_CURRENT_VERSION );
  36. $country_codes = GADWP_Tools::get_countrycodes();
  37. if ( $this->gadwp->config->options['ga_target_geomap'] && isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
  38. $region = $this->gadwp->config->options['ga_target_geomap'];
  39. } else {
  40. $region = false;
  41. }
  42. wp_enqueue_style( "wp-jquery-ui-dialog" );
  43. wp_register_script( 'googlecharts', 'https://www.gstatic.com/charts/loader.js', array(), null );
  44. wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
  45. wp_enqueue_script( 'gadwp-frontend-item-reports', GADWP_URL . 'common/js/reports5.js', array( 'gadwp-nprogress', 'googlecharts', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION, true );
  46. /* @formatter:off */
  47. wp_localize_script( 'gadwp-frontend-item-reports', 'gadwpItemData', array(
  48. 'ajaxurl' => admin_url( 'admin-ajax.php' ),
  49. 'security' => wp_create_nonce( 'gadwp_frontend_item_reports' ),
  50. 'dateList' => array(
  51. 'today' => __( "Today", 'google-analytics-dashboard-for-wp' ),
  52. 'yesterday' => __( "Yesterday", 'google-analytics-dashboard-for-wp' ),
  53. '7daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 7 ),
  54. '14daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 14 ),
  55. '30daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 30 ),
  56. '90daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 90 ),
  57. '365daysAgo' => sprintf( _n( "%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp' ), __('One', 'google-analytics-dashboard-for-wp') ),
  58. '1095daysAgo' => sprintf( _n( "%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp' ), __('Three', 'google-analytics-dashboard-for-wp') ),
  59. ),
  60. 'reportList' => array(
  61. 'uniquePageviews' => __( "Unique Views", 'google-analytics-dashboard-for-wp' ),
  62. 'users' => __( "Users", 'google-analytics-dashboard-for-wp' ),
  63. 'organicSearches' => __( "Organic", 'google-analytics-dashboard-for-wp' ),
  64. 'pageviews' => __( "Page Views", 'google-analytics-dashboard-for-wp' ),
  65. 'visitBounceRate' => __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
  66. 'locations' => __( "Location", 'google-analytics-dashboard-for-wp' ),
  67. 'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
  68. 'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
  69. 'trafficdetails' => __( "Traffic", 'google-analytics-dashboard-for-wp' ),
  70. 'technologydetails' => __( "Technology", 'google-analytics-dashboard-for-wp' ),
  71. ),
  72. 'i18n' => array(
  73. __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
  74. __( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ),
  75. __( "Visitor Type", 'google-analytics-dashboard-for-wp' ),
  76. __( "Search Engines", 'google-analytics-dashboard-for-wp' ),
  77. __( "Social Networks", 'google-analytics-dashboard-for-wp' ),
  78. __( "Unique Views", 'google-analytics-dashboard-for-wp' ),
  79. __( "Users", 'google-analytics-dashboard-for-wp' ),
  80. __( "Page Views", 'google-analytics-dashboard-for-wp' ),
  81. __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
  82. __( "Organic Search", 'google-analytics-dashboard-for-wp' ),
  83. __( "Pages/Session", 'google-analytics-dashboard-for-wp' ),
  84. __( "Invalid response", 'google-analytics-dashboard-for-wp' ),
  85. __( "No Data", 'google-analytics-dashboard-for-wp' ),
  86. __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
  87. __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
  88. __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <strong>' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</strong>!',
  89. __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
  90. __( "Operating System", 'google-analytics-dashboard-for-wp' ),
  91. __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
  92. __( "Mobile Brand", 'google-analytics-dashboard-for-wp' ),
  93. __( "Future Use", 'google-analytics-dashboard-for-wp' ),
  94. __( "Future Use", 'google-analytics-dashboard-for-wp' ),
  95. __( "Future Use", 'google-analytics-dashboard-for-wp' ),
  96. __( "Future Use", 'google-analytics-dashboard-for-wp' ),
  97. __( "Future Use", 'google-analytics-dashboard-for-wp' ),
  98. __( "Future Use", 'google-analytics-dashboard-for-wp' ), //25
  99. __( "Time on Page", 'google-analytics-dashboard-for-wp' ),
  100. __( "Page Load Time", 'google-analytics-dashboard-for-wp' ),
  101. __( "Exit Rate", 'google-analytics-dashboard-for-wp' ),
  102. __( "Precision: ", 'google-analytics-dashboard-for-wp' ), //29
  103. ),
  104. 'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['theme_color'] ),
  105. 'region' => $region,
  106. 'mapsApiKey' => apply_filters( 'gadwp_maps_api_key', $this->gadwp->config->options['maps_api_key'] ),
  107. 'language' => get_bloginfo( 'language' ),
  108. 'filter' => $_SERVER["REQUEST_URI"],
  109. 'viewList' => false,
  110. 'scope' => 'front-item',
  111. )
  112. );
  113. /* @formatter:on */
  114. }
  115. }
  116. }
  117. }