Google Analytics Dashboard for WP (GADWP) - Version 5.3.6

Version Description

Download this release

Release Info

Developer chriscct7
Plugin Icon 128x128 Google Analytics Dashboard for WP (GADWP)
Version 5.3.6
Comparing to
See all releases

Code changes from version 5.3.4 to 5.3.6

Files changed (255) hide show
  1. assets/banner-772x250-old.png +0 -0
  2. assets/banner-772x250.png +0 -0
  3. assets/icon-128x128.png +0 -0
  4. assets/icon-256x256.png +0 -0
  5. assets/logo.png +0 -0
  6. assets/screenshot-1.png +0 -0
  7. assets/screenshot-2.png +0 -0
  8. assets/screenshot-3.png +0 -0
  9. assets/screenshot-4.png +0 -0
  10. assets/screenshot-5.png +0 -0
  11. assets/screenshot-6.png +0 -0
  12. assets/screenshot-7.png +0 -0
  13. assets/screenshot-8.png +0 -0
  14. assets/screenshot-9.png +0 -0
  15. tags/5.3.1.1/SECURITY.md +3 -0
  16. tags/5.3.1.1/admin/ajax-actions.php +143 -0
  17. {admin → tags/5.3.1.1/admin}/css/admin-widgets.css +0 -0
  18. tags/5.3.1.1/admin/css/gadwp.css +1 -0
  19. {admin → tags/5.3.1.1/admin}/css/item-reports.css +0 -0
  20. {admin → tags/5.3.1.1/admin}/images/clicky.png +0 -0
  21. {admin → tags/5.3.1.1/admin}/images/gadwp-icon.png +0 -0
  22. {admin → tags/5.3.1.1/admin}/images/google-analytics-dashboard.png +0 -0
  23. {admin → tags/5.3.1.1/admin}/images/help.png +0 -0
  24. {admin → tags/5.3.1.1/admin}/images/mcdn.png +0 -0
  25. {admin → tags/5.3.1.1/admin}/images/ssl.png +0 -0
  26. {admin → tags/5.3.1.1/admin}/images/star.png +0 -0
  27. {admin → tags/5.3.1.1/admin}/images/wp.png +0 -0
  28. tags/5.3.1.1/admin/item-reports.php +56 -0
  29. {admin → tags/5.3.1.1/admin}/js/settings.js +0 -0
  30. {admin → tags/5.3.1.1/admin}/js/ui.js +0 -0
  31. {admin → tags/5.3.1.1/admin}/js/wp-color-picker-script.js +0 -0
  32. tags/5.3.1.1/admin/settings.php +1901 -0
  33. tags/5.3.1.1/admin/setup.php +378 -0
  34. tags/5.3.1.1/admin/views/access-code.php +36 -0
  35. tags/5.3.1.1/admin/widgets.php +65 -0
  36. tags/5.3.1.1/common/ajax-actions.php +42 -0
  37. tags/5.3.1.1/common/js/reports5.js +1 -0
  38. {common → tags/5.3.1.1/common}/nprogress/nprogress.css +0 -0
  39. {common → tags/5.3.1.1/common}/nprogress/nprogress.js +0 -0
  40. {common → tags/5.3.1.1/common}/realtime/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  41. {common → tags/5.3.1.1/common}/realtime/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  42. {common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  43. {common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  44. {common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  45. {common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  46. {common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  47. {common → tags/5.3.1.1/common}/realtime/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  48. {common → tags/5.3.1.1/common}/realtime/images/ui-icons_222222_256x240.png +0 -0
  49. {common → tags/5.3.1.1/common}/realtime/images/ui-icons_2e83ff_256x240.png +0 -0
  50. {common → tags/5.3.1.1/common}/realtime/images/ui-icons_454545_256x240.png +0 -0
  51. {common → tags/5.3.1.1/common}/realtime/images/ui-icons_888888_256x240.png +0 -0
  52. {common → tags/5.3.1.1/common}/realtime/images/ui-icons_cd0a0a_256x240.png +0 -0
  53. tags/5.3.1.1/common/realtime/jquery.ui.tooltip.html.css +3 -0
  54. {common → tags/5.3.1.1/common}/realtime/jquery.ui.tooltip.html.js +0 -0
  55. tags/5.3.1.1/config.php +456 -0
  56. tags/5.3.1.1/front/ajax-actions.php +157 -0
  57. {front → tags/5.3.1.1/front}/css/item-reports.css +0 -0
  58. {front → tags/5.3.1.1/front}/css/widgets.css +0 -0
  59. tags/5.3.1.1/front/item-reports.php +38 -0
  60. {front → tags/5.3.1.1/front}/js/tracking-analytics-events.js +0 -0
  61. {front → tags/5.3.1.1/front}/js/tracking-scrolldepth.js +0 -0
  62. {front → tags/5.3.1.1/front}/js/widgets.js +0 -0
  63. tags/5.3.1.1/front/setup.php +133 -0
  64. tags/5.3.1.1/front/tracking-analytics.php +775 -0
  65. tags/5.3.1.1/front/tracking-tagmanager.php +177 -0
  66. tags/5.3.1.1/front/tracking.php +66 -0
  67. tags/5.3.1.1/front/views/analytics-amp-clientidapi.php +11 -0
  68. tags/5.3.1.1/front/views/analytics-amp-code.php +14 -0
  69. tags/5.3.1.1/front/views/analytics-code.php +40 -0
  70. tags/5.3.1.1/front/views/analytics-optout-code.php +26 -0
  71. tags/5.3.1.1/front/views/optimize-code.php +21 -0
  72. tags/5.3.1.1/front/views/tagmanager-amp-code.php +14 -0
  73. tags/5.3.1.1/front/views/tagmanager-code.php +24 -0
  74. tags/5.3.1.1/front/widgets.php +195 -0
  75. tags/5.3.1.1/gadwp.php +272 -0
  76. tags/5.3.1.1/install/install.php +190 -0
  77. tags/5.3.1.1/install/uninstall.php +34 -0
  78. tags/5.3.1.1/readme.txt +240 -0
  79. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  80. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  81. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  82. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  83. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  84. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  85. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  86. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  87. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_222222_256x240.png +0 -0
  88. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
  89. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_454545_256x240.png +0 -0
  90. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_888888_256x240.png +0 -0
  91. {realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
  92. tags/5.3.1.1/realtime/jquery/jquery.ui.tooltip.html.css +3 -0
  93. {realtime → tags/5.3.1.1/realtime}/jquery/jquery.ui.tooltip.html.js +0 -0
  94. tags/5.3.1.1/tools/gapi.php +961 -0
  95. tags/5.3.1.1/tools/iso3166.php +255 -0
  96. {tools → tags/5.3.1.1/tools}/src/Deconf/Auth/Abstract.php +0 -0
  97. {tools → tags/5.3.1.1/tools}/src/Deconf/Auth/AppIdentity.php +0 -0
  98. {tools → tags/5.3.1.1/tools}/src/Deconf/Auth/AssertionCredentials.php +0 -0
  99. {tools → tags/5.3.1.1/tools}/src/Deconf/Auth/ComputeEngine.php +0 -0
  100. tags/5.3.1.1/tools/src/Deconf/Auth/Exception.php +24 -0
  101. {tools → tags/5.3.1.1/tools}/src/Deconf/Auth/LoginTicket.php +0 -0
  102. {tools → tags/5.3.1.1/tools}/src/Deconf/Auth/OAuth2.php +0 -0
  103. {tools → tags/5.3.1.1/tools}/src/Deconf/Auth/Simple.php +0 -0
  104. {tools → tags/5.3.1.1/tools}/src/Deconf/Cache/Abstract.php +0 -0
  105. {tools → tags/5.3.1.1/tools}/src/Deconf/Cache/Apc.php +0 -0
  106. tags/5.3.1.1/tools/src/Deconf/Cache/Exception.php +24 -0
  107. {tools → tags/5.3.1.1/tools}/src/Deconf/Cache/File.php +0 -0
  108. {tools → tags/5.3.1.1/tools}/src/Deconf/Cache/Memcache.php +0 -0
  109. {tools → tags/5.3.1.1/tools}/src/Deconf/Cache/Null.php +0 -0
  110. {tools → tags/5.3.1.1/tools}/src/Deconf/Client.php +0 -0
  111. {tools → tags/5.3.1.1/tools}/src/Deconf/Collection.php +0 -0
  112. {tools → tags/5.3.1.1/tools}/src/Deconf/Config.php +0 -0
  113. tags/5.3.1.1/tools/src/Deconf/Exception.php +20 -0
  114. {tools → tags/5.3.1.1/tools}/src/Deconf/Http/Batch.php +0 -0
  115. {tools → tags/5.3.1.1/tools}/src/Deconf/Http/CacheParser.php +0 -0
  116. {tools → tags/5.3.1.1/tools}/src/Deconf/Http/MediaFileUpload.php +0 -0
  117. {tools → tags/5.3.1.1/tools}/src/Deconf/Http/REST.php +0 -0
  118. {tools → tags/5.3.1.1/tools}/src/Deconf/Http/Request.php +0 -0
  119. tags/5.3.1.1/tools/src/Deconf/IO/Abstract.php +343 -0
  120. {tools → tags/5.3.1.1/tools}/src/Deconf/IO/Curl.php +0 -0
  121. tags/5.3.1.1/tools/src/Deconf/IO/Exception.php +69 -0
  122. tags/5.3.1.1/tools/src/Deconf/IO/Stream.php +246 -0
  123. {tools → tags/5.3.1.1/tools}/src/Deconf/IO/cacerts.pem +0 -0
  124. {tools → tags/5.3.1.1/tools}/src/Deconf/Logger/Abstract.php +0 -0
  125. {tools → tags/5.3.1.1/tools}/src/Deconf/Logger/Exception.php +0 -0
  126. {tools → tags/5.3.1.1/tools}/src/Deconf/Logger/File.php +0 -0
  127. {tools → tags/5.3.1.1/tools}/src/Deconf/Logger/Null.php +0 -0
  128. {tools → tags/5.3.1.1/tools}/src/Deconf/Logger/Psr.php +0 -0
  129. {tools → tags/5.3.1.1/tools}/src/Deconf/Model.php +0 -0
  130. {tools → tags/5.3.1.1/tools}/src/Deconf/Service.php +0 -0
  131. {tools → tags/5.3.1.1/tools}/src/Deconf/Service/Analytics.php +0 -0
  132. {tools → tags/5.3.1.1/tools}/src/Deconf/Service/Exception.php +0 -0
  133. {tools → tags/5.3.1.1/tools}/src/Deconf/Service/Resource.php +0 -0
  134. {tools → tags/5.3.1.1/tools}/src/Deconf/Signer/Abstract.php +0 -0
  135. {tools → tags/5.3.1.1/tools}/src/Deconf/Signer/P12.php +0 -0
  136. {tools → tags/5.3.1.1/tools}/src/Deconf/Task/Exception.php +0 -0
  137. {tools → tags/5.3.1.1/tools}/src/Deconf/Task/Retryable.php +0 -0
  138. {tools → tags/5.3.1.1/tools}/src/Deconf/Task/Runner.php +0 -0
  139. {tools → tags/5.3.1.1/tools}/src/Deconf/Utils.php +0 -0
  140. tags/5.3.1.1/tools/src/Deconf/Utils/URITemplate.php +333 -0
  141. {tools → tags/5.3.1.1/tools}/src/Deconf/Verifier/Abstract.php +0 -0
  142. {tools → tags/5.3.1.1/tools}/src/Deconf/Verifier/Pem.php +0 -0
  143. {tools → tags/5.3.1.1/tools}/src/Deconf/autoload.php +0 -0
  144. tags/5.3.1.1/tools/src/readme.txt +25 -0
  145. tags/5.3.1.1/tools/tools.php +314 -0
  146. tags/5.3.1/SECURITY.md +3 -0
  147. tags/5.3.1/admin/ajax-actions.php +143 -0
  148. tags/5.3.1/admin/css/admin-widgets.css +1 -0
  149. tags/5.3.1/admin/css/gadwp.css +1 -0
  150. tags/5.3.1/admin/css/item-reports.css +1 -0
  151. tags/5.3.1/admin/images/clicky.png +0 -0
  152. tags/5.3.1/admin/images/gadwp-icon.png +0 -0
  153. tags/5.3.1/admin/images/google-analytics-dashboard.png +0 -0
  154. tags/5.3.1/admin/images/help.png +0 -0
  155. tags/5.3.1/admin/images/mcdn.png +0 -0
  156. tags/5.3.1/admin/images/ssl.png +0 -0
  157. tags/5.3.1/admin/images/star.png +0 -0
  158. tags/5.3.1/admin/images/wp.png +0 -0
  159. tags/5.3.1/admin/item-reports.php +56 -0
  160. tags/5.3.1/admin/js/settings.js +1 -0
  161. tags/5.3.1/admin/js/ui.js +1 -0
  162. tags/5.3.1/admin/js/wp-color-picker-script.js +1 -0
  163. tags/5.3.1/admin/settings.php +1909 -0
  164. tags/5.3.1/admin/setup.php +378 -0
  165. tags/5.3.1/admin/views/access-code.php +36 -0
  166. tags/5.3.1/admin/widgets.php +65 -0
  167. tags/5.3.1/common/ajax-actions.php +42 -0
  168. tags/5.3.1/common/js/reports5.js +1 -0
  169. tags/5.3.1/common/nprogress/nprogress.css +1 -0
  170. tags/5.3.1/common/nprogress/nprogress.js +1 -0
  171. tags/5.3.1/common/realtime/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  172. tags/5.3.1/common/realtime/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  173. tags/5.3.1/common/realtime/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  174. tags/5.3.1/common/realtime/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  175. tags/5.3.1/common/realtime/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  176. tags/5.3.1/common/realtime/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  177. tags/5.3.1/common/realtime/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  178. tags/5.3.1/common/realtime/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  179. tags/5.3.1/common/realtime/images/ui-icons_222222_256x240.png +0 -0
  180. tags/5.3.1/common/realtime/images/ui-icons_2e83ff_256x240.png +0 -0
  181. tags/5.3.1/common/realtime/images/ui-icons_454545_256x240.png +0 -0
  182. tags/5.3.1/common/realtime/images/ui-icons_888888_256x240.png +0 -0
  183. tags/5.3.1/common/realtime/images/ui-icons_cd0a0a_256x240.png +0 -0
  184. tags/5.3.1/common/realtime/jquery.ui.tooltip.html.css +3 -0
  185. tags/5.3.1/common/realtime/jquery.ui.tooltip.html.js +1 -0
  186. tags/5.3.1/config.php +456 -0
  187. tags/5.3.1/front/ajax-actions.php +157 -0
  188. tags/5.3.1/front/css/item-reports.css +1 -0
  189. tags/5.3.1/front/css/widgets.css +1 -0
  190. tags/5.3.1/front/item-reports.php +38 -0
  191. tags/5.3.1/front/js/tracking-analytics-events.js +1 -0
  192. tags/5.3.1/front/js/tracking-scrolldepth.js +1 -0
  193. tags/5.3.1/front/js/widgets.js +1 -0
  194. tags/5.3.1/front/setup.php +133 -0
  195. tags/5.3.1/front/tracking-analytics.php +775 -0
  196. tags/5.3.1/front/tracking-tagmanager.php +177 -0
  197. tags/5.3.1/front/tracking.php +66 -0
  198. tags/5.3.1/front/views/analytics-amp-clientidapi.php +11 -0
  199. tags/5.3.1/front/views/analytics-amp-code.php +14 -0
  200. tags/5.3.1/front/views/analytics-code.php +40 -0
  201. tags/5.3.1/front/views/analytics-optout-code.php +26 -0
  202. tags/5.3.1/front/views/optimize-code.php +21 -0
  203. tags/5.3.1/front/views/tagmanager-amp-code.php +14 -0
  204. tags/5.3.1/front/views/tagmanager-code.php +24 -0
  205. tags/5.3.1/front/widgets.php +195 -0
  206. tags/5.3.1/gadwp.php +272 -0
  207. tags/5.3.1/install/install.php +190 -0
  208. tags/5.3.1/install/uninstall.php +34 -0
  209. tags/5.3.1/readme.txt +236 -0
  210. tags/5.3.1/realtime/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  211. tags/5.3.1/realtime/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  212. tags/5.3.1/realtime/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  213. tags/5.3.1/realtime/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  214. tags/5.3.1/realtime/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  215. tags/5.3.1/realtime/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  216. tags/5.3.1/realtime/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  217. tags/5.3.1/realtime/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  218. tags/5.3.1/realtime/jquery/images/ui-icons_222222_256x240.png +0 -0
  219. tags/5.3.1/realtime/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
  220. tags/5.3.1/realtime/jquery/images/ui-icons_454545_256x240.png +0 -0
  221. tags/5.3.1/realtime/jquery/images/ui-icons_888888_256x240.png +0 -0
  222. tags/5.3.1/realtime/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
  223. tags/5.3.1/realtime/jquery/jquery.ui.tooltip.html.css +3 -0
  224. tags/5.3.1/realtime/jquery/jquery.ui.tooltip.html.js +1 -0
  225. tags/5.3.1/tools/gapi.php +961 -0
  226. tags/5.3.1/tools/iso3166.php +255 -0
  227. tags/5.3.1/tools/src/Deconf/Auth/Abstract.php +38 -0
  228. tags/5.3.1/tools/src/Deconf/Auth/AppIdentity.php +120 -0
  229. tags/5.3.1/tools/src/Deconf/Auth/AssertionCredentials.php +136 -0
  230. tags/5.3.1/tools/src/Deconf/Auth/ComputeEngine.php +146 -0
  231. tags/5.3.1/tools/src/Deconf/Auth/Exception.php +24 -0
  232. tags/5.3.1/tools/src/Deconf/Auth/LoginTicket.php +71 -0
  233. tags/5.3.1/tools/src/Deconf/Auth/OAuth2.php +646 -0
  234. tags/5.3.1/tools/src/Deconf/Auth/Simple.php +63 -0
  235. tags/5.3.1/tools/src/Deconf/Cache/Abstract.php +53 -0
  236. tags/5.3.1/tools/src/Deconf/Cache/Apc.php +113 -0
  237. tags/5.3.1/tools/src/Deconf/Cache/Exception.php +24 -0
  238. tags/5.3.1/tools/src/Deconf/Cache/File.php +209 -0
  239. tags/5.3.1/tools/src/Deconf/Cache/Memcache.php +184 -0
  240. tags/5.3.1/tools/src/Deconf/Cache/Null.php +57 -0
  241. tags/5.3.1/tools/src/Deconf/Client.php +715 -0
  242. tags/5.3.1/tools/src/Deconf/Collection.php +101 -0
  243. tags/5.3.1/tools/src/Deconf/Config.php +456 -0
  244. tags/5.3.1/tools/src/Deconf/Exception.php +20 -0
  245. tags/5.3.1/tools/src/Deconf/Http/Batch.php +145 -0
  246. tags/5.3.1/tools/src/Deconf/Http/CacheParser.php +185 -0
  247. tags/5.3.1/tools/src/Deconf/Http/MediaFileUpload.php +341 -0
  248. tags/5.3.1/tools/src/Deconf/Http/REST.php +178 -0
  249. tags/5.3.1/tools/src/Deconf/Http/Request.php +504 -0
  250. tags/5.3.1/tools/src/Deconf/IO/Abstract.php +343 -0
  251. tags/5.3.1/tools/src/Deconf/IO/Curl.php +194 -0
  252. tags/5.3.1/tools/src/Deconf/IO/Exception.php +69 -0
  253. tags/5.3.1/tools/src/Deconf/IO/Stream.php +246 -0
  254. tags/5.3.1/tools/src/Deconf/IO/cacerts.pem +2233 -0
  255. tags/5.3.1/tools/src/Deconf/Logger/Abstract.php +221 -0
assets/banner-772x250-old.png ADDED
Binary file
assets/banner-772x250.png ADDED
Binary file
assets/icon-128x128.png ADDED
Binary file
assets/icon-256x256.png ADDED
Binary file
assets/logo.png ADDED
Binary file
assets/screenshot-1.png ADDED
Binary file
assets/screenshot-2.png ADDED
Binary file
assets/screenshot-3.png ADDED
Binary file
assets/screenshot-4.png ADDED
Binary file
assets/screenshot-5.png ADDED
Binary file
assets/screenshot-6.png ADDED
Binary file
assets/screenshot-7.png ADDED
Binary file
assets/screenshot-8.png ADDED
Binary file
assets/screenshot-9.png ADDED
Binary file
tags/5.3.1.1/SECURITY.md ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ Every day we do our best to make sure [Google Analytics Dashboard for WP (GADWP)](https://deconf.com/google-analytics-dashboard-wordpress/) is safe and secure. But we’re only human, and there’s always a chance that we missed something. That’s where you come in – find a security weakness in our plugin, report it on [HackerOne](https://hackerone.com/deconf_eb9eh), and get listed as a contributor!
2
+
3
+ To find out more about our security reports policy for the plugin [click here](https://deconf.com/security/).
tags/5.3.1.1/admin/ajax-actions.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
15
+
16
+ final class GADWP_Backend_Ajax {
17
+
18
+ private $gadwp;
19
+
20
+ public function __construct() {
21
+ $this->gadwp = GADWP();
22
+
23
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) {
24
+ // Items action
25
+ add_action( 'wp_ajax_gadwp_backend_item_reports', array( $this, 'ajax_item_reports' ) );
26
+ }
27
+ if ( current_user_can( 'manage_options' ) ) {
28
+ // Admin Widget action
29
+ add_action( 'wp_ajax_gadwp_dismiss_notices', array( $this, 'ajax_dismiss_notices' ) );
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Ajax handler for Item Reports
35
+ *
36
+ * @return json|int
37
+ */
38
+ public function ajax_item_reports() {
39
+ if ( ! isset( $_POST['gadwp_security_backend_item_reports'] ) || ! wp_verify_nonce( $_POST['gadwp_security_backend_item_reports'], 'gadwp_backend_item_reports' ) ) {
40
+ wp_die( - 30 );
41
+ }
42
+ if ( isset( $_POST['projectId'] ) && $this->gadwp->config->options['switch_profile'] && 'false' !== $_POST['projectId'] ) {
43
+ $projectId = $_POST['projectId'];
44
+ } else {
45
+ $projectId = false;
46
+ }
47
+ $from = $_POST['from'];
48
+ $to = $_POST['to'];
49
+ $query = $_POST['query'];
50
+ if ( isset( $_POST['filter'] ) ) {
51
+ $filter_id = $_POST['filter'];
52
+ } else {
53
+ $filter_id = false;
54
+ }
55
+ if ( isset( $_POST['metric'] ) ) {
56
+ $metric = $_POST['metric'];
57
+ } else {
58
+ $metric = 'sessions';
59
+ }
60
+
61
+ if ( $filter_id && $metric == 'sessions' ) { // Sessions metric is not available for item reports
62
+ $metric = 'pageviews';
63
+ }
64
+
65
+ if ( ob_get_length() ) {
66
+ ob_clean();
67
+ }
68
+
69
+ if ( ! ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) ) {
70
+ wp_die( - 31 );
71
+ }
72
+ if ( $this->gadwp->config->options['token'] && $this->gadwp->config->options['tableid_jail'] && $from && $to ) {
73
+ if ( null === $this->gadwp->gapi_controller ) {
74
+ $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
75
+ }
76
+ } else {
77
+ wp_die( - 24 );
78
+ }
79
+ if ( false == $projectId ) {
80
+ $projectId = $this->gadwp->config->options['tableid_jail'];
81
+ }
82
+ $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_profiles_list'], $projectId );
83
+ if ( isset( $profile_info[4] ) ) {
84
+ $this->gadwp->gapi_controller->timeshift = $profile_info[4];
85
+ } else {
86
+ $this->gadwp->gapi_controller->timeshift = (int) current_time( 'timestamp' ) - time();
87
+ }
88
+
89
+ if ( $filter_id ) {
90
+ $uri_parts = explode( '/', get_permalink( $filter_id ), 4 );
91
+
92
+ if ( isset( $uri_parts[3] ) ) {
93
+ $uri = '/' . $uri_parts[3];
94
+ } else {
95
+ wp_die( - 25 );
96
+ }
97
+
98
+ // allow URL correction before sending an API request
99
+ $filter = apply_filters( 'gadwp_backenditem_uri', $uri, $filter_id );
100
+
101
+ $lastchar = substr( $filter, - 1 );
102
+
103
+ if ( isset( $profile_info[6] ) && $profile_info[6] && '/' == $lastchar ) {
104
+ $filter = $filter . $profile_info[6];
105
+ }
106
+
107
+ // Encode URL
108
+ $filter = rawurlencode( rawurldecode( $filter ) );
109
+ } else {
110
+ $filter = false;
111
+ }
112
+
113
+ $queries = explode( ',', $query );
114
+
115
+ $results = array();
116
+
117
+ foreach ( $queries as $value ) {
118
+ $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter, $metric );
119
+ }
120
+
121
+ wp_send_json( $results );
122
+ }
123
+
124
+ /**
125
+ * Ajax handler for dismissing Admin notices
126
+ *
127
+ * @return json|int
128
+ */
129
+ public function ajax_dismiss_notices() {
130
+ if ( ! isset( $_POST['gadwp_security_dismiss_notices'] ) || ! wp_verify_nonce( $_POST['gadwp_security_dismiss_notices'], 'gadwp_dismiss_notices' ) ) {
131
+ wp_die( - 30 );
132
+ }
133
+
134
+ if ( ! current_user_can( 'manage_options' ) ) {
135
+ wp_die( - 31 );
136
+ }
137
+
138
+ delete_option( 'gadwp_got_updated' );
139
+
140
+ wp_die();
141
+ }
142
+ }
143
+ }
{admin → tags/5.3.1.1/admin}/css/admin-widgets.css RENAMED
File without changes
tags/5.3.1.1/admin/css/gadwp.css ADDED
@@ -0,0 +1 @@
 
1
+ #gadwp-events,#gadwp-custom,#gadwp-advanced,#gadwp-exclude,#gadwp-config,#gadwp-tmdatalayervars,#gadwp-tmintegration,#gadwp-integration{display:none}table.gadwp-settings-options{padding-left:10px;width:100%}.gadwp-settings-options td{padding:0 5px 5px 5px}td.gadwp-settings-title,td.info{width:140px;padding-left:20px}td.gadwp-settings-title-s{width:300px}.gadwp-help{padding-left:15px}td.gadwp-settings-info{padding-bottom:15px}td.gadwp-settings-title label{font-size:1.1em}.gadwp-title{float:left;margin-right:10px;margin-top:2px;clear:left}.gadwp-desc{font-size:1em}.gadwp-top{vertical-align:top}pre.gadwp-settings-logdata{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}pre.gadwp-settings-logdata span{color:#b30000;font-weight:800}table.gadwp-settings-logdata{table-layout:fixed;width:100%}td.gadwp-settings-roles{padding-bottom:15px}#ga_speed_samplerate,#ga_user_samplerate,#ga_realtime_pages{width:50px}#gapi-access-code{color:red !important}#poststuff.gadwp h2{padding-bottom:0;font-size:19.5px;font-weight:normal;padding:0;margin:20px 0 15px 0}#poststuff.gadwp h2.nav-tab-wrapper{border-bottom:1px solid #ccc;padding-bottom:0}.button-primary.gadwp-settings-switchoo{position:relative;width:50px;float:left;border:0;padding:0;height:22px;-moz-box-shadow:none;-webkit-box-shadow:none;-o-box-shadow:none;box-shadow:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}input.gadwp-settings-switchoo-checkbox{display:none}.gadwp-settings-switchoo-label{display:block;overflow:hidden;cursor:pointer;background:transparent;border:1px solid #ddd;border-radius:2px;text-shadow:none}.gadwp-settings-switchoo-inner{width:200%;margin-left:-100%;border-radius:2px;-moz-transition:margin .2s ease-in 0;-webkit-transition:margin .2s ease-in 0;-o-transition:margin .2s ease-in 0;transition:margin .2s ease-in 0}.gadwp-settings-switchoo-inner:before,.gadwp-settings-switchoo-inner:after{float:left;width:50%;font-weight:normal;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;height:22px;line-height:22px;font-size:12px;text-shadow:none}.gadwp-settings-switchoo-inner:before{content:"On";padding-left:5px;border-bottom:0}.gadwp-settings-switchoo-inner:after{content:"Off";padding-right:5px;background-color:#ddd;text-align:right}.gadwp-settings-switchoo-switch{width:22px;height:22px;background:#fff;color:#ddd;border:1px solid #ddd;border-radius:2px;position:absolute;top:0;bottom:0;right:27px;-moz-transition:all .2s ease-in 0;-webkit-transition:all .2s ease-in 0;-o-transition:all .2s ease-in 0;transition:all .2s ease-in 0}.gadwp-settings-switchoo-switch:hover{color:#aaa;border-color:#aaa}.gadwp-settings-switchoo-switch:after{margin:0;outline:0;display:inline-block;font:400 16px/16px dashicons;content:"\f228";padding:3px 0 0 3px;text-align:left;text-decoration:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-inner{margin-left:0}.gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-switch{right:0}.switch-desc{float:left;margin-left:10px;line-height:20px}
{admin → tags/5.3.1.1/admin}/css/item-reports.css RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/images/clicky.png RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/images/gadwp-icon.png RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/images/google-analytics-dashboard.png RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/images/help.png RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/images/mcdn.png RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/images/ssl.png RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/images/star.png RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/images/wp.png RENAMED
File without changes
tags/5.3.1.1/admin/item-reports.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Backend_Item_Reports' ) ) {
15
+
16
+ final class GADWP_Backend_Item_Reports {
17
+
18
+ private $gadwp;
19
+
20
+ public function __construct() {
21
+ $this->gadwp = GADWP();
22
+
23
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && 1 == $this->gadwp->config->options['backend_item_reports'] ) {
24
+ // Add custom column in Posts List
25
+ add_filter( 'manage_posts_columns', array( $this, 'add_columns' ) );
26
+
27
+ // Populate custom column in Posts List
28
+ add_action( 'manage_posts_custom_column', array( $this, 'add_icons' ), 10, 2 );
29
+
30
+ // Add custom column in Pages List
31
+ add_filter( 'manage_pages_columns', array( $this, 'add_columns' ) );
32
+
33
+ // Populate custom column in Pages List
34
+ add_action( 'manage_pages_custom_column', array( $this, 'add_icons' ), 10, 2 );
35
+ }
36
+ }
37
+
38
+ public function add_icons( $column, $id ) {
39
+ global $wp_version;
40
+
41
+ if ( 'gadwp_stats' != $column ) {
42
+ return;
43
+ }
44
+
45
+ if ( version_compare( $wp_version, '3.8.0', '>=' ) ) {
46
+ echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area">&nbsp;</a>';
47
+ } else {
48
+ echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '"><img class="gadwp-icon-oldwp" src="' . GADWP_URL . 'admin/images/gadwp-icon.png"</a>';
49
+ }
50
+ }
51
+
52
+ public function add_columns( $columns ) {
53
+ return array_merge( $columns, array( 'gadwp_stats' => __( 'Analytics', 'google-analytics-dashboard-for-wp' ) ) );
54
+ }
55
+ }
56
+ }
{admin → tags/5.3.1.1/admin}/js/settings.js RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/js/ui.js RENAMED
File without changes
{admin → tags/5.3.1.1/admin}/js/wp-color-picker-script.js RENAMED
File without changes
tags/5.3.1.1/admin/settings.php ADDED
@@ -0,0 +1,1901 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit();
13
+ }
14
+
15
+ final class GADWP_Settings {
16
+
17
+ private static function update_options( $who ) {
18
+ $gadwp = GADWP();
19
+ $network_settings = false;
20
+ $options = $gadwp->config->options; // Get current options
21
+ if ( isset( $_POST['options']['gadwp_hidden'] ) && isset( $_POST['options'] ) && ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) && 'Reset' != $who ) {
22
+ $new_options = $_POST['options'];
23
+ if ( 'tracking' == $who ) {
24
+ $options['ga_anonymize_ip'] = 0;
25
+ $options['ga_optout'] = 0;
26
+ $options['ga_dnt_optout'] = 0;
27
+ $options['ga_event_tracking'] = 0;
28
+ $options['ga_enhanced_links'] = 0;
29
+ $options['ga_event_precision'] = 0;
30
+ $options['ga_remarketing'] = 0;
31
+ $options['ga_event_bouncerate'] = 0;
32
+ $options['ga_crossdomain_tracking'] = 0;
33
+ $options['ga_aff_tracking'] = 0;
34
+ $options['ga_hash_tracking'] = 0;
35
+ $options['ga_formsubmit_tracking'] = 0;
36
+ $options['ga_force_ssl'] = 0;
37
+ $options['ga_pagescrolldepth_tracking'] = 0;
38
+ $options['tm_pagescrolldepth_tracking'] = 0;
39
+ $options['amp_tracking_analytics'] = 0;
40
+ $options['amp_tracking_clientidapi'] = 0;
41
+ $options['amp_tracking_tagmanager'] = 0;
42
+ $options['optimize_pagehiding'] = 0;
43
+ $options['optimize_tracking'] = 0;
44
+ $options['trackingcode_infooter'] = 0;
45
+ $options['trackingevents_infooter'] = 0;
46
+ $options['ga_with_gtag'] = 0;
47
+ if ( isset( $_POST['options']['ga_tracking_code'] ) ) {
48
+ $new_options['ga_tracking_code'] = trim( $new_options['ga_tracking_code'], "\t" );
49
+ }
50
+ if ( empty( $new_options['track_exclude'] ) ) {
51
+ $new_options['track_exclude'] = array();
52
+ }
53
+ } elseif ( 'backend' == $who ) {
54
+ $options['switch_profile'] = 0;
55
+ $options['backend_item_reports'] = 0;
56
+ $options['dashboard_widget'] = 0;
57
+ $options['backend_realtime_report'] = 0;
58
+ if ( empty( $new_options['access_back'] ) ) {
59
+ $new_options['access_back'][] = 'administrator';
60
+ }
61
+ } elseif ( 'frontend' == $who ) {
62
+ $options['frontend_item_reports'] = 0;
63
+ if ( empty( $new_options['access_front'] ) ) {
64
+ $new_options['access_front'][] = 'administrator';
65
+ }
66
+ } elseif ( 'general' == $who ) {
67
+ $options['user_api'] = 0;
68
+ if ( ! is_multisite() ) {
69
+ $options['automatic_updates_minorversion'] = 0;
70
+ }
71
+ } elseif ( 'network' == $who ) {
72
+ $options['user_api'] = 0;
73
+ $options['network_mode'] = 0;
74
+ $options['superadmin_tracking'] = 0;
75
+ $options['automatic_updates_minorversion'] = 0;
76
+ $network_settings = true;
77
+ }
78
+ $options = array_merge( $options, $new_options );
79
+ $gadwp->config->options = $options;
80
+ $gadwp->config->set_plugin_options( $network_settings );
81
+ }
82
+ return $options;
83
+ }
84
+
85
+ private static function navigation_tabs( $tabs ) {
86
+ echo '<h2 class="nav-tab-wrapper">';
87
+ foreach ( $tabs as $tab => $name ) {
88
+ echo "<a class='nav-tab' id='tab-$tab' href='#top#gadwp-$tab'>$name</a>";
89
+ }
90
+ echo '</h2>';
91
+ }
92
+
93
+ public static function frontend_settings() {
94
+ $gadwp = GADWP();
95
+ if ( ! current_user_can( 'manage_options' ) ) {
96
+ return;
97
+ }
98
+ $options = self::update_options( 'frontend' );
99
+ if ( isset( $_POST['options']['gadwp_hidden'] ) ) {
100
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
101
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
102
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
103
+ }
104
+ }
105
+ if ( ! $gadwp->config->options['tableid_jail'] || ! $gadwp->config->options['token'] ) {
106
+ $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( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
107
+ }
108
+ ?>
109
+ <form name="gadwp_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
110
+ <div class="wrap">
111
+ <?php echo "<h2>" . __( "Google Analytics Frontend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
112
+ </div>
113
+ <div id="poststuff" class="gadwp">
114
+ <div id="post-body" class="metabox-holder columns-2">
115
+ <div id="post-body-content">
116
+ <div class="settings-wrapper">
117
+ <div class="inside">
118
+ <?php if (isset($message)) echo $message; ?>
119
+ <table class="gadwp-settings-options">
120
+ <tr>
121
+ <td colspan="2"><?php echo "<h2>" . __( "Permissions", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
122
+ </tr>
123
+ <tr>
124
+ <td class="roles gadwp-settings-title">
125
+ <label for="access_front"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?>
126
+ </label>
127
+ </td>
128
+ <td class="gadwp-settings-roles">
129
+ <table>
130
+ <tr>
131
+ <?php if ( ! isset( $wp_roles ) ) : ?>
132
+ <?php $wp_roles = new WP_Roles(); ?>
133
+ <?php endif; ?>
134
+ <?php $i = 0; ?>
135
+ <?php foreach ( $wp_roles->role_names as $role => $name ) : ?>
136
+ <?php if ( 'subscriber' != $role ) : ?>
137
+ <?php $i++; ?>
138
+ <td>
139
+ <label>
140
+ <input type="checkbox" name="options[access_front][]" value="<?php echo $role; ?>" <?php if ( in_array($role,$options['access_front']) || 'administrator' == $role ) echo 'checked="checked"'; if ( 'administrator' == $role ) echo 'disabled="disabled"';?> /><?php echo $name; ?>
141
+ </label>
142
+ </td>
143
+ <?php endif; ?>
144
+ <?php if ( 0 == $i % 4 ) : ?>
145
+ </tr>
146
+ <tr>
147
+ <?php endif; ?>
148
+ <?php endforeach; ?>
149
+ </table>
150
+ </td>
151
+ </tr>
152
+ <tr>
153
+ <td colspan="2" class="gadwp-settings-title">
154
+ <div class="button-primary gadwp-settings-switchoo">
155
+ <input type="checkbox" name="options[frontend_item_reports]" value="1" class="gadwp-settings-switchoo-checkbox" id="frontend_item_reports" <?php checked( $options['frontend_item_reports'], 1 ); ?>>
156
+ <label class="gadwp-settings-switchoo-label" for="frontend_item_reports">
157
+ <div class="gadwp-settings-switchoo-inner"></div>
158
+ <div class="gadwp-settings-switchoo-switch"></div>
159
+ </label>
160
+ </div>
161
+ <div class="switch-desc"><?php echo " ".__("enable web page reports on frontend", 'google-analytics-dashboard-for-wp' );?></div>
162
+ </td>
163
+ </tr>
164
+ <tr>
165
+ <td colspan="2">
166
+ <hr>
167
+ </td>
168
+ </tr>
169
+ <tr>
170
+ <td colspan="2" class="submit">
171
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
172
+ </td>
173
+ </tr>
174
+ </table>
175
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
176
+ <?php wp_nonce_field('gadwp_form','gadwp_security');?>
177
+
178
+
179
+
180
+
181
+
182
+
183
+ </form>
184
+ <?php
185
+ self::output_sidebar();
186
+ }
187
+
188
+ public static function backend_settings() {
189
+ $gadwp = GADWP();
190
+ if ( ! current_user_can( 'manage_options' ) ) {
191
+ return;
192
+ }
193
+ $options = self::update_options( 'backend' );
194
+ if ( isset( $_POST['options']['gadwp_hidden'] ) ) {
195
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
196
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
197
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
198
+ }
199
+ }
200
+ if ( ! $gadwp->config->options['tableid_jail'] || ! $gadwp->config->options['token'] ) {
201
+ $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( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
202
+ }
203
+ ?>
204
+ <form name="gadwp_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
205
+ <div class="wrap">
206
+ <?php echo "<h2>" . __( "Google Analytics Backend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
207
+ </div>
208
+ <div id="poststuff" class="gadwp">
209
+ <div id="post-body" class="metabox-holder columns-2">
210
+ <div id="post-body-content">
211
+ <div class="settings-wrapper">
212
+ <div class="inside">
213
+ <?php if (isset($message)) echo $message; ?>
214
+ <table class="gadwp-settings-options">
215
+ <tr>
216
+ <td colspan="2"><?php echo "<h2>" . __( "Permissions", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
217
+ </tr>
218
+ <tr>
219
+ <td class="roles gadwp-settings-title">
220
+ <label for="access_back"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?>
221
+ </label>
222
+ </td>
223
+ <td class="gadwp-settings-roles">
224
+ <table>
225
+ <tr>
226
+ <?php if ( ! isset( $wp_roles ) ) : ?>
227
+ <?php $wp_roles = new WP_Roles(); ?>
228
+ <?php endif; ?>
229
+ <?php $i = 0; ?>
230
+ <?php foreach ( $wp_roles->role_names as $role => $name ) : ?>
231
+ <?php if ( 'subscriber' != $role ) : ?>
232
+ <?php $i++; ?>
233
+ <td>
234
+ <label>
235
+ <input type="checkbox" name="options[access_back][]" value="<?php echo $role; ?>" <?php if ( in_array($role,$options['access_back']) || 'administrator' == $role ) echo 'checked="checked"'; if ( 'administrator' == $role ) echo 'disabled="disabled"';?> /> <?php echo $name; ?>
236
+ </label>
237
+ </td>
238
+ <?php endif; ?>
239
+ <?php if ( 0 == $i % 4 ) : ?>
240
+ </tr>
241
+ <tr>
242
+ <?php endif; ?>
243
+ <?php endforeach; ?>
244
+
245
+
246
+
247
+
248
+
249
+
250
+ </table>
251
+ </td>
252
+ </tr>
253
+ <tr>
254
+ <td colspan="2" class="gadwp-settings-title">
255
+ <div class="button-primary gadwp-settings-switchoo">
256
+ <input type="checkbox" name="options[switch_profile]" value="1" class="gadwp-settings-switchoo-checkbox" id="switch_profile" <?php checked( $options['switch_profile'], 1 ); ?>>
257
+ <label class="gadwp-settings-switchoo-label" for="switch_profile">
258
+ <div class="gadwp-settings-switchoo-inner"></div>
259
+ <div class="gadwp-settings-switchoo-switch"></div>
260
+ </label>
261
+ </div>
262
+ <div class="switch-desc"><?php _e ( "enable Switch View functionality", 'google-analytics-dashboard-for-wp' );?></div>
263
+ </td>
264
+ </tr>
265
+ <tr>
266
+ <td colspan="2" class="gadwp-settings-title">
267
+ <div class="button-primary gadwp-settings-switchoo">
268
+ <input type="checkbox" name="options[backend_item_reports]" value="1" class="gadwp-settings-switchoo-checkbox" id="backend_item_reports" <?php checked( $options['backend_item_reports'], 1 ); ?>>
269
+ <label class="gadwp-settings-switchoo-label" for="backend_item_reports">
270
+ <div class="gadwp-settings-switchoo-inner"></div>
271
+ <div class="gadwp-settings-switchoo-switch"></div>
272
+ </label>
273
+ </div>
274
+ <div class="switch-desc"><?php _e ( "enable reports on Posts List and Pages List", 'google-analytics-dashboard-for-wp' );?></div>
275
+ </td>
276
+ </tr>
277
+ <tr>
278
+ <td colspan="2" class="gadwp-settings-title">
279
+ <div class="button-primary gadwp-settings-switchoo">
280
+ <input type="checkbox" name="options[dashboard_widget]" value="1" class="gadwp-settings-switchoo-checkbox" id="dashboard_widget" <?php checked( $options['dashboard_widget'], 1 ); ?>>
281
+ <label class="gadwp-settings-switchoo-label" for="dashboard_widget">
282
+ <div class="gadwp-settings-switchoo-inner"></div>
283
+ <div class="gadwp-settings-switchoo-switch"></div>
284
+ </label>
285
+ </div>
286
+ <div class="switch-desc"><?php _e ( "enable the main Dashboard Widget", 'google-analytics-dashboard-for-wp' );?></div>
287
+ </td>
288
+ </tr>
289
+ <tr>
290
+ <td colspan="2">
291
+ <hr><?php echo "<h2>" . __( "Real-Time Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
292
+ </tr>
293
+ <?php if ( $options['user_api'] ) : ?>
294
+ <tr>
295
+ <td colspan="2" class="gadwp-settings-title">
296
+ <div class="button-primary gadwp-settings-switchoo">
297
+ <input type="checkbox" name="options[backend_realtime_report]" value="1" class="gadwp-settings-switchoo-checkbox" id="backend_realtime_report" <?php checked( $options['backend_realtime_report'], 1 ); ?>>
298
+ <label class="gadwp-settings-switchoo-label" for="backend_realtime_report">
299
+ <div class="gadwp-settings-switchoo-inner"></div>
300
+ <div class="gadwp-settings-switchoo-switch"></div>
301
+ </label>
302
+ </div>
303
+ <div class="switch-desc"><?php _e ( "enable Real-Time report (requires access to Real-Time Reporting API)", 'google-analytics-dashboard-for-wp' );?></div>
304
+ </td>
305
+ </tr>
306
+ <?php endif; ?>
307
+ <tr>
308
+ <td colspan="2" class="gadwp-settings-title"> <?php _e("Maximum number of pages to display on real-time tab:", 'google-analytics-dashboard-for-wp'); ?>
309
+ <input type="number" name="options[ga_realtime_pages]" id="ga_realtime_pages" value="<?php echo (int)$options['ga_realtime_pages']; ?>" size="3">
310
+ </td>
311
+ </tr>
312
+ <tr>
313
+ <td colspan="2">
314
+ <hr><?php echo "<h2>" . __( "Location Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
315
+ </tr>
316
+ <tr>
317
+ <td colspan="2" class="gadwp-settings-title">
318
+ <?php echo __("Target Geo Map to country:", 'google-analytics-dashboard-for-wp'); ?>
319
+ <input type="text" style="text-align: center;" name="options[ga_target_geomap]" value="<?php echo esc_attr($options['ga_target_geomap']); ?>" size="3">
320
+ </td>
321
+ </tr>
322
+ <tr>
323
+ <td colspan="2" class="gadwp-settings-title">
324
+ <?php echo __("Maps API Key:", 'google-analytics-dashboard-for-wp'); ?>
325
+ <input type="text" style="text-align: center;" name="options[maps_api_key]" value="<?php echo esc_attr($options['maps_api_key']); ?>" size="50">
326
+ </td>
327
+ </tr>
328
+ <tr>
329
+ <td colspan="2">
330
+ <hr><?php echo "<h2>" . __( "404 Errors Report", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
331
+ </tr>
332
+ <tr>
333
+ <td colspan="2" class="gadwp-settings-title">
334
+ <?php echo __("404 Page Title contains:", 'google-analytics-dashboard-for-wp'); ?>
335
+ <input type="text" style="text-align: center;" name="options[pagetitle_404]" value="<?php echo esc_attr($options['pagetitle_404']); ?>" size="20">
336
+ </td>
337
+ </tr>
338
+ <tr>
339
+ <td colspan="2">
340
+ <hr>
341
+ </td>
342
+ </tr>
343
+ <tr>
344
+ <td colspan="2" class="submit">
345
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
346
+ </td>
347
+ </tr>
348
+ </table>
349
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
350
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
351
+
352
+
353
+
354
+
355
+
356
+
357
+ </form>
358
+ <?php
359
+ self::output_sidebar();
360
+ }
361
+
362
+ public static function tracking_settings() {
363
+ $gadwp = GADWP();
364
+
365
+ if ( ! current_user_can( 'manage_options' ) ) {
366
+ return;
367
+ }
368
+ $options = self::update_options( 'tracking' );
369
+ if ( isset( $_POST['options']['gadwp_hidden'] ) ) {
370
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
371
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
372
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
373
+ }
374
+ }
375
+ if ( ! $gadwp->config->options['tableid_jail'] ) {
376
+ $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( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
377
+ }
378
+ ?>
379
+ <form name="gadwp_form" method="post" action="<?php esc_url($_SERVER['REQUEST_URI']); ?>">
380
+ <div class="wrap">
381
+ <?php echo "<h2>" . __( "Google Analytics Tracking Code", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
382
+ </div>
383
+ <div id="poststuff" class="gadwp">
384
+ <div id="post-body" class="metabox-holder columns-2">
385
+ <div id="post-body-content">
386
+ <div class="settings-wrapper">
387
+ <div class="inside">
388
+ <?php if ( 'universal' == $options['tracking_type'] ) :?>
389
+ <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'events' => __( "Events Tracking", 'google-analytics-dashboard-for-wp' ), 'custom' => __( "Custom Definitions", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'advanced' => __( "Advanced Settings", 'google-analytics-dashboard-for-wp' ), 'integration' => __( "Integration", 'google-analytics-dashboard-for-wp' ) );?>
390
+ <?php elseif ( 'tagmanager' == $options['tracking_type'] ) :?>
391
+ <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'tmdatalayervars' => __( "DataLayer Variables", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'tmintegration' => __( "Integration", 'google-analytics-dashboard-for-wp' ) );?>
392
+ <?php else :?>
393
+ <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ) );?>
394
+ <?php endif; ?>
395
+ <?php self::navigation_tabs( $tabs ); ?>
396
+ <?php if ( isset( $message ) ) : ?>
397
+ <?php echo $message; ?>
398
+ <?php endif; ?>
399
+ <div id="gadwp-basic">
400
+ <table class="gadwp-settings-options">
401
+ <tr>
402
+ <td colspan="2"><?php echo "<h2>" . __( "Tracking Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
403
+ </tr>
404
+ <tr>
405
+ <td class="gadwp-settings-title">
406
+ <label for="tracking_type"><?php _e("Tracking Type:", 'google-analytics-dashboard-for-wp' ); ?>
407
+ </label>
408
+ </td>
409
+ <td>
410
+ <select id="tracking_type" name="options[tracking_type]" onchange="this.form.submit()">
411
+ <option value="universal" <?php selected( $options['tracking_type'], 'universal' ); ?>><?php _e("Analytics", 'google-analytics-dashboard-for-wp');?></option>
412
+ <option value="tagmanager" <?php selected( $options['tracking_type'], 'tagmanager' ); ?>><?php _e("Tag Manager", 'google-analytics-dashboard-for-wp');?></option>
413
+ <option value="disabled" <?php selected( $options['tracking_type'], 'disabled' ); ?>><?php _e("Disabled", 'google-analytics-dashboard-for-wp');?></option>
414
+ </select>
415
+ </td>
416
+ </tr>
417
+ <?php if ( 'universal' == $options['tracking_type'] ) : ?>
418
+ <tr>
419
+ <td class="gadwp-settings-title"></td>
420
+ <td>
421
+ <?php $profile_info = GADWP_Tools::get_selected_profile($gadwp->config->options['ga_profiles_list'], $gadwp->config->options['tableid_jail']); ?>
422
+ <?php echo '<pre>' . __("View Name:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[5]) . '</pre>';?>
423
+ </td>
424
+ </tr>
425
+ <tr>
426
+ <td colspan="2" class="gadwp-settings-title">
427
+ <div class="button-primary gadwp-settings-switchoo">
428
+ <input type="checkbox" name="options[ga_with_gtag]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_with_gtag" <?php checked( $options['ga_with_gtag'], 1 ); ?>>
429
+ <label class="gadwp-settings-switchoo-label" for="ga_with_gtag">
430
+ <div class="gadwp-settings-switchoo-inner"></div>
431
+ <div class="gadwp-settings-switchoo-switch"></div>
432
+ </label>
433
+ </div>
434
+ <div class="switch-desc"><?php echo " ".__("use global site tag gtag.js (not recommended)", 'google-analytics-dashboard-for-wp' );?></div>
435
+ </td>
436
+ </tr>
437
+ <?php elseif ( 'tagmanager' == $options['tracking_type'] ) : ?>
438
+ <tr>
439
+ <td class="gadwp-settings-title">
440
+ <label for="tracking_type"><?php _e("Web Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
441
+ </label>
442
+ </td>
443
+ <td>
444
+ <input type="text" name="options[web_containerid]" value="<?php echo esc_attr($options['web_containerid']); ?>" size="15">
445
+ </td>
446
+ </tr>
447
+ <?php endif; ?>
448
+ <tr>
449
+ <td class="gadwp-settings-title">
450
+ <label for="trackingcode_infooter"><?php _e("Code Placement:", 'google-analytics-dashboard-for-wp' ); ?>
451
+ </label>
452
+ </td>
453
+ <td>
454
+ <select id="trackingcode_infooter" name="options[trackingcode_infooter]">
455
+ <option value="0" <?php selected( $options['trackingcode_infooter'], 0 ); ?>><?php _e("HTML Head", 'google-analytics-dashboard-for-wp');?></option>
456
+ <option value="1" <?php selected( $options['trackingcode_infooter'], 1 ); ?>><?php _e("HTML Body", 'google-analytics-dashboard-for-wp');?></option>
457
+ </select>
458
+ </td>
459
+ </tr>
460
+ </table>
461
+ </div>
462
+ <div id="gadwp-events">
463
+ <table class="gadwp-settings-options">
464
+ <tr>
465
+ <td colspan="2"><?php echo "<h2>" . __( "Events Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
466
+ </tr>
467
+ <tr>
468
+ <td colspan="2" class="gadwp-settings-title">
469
+ <div class="button-primary gadwp-settings-switchoo">
470
+ <input type="checkbox" name="options[ga_event_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_event_tracking" <?php checked( $options['ga_event_tracking'], 1 ); ?>>
471
+ <label class="gadwp-settings-switchoo-label" for="ga_event_tracking">
472
+ <div class="gadwp-settings-switchoo-inner"></div>
473
+ <div class="gadwp-settings-switchoo-switch"></div>
474
+ </label>
475
+ </div>
476
+ <div class="switch-desc"><?php echo " ".__("track downloads, mailto, telephone and outbound links", 'google-analytics-dashboard-for-wp' ); ?></div>
477
+ </td>
478
+ </tr>
479
+ <tr>
480
+ <td colspan="2" class="gadwp-settings-title">
481
+ <div class="button-primary gadwp-settings-switchoo">
482
+ <input type="checkbox" name="options[ga_aff_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_aff_tracking" <?php checked( $options['ga_aff_tracking'], 1 ); ?>>
483
+ <label class="gadwp-settings-switchoo-label" for="ga_aff_tracking">
484
+ <div class="gadwp-settings-switchoo-inner"></div>
485
+ <div class="gadwp-settings-switchoo-switch"></div>
486
+ </label>
487
+ </div>
488
+ <div class="switch-desc"><?php echo " ".__("track affiliate links", 'google-analytics-dashboard-for-wp' ); ?></div>
489
+ </td>
490
+ </tr>
491
+ <tr>
492
+ <td colspan="2" class="gadwp-settings-title">
493
+ <div class="button-primary gadwp-settings-switchoo">
494
+ <input type="checkbox" name="options[ga_hash_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_hash_tracking" <?php checked( $options['ga_hash_tracking'], 1 ); ?>>
495
+ <label class="gadwp-settings-switchoo-label" for="ga_hash_tracking">
496
+ <div class="gadwp-settings-switchoo-inner"></div>
497
+ <div class="gadwp-settings-switchoo-switch"></div>
498
+ </label>
499
+ </div>
500
+ <div class="switch-desc"><?php echo " ".__("track fragment identifiers, hashmarks (#) in URI links", 'google-analytics-dashboard-for-wp' ); ?></div>
501
+ </td>
502
+ </tr>
503
+ <tr>
504
+ <td colspan="2" class="gadwp-settings-title">
505
+ <div class="button-primary gadwp-settings-switchoo">
506
+ <input type="checkbox" name="options[ga_formsubmit_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_formsubmit_tracking" <?php checked( $options['ga_formsubmit_tracking'], 1 ); ?>>
507
+ <label class="gadwp-settings-switchoo-label" for="ga_formsubmit_tracking">
508
+ <div class="gadwp-settings-switchoo-inner"></div>
509
+ <div class="gadwp-settings-switchoo-switch"></div>
510
+ </label>
511
+ </div>
512
+ <div class="switch-desc"><?php echo " ".__("track form submit actions", 'google-analytics-dashboard-for-wp' ); ?></div>
513
+ </td>
514
+ </tr>
515
+ <tr>
516
+ <td colspan="2" class="gadwp-settings-title">
517
+ <div class="button-primary gadwp-settings-switchoo">
518
+ <input type="checkbox" name="options[ga_pagescrolldepth_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_pagescrolldepth_tracking" <?php checked( $options['ga_pagescrolldepth_tracking'], 1 ); ?>>
519
+ <label class="gadwp-settings-switchoo-label" for="ga_pagescrolldepth_tracking">
520
+ <div class="gadwp-settings-switchoo-inner"></div>
521
+ <div class="gadwp-settings-switchoo-switch"></div>
522
+ </label>
523
+ </div>
524
+ <div class="switch-desc"><?php echo " ".__("track page scrolling depth", 'google-analytics-dashboard-for-wp' ); ?></div>
525
+ </td>
526
+ </tr>
527
+ <tr>
528
+ <td class="gadwp-settings-title">
529
+ <label for="ga_event_downloads"><?php _e("Downloads Regex:", 'google-analytics-dashboard-for-wp'); ?>
530
+ </label>
531
+ </td>
532
+ <td>
533
+ <input type="text" id="ga_event_downloads" name="options[ga_event_downloads]" value="<?php echo esc_attr($options['ga_event_downloads']); ?>" size="50">
534
+ </td>
535
+ </tr>
536
+ <tr>
537
+ <td class="gadwp-settings-title">
538
+ <label for="ga_event_affiliates"><?php _e("Affiliates Regex:", 'google-analytics-dashboard-for-wp'); ?>
539
+ </label>
540
+ </td>
541
+ <td>
542
+ <input type="text" id="ga_event_affiliates" name="options[ga_event_affiliates]" value="<?php echo esc_attr($options['ga_event_affiliates']); ?>" size="50">
543
+ </td>
544
+ </tr>
545
+ <tr>
546
+ <td class="gadwp-settings-title">
547
+ <label for="trackingevents_infooter"><?php _e("Code Placement:", 'google-analytics-dashboard-for-wp' ); ?>
548
+ </label>
549
+ </td>
550
+ <td>
551
+ <select id="trackingevents_infooter" name="options[trackingevents_infooter]">
552
+ <option value="0" <?php selected( $options['trackingevents_infooter'], 0 ); ?>><?php _e("HTML Head", 'google-analytics-dashboard-for-wp');?></option>
553
+ <option value="1" <?php selected( $options['trackingevents_infooter'], 1 ); ?>><?php _e("HTML Body", 'google-analytics-dashboard-for-wp');?></option>
554
+ </select>
555
+ </td>
556
+ </tr>
557
+ </table>
558
+ </div>
559
+ <div id="gadwp-custom">
560
+ <table class="gadwp-settings-options">
561
+ <tr>
562
+ <td colspan="2"><?php echo "<h2>" . __( "Custom Dimensions", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
563
+ </tr>
564
+ <tr>
565
+ <td class="gadwp-settings-title">
566
+ <label for="ga_author_dimindex"><?php _e("Authors:", 'google-analytics-dashboard-for-wp' ); ?>
567
+ </label>
568
+ </td>
569
+ <td>
570
+ <select id="ga_author_dimindex" name="options[ga_author_dimindex]">
571
+ <?php for ($i=0;$i<21;$i++) : ?>
572
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_author_dimindex'], $i ); ?>><?php echo 0 == $i ?'Disabled':'dimension '.$i; ?></option>
573
+ <?php endfor; ?>
574
+ </select>
575
+ </td>
576
+ </tr>
577
+ <tr>
578
+ <td class="gadwp-settings-title">
579
+ <label for="ga_pubyear_dimindex"><?php _e("Publication Year:", 'google-analytics-dashboard-for-wp' ); ?>
580
+ </label>
581
+ </td>
582
+ <td>
583
+ <select id="ga_pubyear_dimindex" name="options[ga_pubyear_dimindex]">
584
+ <?php for ($i=0;$i<21;$i++) : ?>
585
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_pubyear_dimindex'], $i ); ?>><?php echo 0 == $i ?'Disabled':'dimension '.$i; ?></option>
586
+ <?php endfor; ?>
587
+ </select>
588
+ </td>
589
+ </tr>
590
+ <tr>
591
+ <td class="gadwp-settings-title">
592
+ <label for="ga_pubyearmonth_dimindex"><?php _e("Publication Month:", 'google-analytics-dashboard-for-wp' ); ?>
593
+ </label>
594
+ </td>
595
+ <td>
596
+ <select id="ga_pubyearmonth_dimindex" name="options[ga_pubyearmonth_dimindex]">
597
+ <?php for ($i=0;$i<21;$i++) : ?>
598
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_pubyearmonth_dimindex'], $i ); ?>><?php echo 0 == $i ?'Disabled':'dimension '.$i; ?></option>
599
+ <?php endfor; ?>
600
+ </select>
601
+ </td>
602
+ </tr>
603
+ <tr>
604
+ <td class="gadwp-settings-title">
605
+ <label for="ga_category_dimindex"><?php _e("Categories:", 'google-analytics-dashboard-for-wp' ); ?>
606
+ </label>
607
+ </td>
608
+ <td>
609
+ <select id="ga_category_dimindex" name="options[ga_category_dimindex]">
610
+ <?php for ($i=0;$i<21;$i++) : ?>
611
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_category_dimindex'], $i ); ?>><?php echo 0 == $i ? 'Disabled':'dimension '.$i; ?></option>
612
+ <?php endfor; ?>
613
+ </select>
614
+ </td>
615
+ </tr>
616
+ <tr>
617
+ <td class="gadwp-settings-title">
618
+ <label for="ga_user_dimindex"><?php _e("User Type:", 'google-analytics-dashboard-for-wp' ); ?>
619
+ </label>
620
+ </td>
621
+ <td>
622
+ <select id="ga_user_dimindex" name="options[ga_user_dimindex]">
623
+ <?php for ($i=0;$i<21;$i++) : ?>
624
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_user_dimindex'], $i ); ?>><?php echo 0 == $i ? 'Disabled':'dimension '.$i; ?></option>
625
+ <?php endfor; ?>
626
+ </select>
627
+ </td>
628
+ </tr>
629
+ <tr>
630
+ <td class="gadwp-settings-title">
631
+ <label for="ga_tag_dimindex"><?php _e("Tags:", 'google-analytics-dashboard-for-wp' ); ?>
632
+ </label>
633
+ </td>
634
+ <td>
635
+ <select id="ga_tag_dimindex" name="options[ga_tag_dimindex]">
636
+ <?php for ($i=0;$i<21;$i++) : ?>
637
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_tag_dimindex'], $i ); ?>><?php echo 0 == $i ? 'Disabled':'dimension '.$i; ?></option>
638
+ <?php endfor; ?>
639
+ </select>
640
+ </td>
641
+ </tr>
642
+ </table>
643
+ </div>
644
+ <div id="gadwp-tmdatalayervars">
645
+ <table class="gadwp-settings-options">
646
+ <tr>
647
+ <td colspan="2"><?php echo "<h2>" . __( "Main Variables", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
648
+ </tr>
649
+ <tr>
650
+ <td class="gadwp-settings-title">
651
+ <label for="tm_author_var"><?php _e("Authors:", 'google-analytics-dashboard-for-wp' ); ?>
652
+ </label>
653
+ </td>
654
+ <td>
655
+ <select id="tm_author_var" name="options[tm_author_var]">
656
+ <option value="1" <?php selected( $options['tm_author_var'], 1 ); ?>>gadwpAuthor</option>
657
+ <option value="0" <?php selected( $options['tm_author_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
658
+ </select>
659
+ </td>
660
+ </tr>
661
+ <tr>
662
+ <td class="gadwp-settings-title">
663
+ <label for="tm_pubyear_var"><?php _e("Publication Year:", 'google-analytics-dashboard-for-wp' ); ?>
664
+ </label>
665
+ </td>
666
+ <td>
667
+ <select id="tm_pubyear_var" name="options[tm_pubyear_var]">
668
+ <option value="1" <?php selected( $options['tm_pubyear_var'], 1 ); ?>>gadwpPublicationYear</option>
669
+ <option value="0" <?php selected( $options['tm_pubyear_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
670
+ </select>
671
+ </td>
672
+ </tr>
673
+ <tr>
674
+ <td class="gadwp-settings-title">
675
+ <label for="tm_pubyearmonth_var"><?php _e("Publication Month:", 'google-analytics-dashboard-for-wp' ); ?>
676
+ </label>
677
+ </td>
678
+ <td>
679
+ <select id="tm_pubyearmonth_var" name="options[tm_pubyearmonth_var]">
680
+ <option value="1" <?php selected( $options['tm_pubyearmonth_var'], 1 ); ?>>gadwpPublicationYearMonth</option>
681
+ <option value="0" <?php selected( $options['tm_pubyearmonth_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
682
+ </select>
683
+ </td>
684
+ </tr>
685
+ <tr>
686
+ <td class="gadwp-settings-title">
687
+ <label for="tm_category_var"><?php _e("Categories:", 'google-analytics-dashboard-for-wp' ); ?>
688
+ </label>
689
+ </td>
690
+ <td>
691
+ <select id="tm_category_var" name="options[tm_category_var]">
692
+ <option value="1" <?php selected( $options['tm_category_var'], 1 ); ?>>gadwpCategory</option>
693
+ <option value="0" <?php selected( $options['tm_category_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
694
+ </select>
695
+ </td>
696
+ </tr>
697
+ <tr>
698
+ <td class="gadwp-settings-title">
699
+ <label for="tm_user_var"><?php _e("User Type:", 'google-analytics-dashboard-for-wp' ); ?>
700
+ </label>
701
+ </td>
702
+ <td>
703
+ <select id="tm_user_var" name="options[tm_user_var]">
704
+ <option value="1" <?php selected( $options['tm_user_var'], 1 ); ?>>gadwpUser</option>
705
+ <option value="0" <?php selected( $options['tm_user_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
706
+ </select>
707
+ </td>
708
+ </tr>
709
+ <tr>
710
+ <td class="gadwp-settings-title">
711
+ <label for="tm_tag_var"><?php _e("Tags:", 'google-analytics-dashboard-for-wp' ); ?>
712
+ </label>
713
+ </td>
714
+ <td>
715
+ <select id="tm_tag_var" name="options[tm_tag_var]">
716
+ <option value="1" <?php selected( $options['tm_tag_var'], 1 ); ?>>gadwpTag</option>
717
+ <option value="0" <?php selected( $options['tm_tag_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
718
+ </select>
719
+ </td>
720
+ </tr>
721
+ </table>
722
+ </div>
723
+ <div id="gadwp-advanced">
724
+ <table class="gadwp-settings-options">
725
+ <tr>
726
+ <td colspan="2"><?php echo "<h2>" . __( "Advanced Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
727
+ </tr>
728
+ <tr>
729
+ <td class="gadwp-settings-title">
730
+ <label for="ga_speed_samplerate"><?php _e("Speed Sample Rate:", 'google-analytics-dashboard-for-wp'); ?>
731
+ </label>
732
+ </td>
733
+ <td>
734
+ <input type="number" id="ga_speed_samplerate" name="options[ga_speed_samplerate]" value="<?php echo (int)($options['ga_speed_samplerate']); ?>" max="100" min="1">
735
+ %
736
+ </td>
737
+ </tr>
738
+ <tr>
739
+ <td class="gadwp-settings-title">
740
+ <label for="ga_user_samplerate"><?php _e("User Sample Rate:", 'google-analytics-dashboard-for-wp'); ?>
741
+ </label>
742
+ </td>
743
+ <td>
744
+ <input type="number" id="ga_user_samplerate" name="options[ga_user_samplerate]" value="<?php echo (int)($options['ga_user_samplerate']); ?>" max="100" min="1">
745
+ %
746
+ </td>
747
+ </tr>
748
+ <tr>
749
+ <td colspan="2" class="gadwp-settings-title">
750
+ <div class="button-primary gadwp-settings-switchoo">
751
+ <input type="checkbox" name="options[ga_anonymize_ip]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_anonymize_ip" <?php checked( $options['ga_anonymize_ip'], 1 ); ?>>
752
+ <label class="gadwp-settings-switchoo-label" for="ga_anonymize_ip">
753
+ <div class="gadwp-settings-switchoo-inner"></div>
754
+ <div class="gadwp-settings-switchoo-switch"></div>
755
+ </label>
756
+ </div>
757
+ <div class="switch-desc"><?php echo " ".__("anonymize IPs while tracking", 'google-analytics-dashboard-for-wp' );?></div>
758
+ </td>
759
+ </tr>
760
+ <tr>
761
+ <td colspan="2" class="gadwp-settings-title">
762
+ <div class="button-primary gadwp-settings-switchoo">
763
+ <input type="checkbox" name="options[ga_optout]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_optout" <?php checked( $options['ga_optout'], 1 ); ?>>
764
+ <label class="gadwp-settings-switchoo-label" for="ga_optout">
765
+ <div class="gadwp-settings-switchoo-inner"></div>
766
+ <div class="gadwp-settings-switchoo-switch"></div>
767
+ </label>
768
+ </div>
769
+ <div class="switch-desc"><?php echo " ".__("enable support for user opt-out", 'google-analytics-dashboard-for-wp' );?></div>
770
+ </td>
771
+ </tr>
772
+ <tr>
773
+ <td colspan="2" class="gadwp-settings-title">
774
+ <div class="button-primary gadwp-settings-switchoo">
775
+ <input type="checkbox" name="options[ga_dnt_optout]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dnt_optout" <?php checked( $options['ga_dnt_optout'], 1 ); ?>>
776
+ <label class="gadwp-settings-switchoo-label" for="ga_dnt_optout">
777
+ <div class="gadwp-settings-switchoo-inner"></div>
778
+ <div class="gadwp-settings-switchoo-switch"></div>
779
+ </label>
780
+ </div>
781
+ <div class="switch-desc"> <?php _e( 'exclude tracking for users sending Do Not Track header', 'google-analytics-dashboard-for-wp' ); ?></div>
782
+ </td>
783
+ </tr>
784
+ <tr>
785
+ <td colspan="2" class="gadwp-settings-title">
786
+ <div class="button-primary gadwp-settings-switchoo">
787
+ <input type="checkbox" name="options[ga_remarketing]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_remarketing" <?php checked( $options['ga_remarketing'], 1 ); ?>>
788
+ <label class="gadwp-settings-switchoo-label" for="ga_remarketing">
789
+ <div class="gadwp-settings-switchoo-inner"></div>
790
+ <div class="gadwp-settings-switchoo-switch"></div>
791
+ </label>
792
+ </div>
793
+ <div class="switch-desc"><?php echo " ".__("enable remarketing, demographics and interests reports", 'google-analytics-dashboard-for-wp' );?></div>
794
+ </td>
795
+ </tr>
796
+ <tr>
797
+ <td colspan="2" class="gadwp-settings-title">
798
+ <div class="button-primary gadwp-settings-switchoo">
799
+ <input type="checkbox" name="options[ga_event_bouncerate]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_event_bouncerate" <?php checked( $options['ga_event_bouncerate'], 1 ); ?>>
800
+ <label class="gadwp-settings-switchoo-label" for="ga_event_bouncerate">
801
+ <div class="gadwp-settings-switchoo-inner"></div>
802
+ <div class="gadwp-settings-switchoo-switch"></div>
803
+ </label>
804
+ </div>
805
+ <div class="switch-desc"><?php echo " ".__("exclude events from bounce-rate and time on page calculation", 'google-analytics-dashboard-for-wp' );?></div>
806
+ </td>
807
+ </tr>
808
+ <tr>
809
+ <td colspan="2" class="gadwp-settings-title">
810
+ <div class="button-primary gadwp-settings-switchoo">
811
+ <input type="checkbox" name="options[ga_enhanced_links]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_enhanced_links" <?php checked( $options['ga_enhanced_links'], 1 ); ?>>
812
+ <label class="gadwp-settings-switchoo-label" for="ga_enhanced_links">
813
+ <div class="gadwp-settings-switchoo-inner"></div>
814
+ <div class="gadwp-settings-switchoo-switch"></div>
815
+ </label>
816
+ </div>
817
+ <div class="switch-desc"><?php echo " ".__("enable enhanced link attribution", 'google-analytics-dashboard-for-wp' );?></div>
818
+ </td>
819
+ </tr>
820
+ <tr>
821
+ <td colspan="2" class="gadwp-settings-title">
822
+ <div class="button-primary gadwp-settings-switchoo">
823
+ <input type="checkbox" name="options[ga_event_precision]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_event_precision" <?php checked( $options['ga_event_precision'], 1 ); ?>>
824
+ <label class="gadwp-settings-switchoo-label" for="ga_event_precision">
825
+ <div class="gadwp-settings-switchoo-inner"></div>
826
+ <div class="gadwp-settings-switchoo-switch"></div>
827
+ </label>
828
+ </div>
829
+ <div class="switch-desc"><?php echo " ".__("use hitCallback to increase event tracking accuracy", 'google-analytics-dashboard-for-wp' );?></div>
830
+ </td>
831
+ </tr>
832
+ <tr>
833
+ <td colspan="2" class="gadwp-settings-title">
834
+ <div class="button-primary gadwp-settings-switchoo">
835
+ <input type="checkbox" name="options[ga_force_ssl]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_force_ssl" <?php checked( $options['ga_force_ssl'] || $options['ga_with_gtag'], 1 ); ?> <?php disabled( $options['ga_with_gtag'], true );?>>
836
+ <label class="gadwp-settings-switchoo-label" for="ga_force_ssl">
837
+ <div class="gadwp-settings-switchoo-inner"></div>
838
+ <div class="gadwp-settings-switchoo-switch"></div>
839
+ </label>
840
+ </div>
841
+ <div class="switch-desc"><?php echo " ".__("enable Force SSL", 'google-analytics-dashboard-for-wp' );?></div>
842
+ </td>
843
+ </tr>
844
+ <tr>
845
+ <td colspan="2"><?php echo "<h2>" . __( "Cross-domain Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
846
+ </tr>
847
+ <tr>
848
+ <td colspan="2" class="gadwp-settings-title">
849
+ <div class="button-primary gadwp-settings-switchoo">
850
+ <input type="checkbox" name="options[ga_crossdomain_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_crossdomain_tracking" <?php checked( $options['ga_crossdomain_tracking'], 1 ); ?>>
851
+ <label class="gadwp-settings-switchoo-label" for="ga_crossdomain_tracking">
852
+ <div class="gadwp-settings-switchoo-inner"></div>
853
+ <div class="gadwp-settings-switchoo-switch"></div>
854
+ </label>
855
+ </div>
856
+ <div class="switch-desc"><?php echo " ".__("enable cross domain tracking", 'google-analytics-dashboard-for-wp' ); ?></div>
857
+ </td>
858
+ </tr>
859
+ <tr>
860
+ <td class="gadwp-settings-title">
861
+ <label for="ga_crossdomain_list"><?php _e("Cross Domains:", 'google-analytics-dashboard-for-wp'); ?>
862
+ </label>
863
+ </td>
864
+ <td>
865
+ <input type="text" id="ga_crossdomain_list" name="options[ga_crossdomain_list]" value="<?php echo esc_attr($options['ga_crossdomain_list']); ?>" size="50">
866
+ </td>
867
+ </tr>
868
+ <tr>
869
+ <td colspan="2"><?php echo "<h2>" . __( "Cookie Customization", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
870
+ </tr>
871
+ <tr>
872
+ <td class="gadwp-settings-title">
873
+ <label for="ga_cookiedomain"><?php _e("Cookie Domain:", 'google-analytics-dashboard-for-wp'); ?>
874
+ </label>
875
+ </td>
876
+ <td>
877
+ <input type="text" id="ga_cookiedomain" name="options[ga_cookiedomain]" value="<?php echo esc_attr($options['ga_cookiedomain']); ?>" size="50">
878
+ </td>
879
+ </tr>
880
+ <tr>
881
+ <td class="gadwp-settings-title">
882
+ <label for="ga_cookiename"><?php _e("Cookie Name:", 'google-analytics-dashboard-for-wp'); ?>
883
+ </label>
884
+ </td>
885
+ <td>
886
+ <input type="text" id="ga_cookiename" name="options[ga_cookiename]" value="<?php echo esc_attr($options['ga_cookiename']); ?>" size="50">
887
+ </td>
888
+ </tr>
889
+ <tr>
890
+ <td class="gadwp-settings-title">
891
+ <label for="ga_cookieexpires"><?php _e("Cookie Expires:", 'google-analytics-dashboard-for-wp'); ?>
892
+ </label>
893
+ </td>
894
+ <td>
895
+ <input type="text" id="ga_cookieexpires" name="options[ga_cookieexpires]" value="<?php echo esc_attr($options['ga_cookieexpires']); ?>" size="10">
896
+ <?php _e("seconds", 'google-analytics-dashboard-for-wp' ); ?>
897
+ </td>
898
+ </tr>
899
+ </table>
900
+ </div>
901
+ <div id="gadwp-integration">
902
+ <table class="gadwp-settings-options">
903
+ <tr>
904
+ <td colspan="2"><?php echo "<h2>" . __( "Accelerated Mobile Pages (AMP)", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
905
+ </tr>
906
+ <tr>
907
+ <td colspan="2" class="gadwp-settings-title">
908
+ <div class="button-primary gadwp-settings-switchoo">
909
+ <input type="checkbox" name="options[amp_tracking_analytics]" value="1" class="gadwp-settings-switchoo-checkbox" id="amp_tracking_analytics" <?php checked( $options['amp_tracking_analytics'], 1 ); ?>>
910
+ <label class="gadwp-settings-switchoo-label" for="amp_tracking_analytics">
911
+ <div class="gadwp-settings-switchoo-inner"></div>
912
+ <div class="gadwp-settings-switchoo-switch"></div>
913
+ </label>
914
+ </div>
915
+ <div class="switch-desc"><?php echo " ".__("enable tracking for Accelerated Mobile Pages (AMP)", 'google-analytics-dashboard-for-wp' );?></div>
916
+ </td>
917
+ </tr>
918
+ <tr>
919
+ <td colspan="2" class="gadwp-settings-title">
920
+ <div class="button-primary gadwp-settings-switchoo">
921
+ <input type="checkbox" name="options[amp_tracking_clientidapi]" value="1" class="gadwp-settings-switchoo-checkbox" id="amp_tracking_clientidapi" <?php checked( $options['amp_tracking_clientidapi'] && !$options['ga_with_gtag'], 1 ); ?> <?php disabled( $options['ga_with_gtag'], true );?>>
922
+ <label class="gadwp-settings-switchoo-label" for="amp_tracking_clientidapi">
923
+ <div class="gadwp-settings-switchoo-inner"></div>
924
+ <div class="gadwp-settings-switchoo-switch"></div>
925
+ </label>
926
+ </div>
927
+ <div class="switch-desc"><?php echo " ".__("enable Google AMP Client Id API", 'google-analytics-dashboard-for-wp' );?></div>
928
+ </td>
929
+ </tr>
930
+ <tr>
931
+ <td colspan="2"><?php echo "<h2>" . __( "Ecommerce", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
932
+ </tr>
933
+ <tr>
934
+ <td class="gadwp-settings-title">
935
+ <label for="tracking_type"><?php _e("Ecommerce Tracking:", 'google-analytics-dashboard-for-wp' ); ?>
936
+ </label>
937
+ </td>
938
+ <td>
939
+ <select id="ecommerce_mode" name="options[ecommerce_mode]" <?php disabled( $options['ga_with_gtag'], true );?>>
940
+ <option value="disabled" <?php selected( $options['ecommerce_mode'], 'disabled' ); ?>><?php _e("Disabled", 'google-analytics-dashboard-for-wp');?></option>
941
+ <option value="standard" <?php selected( $options['ecommerce_mode'], 'standard' ); ?>><?php _e("Ecommerce Plugin", 'google-analytics-dashboard-for-wp');?></option>
942
+ <option value="enhanced" <?php selected( $options['ecommerce_mode'], 'enhanced' ); selected( $options['ga_with_gtag'], true );?>><?php _e("Enhanced Ecommerce Plugin", 'google-analytics-dashboard-for-wp');?></option>
943
+ </select>
944
+ </td>
945
+ </tr>
946
+ <tr>
947
+ <td colspan="2"><?php echo "<h2>" . __( "Optimize", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
948
+ </tr>
949
+ <tr>
950
+ <td colspan="2" class="gadwp-settings-title">
951
+ <div class="button-primary gadwp-settings-switchoo">
952
+ <input type="checkbox" name="options[optimize_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="optimize_tracking" <?php checked( $options['optimize_tracking'], 1 ); ?>>
953
+ <label class="gadwp-settings-switchoo-label" for="optimize_tracking">
954
+ <div class="gadwp-settings-switchoo-inner"></div>
955
+ <div class="gadwp-settings-switchoo-switch"></div>
956
+ </label>
957
+ </div>
958
+ <div class="switch-desc"><?php echo " ".__("enable Optimize tracking", 'google-analytics-dashboard-for-wp' );?></div>
959
+ </td>
960
+ </tr>
961
+ <tr>
962
+ <td colspan="2" class="gadwp-settings-title">
963
+ <div class="button-primary gadwp-settings-switchoo">
964
+ <input type="checkbox" name="options[optimize_pagehiding]" value="1" class="gadwp-settings-switchoo-checkbox" id="optimize_pagehiding" <?php checked( $options['optimize_pagehiding'], 1 ); ?>>
965
+ <label class="gadwp-settings-switchoo-label" for="optimize_pagehiding">
966
+ <div class="gadwp-settings-switchoo-inner"></div>
967
+ <div class="gadwp-settings-switchoo-switch"></div>
968
+ </label>
969
+ </div>
970
+ <div class="switch-desc"><?php echo " ".__("enable Page Hiding support", 'google-analytics-dashboard-for-wp' );?></div>
971
+ </td>
972
+ </tr>
973
+ <tr>
974
+ <td class="gadwp-settings-title">
975
+ <label for="tracking_type"><?php _e("Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
976
+ </label>
977
+ </td>
978
+ <td>
979
+ <input type="text" name="options[optimize_containerid]" value="<?php echo esc_attr($options['optimize_containerid']); ?>" size="15">
980
+ </td>
981
+ </tr>
982
+ </table>
983
+ </div>
984
+ <div id="gadwp-tmintegration">
985
+ <table class="gadwp-settings-options">
986
+ <tr>
987
+ <td colspan="2"><?php echo "<h2>" . __( "Accelerated Mobile Pages (AMP)", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
988
+ </tr>
989
+ <tr>
990
+ <td colspan="2" class="gadwp-settings-title">
991
+ <div class="button-primary gadwp-settings-switchoo">
992
+ <input type="checkbox" name="options[amp_tracking_tagmanager]" value="1" class="gadwp-settings-switchoo-checkbox" id="amp_tracking_tagmanager" <?php checked( $options['amp_tracking_tagmanager'], 1 ); ?>>
993
+ <label class="gadwp-settings-switchoo-label" for="amp_tracking_tagmanager">
994
+ <div class="gadwp-settings-switchoo-inner"></div>
995
+ <div class="gadwp-settings-switchoo-switch"></div>
996
+ </label>
997
+ </div>
998
+ <div class="switch-desc"><?php echo " ".__("enable tracking for Accelerated Mobile Pages (AMP)", 'google-analytics-dashboard-for-wp' );?></div>
999
+ </td>
1000
+ </tr>
1001
+ <tr>
1002
+ <td class="gadwp-settings-title">
1003
+ <label for="tracking_type"><?php _e("AMP Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
1004
+ </label>
1005
+ </td>
1006
+ <td>
1007
+ <input type="text" name="options[amp_containerid]" value="<?php echo esc_attr($options['amp_containerid']); ?>" size="15">
1008
+ </td>
1009
+ </tr>
1010
+ </table>
1011
+ </div>
1012
+ <div id="gadwp-exclude">
1013
+ <table class="gadwp-settings-options">
1014
+ <tr>
1015
+ <td colspan="2"><?php echo "<h2>" . __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1016
+ </tr>
1017
+ <tr>
1018
+ <td class="roles gadwp-settings-title">
1019
+ <label for="track_exclude"><?php _e("Exclude tracking for:", 'google-analytics-dashboard-for-wp' ); ?></label>
1020
+ </td>
1021
+ <td class="gadwp-settings-roles">
1022
+ <table>
1023
+ <tr>
1024
+ <?php if ( ! isset( $wp_roles ) ) : ?>
1025
+ <?php $wp_roles = new WP_Roles(); ?>
1026
+ <?php endif; ?>
1027
+ <?php $i = 0; ?>
1028
+ <?php foreach ( $wp_roles->role_names as $role => $name ) : ?>
1029
+ <?php if ( 'subscriber' != $role ) : ?>
1030
+ <?php $i++; ?>
1031
+ <td>
1032
+ <label>
1033
+ <input type="checkbox" name="options[track_exclude][]" value="<?php echo $role; ?>" <?php if (in_array($role,$options['track_exclude'])) echo 'checked="checked"'; ?> /> <?php echo $name; ?>
1034
+ </label>
1035
+ </td>
1036
+ <?php endif; ?>
1037
+ <?php if ( 0 == $i % 4 ) : ?>
1038
+ </tr>
1039
+ <tr>
1040
+ <?php endif; ?>
1041
+ <?php endforeach; ?>
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+ </table>
1049
+ </td>
1050
+ </tr>
1051
+ </table>
1052
+ </div>
1053
+ <table class="gadwp-settings-options">
1054
+ <tr>
1055
+ <td colspan="2">
1056
+ <hr>
1057
+ </td>
1058
+ </tr>
1059
+ <tr>
1060
+ <td colspan="2" class="submit">
1061
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
1062
+ </td>
1063
+ </tr>
1064
+ </table>
1065
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1066
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+ </form>
1074
+ <?php
1075
+ self::output_sidebar();
1076
+ }
1077
+
1078
+ public static function errors_debugging() {
1079
+
1080
+ $gadwp = GADWP();
1081
+
1082
+ if ( ! current_user_can( 'manage_options' ) ) {
1083
+ return;
1084
+ }
1085
+
1086
+ $anonim = GADWP_Tools::anonymize_options( $gadwp->config->options );
1087
+
1088
+ $options = self::update_options( 'frontend' );
1089
+ if ( ! $gadwp->config->options['tableid_jail'] || ! $gadwp->config->options['token'] ) {
1090
+ $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( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
1091
+ }
1092
+ ?>
1093
+ <div class="wrap">
1094
+ <?php echo "<h2>" . __( "Google Analytics Errors & Debugging", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1095
+ </div>
1096
+ <div id="poststuff" class="gadwp">
1097
+ <div id="post-body" class="metabox-holder columns-2">
1098
+ <div id="post-body-content">
1099
+ <div class="settings-wrapper">
1100
+ <div class="inside">
1101
+ <?php if (isset($message)) echo $message; ?>
1102
+ <?php $tabs = array( 'errors' => __( "Errors & Details", 'google-analytics-dashboard-for-wp' ), 'config' => __( "Plugin Settings", 'google-analytics-dashboard-for-wp' ), 'sysinfo' => __( "System", 'google-analytics-dashboard-for-wp' ) ); ?>
1103
+ <?php self::navigation_tabs( $tabs ); ?>
1104
+ <div id="gadwp-errors">
1105
+ <table class="gadwp-settings-logdata">
1106
+ <tr>
1107
+ <td>
1108
+ <?php echo "<h2>" . __( "Error Details", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1109
+ </td>
1110
+ </tr>
1111
+ <tr>
1112
+ <td>
1113
+ <?php $errors_count = GADWP_Tools::get_cache( 'errors_count' ); ?>
1114
+ <pre class="gadwp-settings-logdata"><?php echo '<span>' . __("Count: ", 'google-analytics-dashboard-for-wp') . '</span>' . (int)$errors_count;?></pre>
1115
+ <?php $errors = print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ? esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : ''; ?>
1116
+ <?php $errors = str_replace( 'Deconf_', 'Google_', $errors); ?>
1117
+ <pre class="gadwp-settings-logdata"><?php echo '<span>' . __("Last Error: ", 'google-analytics-dashboard-for-wp') . '</span>' . "\n" . $errors;?></pre>
1118
+ <pre class="gadwp-settings-logdata"><?php echo '<span>' . __("GAPI Error: ", 'google-analytics-dashboard-for-wp') . '</span>'; echo "\n" . esc_html( print_r( GADWP_Tools::get_cache( 'gapi_errors' ), true ) ) ?></pre>
1119
+ <br />
1120
+ <hr>
1121
+ </td>
1122
+ </tr>
1123
+ <tr>
1124
+ <td>
1125
+ <?php echo "<h2>" . __( "Sampled Data", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1126
+ </td>
1127
+ </tr>
1128
+ <tr>
1129
+ <td>
1130
+ <?php $sampling = GADWP_TOOLS::get_cache( 'sampleddata' ); ?>
1131
+ <?php if ( $sampling ) :?>
1132
+ <?php printf( __( "Last Detected on %s.", 'google-analytics-dashboard-for-wp' ), '<strong>'. $sampling['date'] . '</strong>' );?>
1133
+ <br />
1134
+ <?php printf( __( "The report was based on %s of sessions.", 'google-analytics-dashboard-for-wp' ), '<strong>'. $sampling['percent'] . '</strong>' );?>
1135
+ <br />
1136
+ <?php printf( __( "Sessions ratio: %s.", 'google-analytics-dashboard-for-wp' ), '<strong>'. $sampling['sessions'] . '</strong>' ); ?>
1137
+ <?php else :?>
1138
+ <?php _e( "None", 'google-analytics-dashboard-for-wp' ); ?>
1139
+ <?php endif;?>
1140
+ </td>
1141
+ </tr>
1142
+ </table>
1143
+ </div>
1144
+ <div id="gadwp-config">
1145
+ <table class="gadwp-settings-options">
1146
+ <tr>
1147
+ <td><?php echo "<h2>" . __( "Plugin Configuration", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1148
+ </tr>
1149
+ <tr>
1150
+ <td>
1151
+ <pre class="gadwp-settings-logdata"><?php echo esc_html(print_r($anonim, true));?></pre>
1152
+ <br />
1153
+ <hr>
1154
+ </td>
1155
+ </tr>
1156
+ </table>
1157
+ </div>
1158
+ <div id="gadwp-sysinfo">
1159
+ <table class="gadwp-settings-options">
1160
+ <tr>
1161
+ <td><?php echo "<h2>" . __( "System Information", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1162
+ </tr>
1163
+ <tr>
1164
+ <td>
1165
+ <pre class="gadwp-settings-logdata"><?php echo esc_html(GADWP_Tools::system_info());?></pre>
1166
+ <br />
1167
+ <hr>
1168
+ </td>
1169
+ </tr>
1170
+ </table>
1171
+ </div>
1172
+ <?php
1173
+ self::output_sidebar();
1174
+ }
1175
+
1176
+ public static function general_settings() {
1177
+ $gadwp = GADWP();
1178
+
1179
+ if ( ! current_user_can( 'manage_options' ) ) {
1180
+ return;
1181
+ }
1182
+ $options = self::update_options( 'general' );
1183
+ printf( '<div id="gapi-warning" class="updated"><p>%1$s <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=general_screen&utm_campaign=gadwp">%2$s</a></p></div>', __( 'Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', 'google-analytics-dashboard-for-wp' ), __( 'Library conflicts between WordPress plugins', 'google-analytics-dashboard-for-wp' ) );
1184
+ if ( null === $gadwp->gapi_controller ) {
1185
+ $gadwp->gapi_controller = new GADWP_GAPI_Controller();
1186
+ }
1187
+ echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
1188
+ if ( isset( $_POST['gadwp_access_code'] ) ) {
1189
+ if ( 1 == ! stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) && $_POST['gadwp_access_code'] != get_option( 'gadwp_redeemed_code' ) ) {
1190
+ try {
1191
+ $gadwp_access_code = $_POST['gadwp_access_code'];
1192
+ update_option( 'gadwp_redeemed_code', $gadwp_access_code );
1193
+ GADWP_Tools::delete_cache( 'gapi_errors' );
1194
+ GADWP_Tools::delete_cache( 'last_error' );
1195
+ $gadwp->gapi_controller->client->authenticate( $_POST['gadwp_access_code'] );
1196
+ $gadwp->config->options['token'] = $gadwp->gapi_controller->client->getAccessToken();
1197
+ $gadwp->config->options['automatic_updates_minorversion'] = 1;
1198
+ $gadwp->config->set_plugin_options();
1199
+ $options = self::update_options( 'general' );
1200
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1201
+ if ( $gadwp->config->options['token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1202
+ $profiles = $gadwp->gapi_controller->refresh_profiles();
1203
+ if ( is_array ( $profiles ) && ! empty( $profiles ) ) {
1204
+ $gadwp->config->options['ga_profiles_list'] = $profiles;
1205
+ if ( ! $gadwp->config->options['tableid_jail'] ) {
1206
+ $profile = GADWP_Tools::guess_default_domain( $profiles );
1207
+ $gadwp->config->options['tableid_jail'] = $profile;
1208
+ }
1209
+ $gadwp->config->set_plugin_options();
1210
+ $options = self::update_options( 'general' );
1211
+ }
1212
+ }
1213
+ } catch ( Deconf_IO_Exception $e ) {
1214
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1215
+ GADWP_Tools::set_error( $e, $timeout );
1216
+ } catch ( Deconf_Service_Exception $e ) {
1217
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1218
+ GADWP_Tools::set_error( $e, $timeout );
1219
+ } catch ( Exception $e ) {
1220
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1221
+ GADWP_Tools::set_error( $e, $timeout );
1222
+ $gadwp->gapi_controller->reset_token();
1223
+ }
1224
+ } else {
1225
+ if ( 1 == stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) ) {
1226
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "The access code is <strong>not</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X) <strong>nor</strong> your <strong>email address</strong>!", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1227
+ } else {
1228
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "You can only use the access code <strong>once</strong>, please generate a <strong>new access</strong> code following the instructions!", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1229
+ }
1230
+ }
1231
+ }
1232
+ if ( isset( $_POST['Clear'] ) ) {
1233
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1234
+ GADWP_Tools::clear_cache();
1235
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1236
+ } else {
1237
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1238
+ }
1239
+ }
1240
+ if ( isset( $_POST['Reset'] ) ) {
1241
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1242
+ $gadwp->gapi_controller->reset_token();
1243
+ GADWP_Tools::clear_cache();
1244
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1245
+ $options = self::update_options( 'Reset' );
1246
+ } else {
1247
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1248
+ }
1249
+ }
1250
+ if ( isset( $_POST['Reset_Err'] ) ) {
1251
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1252
+
1253
+ if ( GADWP_Tools::get_cache( 'gapi_errors' ) || GADWP_Tools::get_cache( 'last_error' ) ) {
1254
+
1255
+ $info = GADWP_Tools::system_info();
1256
+ $info .= 'GADWP Version: ' . GADWP_CURRENT_VERSION;
1257
+
1258
+ $sep = "\n---------------------------\n";
1259
+ $error_report = GADWP_Tools::get_cache( 'last_error' );
1260
+ $error_report .= $sep . print_r( GADWP_Tools::get_cache( 'gapi_errors' ), true );
1261
+ $error_report .= $sep . GADWP_Tools::get_cache( 'errors_count' );
1262
+ $error_report .= $sep . $info;
1263
+
1264
+ $error_report = urldecode( $error_report );
1265
+
1266
+ $url = GADWP_ENDPOINT_URL . 'gadwp-report.php';
1267
+ /* @formatter:off */
1268
+ $response = wp_remote_post( $url, array(
1269
+ 'method' => 'POST',
1270
+ 'timeout' => 45,
1271
+ 'redirection' => 5,
1272
+ 'httpversion' => '1.0',
1273
+ 'blocking' => true,
1274
+ 'headers' => array(),
1275
+ 'body' => array( 'error_report' => $error_report ),
1276
+ 'cookies' => array()
1277
+ )
1278
+ );
1279
+ }
1280
+
1281
+ /* @formatter:on */
1282
+ GADWP_Tools::delete_cache( 'last_error' );
1283
+ GADWP_Tools::delete_cache( 'gapi_errors' );
1284
+ delete_option( 'gadwp_got_updated' );
1285
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "All errors reseted.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1286
+ } else {
1287
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1288
+ }
1289
+ }
1290
+ if ( isset( $_POST['options']['gadwp_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Reset_Err'] ) ) {
1291
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1292
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
1293
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1294
+ }
1295
+ }
1296
+ if ( isset( $_POST['Hide'] ) ) {
1297
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1298
+ $message = "<div class='updated' id='gadwp-action'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1299
+ $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_profiles_list'], $gadwp->config->options['tableid_jail'] );
1300
+ $gadwp->config->options['ga_profiles_list'] = array( $lock_profile );
1301
+ $options = self::update_options( 'general' );
1302
+ } else {
1303
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1304
+ }
1305
+ }
1306
+ ?>
1307
+ <div class="wrap">
1308
+ <?php echo "<h2>" . __( "Google Analytics Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1309
+ <hr>
1310
+ </div>
1311
+ <div id="poststuff" class="gadwp">
1312
+ <div id="post-body" class="metabox-holder columns-2">
1313
+ <div id="post-body-content">
1314
+ <div class="settings-wrapper">
1315
+ <div class="inside">
1316
+ <?php if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
1317
+ <?php $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( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
1318
+ <?php endif;?>
1319
+ <?php if ( isset( $_POST['Authorize'] ) ) : ?>
1320
+ <?php GADWP_Tools::clear_cache(); ?>
1321
+ <?php $gadwp->gapi_controller->token_request(); ?>
1322
+ <div class="updated">
1323
+ <p><?php _e( "Use the red link (see below) to generate and get your access code! You need to generate a new code each time you authorize!", 'google-analytics-dashboard-for-wp' )?></p>
1324
+ </div>
1325
+ <?php else : ?>
1326
+ <?php if ( isset( $message ) ) :?>
1327
+ <?php echo $message;?>
1328
+ <?php endif; ?>
1329
+ <form name="gadwp_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1330
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1331
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1332
+ <table class="gadwp-settings-options">
1333
+ <tr>
1334
+ <td colspan="2">
1335
+ <?php echo "<h2>" . __( "Plugin Authorization", 'google-analytics-dashboard-for-wp' ) . "</h2>";?>
1336
+ </td>
1337
+ </tr>
1338
+ <tr>
1339
+ <td colspan="2" class="gadwp-settings-info">
1340
+ <?php printf(__('You need to create a %1$s and watch this %2$s before proceeding to authorization.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/creating-a-google-analytics-account/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("free analytics account", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video tutorial", 'google-analytics-dashboard-for-wp')));?>
1341
+ </td>
1342
+ </tr>
1343
+ <?php if (! $options['token'] || ($options['user_api'] && ! $options['network_mode'])) : ?>
1344
+ <tr>
1345
+ <td colspan="2" class="gadwp-settings-info">
1346
+ <input name="options[user_api]" type="checkbox" id="user_api" value="1" <?php checked( $options['user_api'], 1 ); ?> onchange="this.form.submit()" <?php echo ($options['network_mode'])?'disabled="disabled"':''; ?> /><?php echo " ".__("developer mode (requires advanced API knowledge)", 'google-analytics-dashboard-for-wp' );?>
1347
+ </td>
1348
+ </tr>
1349
+ <?php endif; ?>
1350
+ <?php if ($options['user_api'] && ! $options['network_mode']) : ?>
1351
+ <tr>
1352
+ <td class="gadwp-settings-title">
1353
+ <label for="options[client_id]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label>
1354
+ </td>
1355
+ <td>
1356
+ <input type="text" name="options[client_id]" value="<?php echo esc_attr($options['client_id']); ?>" size="40" required="required">
1357
+ </td>
1358
+ </tr>
1359
+ <tr>
1360
+ <td class="gadwp-settings-title">
1361
+ <label for="options[client_secret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?></label>
1362
+ </td>
1363
+ <td>
1364
+ <input type="text" name="options[client_secret]" value="<?php echo esc_attr($options['client_secret']); ?>" size="40" required="required">
1365
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1366
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1367
+ </td>
1368
+ </tr>
1369
+ <?php endif; ?>
1370
+ <?php if ( $options['token'] ) : ?>
1371
+ <tr>
1372
+ <td colspan="2">
1373
+ <input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['network_mode']?'disabled="disabled"':''; ?> />
1374
+ <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1375
+ <input type="submit" name="Reset_Err" class="button button-secondary" value="<?php _e( "Report & Reset Errors", 'google-analytics-dashboard-for-wp' ); ?>" />
1376
+ </td>
1377
+ </tr>
1378
+ <tr>
1379
+ <td colspan="2">
1380
+ <hr>
1381
+ </td>
1382
+ </tr>
1383
+ <tr>
1384
+ <td colspan="2"><?php echo "<h2>" . __( "General Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1385
+ </tr>
1386
+ <tr>
1387
+ <td class="gadwp-settings-title">
1388
+ <label for="tableid_jail"><?php _e("Select View:", 'google-analytics-dashboard-for-wp' ); ?></label>
1389
+ </td>
1390
+ <td>
1391
+ <select id="tableid_jail" <?php disabled(empty($options['ga_profiles_list']) || 1 == count($options['ga_profiles_list']), true); ?> name="options[tableid_jail]">
1392
+ <?php if ( ! empty( $options['ga_profiles_list'] ) ) : ?>
1393
+ <?php foreach ( $options['ga_profiles_list'] as $items ) : ?>
1394
+ <?php if ( $items[3] ) : ?>
1395
+ <option value="<?php echo esc_attr( $items[1] ); ?>" <?php selected( $items[1], $options['tableid_jail'] ); ?> title="<?php _e( "View Name:", 'google-analytics-dashboard-for-wp' ); ?> <?php echo esc_attr( $items[0] ); ?>">
1396
+ <?php echo esc_html( GADWP_Tools::strip_protocol( $items[3] ) )?> &#8658; <?php echo esc_attr( $items[0] ); ?>
1397
+ </option>
1398
+ <?php endif; ?>
1399
+ <?php endforeach; ?>
1400
+ <?php else : ?>
1401
+ <option value=""><?php _e( "Property not found", 'google-analytics-dashboard-for-wp' ); ?></option>
1402
+ <?php endif; ?>
1403
+ </select>
1404
+ <?php if ( count( $options['ga_profiles_list'] ) > 1 ) : ?>
1405
+ &nbsp;<input type="submit" name="Hide" class="button button-secondary" value="<?php _e( "Lock Selection", 'google-analytics-dashboard-for-wp' ); ?>" />
1406
+ <?php endif; ?>
1407
+ </td>
1408
+ </tr>
1409
+ <?php if ( $options['tableid_jail'] ) : ?>
1410
+ <tr>
1411
+ <td class="gadwp-settings-title"></td>
1412
+ <td>
1413
+ <?php $profile_info = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_profiles_list'], $gadwp->config->options['tableid_jail'] ); ?>
1414
+ <pre><?php echo __( "View Name:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[0] ) . "<br />" . __( "Tracking ID:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[2] ) . "<br />" . __( "Default URL:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[3] ) . "<br />" . __( "Time Zone:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[5] );?></pre>
1415
+ </td>
1416
+ </tr>
1417
+ <?php endif; ?>
1418
+ <tr>
1419
+ <td class="gadwp-settings-title">
1420
+ <label for="theme_color"><?php _e("Theme Color:", 'google-analytics-dashboard-for-wp' ); ?></label>
1421
+ </td>
1422
+ <td>
1423
+ <input type="text" id="theme_color" class="theme_color" name="options[theme_color]" value="<?php echo esc_attr($options['theme_color']); ?>" size="10">
1424
+ </td>
1425
+ </tr>
1426
+ <tr>
1427
+ <td colspan="2">
1428
+ <hr>
1429
+ </td>
1430
+ </tr>
1431
+ <?php if ( !is_multisite()) :?>
1432
+ <tr>
1433
+ <td colspan="2"><?php echo "<h2>" . __( "Automatic Updates", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1434
+ </tr>
1435
+ <tr>
1436
+ <td colspan="2" class="gadwp-settings-title">
1437
+ <div class="button-primary gadwp-settings-switchoo">
1438
+ <input type="checkbox" name="options[automatic_updates_minorversion]" value="1" class="gadwp-settings-switchoo-checkbox" id="automatic_updates_minorversion" <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>>
1439
+ <label class="gadwp-settings-switchoo-label" for="automatic_updates_minorversion">
1440
+ <div class="gadwp-settings-switchoo-inner"></div>
1441
+ <div class="gadwp-settings-switchoo-switch"></div>
1442
+ </label>
1443
+ </div>
1444
+ <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'google-analytics-dashboard-for-wp' );?></div>
1445
+ </td>
1446
+ </tr>
1447
+ <tr>
1448
+ <td colspan="2">
1449
+ <hr>
1450
+ </td>
1451
+ </tr>
1452
+ <?php endif; ?>
1453
+ <tr>
1454
+ <td colspan="2" class="submit">
1455
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
1456
+ </td>
1457
+ </tr>
1458
+ <?php else : ?>
1459
+ <tr>
1460
+ <td colspan="2">
1461
+ <hr>
1462
+ </td>
1463
+ </tr>
1464
+ <tr>
1465
+ <td colspan="2">
1466
+ <input type="submit" name="Authorize" class="button button-secondary" id="authorize" value="<?php _e( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['network_mode']?'disabled="disabled"':''; ?> />
1467
+ <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1468
+ </td>
1469
+ </tr>
1470
+ <tr>
1471
+ <td colspan="2">
1472
+ <hr>
1473
+ </td>
1474
+ </tr>
1475
+ </table>
1476
+ </form>
1477
+ <?php self::output_sidebar(); ?>
1478
+ <?php return; ?>
1479
+ <?php endif; ?>
1480
+ </table>
1481
+ </form>
1482
+ <?php endif; ?>
1483
+ <?php
1484
+
1485
+ self::output_sidebar();
1486
+ }
1487
+
1488
+ // Network Settings
1489
+ public static function general_settings_network() {
1490
+ $gadwp = GADWP();
1491
+
1492
+ if ( ! current_user_can( 'manage_network_options' ) ) {
1493
+ return;
1494
+ }
1495
+ $options = self::update_options( 'network' );
1496
+ /*
1497
+ * Include GAPI
1498
+ */
1499
+ 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>';
1500
+
1501
+ if ( null === $gadwp->gapi_controller ) {
1502
+ $gadwp->gapi_controller = new GADWP_GAPI_Controller();
1503
+ }
1504
+
1505
+ echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
1506
+ if ( isset( $_POST['gadwp_access_code'] ) ) {
1507
+ if ( 1 == ! stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) && $_POST['gadwp_access_code'] != get_option( 'gadwp_redeemed_code' ) ) {
1508
+ try {
1509
+ $gadwp_access_code = $_POST['gadwp_access_code'];
1510
+ update_option( 'gadwp_redeemed_code', $gadwp_access_code );
1511
+ $gadwp->gapi_controller->client->authenticate( $_POST['gadwp_access_code'] );
1512
+ $gadwp->config->options['token'] = $gadwp->gapi_controller->client->getAccessToken();
1513
+ $gadwp->config->options['automatic_updates_minorversion'] = 1;
1514
+ $gadwp->config->set_plugin_options( true );
1515
+ $options = self::update_options( 'network' );
1516
+ $message = "<div class='updated' id='gadwp-action'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1517
+ if ( is_multisite() ) { // Cleanup errors on the entire network
1518
+ foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
1519
+ switch_to_blog( $blog['blog_id'] );
1520
+ GADWP_Tools::delete_cache( 'last_error' );
1521
+ GADWP_Tools::delete_cache( 'gapi_errors' );
1522
+ restore_current_blog();
1523
+ }
1524
+ } else {
1525
+ GADWP_Tools::delete_cache( 'last_error' );
1526
+ GADWP_Tools::delete_cache( 'gapi_errors' );
1527
+ }
1528
+ if ( $gadwp->config->options['token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1529
+ $profiles = $gadwp->gapi_controller->refresh_profiles();
1530
+ if ( is_array ( $profiles ) && ! empty( $profiles ) ) {
1531
+ $gadwp->config->options['ga_profiles_list'] = $profiles;
1532
+ if ( isset( $gadwp->config->options['tableid_jail'] ) && ! $gadwp->config->options['tableid_jail'] ) {
1533
+ $profile = GADWP_Tools::guess_default_domain( $profiles );
1534
+ $gadwp->config->options['tableid_jail'] = $profile;
1535
+ }
1536
+ $gadwp->config->set_plugin_options( true );
1537
+ $options = self::update_options( 'network' );
1538
+ }
1539
+ }
1540
+ } catch ( Deconf_IO_Exception $e ) {
1541
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1542
+ GADWP_Tools::set_error( $e, $timeout );
1543
+ } catch ( Deconf_Service_Exception $e ) {
1544
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1545
+ GADWP_Tools::set_error( $e, $timeout );
1546
+ } catch ( Exception $e ) {
1547
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1548
+ GADWP_Tools::set_error( $e, $timeout );
1549
+ $gadwp->gapi_controller->reset_token();
1550
+ }
1551
+ } else {
1552
+ if ( 1 == stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) ) {
1553
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "The access code is <strong>not</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X) <strong>nor</strong> your <strong>email address</strong>!", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1554
+ } else {
1555
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "You can only use the access code <strong>once</strong>, please generate a <strong>new access code</strong> using the red link", 'google-analytics-dashboard-for-wp' ) . "!</p></div>";
1556
+ }
1557
+ }
1558
+ }
1559
+ if ( isset( $_POST['Refresh'] ) ) {
1560
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1561
+ $gadwp->config->options['ga_profiles_list'] = array();
1562
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Properties refreshed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1563
+ $options = self::update_options( 'network' );
1564
+ if ( $gadwp->config->options['token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1565
+ if ( ! empty( $gadwp->config->options['ga_profiles_list'] ) ) {
1566
+ $profiles = $gadwp->config->options['ga_profiles_list'];
1567
+ } else {
1568
+ $profiles = $gadwp->gapi_controller->refresh_profiles();
1569
+ }
1570
+ if ( $profiles ) {
1571
+ $gadwp->config->options['ga_profiles_list'] = $profiles;
1572
+ if ( isset( $gadwp->config->options['tableid_jail'] ) && ! $gadwp->config->options['tableid_jail'] ) {
1573
+ $profile = GADWP_Tools::guess_default_domain( $profiles );
1574
+ $gadwp->config->options['tableid_jail'] = $profile;
1575
+ }
1576
+ $gadwp->config->set_plugin_options( true );
1577
+ $options = self::update_options( 'network' );
1578
+ }
1579
+ }
1580
+ } else {
1581
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1582
+ }
1583
+ }
1584
+ if ( isset( $_POST['Clear'] ) ) {
1585
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1586
+ GADWP_Tools::clear_cache();
1587
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1588
+ } else {
1589
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1590
+ }
1591
+ }
1592
+ if ( isset( $_POST['Reset'] ) ) {
1593
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1594
+ $gadwp->gapi_controller->reset_token();
1595
+ GADWP_Tools::clear_cache();
1596
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1597
+ $options = self::update_options( 'Reset' );
1598
+ } else {
1599
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1600
+ }
1601
+ }
1602
+ if ( isset( $_POST['options']['gadwp_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Refresh'] ) ) {
1603
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1604
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
1605
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1606
+ }
1607
+ }
1608
+ if ( isset( $_POST['Hide'] ) ) {
1609
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1610
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1611
+ $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_profiles_list'], $gadwp->config->options['tableid_jail'] );
1612
+ $gadwp->config->options['ga_profiles_list'] = array( $lock_profile );
1613
+ $options = self::update_options( 'network' );
1614
+ } else {
1615
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1616
+ }
1617
+ }
1618
+ ?>
1619
+ <div class="wrap">
1620
+ <h2><?php _e( "Google Analytics Settings", 'google-analytics-dashboard-for-wp' );?></h2>
1621
+ <hr>
1622
+ </div>
1623
+ <div id="poststuff" class="gadwp">
1624
+ <div id="post-body" class="metabox-holder columns-2">
1625
+ <div id="post-body-content">
1626
+ <div class="settings-wrapper">
1627
+ <div class="inside">
1628
+ <?php if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
1629
+ <?php $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( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
1630
+ <?php endif; ?>
1631
+ <?php if ( isset( $_POST['Authorize'] ) ) : ?>
1632
+ <?php GADWP_Tools::clear_cache();?>
1633
+ <?php $gadwp->gapi_controller->token_request();?>
1634
+ <div class="updated">
1635
+ <p><?php _e( "Use the red link (see below) to generate and get your access code! You need to generate a new code each time you authorize!", 'google-analytics-dashboard-for-wp' );?></p>
1636
+ </div>
1637
+ <?php else : ?>
1638
+ <?php if ( isset( $message ) ) : ?>
1639
+ <?php echo $message; ?>
1640
+ <?php endif; ?>
1641
+ <form name="gadwp_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1642
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1643
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1644
+ <table class="gadwp-settings-options">
1645
+ <tr>
1646
+ <td colspan="2">
1647
+ <?php echo "<h2>" . __( "Network Setup", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1648
+ </td>
1649
+ </tr>
1650
+ <tr>
1651
+ <td colspan="2" class="gadwp-settings-title">
1652
+ <div class="button-primary gadwp-settings-switchoo">
1653
+ <input type="checkbox" name="options[network_mode]" value="1" class="gadwp-settings-switchoo-checkbox" id="network_mode" <?php checked( $options['network_mode'], 1); ?> onchange="this.form.submit()">
1654
+ <label class="gadwp-settings-switchoo-label" for="network_mode">
1655
+ <div class="gadwp-settings-switchoo-inner"></div>
1656
+ <div class="gadwp-settings-switchoo-switch"></div>
1657
+ </label>
1658
+ </div>
1659
+ <div class="switch-desc"><?php echo " ".__("use a single Google Analytics account for the entire network", 'google-analytics-dashboard-for-wp' );?></div>
1660
+ </td>
1661
+ </tr>
1662
+ <?php if ($options['network_mode']) : ?>
1663
+ <tr>
1664
+ <td colspan="2">
1665
+ <hr>
1666
+ </td>
1667
+ </tr>
1668
+ <tr>
1669
+ <td colspan="2"><?php echo "<h2>" . __( "Plugin Authorization", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1670
+ </tr>
1671
+ <tr>
1672
+ <td colspan="2" class="gadwp-settings-info">
1673
+ <?php printf(__('You need to create a %1$s and watch this %2$s before proceeding to authorization.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/creating-a-google-analytics-account/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("free analytics account", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video tutorial", 'google-analytics-dashboard-for-wp')));?>
1674
+ </td>
1675
+ </tr>
1676
+ <?php if ( ! $options['token'] || $options['user_api'] ) : ?>
1677
+ <tr>
1678
+ <td colspan="2" class="gadwp-settings-info">
1679
+ <input name="options[user_api]" type="checkbox" id="user_api" value="1" <?php checked( $options['user_api'], 1 ); ?> onchange="this.form.submit()" /><?php echo " ".__("developer mode (requires advanced API knowledge)", 'google-analytics-dashboard-for-wp' );?>
1680
+ </td>
1681
+ </tr>
1682
+ <?php endif; ?>
1683
+ <?php if ( $options['user_api'] ) : ?>
1684
+ <tr>
1685
+ <td class="gadwp-settings-title">
1686
+ <label for="options[client_id]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?>
1687
+ </label>
1688
+ </td>
1689
+ <td>
1690
+ <input type="text" name="options[client_id]" value="<?php echo esc_attr($options['client_id']); ?>" size="40" required="required">
1691
+ </td>
1692
+ </tr>
1693
+ <tr>
1694
+ <td class="gadwp-settings-title">
1695
+ <label for="options[client_secret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?>
1696
+ </label>
1697
+ </td>
1698
+ <td>
1699
+ <input type="text" name="options[client_secret]" value="<?php echo esc_attr($options['client_secret']); ?>" size="40" required="required">
1700
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1701
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1702
+ </td>
1703
+ </tr>
1704
+ <?php endif; ?>
1705
+ <?php if ( $options['token'] ) : ?>
1706
+ <tr>
1707
+ <td colspan="2">
1708
+ <input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" />
1709
+ <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1710
+ <input type="submit" name="Refresh" class="button button-secondary" value="<?php _e( "Refresh Properties", 'google-analytics-dashboard-for-wp' ); ?>" />
1711
+ </td>
1712
+ </tr>
1713
+ <tr>
1714
+ <td colspan="2">
1715
+ <hr>
1716
+ </td>
1717
+ </tr>
1718
+ <tr>
1719
+ <td colspan="2">
1720
+ <?php echo "<h2>" . __( "Properties/Views Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1721
+ </td>
1722
+ </tr>
1723
+ <?php if ( isset( $options['network_tableid'] ) ) : ?>
1724
+ <?php $options['network_tableid'] = json_decode( json_encode( $options['network_tableid'] ), false ); ?>
1725
+ <?php endif; ?>
1726
+ <?php foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) : ?>
1727
+ <tr>
1728
+ <td class="gadwp-settings-title-s">
1729
+ <label for="network_tableid"><?php echo '<strong>'.$blog['domain'].$blog['path'].'</strong>: ';?></label>
1730
+ </td>
1731
+ <td>
1732
+ <select id="network_tableid" <?php disabled(!empty($options['ga_profiles_list']),false);?> name="options[network_tableid][<?php echo $blog['blog_id'];?>]">
1733
+ <?php if ( ! empty( $options['ga_profiles_list'] ) ) : ?>
1734
+ <?php foreach ( $options['ga_profiles_list'] as $items ) : ?>
1735
+ <?php if ( $items[3] ) : ?>
1736
+ <?php $temp_id = $blog['blog_id']; ?>
1737
+ <option value="<?php echo esc_attr( $items[1] );?>" <?php selected( $items[1], isset( $options['network_tableid']->$temp_id ) ? $options['network_tableid']->$temp_id : '');?> title="<?php echo __( "View Name:", 'google-analytics-dashboard-for-wp' ) . ' ' . esc_attr( $items[0] );?>">
1738
+ <?php echo esc_html( GADWP_Tools::strip_protocol( $items[3] ) );?> &#8658; <?php echo esc_attr( $items[0] );?>
1739
+ </option>
1740
+ <?php endif; ?>
1741
+ <?php endforeach; ?>
1742
+ <?php else : ?>
1743
+ <option value="">
1744
+ <?php _e( "Property not found", 'google-analytics-dashboard-for-wp' );?>
1745
+ </option>
1746
+ <?php endif; ?>
1747
+ </select>
1748
+ <br />
1749
+ </td>
1750
+ </tr>
1751
+ <?php endforeach; ?>
1752
+ <tr>
1753
+ <td colspan="2">
1754
+ <h2><?php echo _e( "Automatic Updates", 'google-analytics-dashboard-for-wp' );?></h2>
1755
+ </td>
1756
+ </tr>
1757
+ <tr>
1758
+ <td colspan="2" class="gadwp-settings-title">
1759
+ <div class="button-primary gadwp-settings-switchoo">
1760
+ <input type="checkbox" name="options[automatic_updates_minorversion]" value="1" class="gadwp-settings-switchoo-checkbox" id="automatic_updates_minorversion" <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>>
1761
+ <label class="gadwp-settings-switchoo-label" for="automatic_updates_minorversion">
1762
+ <div class="gadwp-settings-switchoo-inner"></div>
1763
+ <div class="gadwp-settings-switchoo-switch"></div>
1764
+ </label>
1765
+ </div>
1766
+ <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'google-analytics-dashboard-for-wp' );?></div>
1767
+ </td>
1768
+ </tr>
1769
+ <tr>
1770
+ <td colspan="2">
1771
+ <hr><?php echo "<h2>" . __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1772
+ </tr>
1773
+ <tr>
1774
+ <td colspan="2" class="gadwp-settings-title">
1775
+ <div class="button-primary gadwp-settings-switchoo">
1776
+ <input type="checkbox" name="options[superadmin_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="superadmin_tracking"<?php checked( $options['superadmin_tracking'], 1); ?>">
1777
+ <label class="gadwp-settings-switchoo-label" for="superadmin_tracking">
1778
+ <div class="gadwp-settings-switchoo-inner"></div>
1779
+ <div class="gadwp-settings-switchoo-switch"></div>
1780
+ </label>
1781
+ </div>
1782
+ <div class="switch-desc"><?php echo " ".__("exclude Super Admin tracking for the entire network", 'google-analytics-dashboard-for-wp' );?></div>
1783
+ </td>
1784
+ </tr>
1785
+ <tr>
1786
+ <td colspan="2">
1787
+ <hr>
1788
+ </td>
1789
+ </tr>
1790
+ <tr>
1791
+ <td colspan="2" class="submit">
1792
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
1793
+ </td>
1794
+ </tr>
1795
+ <?php else : ?>
1796
+ <tr>
1797
+ <td colspan="2">
1798
+ <hr>
1799
+ </td>
1800
+ </tr>
1801
+ <tr>
1802
+ <td colspan="2">
1803
+ <input type="submit" name="Authorize" class="button button-secondary" id="authorize" value="<?php _e( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ); ?>" />
1804
+ <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1805
+ </td>
1806
+ </tr>
1807
+ <?php endif; ?>
1808
+ <tr>
1809
+ <td colspan="2">
1810
+ <hr>
1811
+ </td>
1812
+ </tr>
1813
+ </table>
1814
+ </form>
1815
+ <?php self::output_sidebar(); ?>
1816
+ <?php return; ?>
1817
+ <?php endif;?>
1818
+ </table>
1819
+ </form>
1820
+ <?php endif; ?>
1821
+ <?php
1822
+
1823
+ self::output_sidebar();
1824
+ }
1825
+
1826
+ public static function output_sidebar() {
1827
+ global $wp_version;
1828
+
1829
+ $gadwp = GADWP();
1830
+ ?>
1831
+ </div>
1832
+ </div>
1833
+ </div>
1834
+ <div id="postbox-container-1" class="postbox-container">
1835
+ <div class="meta-box-sortables">
1836
+ <div class="postbox">
1837
+ <h3>
1838
+ <span><?php _e("Setup Tutorial & Demo",'google-analytics-dashboard-for-wp') ?></span>
1839
+ </h3>
1840
+ <div class="inside">
1841
+ <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=video&utm_campaign=gadwp" target="_blank"><img src="<?php echo plugins_url( 'images/google-analytics-dashboard.png' , __FILE__ );?>" width="100%" alt="" /></a>
1842
+ </div>
1843
+ </div>
1844
+ <div class="postbox">
1845
+ <h3>
1846
+ <span><?php _e("Stay Updated",'google-analytics-dashboard-for-wp')?></span>
1847
+ </h3>
1848
+ <div class="inside">
1849
+ <div class="gadwp-desc">
1850
+ <div class="g-ytsubscribe" data-channel="TheDeConf" data-layout="default" data-count="default"></div>
1851
+ </div>
1852
+ <br />
1853
+ <div class="gadwp-desc">
1854
+ <div class="g-follow" data-annotation="bubble" data-height="24" data-href="//plus.google.com/u/0/114149166432576972465" data-rel="publisher"></div>
1855
+ <script src="https://apis.google.com/js/platform.js" async defer></script>
1856
+ </div>
1857
+ <br />
1858
+ <div class="gadwp-desc">
1859
+ <a href="https://twitter.com/deconfcom" class="twitter-follow-button" data-show-screen-name="false"></a>
1860
+ <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
1861
+ </div>
1862
+ </div>
1863
+ </div>
1864
+ <div class="postbox">
1865
+ <h3>
1866
+ <span><?php _e("Further Reading",'google-analytics-dashboard-for-wp')?></span>
1867
+ </h3>
1868
+ <div class="inside">
1869
+ <div class="gadwp-title">
1870
+ <a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/clicky.png' , __FILE__ ); ?>" /></a>
1871
+ </div>
1872
+ <div class="gadwp-desc">
1873
+ <?php printf(__('%s service with users tracking at IP level.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp">%s</a>', __('Web Analytics', 'google-analytics-dashboard-for-wp')));?>
1874
+ </div>
1875
+ <br />
1876
+ <div class="gadwp-title">
1877
+ <a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/ssl.png' , __FILE__ ); ?>" /></a>
1878
+ </div>
1879
+ <div class="gadwp-desc">
1880
+ <?php printf(__('%s by moving your website to HTTPS/SSL.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp">%s</a>', __('Improve search rankings', 'google-analytics-dashboard-for-wp')));?>
1881
+ </div>
1882
+ <br />
1883
+ <div class="gadwp-title">
1884
+ <a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info"><img src="<?php echo plugins_url( 'images/star.png' , __FILE__ ); ?>" /></a>
1885
+ </div>
1886
+ <div class="gadwp-desc">
1887
+ <?php printf(__('Your feedback and review are both important, %s!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info">%s</a>', __('rate this plugin', 'google-analytics-dashboard-for-wp')));?>
1888
+ </div>
1889
+ </div>
1890
+ </div>
1891
+ </div>
1892
+ </div>
1893
+ </div>
1894
+ </div>
1895
+ <?php
1896
+ // Dismiss the admin update notice
1897
+ if ( version_compare( $wp_version, '4.2', '<' ) && current_user_can( 'manage_options' ) ) {
1898
+ delete_option( 'gadwp_got_updated' );
1899
+ }
1900
+ }
1901
+ }
tags/5.3.1.1/admin/setup.php ADDED
@@ -0,0 +1,378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
15
+
16
+ final class GADWP_Backend_Setup {
17
+
18
+ private $gadwp;
19
+
20
+ public function __construct() {
21
+ $this->gadwp = GADWP();
22
+
23
+ // Styles & Scripts
24
+ add_action( 'admin_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
25
+ // Site Menu
26
+ add_action( 'admin_menu', array( $this, 'site_menu' ) );
27
+ // Network Menu
28
+ add_action( 'network_admin_menu', array( $this, 'network_menu' ) );
29
+ // Settings link
30
+ add_filter( "plugin_action_links_" . plugin_basename( GADWP_DIR . 'gadwp.php' ), array( $this, 'settings_link' ) );
31
+ // Updated admin notice
32
+ add_action( 'admin_notices', array( $this, 'admin_notice' ) );
33
+ }
34
+
35
+ /**
36
+ * Add Site Menu
37
+ */
38
+ public function site_menu() {
39
+ global $wp_version;
40
+ if ( current_user_can( 'manage_options' ) ) {
41
+ include ( GADWP_DIR . 'admin/settings.php' );
42
+ add_menu_page( __( "Google Analytics", 'google-analytics-dashboard-for-wp' ), __( "Google Analytics", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_settings', array( 'GADWP_Settings', 'general_settings' ), version_compare( $wp_version, '3.8.0', '>=' ) ? 'dashicons-chart-area' : GADWP_URL . 'admin/images/gadwp-icon.png' );
43
+ add_submenu_page( 'gadwp_settings', __( "General Settings", 'google-analytics-dashboard-for-wp' ), __( "General Settings", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_settings', array( 'GADWP_Settings', 'general_settings' ) );
44
+ add_submenu_page( 'gadwp_settings', __( "Backend Settings", 'google-analytics-dashboard-for-wp' ), __( "Backend Settings", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_backend_settings', array( 'GADWP_Settings', 'backend_settings' ) );
45
+ add_submenu_page( 'gadwp_settings', __( "Frontend Settings", 'google-analytics-dashboard-for-wp' ), __( "Frontend Settings", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_frontend_settings', array( 'GADWP_Settings', 'frontend_settings' ) );
46
+ add_submenu_page( 'gadwp_settings', __( "Tracking Code", 'google-analytics-dashboard-for-wp' ), __( "Tracking Code", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_tracking_settings', array( 'GADWP_Settings', 'tracking_settings' ) );
47
+ add_submenu_page( 'gadwp_settings', __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_errors_debugging', array( 'GADWP_Settings', 'errors_debugging' ) );
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Add Network Menu
53
+ */
54
+ public function network_menu() {
55
+ global $wp_version;
56
+ if ( current_user_can( 'manage_network' ) ) {
57
+ include ( GADWP_DIR . 'admin/settings.php' );
58
+ add_menu_page( __( "Google Analytics", 'google-analytics-dashboard-for-wp' ), "Google Analytics", 'manage_network', 'gadwp_settings', array( 'GADWP_Settings', 'general_settings_network' ), version_compare( $wp_version, '3.8.0', '>=' ) ? 'dashicons-chart-area' : GADWP_URL . 'admin/images/gadwp-icon.png' );
59
+ add_submenu_page( 'gadwp_settings', __( "General Settings", 'google-analytics-dashboard-for-wp' ), __( "General Settings", 'google-analytics-dashboard-for-wp' ), 'manage_network', 'gadwp_settings', array( 'GADWP_Settings', 'general_settings_network' ) );
60
+ add_submenu_page( 'gadwp_settings', __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), 'manage_network', 'gadwp_errors_debugging', array( 'GADWP_Settings', 'errors_debugging' ) );
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Styles & Scripts conditional loading (based on current URI)
66
+ *
67
+ * @param
68
+ * $hook
69
+ */
70
+ public function load_styles_scripts( $hook ) {
71
+ $new_hook = explode( '_page_', $hook );
72
+
73
+ if ( isset( $new_hook[1] ) ) {
74
+ $new_hook = '_page_' . $new_hook[1];
75
+ } else {
76
+ $new_hook = $hook;
77
+ }
78
+
79
+ /*
80
+ * GADWP main stylesheet
81
+ */
82
+ wp_enqueue_style( 'gadwp', GADWP_URL . 'admin/css/gadwp.css', null, GADWP_CURRENT_VERSION );
83
+
84
+ /*
85
+ * GADWP UI
86
+ */
87
+
88
+ if ( GADWP_Tools::get_cache( 'gapi_errors' ) ) {
89
+ $ed_bubble = '!';
90
+ } else {
91
+ $ed_bubble = '';
92
+ }
93
+
94
+ wp_enqueue_script( 'gadwp-backend-ui', plugins_url( 'js/ui.js', __FILE__ ), array( 'jquery' ), GADWP_CURRENT_VERSION, true );
95
+
96
+ /* @formatter:off */
97
+ wp_localize_script( 'gadwp-backend-ui', 'gadwp_ui_data', array(
98
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
99
+ 'security' => wp_create_nonce( 'gadwp_dismiss_notices' ),
100
+ 'ed_bubble' => $ed_bubble,
101
+ )
102
+ );
103
+ /* @formatter:on */
104
+
105
+ if ( $this->gadwp->config->options['switch_profile'] && count( $this->gadwp->config->options['ga_profiles_list'] ) > 1 ) {
106
+ $views = array();
107
+ foreach ( $this->gadwp->config->options['ga_profiles_list'] as $items ) {
108
+ if ( $items[3] ) {
109
+ $views[$items[1]] = esc_js( GADWP_Tools::strip_protocol( $items[3] ) ); // . ' &#8658; ' . $items[0] );
110
+ }
111
+ }
112
+ } else {
113
+ $views = false;
114
+ }
115
+
116
+ /*
117
+ * Main Dashboard Widgets Styles & Scripts
118
+ */
119
+ $widgets_hooks = array( 'index.php' );
120
+
121
+ if ( in_array( $new_hook, $widgets_hooks ) ) {
122
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && $this->gadwp->config->options['dashboard_widget'] ) {
123
+
124
+ if ( $this->gadwp->config->options['ga_target_geomap'] ) {
125
+ $country_codes = GADWP_Tools::get_countrycodes();
126
+ if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
127
+ $region = $this->gadwp->config->options['ga_target_geomap'];
128
+ } else {
129
+ $region = false;
130
+ }
131
+ } else {
132
+ $region = false;
133
+ }
134
+
135
+ wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
136
+
137
+ wp_enqueue_style( 'gadwp-backend-item-reports', GADWP_URL . 'admin/css/admin-widgets.css', null, GADWP_CURRENT_VERSION );
138
+
139
+ wp_register_style( 'jquery-ui-tooltip-html', GADWP_URL . 'common/realtime/jquery.ui.tooltip.html.css' );
140
+
141
+ wp_enqueue_style( 'jquery-ui-tooltip-html' );
142
+
143
+ wp_register_script( 'jquery-ui-tooltip-html', GADWP_URL . 'common/realtime/jquery.ui.tooltip.html.js' );
144
+
145
+ wp_register_script( 'googlecharts', 'https://www.gstatic.com/charts/loader.js', array(), null );
146
+
147
+ wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
148
+
149
+ wp_enqueue_script( 'gadwp-backend-dashboard-reports', GADWP_URL . 'common/js/reports5.js', array( 'jquery', 'googlecharts', 'gadwp-nprogress', 'jquery-ui-tooltip', 'jquery-ui-core', 'jquery-ui-position', 'jquery-ui-tooltip-html' ), GADWP_CURRENT_VERSION, true );
150
+
151
+ /* @formatter:off */
152
+
153
+ $datelist = array(
154
+ 'realtime' => __( "Real-Time", 'google-analytics-dashboard-for-wp' ),
155
+ 'today' => __( "Today", 'google-analytics-dashboard-for-wp' ),
156
+ 'yesterday' => __( "Yesterday", 'google-analytics-dashboard-for-wp' ),
157
+ '7daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 7 ),
158
+ '14daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 14 ),
159
+ '30daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 30 ),
160
+ '90daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 90 ),
161
+ '365daysAgo' => sprintf( _n( "%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp' ), __('One', 'google-analytics-dashboard-for-wp') ),
162
+ '1095daysAgo' => sprintf( _n( "%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp' ), __('Three', 'google-analytics-dashboard-for-wp') ),
163
+ );
164
+
165
+
166
+ if ( $this->gadwp->config->options['user_api'] && ! $this->gadwp->config->options['backend_realtime_report'] ) {
167
+ array_shift( $datelist );
168
+ }
169
+
170
+ wp_localize_script( 'gadwp-backend-dashboard-reports', 'gadwpItemData', array(
171
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
172
+ 'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
173
+ 'dateList' => $datelist,
174
+ 'reportList' => array(
175
+ 'sessions' => __( "Sessions", 'google-analytics-dashboard-for-wp' ),
176
+ 'users' => __( "Users", 'google-analytics-dashboard-for-wp' ),
177
+ 'organicSearches' => __( "Organic", 'google-analytics-dashboard-for-wp' ),
178
+ 'pageviews' => __( "Page Views", 'google-analytics-dashboard-for-wp' ),
179
+ 'visitBounceRate' => __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
180
+ 'locations' => __( "Location", 'google-analytics-dashboard-for-wp' ),
181
+ 'contentpages' => __( "Pages", 'google-analytics-dashboard-for-wp' ),
182
+ 'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
183
+ 'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
184
+ 'trafficdetails' => __( "Traffic", 'google-analytics-dashboard-for-wp' ),
185
+ 'technologydetails' => __( "Technology", 'google-analytics-dashboard-for-wp' ),
186
+ '404errors' => __( "404 Errors", 'google-analytics-dashboard-for-wp' ),
187
+ ),
188
+ 'i18n' => array(
189
+ __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
190
+ __( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ),
191
+ __( "Visitor Type", 'google-analytics-dashboard-for-wp' ),
192
+ __( "Search Engines", 'google-analytics-dashboard-for-wp' ),
193
+ __( "Social Networks", 'google-analytics-dashboard-for-wp' ),
194
+ __( "Sessions", 'google-analytics-dashboard-for-wp' ),
195
+ __( "Users", 'google-analytics-dashboard-for-wp' ),
196
+ __( "Page Views", 'google-analytics-dashboard-for-wp' ),
197
+ __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
198
+ __( "Organic Search", 'google-analytics-dashboard-for-wp' ),
199
+ __( "Pages/Session", 'google-analytics-dashboard-for-wp' ),
200
+ __( "Invalid response", 'google-analytics-dashboard-for-wp' ),
201
+ __( "No Data", 'google-analytics-dashboard-for-wp' ),
202
+ __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
203
+ __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
204
+ __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadwp_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
205
+ __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
206
+ __( "Operating System", 'google-analytics-dashboard-for-wp' ),
207
+ __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
208
+ __( "Mobile Brand", 'google-analytics-dashboard-for-wp' ),
209
+ __( "REFERRALS", 'google-analytics-dashboard-for-wp' ), //20
210
+ __( "KEYWORDS", 'google-analytics-dashboard-for-wp' ),
211
+ __( "SOCIAL", 'google-analytics-dashboard-for-wp' ),
212
+ __( "CAMPAIGN", 'google-analytics-dashboard-for-wp' ),
213
+ __( "DIRECT", 'google-analytics-dashboard-for-wp' ),
214
+ __( "NEW", 'google-analytics-dashboard-for-wp' ), //25
215
+ __( "Time on Page", 'google-analytics-dashboard-for-wp' ),
216
+ __( "Page Load Time", 'google-analytics-dashboard-for-wp' ),
217
+ __( "Session Duration", 'google-analytics-dashboard-for-wp' ),
218
+ ),
219
+ 'rtLimitPages' => $this->gadwp->config->options['ga_realtime_pages'],
220
+ 'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['theme_color'] ),
221
+ 'region' => $region,
222
+ 'mapsApiKey' => apply_filters( 'gadwp_maps_api_key', $this->gadwp->config->options['maps_api_key'] ),
223
+ 'language' => get_bloginfo( 'language' ),
224
+ 'viewList' => $views,
225
+ 'scope' => 'admin-widgets',
226
+ )
227
+
228
+ );
229
+ /* @formatter:on */
230
+ }
231
+ }
232
+
233
+ /*
234
+ * Posts/Pages List Styles & Scripts
235
+ */
236
+ $contentstats_hooks = array( 'edit.php' );
237
+ if ( in_array( $hook, $contentstats_hooks ) ) {
238
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && $this->gadwp->config->options['backend_item_reports'] ) {
239
+
240
+ if ( $this->gadwp->config->options['ga_target_geomap'] ) {
241
+ $country_codes = GADWP_Tools::get_countrycodes();
242
+ if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
243
+ $region = $this->gadwp->config->options['ga_target_geomap'];
244
+ } else {
245
+ $region = false;
246
+ }
247
+ } else {
248
+ $region = false;
249
+ }
250
+
251
+ wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
252
+
253
+ wp_enqueue_style( 'gadwp-backend-item-reports', GADWP_URL . 'admin/css/item-reports.css', null, GADWP_CURRENT_VERSION );
254
+
255
+ wp_enqueue_style( "wp-jquery-ui-dialog" );
256
+
257
+ wp_register_script( 'googlecharts', 'https://www.gstatic.com/charts/loader.js', array(), null );
258
+
259
+ wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
260
+
261
+ wp_enqueue_script( 'gadwp-backend-item-reports', GADWP_URL . 'common/js/reports5.js', array( 'gadwp-nprogress', 'googlecharts', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION, true );
262
+
263
+ /* @formatter:off */
264
+ wp_localize_script( 'gadwp-backend-item-reports', 'gadwpItemData', array(
265
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
266
+ 'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
267
+ 'dateList' => array(
268
+ 'today' => __( "Today", 'google-analytics-dashboard-for-wp' ),
269
+ 'yesterday' => __( "Yesterday", 'google-analytics-dashboard-for-wp' ),
270
+ '7daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 7 ),
271
+ '14daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 14 ),
272
+ '30daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 30 ),
273
+ '90daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 90 ),
274
+ '365daysAgo' => sprintf( _n( "%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp' ), __('One', 'google-analytics-dashboard-for-wp') ),
275
+ '1095daysAgo' => sprintf( _n( "%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp' ), __('Three', 'google-analytics-dashboard-for-wp') ),
276
+ ),
277
+ 'reportList' => array(
278
+ 'uniquePageviews' => __( "Unique Views", 'google-analytics-dashboard-for-wp' ),
279
+ 'users' => __( "Users", 'google-analytics-dashboard-for-wp' ),
280
+ 'organicSearches' => __( "Organic", 'google-analytics-dashboard-for-wp' ),
281
+ 'pageviews' => __( "Page Views", 'google-analytics-dashboard-for-wp' ),
282
+ 'visitBounceRate' => __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
283
+ 'locations' => __( "Location", 'google-analytics-dashboard-for-wp' ),
284
+ 'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
285
+ 'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
286
+ 'trafficdetails' => __( "Traffic", 'google-analytics-dashboard-for-wp' ),
287
+ 'technologydetails' => __( "Technology", 'google-analytics-dashboard-for-wp' ),
288
+ ),
289
+ 'i18n' => array(
290
+ __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
291
+ __( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ),
292
+ __( "Visitor Type", 'google-analytics-dashboard-for-wp' ),
293
+ __( "Social Networks", 'google-analytics-dashboard-for-wp' ),
294
+ __( "Search Engines", 'google-analytics-dashboard-for-wp' ),
295
+ __( "Unique Views", 'google-analytics-dashboard-for-wp' ),
296
+ __( "Users", 'google-analytics-dashboard-for-wp' ),
297
+ __( "Page Views", 'google-analytics-dashboard-for-wp' ),
298
+ __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
299
+ __( "Organic Search", 'google-analytics-dashboard-for-wp' ),
300
+ __( "Pages/Session", 'google-analytics-dashboard-for-wp' ),
301
+ __( "Invalid response", 'google-analytics-dashboard-for-wp' ),
302
+ __( "No Data", 'google-analytics-dashboard-for-wp' ),
303
+ __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
304
+ __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
305
+ __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadwp_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
306
+ __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
307
+ __( "Operating System", 'google-analytics-dashboard-for-wp' ),
308
+ __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
309
+ __( "Mobile Brand", 'google-analytics-dashboard-for-wp' ), //19
310
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
311
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
312
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
313
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
314
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
315
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ), //25
316
+ __( "Time on Page", 'google-analytics-dashboard-for-wp' ),
317
+ __( "Page Load Time", 'google-analytics-dashboard-for-wp' ),
318
+ __( "Exit Rate", 'google-analytics-dashboard-for-wp' ),
319
+ ),
320
+ 'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['theme_color'] ),
321
+ 'region' => $region,
322
+ 'mapsApiKey' => apply_filters( 'gadwp_maps_api_key', $this->gadwp->config->options['maps_api_key'] ),
323
+ 'language' => get_bloginfo( 'language' ),
324
+ 'viewList' => false,
325
+ 'scope' => 'admin-item',
326
+ )
327
+ );
328
+ /* @formatter:on */
329
+ }
330
+ }
331
+
332
+ /*
333
+ * Settings Styles & Scripts
334
+ */
335
+ $settings_hooks = array( '_page_gadwp_settings', '_page_gadwp_backend_settings', '_page_gadwp_frontend_settings', '_page_gadwp_tracking_settings', '_page_gadwp_errors_debugging' );
336
+
337
+ if ( in_array( $new_hook, $settings_hooks ) ) {
338
+ wp_enqueue_style( 'wp-color-picker' );
339
+ wp_enqueue_script( 'wp-color-picker' );
340
+ wp_enqueue_script( 'wp-color-picker-script-handle', plugins_url( 'js/wp-color-picker-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
341
+ wp_enqueue_script( 'gadwp-settings', plugins_url( 'js/settings.js', __FILE__ ), array( 'jquery' ), GADWP_CURRENT_VERSION, true );
342
+ }
343
+ }
344
+
345
+ /**
346
+ * Add "Settings" link in Plugins List
347
+ *
348
+ * @param
349
+ * $links
350
+ * @return array
351
+ */
352
+ public function settings_link( $links ) {
353
+ $settings_link = '<a href="' . esc_url( get_admin_url( null, 'admin.php?page=gadwp_settings' ) ) . '">' . __( "Settings", 'google-analytics-dashboard-for-wp' ) . '</a>';
354
+ array_unshift( $links, $settings_link );
355
+ return $links;
356
+ }
357
+
358
+ /**
359
+ * Add an admin notice after a manual or atuomatic update
360
+ */
361
+ function admin_notice() {
362
+ $currentScreen = get_current_screen();
363
+
364
+ if ( ! current_user_can( 'manage_options' ) || strpos( $currentScreen->base, '_gadwp_' ) === false ) {
365
+ return;
366
+ }
367
+
368
+ if ( get_option( 'gadwp_got_updated' ) ) :
369
+ ?>
370
+ <div id="gadwp-notice" class="notice is-dismissible">
371
+ <p><?php echo sprintf( __('Google Analytics Dashboard for WP has been updated to version %s.', 'google-analytics-dashboard-for-wp' ), GADWP_CURRENT_VERSION).' '.sprintf( __('For details, check out %1$s.', 'google-analytics-dashboard-for-wp' ), sprintf(' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_notice&utm_medium=link&utm_content=release_notice&utm_campaign=gadwp">%s</a>', __('the plugin documentation', 'google-analytics-dashboard-for-wp') ) ); ?></p>
372
+ </div>
373
+
374
+ <?php
375
+ endif;
376
+ }
377
+ }
378
+ }
tags/5.3.1.1/admin/views/access-code.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Copyright 2017 Alin Marcu
5
+ * Author URI: https://deconf.com
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+ ?>
10
+ <form name="input" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" method="post">
11
+ <table class="gadwp-settings-options">
12
+ <tr>
13
+ <td colspan="2" class="gadwp-settings-info">
14
+ <?php echo __( "Use this link to get your <strong>one-time-use</strong> access code:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . $data['authUrl'] . '" id="gapi-access-code" target="_blank">' . __ ( "Get Access Code", 'google-analytics-dashboard-for-wp' ) . '</a>.'; ?>
15
+ </td>
16
+ </tr>
17
+ <tr>
18
+ <td class="gadwp-settings-title">
19
+ <label for="gadwp_access_code" title="<?php _e("Use the red link to get your access code! You need to generate a new one each time you authorize!",'google-analytics-dashboard-for-wp')?>"><?php echo _e( "Access Code:", 'google-analytics-dashboard-for-wp' ); ?></label>
20
+ </td>
21
+ <td>
22
+ <input type="text" id="gadwp_access_code" name="gadwp_access_code" value="" size="61" autocomplete="off" pattern=".\/.{30,}" required="required" title="<?php _e("Use the red link to get your access code! You need to generate a new one each time you authorize!",'google-analytics-dashboard-for-wp')?>">
23
+ </td>
24
+ </tr>
25
+ <tr>
26
+ <td colspan="2">
27
+ <hr>
28
+ </td>
29
+ </tr>
30
+ <tr>
31
+ <td colspan="2">
32
+ <input type="submit" class="button button-secondary" name="gadwp_authorize" value="<?php _e( "Save Access Code", 'google-analytics-dashboard-for-wp' ); ?>" />
33
+ </td>
34
+ </tr>
35
+ </table>
36
+ </form>
tags/5.3.1.1/admin/widgets.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Backend_Widgets' ) ) {
15
+
16
+ class GADWP_Backend_Widgets {
17
+
18
+ private $gadwp;
19
+
20
+ public function __construct() {
21
+ $this->gadwp = GADWP();
22
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) {
23
+ add_action( 'wp_dashboard_setup', array( $this, 'add_widget' ) );
24
+ }
25
+ }
26
+
27
+ public function add_widget() {
28
+ wp_add_dashboard_widget( 'gadwp-widget', __( "Google Analytics Dashboard", 'google-analytics-dashboard-for-wp' ), array( $this, 'dashboard_widget' ), $control_callback = null );
29
+ }
30
+
31
+ public function dashboard_widget() {
32
+ $projectId = 0;
33
+
34
+ if ( empty( $this->gadwp->config->options['token'] ) ) {
35
+ echo '<p>' . __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadwp_settings', false ) . '" method="POST">' . get_submit_button( __( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
36
+ return;
37
+ }
38
+
39
+ if ( current_user_can( 'manage_options' ) ) {
40
+ if ( $this->gadwp->config->options['tableid_jail'] ) {
41
+ $projectId = $this->gadwp->config->options['tableid_jail'];
42
+ } else {
43
+ echo '<p>' . __( "An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadwp_settings', false ) . '" method="POST">' . get_submit_button( __( "Select Domain", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
44
+ return;
45
+ }
46
+ } else {
47
+ if ( $this->gadwp->config->options['tableid_jail'] ) {
48
+ $projectId = $this->gadwp->config->options['tableid_jail'];
49
+ } else {
50
+ echo '<p>' . __( "An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadwp_settings', false ) . '" method="POST">' . get_submit_button( __( "Select Domain", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
51
+ return;
52
+ }
53
+ }
54
+
55
+ if ( ! ( $projectId ) ) {
56
+ echo '<p>' . __( "Something went wrong while retrieving property data. You need to create and properly configure a Google Analytics account:", 'google-analytics-dashboard-for-wp' ) . '</p> <form action="https://deconf.com/how-to-set-up-google-analytics-on-your-website/" method="POST">' . get_submit_button( __( "Find out more!", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
57
+ return;
58
+ }
59
+
60
+ ?>
61
+ <div id="gadwp-window-1"></div>
62
+ <?php
63
+ }
64
+ }
65
+ }
tags/5.3.1.1/common/ajax-actions.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Common_Ajax' ) ) {
15
+
16
+ final class GADWP_Common_Ajax {
17
+
18
+ private $gadwp;
19
+
20
+ public function __construct() {
21
+ $this->gadwp = GADWP();
22
+
23
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) || GADWP_Tools::check_roles( $this->gadwp->config->options['access_front'] ) ) {
24
+ add_action( 'wp_ajax_gadwp_set_error', array( $this, 'ajax_set_error' ) );
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Ajax handler for storing JavaScript Errors
30
+ *
31
+ * @return json|int
32
+ */
33
+ public function ajax_set_error() {
34
+ if ( ! isset( $_POST['gadwp_security_set_error'] ) || ! ( wp_verify_nonce( $_POST['gadwp_security_set_error'], 'gadwp_backend_item_reports' ) || wp_verify_nonce( $_POST['gadwp_security_set_error'], 'gadwp_frontend_item_reports' ) ) ) {
35
+ wp_die( - 40 );
36
+ }
37
+ $timeout = 24 * 60 * 60;
38
+ GADWP_Tools::set_error( $_POST['response'], $timeout );
39
+ wp_die();
40
+ }
41
+ }
42
+ }
tags/5.3.1.1/common/js/reports5.js ADDED
@@ -0,0 +1 @@
 
1
+ "use strict";if(gadwpItemData.mapsApiKey){google.charts.load("current",{mapsApiKey:gadwpItemData.mapsApiKey,packages:["corechart","table","orgchart","geochart"]})}else{google.charts.load("current",{packages:["corechart","table","orgchart","geochart"]})}google.charts.setOnLoadCallback(GADWPReportLoad);gadwpItemData.getID=function(a){if(gadwpItemData.scope=="admin-item"){if(typeof a.id=="undefined"){return 0}if(a.id.split("-")[1]=="undefined"){return 0}else{return a.id.split("-")[1]}}else{if(typeof a.id=="undefined"){return 1}if(a.id.split("-")[4]=="undefined"){return 1}else{return a.id.split("-")[4]}}};gadwpItemData.getSelector=function(a){if(a=="admin-item"){return'a[id^="gadwp-"]'}else{return'li[id^="wp-admin-bar-gadwp"] a'}};gadwpItemData.responsiveDialog=function(){var b,a,c;c=jQuery(".ui-dialog:visible");c.each(function(){b=jQuery(this).find(".ui-dialog-content").data("ui-dialog");if(b.options.fluid){a=jQuery(window).width();if(a<(parseInt(b.options.maxWidth)+50)){jQuery(this).css("max-width","90%")}else{jQuery(this).css("max-width",b.options.maxWidth+"px")}b.option("position",b.options.position)}})};jQuery.fn.extend({gadwpItemReport:function(g){var a,d,h,e,f,i,c,b="-"+g;d={setCookie:function(k,m){var j,l=new Date();if(gadwpItemData.scope=="admin-widgets"){k="gadwp_wg_"+k}else{k="gadwp_ir_"+k}l.setTime(l.getTime()+(24*60*60*1000*365));j="expires="+l.toUTCString();document.cookie=k+"="+m+"; "+j+"; path=/"},getCookie:function(j){var l,m,n,k=0;if(gadwpItemData.scope=="admin-widgets"){j="gadwp_wg_"+j+"="}else{j="gadwp_ir_"+j+"="}m=document.cookie.split(";");for(k=0;k<m.length;k++){l=m[k];while(l.charAt(0)==" "){l=l.substring(1)}if(l.indexOf(j)==0){return l.substring(j.length,l.length)}}return false},escape:function(j){div=document.createElement("div");div.appendChild(document.createTextNode(j));return div.innerHTML}};h={addOptions:function(o,n){var j,l,m,k=[];if(!d.getCookie("default_metric")||!d.getCookie("default_dimension")||!d.getCookie("default_swmetric")){j="sessions";l="30daysAgo";if(gadwpItemData.scope=="front-item"||gadwpItemData.scope=="admin-item"){c="pageviews"}else{c="sessions"}d.setCookie("default_metric",j);d.setCookie("default_dimension",l);d.setCookie("default_swmetric",c)}else{j=d.getCookie("default_metric");l=d.getCookie("default_dimension");m=d.getCookie("default_view");c=d.getCookie("default_swmetric")}if(n==false){if(gadwpItemData.scope=="front-item"||gadwpItemData.scope=="admin-item"){k=""}else{k='<span id="gadwp-swmetric-sessions" title="'+gadwpItemData.i18n[5]+'" class="dashicons dashicons-clock" style="font-size:22px;padding:4px;"></span>'}k+='<span id="gadwp-swmetric-users" title="'+gadwpItemData.i18n[6]+'" class="dashicons dashicons-admin-users" style="font-size:22px;padding:4px;"></span>';k+='<span id="gadwp-swmetric-pageviews" title="'+gadwpItemData.i18n[7]+'" class="dashicons dashicons-admin-page" style="font-size:22px;padding:4px;"></span>';jQuery(o).html(k);jQuery("#gadwp-swmetric-"+c).css("color","#008ec2")}else{jQuery.each(n,function(p,q){if(p==j||p==l||p==m){k.push('<option value="'+p+'" selected="selected">'+q+"</option>")}else{k.push('<option value="'+p+'">'+q+"</option>")}});jQuery(o).html(k.join(""))}},init:function(){var j;if(!jQuery("#gadwp-window"+b).length){return}if(jQuery("#gadwp-window"+b).html().length){return}j='<div id="gadwp-container'+b+'">';if(gadwpItemData.viewList!=false){j+='<select id="gadwp-sel-view'+b+'"></select>'}j+='<select id="gadwp-sel-period'+b+'"></select> ';j+='<select id="gadwp-sel-report'+b+'"></select>';j+='<div id="gadwp-sel-metric'+b+'" style="float:right;display:none;">';j+="</div>";j+='<div id="gadwp-progressbar'+b+'"></div>';j+='<div id="gadwp-status'+b+'"></div>';j+='<div id="gadwp-reports'+b+'"></div>';j+='<div style="text-align:right;width:100%;font-size:0.8em;clear:both;margin-right:5px;margin-top:10px;">';j+=gadwpItemData.i18n[14];j+=' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=back_report&utm_campaign=gadwp" rel="nofollow" style="text-decoration:none;font-size:1em;">GADWP</a>&nbsp;';j+="</div>";j+="</div>",jQuery("#gadwp-window"+b).append(j);h.addOptions("#gadwp-sel-view"+b,gadwpItemData.viewList);h.addOptions("#gadwp-sel-period"+b,gadwpItemData.dateList);h.addOptions("#gadwp-sel-report"+b,gadwpItemData.reportList);h.addOptions("#gadwp-sel-metric"+b,false)}};e={oldViewPort:0,orgChartTableChartData:"",tableChartData:"",orgChartPieChartsData:"",geoChartTableChartData:"",areaChartBottomStatsData:"",realtime:"",rtRuns:null,i18n:null,getTitle:function(j){if(j=="admin-item"){return jQuery("#gadwp"+b).attr("title")}else{return document.getElementsByTagName("title")[0].innerHTML}},alertMessage:function(j){jQuery("#gadwp-status"+b).css({"margin-top":"3px","padding-left":"5px",height:"auto",color:"#000","border-left":"5px solid red"});jQuery("#gadwp-status"+b).html(j)},areaChartBottomStats:function(j){e.areaChartBottomStatsData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();if(a.query=="visitBounceRate,bottomstats"){e.drawAreaChart(j[0],true)}else{e.drawAreaChart(j[0],false)}}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-areachart"+b,j[0],"125px")}if(!jQuery.isNumeric(j[1])){if(jQuery.isArray(j[1])){jQuery("#gadwp-reports"+b).show();e.drawBottomStats(j[1])}else{e.throwDebug(j[1])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-bottomstats"+b,j[1],"40px")}}else{e.throwDebug(j)}NProgress.done()},orgChartPieCharts:function(j){var k=0;e.orgChartPieChartsData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawOrgChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-orgchart"+b,j[0],"125px")}for(k=1;k<j.length;k++){if(!jQuery.isNumeric(j[k])){if(jQuery.isArray(j[k])){jQuery("#gadwp-reports"+b).show();e.drawPieChart("piechart-"+k,j[k],e.i18n[k])}else{e.throwDebug(j[k])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-piechart-"+k+b,j[k],"80px")}}}else{e.throwDebug(j)}NProgress.done()},geoChartTableChart:function(j){e.geoChartTableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawGeoChart(j[0]);e.drawTableChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-geochart"+b,j[0],"125px");e.throwError("#gadwp-tablechart"+b,j[0],"125px")}}else{e.throwDebug(j)}NProgress.done()},orgChartTableChart:function(j){e.orgChartTableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawOrgChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-orgchart"+b,j[0],"125px")}if(!jQuery.isNumeric(j[1])){if(jQuery.isArray(j[1])){e.drawTableChart(j[1])}else{e.throwDebug(j[1])}}else{e.throwError("#gadwp-tablechart"+b,j[1],"125px")}}else{e.throwDebug(j)}NProgress.done()},tableChart:function(j){e.tableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawTableChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-tablechart"+b,j[0],"125px")}}else{e.throwDebug(j)}NProgress.done()},drawTableChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={page:"enable",pageSize:10,width:"100%",allowHtml:true};k=new google.visualization.Table(document.getElementById("gadwp-tablechart"+b));k.draw(l,j)},drawOrgChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={allowCollapse:true,allowHtml:true,height:"100%"};k=new google.visualization.OrgChart(document.getElementById("gadwp-orgchart"+b));k.draw(l,j)},drawPieChart:function(o,m,n){var l,j,k;l=google.visualization.arrayToDataTable(m);j={is3D:false,tooltipText:"percentage",legend:"none",chartArea:{width:"99%",height:"80%"},title:n,pieSliceText:"value",colors:gadwpItemData.colorVariations};k=new google.visualization.PieChart(document.getElementById("gadwp-"+o+b));k.draw(l,j)},drawGeoChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={chartArea:{width:"99%",height:"90%"},colors:[gadwpItemData.colorVariations[5],gadwpItemData.colorVariations[4]]};if(gadwpItemData.region){j.region=gadwpItemData.region;j.displayMode="markers";j.datalessRegionColor="EFEFEF"}k=new google.visualization.GeoChart(document.getElementById("gadwp-geochart"+b));k.draw(l,j)},drawAreaChart:function(n,o){var m,j,l,k;m=google.visualization.arrayToDataTable(n);if(o){k=new google.visualization.NumberFormat({suffix:"%",fractionDigits:2});k.format(m,1)}j={legend:{position:"none"},pointSize:3,colors:[gadwpItemData.colorVariations[0],gadwpItemData.colorVariations[4]],chartArea:{width:"99%",height:"90%"},vAxis:{textPosition:"in",minValue:0},hAxis:{textPosition:"none"}};l=new google.visualization.AreaChart(document.getElementById("gadwp-areachart"+b));l.draw(m,j)},drawBottomStats:function(j){jQuery("#gdsessions"+b).html(j[0]);jQuery("#gdusers"+b).html(j[1]);jQuery("#gdpageviews"+b).html(j[2]);jQuery("#gdbouncerate"+b).html(j[3]);jQuery("#gdorganicsearch"+b).html(j[4]);jQuery("#gdpagespervisit"+b).html(j[5]);jQuery("#gdpagetime"+b).html(j[6]);jQuery("#gdpageload"+b).html(j[7]);jQuery("#gdsessionduration"+b).html(j[8])},rtOnlyUniqueValues:function(l,k,j){return j.indexOf(l)===k},rtCountSessions:function(k,m){var l=0,j=0;for(j=0;j<k.rows.length;j++){if(jQuery.inArray(m,k.rows[j])>-1){l+=parseInt(k.rows[j][6])}}return l},rtGenerateTooltip:function(k){var m=0,l="",j=0;for(j=0;j<k.length;j++){m+=parseInt(k[j].count);l+="<tr><td class='gadwp-pgdetailsl'>"+k[j].value+"</td><td class='gadwp-pgdetailsr'>"+k[j].count+"</td></tr>"}if(m){return("<table>"+l+"</table>")}else{return("")}},rtPageDetails:function(y,n){var w,o,r,x=0,v=0,m=0,s=0,t=0,z=0,C=0,q=0,l=0,u="",A="",p="",k="",B="";y=y.rows;for(x=0;x<y.length;x++){if(y[x][0]==n){o=y[x][5];switch(y[x][3]){case"REFERRAL":t+=parseInt(y[x][6]);u+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"ORGANIC":z+=parseInt(y[x][6]);A+="<tr><td class='gadwp-pgdetailsl'>"+y[x][2]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"SOCIAL":q+=parseInt(y[x][6]);p+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"CUSTOM":l+=parseInt(y[x][6]);k+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"DIRECT":C+=parseInt(y[x][6]);break}}}if(t){u="<table><tr><td>"+e.i18n[0]+"("+t+")</td></tr>"+u+"</table><br />"}if(z){A="<table><tr><td>"+e.i18n[1]+"("+z+")</td></tr>"+A+"</table><br />"}if(q){p="<table><tr><td>"+e.i18n[2]+"("+q+")</td></tr>"+p+"</table><br />"}if(l){k="<table><tr><td>"+e.i18n[3]+"("+l+")</td></tr>"+k+"</table><br />"}if(C){B="<table><tr><td>"+e.i18n[4]+"("+C+")</td></tr></table><br />"}return("<p><center><strong>"+o+"</strong></center></p>"+u+A+p+k+B)},rtRefresh:function(){if(e.render.focusFlag){a.from=false;a.to=false;a.query="realtime";jQuery.post(gadwpItemData.ajaxurl,a,function(j){if(jQuery.isArray(j)){jQuery("#gadwp-reports"+b).show();e.realtime=j[0];e.drawRealtime(e.realtime)}else{e.throwDebug(j)}NProgress.done()})}},drawRealtime:function(y){var j,n,o,w,t,r,x=0,v=[],z=[],p=[],m=[],q=[],k=[],l=[],s="",o=[],w=[],t=[],r=[],u=["REFERRAL","ORGANIC","SOCIAL","CUSTOM"],A=["DIRECT","NEW"];jQuery(function(){jQuery("#gadwp-widget *").tooltip({tooltipClass:"gadwp"})});y=y[0];if(jQuery.isNumeric(y)||typeof y==="undefined"){y=[];y.totalsForAllResults=[];y.totalsForAllResults["rt:activeUsers"]="0";y.rows=[]}if(y.totalsForAllResults["rt:activeUsers"]!==document.getElementById("gadwp-online").innerHTML){jQuery("#gadwp-online").fadeOut("slow");jQuery("#gadwp-online").fadeOut(500);jQuery("#gadwp-online").fadeOut("slow",function(){if((parseInt(y.totalsForAllResults["rt:activeUsers"]))<(parseInt(document.getElementById("gadwp-online").innerHTML))){jQuery("#gadwp-online").css({"background-color":"#FFE8E8"})}else{jQuery("#gadwp-online").css({"background-color":"#E0FFEC"})}document.getElementById("gadwp-online").innerHTML=y.totalsForAllResults["rt:activeUsers"]});jQuery("#gadwp-online").fadeIn("slow");jQuery("#gadwp-online").fadeIn(500);jQuery("#gadwp-online").fadeIn("slow",function(){jQuery("#gadwp-online").css({"background-color":"#FFFFFF"})})}if(y.totalsForAllResults["rt:activeUsers"]==0){y.rows=[]}for(x=0;x<y.rows.length;x++){v.push(y.rows[x][0]);if(y.rows[x][3]=="REFERRAL"){z.push(y.rows[x][1])}if(y.rows[x][3]=="ORGANIC"){p.push(y.rows[x][2])}if(y.rows[x][3]=="SOCIAL"){m.push(y.rows[x][1])}if(y.rows[x][3]=="CUSTOM"){k.push(y.rows[x][1])}q.push(y.rows[x][3])}n=v.filter(e.rtOnlyUniqueValues);for(x=0;x<n.length;x++){l[x]={pagepath:n[x],count:e.rtCountSessions(y,n[x])}}l.sort(function(C,B){return B.count-C.count});s="";for(x=0;x<l.length;x++){if(x<gadwpItemData.rtLimitPages){s+='<div class="gadwp-pline"><div class="gadwp-pleft"><a href="#" data-gadwp="'+e.rtPageDetails(y,l[x].pagepath)+'">'+l[x].pagepath.substring(0,70)+'</a></div><div class="gadwp-pright">'+l[x].count+"</div></div>"}}document.getElementById("gadwp-pages").innerHTML='<br /><div class="gadwp-pg">'+s+"</div>";o=z.filter(e.rtOnlyUniqueValues);for(x=0;x<o.length;x++){o[x]={value:o[x],count:e.rtCountSessions(y,o[x])}}o.sort(function(C,B){return B.count-C.count});w=p.filter(e.rtOnlyUniqueValues);for(x=0;x<w.length;x++){w[x]={value:w[x],count:e.rtCountSessions(y,w[x])}}w.sort(function(C,B){return B.count-C.count});t=m.filter(e.rtOnlyUniqueValues);for(x=0;x<t.length;x++){t[x]={value:t[x],count:e.rtCountSessions(y,t[x])}}t.sort(function(C,B){return B.count-C.count});r=k.filter(e.rtOnlyUniqueValues);for(x=0;x<r.length;x++){r[x]={value:r[x],count:e.rtCountSessions(y,r[x])}}r.sort(function(C,B){return B.count-C.count});j='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(o)+'"><div class="gadwp-bleft">'+e.i18n[0]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[0])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(w)+'"><div class="gadwp-bleft">'+e.i18n[1]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[1])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(t)+'"><div class="gadwp-bleft">'+e.i18n[2]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[2])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(r)+'"><div class="gadwp-bleft">'+e.i18n[3]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[3])+"</div></div>";j+='<div class="gadwp-bigtext"><div class="gadwp-bleft">'+e.i18n[4]+'</div><div class="gadwp-bright">'+e.rtCountSessions(y,A[0])+"</div></div>";j+='<div class="gadwp-bigtext"><div class="gadwp-bleft">'+e.i18n[5]+'</div><div class="gadwp-bright">'+e.rtCountSessions(y,A[1])+"</div></div>";document.getElementById("gadwp-tdo-right").innerHTML=j},throwDebug:function(j){jQuery("#gadwp-status"+b).css({"margin-top":"3px","padding-left":"5px",height:"auto",color:"#000","border-left":"5px solid red"});if(j=="-24"){jQuery("#gadwp-status"+b).html(gadwpItemData.i18n[15])}else{jQuery("#gadwp-reports"+b).css({"background-color":"#F7F7F7",height:"auto","margin-top":"10px","padding-top":"50px","padding-bottom":"50px",color:"#000","text-align":"center"});jQuery("#gadwp-reports"+b).html(j);jQuery("#gadwp-reports"+b).show();jQuery("#gadwp-status"+b).html(gadwpItemData.i18n[11]);console.log("\n********************* GADWP Log ********************* \n\n"+j);a={action:"gadwp_set_error",response:j,gadwp_security_set_error:gadwpItemData.security};jQuery.post(gadwpItemData.ajaxurl,a)}},throwError:function(l,j,k){jQuery(l).css({"background-color":"#F7F7F7",height:"auto","padding-top":k,"padding-bottom":k,color:"#000","text-align":"center"});if(j==-21){jQuery(l).html(gadwpItemData.i18n[12])}else{jQuery(l).html(gadwpItemData.i18n[13]+" ("+j+")")}},render:function(j,o,n){var k,q,p,l,m;if(o=="realtime"){jQuery("#gadwp-sel-report"+b).hide()}else{jQuery("#gadwp-sel-report"+b).show();clearInterval(e.rtRuns)}jQuery("#gadwp-status"+b).html("");switch(o){case"today":q="today";p="today";break;case"yesterday":q="yesterday";p="yesterday";break;case"7daysAgo":q="7daysAgo";p="yesterday";break;case"14daysAgo":q="14daysAgo";p="yesterday";break;case"90daysAgo":q="90daysAgo";p="yesterday";break;case"365daysAgo":q="365daysAgo";p="yesterday";break;case"1095daysAgo":q="1095daysAgo";p="yesterday";break;default:q="30daysAgo";p="yesterday";break}d.setCookie("default_metric",n);d.setCookie("default_dimension",o);if(typeof j!=="undefined"){d.setCookie("default_view",j);k=j}else{k=false}if(gadwpItemData.scope=="admin-item"){a={action:"gadwp_backend_item_reports",gadwp_security_backend_item_reports:gadwpItemData.security,from:q,to:p,filter:g}}else{if(gadwpItemData.scope=="front-item"){a={action:"gadwp_frontend_item_reports",gadwp_security_frontend_item_reports:gadwpItemData.security,from:q,to:p,filter:gadwpItemData.filter}}else{a={action:"gadwp_backend_item_reports",gadwp_security_backend_item_reports:gadwpItemData.security,projectId:k,from:q,to:p}}}if(o=="realtime"){e.i18n=gadwpItemData.i18n.slice(20,26);e.render.focusFlag=1;jQuery(window).bind("focus",function(r){e.render.focusFlag=1}).bind("blur",function(r){e.render.focusFlag=0});l='<div id="gadwp-realtime'+b+'">';l+='<div class="gadwp-rt-box">';l+='<div class="gadwp-tdo-left">';l+='<div class="gadwp-online" id="gadwp-online">0</div>';l+="</div>";l+='<div class="gadwp-tdo-right" id="gadwp-tdo-right">';l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[0]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[1]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[2]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[3]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[4]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[5]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+="</div>";l+="</div>";l+="<div>";l+='<div id="gadwp-pages" class="gadwp-pages">&nbsp;</div>';l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);e.rtRefresh(e.render.focusFlag);e.rtRuns=setInterval(e.rtRefresh,55000)}else{if(jQuery.inArray(n,["referrers","contentpages","searches"])>-1){l='<div id="gadwp-orgcharttablechart'+b+'">';l+='<div id="gadwp-orgchart'+b+'"></div>';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query="channelGrouping,"+n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.orgChartTableChart(r)})}else{if(n=="404errors"){l='<div id="gadwp-404tablechart'+b+'">';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query=n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.tableChart(r)})}else{if(n=="trafficdetails"||n=="technologydetails"){l='<div id="gadwp-orgchartpiecharts'+b+'">';l+='<div id="gadwp-orgchart'+b+'"></div>';l+='<div class="gadwp-floatwraper">';l+='<div id="gadwp-piechart-1'+b+'" class="halfsize floatleft"></div>';l+='<div id="gadwp-piechart-2'+b+'" class="halfsize floatright"></div>';l+="</div>";l+='<div class="gadwp-floatwraper">';l+='<div id="gadwp-piechart-3'+b+'" class="halfsize floatleft"></div>';l+='<div id="gadwp-piechart-4'+b+'" class="halfsize floatright"></div>';l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();if(n=="trafficdetails"){a.query="channelGrouping,medium,visitorType,source,socialNetwork";e.i18n=gadwpItemData.i18n.slice(0,5)}else{e.i18n=gadwpItemData.i18n.slice(15,20);a.query="deviceCategory,browser,operatingSystem,screenResolution,mobileDeviceBranding"}a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.orgChartPieCharts(r)})}else{if(n=="locations"){l='<div id="gadwp-geocharttablechart'+b+'">';l+='<div id="gadwp-geochart'+b+'"></div>';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query=n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.geoChartTableChart(r)})}else{l='<div id="gadwp-areachartbottomstats'+b+'">';l+='<div id="gadwp-areachart'+b+'"></div>';l+='<div id="gadwp-bottomstats'+b+'">';l+='<div class="inside">';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[5]+'</h3><p id="gdsessions'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[6]+'</h3><p id="gdusers'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[7]+'</h3><p id="gdpageviews'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[8]+'</h3><p id="gdbouncerate'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[9]+'</h3><p id="gdorganicsearch'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[10]+'</h3><p id="gdpagespervisit'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[26]+'</h3><p id="gdpagetime'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[27]+'</h3><p id="gdpageload'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[28]+'</h3><p id="gdsessionduration'+b+'">&nbsp;</p></div>';l+="</div>";l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();a.query=n+",bottomstats";jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.areaChartBottomStats(r)})}}}}}},refresh:function(){if(jQuery("#gadwp-areachartbottomstats"+b).length>0&&jQuery.isArray(e.areaChartBottomStatsData)){e.areaChartBottomStats(e.areaChartBottomStatsData)}if(jQuery("#gadwp-orgchartpiecharts"+b).length>0&&jQuery.isArray(e.orgChartPieChartsData)){e.orgChartPieCharts(e.orgChartPieChartsData)}if(jQuery("#gadwp-geocharttablechart"+b).length>0&&jQuery.isArray(e.geoChartTableChartData)){e.geoChartTableChart(e.geoChartTableChartData)}if(jQuery("#gadwp-orgcharttablechart"+b).length>0&&jQuery.isArray(e.orgChartTableChartData)){e.orgChartTableChart(e.orgChartTableChartData)}if(jQuery("#gadwp-404tablechart"+b).length>0&&jQuery.isArray(e.tableChartData)){e.tableChart(e.tableChartData)}},init:function(){if(!jQuery("#gadwp-reports"+b).length){return}if(jQuery("#gadwp-reports"+b).html().length){return}try{NProgress.configure({parent:"#gadwp-progressbar"+b,showSpinner:false});NProgress.start()}catch(j){e.alertMessage(gadwpItemData.i18n[0])}e.render(jQuery("#gadwp-sel-view"+b).val(),jQuery("#gadwp-sel-period"+b).val(),jQuery("#gadwp-sel-report"+b).val());jQuery(window).resize(function(){var k=jQuery(window).width()-e.oldViewPort;if((k<-5)||(k>5)){e.oldViewPort=jQuery(window).width();e.refresh()}})}};h.init();e.init();jQuery("#gadwp-sel-view"+b).change(function(){jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("#gadwp-sel-period"+b).change(function(){jQuery("#gadwp-sel-metric"+b).hide();jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("#gadwp-sel-report"+b).change(function(){jQuery("#gadwp-sel-metric"+b).hide();jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("[id^=gadwp-swmetric-]").click(function(){c=this.id.replace("gadwp-swmetric-","");d.setCookie("default_swmetric",c);jQuery("#gadwp-swmetric-sessions").css("color","#444");jQuery("#gadwp-swmetric-users").css("color","#444");jQuery("#gadwp-swmetric-pageviews").css("color","#444");jQuery("#"+this.id).css("color","#008ec2");jQuery("#gadwp-reports"+b).html("");e.init()});if(gadwpItemData.scope=="admin-widgets"){return}else{return this.dialog({width:"auto",maxWidth:510,height:"auto",modal:true,fluid:true,dialogClass:"gadwp wp-dialog",resizable:false,title:e.getTitle(gadwpItemData.scope),position:{my:"top",at:"top+100",of:window}})}}});function GADWPReportLoad(){if(gadwpItemData.scope=="admin-widgets"){jQuery("#gadwp-window-1").gadwpItemReport(1)}else{jQuery(gadwpItemData.getSelector(gadwpItemData.scope)).click(function(){if(!jQuery("#gadwp-window-"+gadwpItemData.getID(this)).length>0){jQuery("body").append('<div id="gadwp-window-'+gadwpItemData.getID(this)+'"></div>')}jQuery("#gadwp-window-"+gadwpItemData.getID(this)).gadwpItemReport(gadwpItemData.getID(this))})}jQuery(window).resize(function(){gadwpItemData.responsiveDialog()});jQuery(document).on("dialogopen",".ui-dialog",function(a,b){gadwpItemData.responsiveDialog()})};
{common → tags/5.3.1.1/common}/nprogress/nprogress.css RENAMED
File without changes
{common → tags/5.3.1.1/common}/nprogress/nprogress.js RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-bg_flat_0_aaaaaa_40x100.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-bg_flat_75_ffffff_40x100.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_55_fbf9ee_1x400.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_65_ffffff_1x400.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_75_dadada_1x400.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_75_e6e6e6_1x400.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-bg_glass_95_fef1ec_1x400.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-bg_highlight-soft_75_cccccc_1x100.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-icons_222222_256x240.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-icons_2e83ff_256x240.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-icons_454545_256x240.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-icons_888888_256x240.png RENAMED
File without changes
{common → tags/5.3.1.1/common}/realtime/images/ui-icons_cd0a0a_256x240.png RENAMED
File without changes
tags/5.3.1.1/common/realtime/jquery.ui.tooltip.html.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ /*! jQuery UI - v1.9.2 - 2013-09-22
2
+ * http://jqueryui.com
3
+ * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */.ui-tooltip.gadwp{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}* html .ui-tooltip.gadwp{background-image:none}body .ui-tooltip.gadwp{border-width:2px}.ui-widget.gadwp{font-family:Verdana,Arial,sans-serif;font-size:1.1em}.ui-widget.gadwp .ui-widget{font-size:1em}.ui-widget.gadwp input,.ui-widget.gadwp select,.ui-widget.gadwp textarea,.ui-widget.gadwp button{font-family:Verdana,Arial,sans-serif;font-size:1em}.ui-widget-content.gadwp{border:1px solid #aaa;background:#fff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;color:#222}.ui-widget-content.gadwp a{color:#222}.gadwp .ui-widget-header{border:1px solid #aaa;background:#ccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;color:#222;font-weight:bold}.gadwp .ui-widget-header a{color:#222}
{common → tags/5.3.1.1/common}/realtime/jquery.ui.tooltip.html.js RENAMED
File without changes
tags/5.3.1.1/config.php ADDED
@@ -0,0 +1,456 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Config' ) ) {
15
+
16
+ final class GADWP_Config {
17
+
18
+ public $options;
19
+
20
+ public function __construct() {
21
+ // Rename old option keys
22
+ $this->option_keys_rename(); // v5.2
23
+ // Get plugin options
24
+ $this->get_plugin_options();
25
+ // Automatic updates
26
+ add_filter( 'auto_update_plugin', array( $this, 'automatic_update' ), 10, 2 );
27
+ // Provide language packs for all available Network languages
28
+ if ( is_multisite() ) {
29
+ add_filter( 'plugins_update_check_locales', array( $this, 'translation_updates' ), 10, 1 );
30
+ }
31
+ }
32
+
33
+ public function get_major_version( $version ) {
34
+ $exploded_version = explode( '.', $version );
35
+ if ( isset( $exploded_version[2] ) ) {
36
+ return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2];
37
+ } else {
38
+ return $exploded_version[0] . '.' . $exploded_version[1] . '.0';
39
+ }
40
+ }
41
+
42
+ public function automatic_update( $update, $item ) {
43
+ $item = (array) $item;
44
+ if ( is_multisite() && ! is_main_site() ) {
45
+ return;
46
+ }
47
+ if ( ! isset( $item['new_version'] ) || ! isset( $item['plugin'] ) || ! $this->options['automatic_updates_minorversion'] ) {
48
+ return $update;
49
+ }
50
+ if ( isset( $item['slug'] ) && 'google-analytics-dashboard-for-wp' == $item['slug'] ) {
51
+ // Only when a minor update is available
52
+ if ( $this->get_major_version( GADWP_CURRENT_VERSION ) == $this->get_major_version( $item['new_version'] ) ) {
53
+ return ( $this->get_major_version( GADWP_CURRENT_VERSION ) == $this->get_major_version( $item['new_version'] ) );
54
+ }
55
+ }
56
+ return $update;
57
+ }
58
+
59
+ public function translation_updates( $locales ) {
60
+ $languages = get_available_languages();
61
+ return array_values( $languages );
62
+ }
63
+
64
+ // Validates data before storing
65
+ private function validate_data( $options ) {
66
+ /* @formatter:off */
67
+ $numerics = array( 'ga_realtime_pages',
68
+ 'ga_enhanced_links',
69
+ 'ga_crossdomain_tracking',
70
+ 'ga_author_dimindex',
71
+ 'ga_category_dimindex',
72
+ 'ga_tag_dimindex',
73
+ 'ga_user_dimindex',
74
+ 'ga_pubyear_dimindex',
75
+ 'ga_pubyearmonth_dimindex',
76
+ 'tm_author_var',
77
+ 'tm_category_var',
78
+ 'tm_tag_var',
79
+ 'tm_user_var',
80
+ 'tm_pubyear_var',
81
+ 'tm_pubyearmonth_var',
82
+ 'ga_aff_tracking',
83
+ 'amp_tracking_analytics',
84
+ 'amp_tracking_clientidapi',
85
+ 'amp_tracking_tagmanager',
86
+ 'optimize_tracking',
87
+ 'optimize_pagehiding',
88
+ 'trackingcode_infooter',
89
+ 'trackingevents_infooter',
90
+ 'ga_formsubmit_tracking',
91
+ 'superadmin_tracking',
92
+ 'ga_pagescrolldepth_tracking',
93
+ 'tm_pagescrolldepth_tracking',
94
+ 'ga_speed_samplerate',
95
+ 'ga_user_samplerate',
96
+ 'ga_event_precision',
97
+ 'with_endpoint',
98
+ 'backend_realtime_report',
99
+ 'ga_optout',
100
+ 'ga_dnt_optout',
101
+ 'ga_with_gtag',
102
+ );
103
+ foreach ( $numerics as $key ) {
104
+ if ( isset( $options[$key] ) ) {
105
+ $options[$key] = (int) $options[$key];
106
+ }
107
+ }
108
+
109
+ $texts = array( 'ga_crossdomain_list',
110
+ 'client_id',
111
+ 'client_secret',
112
+ 'theme_color',
113
+ 'ga_target_geomap',
114
+ 'ga_cookiedomain',
115
+ 'ga_cookiename',
116
+ 'pagetitle_404',
117
+ 'maps_api_key',
118
+ 'web_containerid',
119
+ 'amp_containerid',
120
+ 'optimize_containerid',
121
+ 'ga_event_downloads',
122
+ 'ga_event_affiliates',
123
+ 'ecommerce_mode',
124
+ 'tracking_type',
125
+ );
126
+ foreach ( $texts as $key ) {
127
+ if ( isset( $options[$key] ) ) {
128
+ $options[$key] = trim (sanitize_text_field( $options[$key] ));
129
+ }
130
+ }
131
+ /* @formatter:on */
132
+
133
+ if ( isset( $options['ga_event_downloads'] ) && empty( $options['ga_event_downloads'] ) ) {
134
+ $options['ga_event_downloads'] = 'zip|mp3*|mpe*g|pdf|docx*|pptx*|xlsx*|rar*';
135
+ }
136
+
137
+ if ( isset( $options['pagetitle_404'] ) && empty( $options['pagetitle_404'] ) ) {
138
+ $options['pagetitle_404'] = 'Page Not Found';
139
+ }
140
+
141
+ if ( isset( $options['ga_event_affiliates'] ) && empty( $options['ga_event_affiliates'] ) ) {
142
+ $options['ga_event_affiliates'] = '/out/';
143
+ }
144
+
145
+ if ( isset( $options['ga_speed_samplerate'] ) && ( $options['ga_speed_samplerate'] < 1 || $options['ga_speed_samplerate'] > 100 ) ) {
146
+ $options['ga_speed_samplerate'] = 1;
147
+ }
148
+
149
+ if ( isset( $options['ga_user_samplerate'] ) && ( $options['ga_user_samplerate'] < 1 || $options['ga_user_samplerate'] > 100 ) ) {
150
+ $options['ga_user_samplerate'] = 100;
151
+ }
152
+
153
+ if ( isset( $options['ga_cookieexpires'] ) && $options['ga_cookieexpires'] ) { // v4.9
154
+ $options['ga_cookieexpires'] = (int) $options['ga_cookieexpires'];
155
+ }
156
+
157
+ return $options;
158
+ }
159
+
160
+ public function set_plugin_options( $network_settings = false ) {
161
+ // Handle Network Mode
162
+ $options = $this->options;
163
+ $get_network_options = get_site_option( 'gadwp_network_options' );
164
+ $old_network_options = (array) json_decode( $get_network_options );
165
+
166
+ if ( is_multisite() ) {
167
+ if ( $network_settings ) { // Retrieve network options, clear blog options, store both to db
168
+ $network_options['token'] = $this->options['token'];
169
+ $options['token'] = '';
170
+ if ( is_network_admin() ) {
171
+ $network_options['ga_profiles_list'] = $this->options['ga_profiles_list'];
172
+ $options['ga_profiles_list'] = array();
173
+ $network_options['client_id'] = $this->options['client_id'];
174
+ $options['client_id'] = '';
175
+ $network_options['client_secret'] = $this->options['client_secret'];
176
+ $options['client_secret'] = '';
177
+ $network_options['user_api'] = $this->options['user_api'];
178
+ $options['user_api'] = 0;
179
+ $network_options['network_mode'] = $this->options['network_mode'];
180
+ $network_options['superadmin_tracking'] = $this->options['superadmin_tracking'];
181
+ $network_options['automatic_updates_minorversion'] = $this->options['automatic_updates_minorversion'];
182
+ unset( $options['network_mode'] );
183
+ if ( isset( $this->options['network_tableid'] ) ) {
184
+ $network_options['network_tableid'] = $this->options['network_tableid'];
185
+ unset( $options['network_tableid'] );
186
+ }
187
+ }
188
+ $merged_options = array_merge( $old_network_options, $network_options );
189
+ update_site_option( 'gadwp_network_options', json_encode( $this->validate_data( $merged_options ) ) );
190
+ }
191
+ }
192
+ update_option( 'gadwp_options', json_encode( $this->validate_data( $options ) ) );
193
+ }
194
+
195
+ private function get_plugin_options() {
196
+ /*
197
+ * Get plugin options
198
+ */
199
+ global $blog_id;
200
+
201
+ if ( ! get_option( 'gadwp_options' ) ) {
202
+ GADWP_Install::install();
203
+ }
204
+ $this->options = (array) json_decode( get_option( 'gadwp_options' ) );
205
+ // Maintain Compatibility
206
+ $this->maintain_compatibility();
207
+ // Handle Network Mode
208
+ if ( is_multisite() ) {
209
+ $get_network_options = get_site_option( 'gadwp_network_options' );
210
+ $network_options = (array) json_decode( $get_network_options );
211
+ if ( isset( $network_options['network_mode'] ) && ( $network_options['network_mode'] ) ) {
212
+ if ( ! is_network_admin() && ! empty( $network_options['ga_profiles_list'] ) && isset( $network_options['network_tableid']->$blog_id ) ) {
213
+ $network_options['ga_profiles_list'] = array( 0 => GADWP_Tools::get_selected_profile( $network_options['ga_profiles_list'], $network_options['network_tableid']->$blog_id ) );
214
+ $network_options['tableid_jail'] = $network_options['ga_profiles_list'][0][1];
215
+ }
216
+ $this->options = array_merge( $this->options, $network_options );
217
+ } else {
218
+ $this->options['network_mode'] = 0;
219
+ }
220
+ }
221
+ }
222
+
223
+ private function maintain_compatibility() {
224
+ $flag = false;
225
+
226
+ $prevver = get_option( 'gadwp_version' );
227
+ if ( $prevver && GADWP_CURRENT_VERSION != $prevver ) {
228
+ $flag = true;
229
+ update_option( 'gadwp_version', GADWP_CURRENT_VERSION );
230
+ update_option( 'gadwp_got_updated', true );
231
+ GADWP_Tools::clear_cache();
232
+ GADWP_Tools::delete_cache( 'last_error' );
233
+ if ( is_multisite() ) { // Cleanup errors and cookies on the entire network
234
+ foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
235
+ switch_to_blog( $blog['blog_id'] );
236
+ GADWP_Tools::delete_cache( 'gapi_errors' );
237
+ restore_current_blog();
238
+ }
239
+ } else {
240
+ GADWP_Tools::delete_cache( 'gapi_errors' );
241
+ }
242
+
243
+ // Enable GADWP EndPoint for those updating from a version lower than 5.2, introduced in GADWP v5.3
244
+ if (version_compare( $prevver, '5.2', '<' ) ) {
245
+ $this->options['with_endpoint'] = 2;
246
+ }
247
+ }
248
+
249
+ if ( isset( $this->options['item_reports'] ) ) { // v4.8
250
+ $this->options['backend_item_reports'] = $this->options['item_reports'];
251
+ }
252
+ if ( isset( $this->options['ga_dash_frontend_stats'] ) ) { // v4.8
253
+ $this->options['frontend_item_reports'] = $this->options['ga_dash_frontend_stats'];
254
+ }
255
+
256
+ /* @formatter:off */
257
+ $zeros = array( 'ga_enhanced_links',
258
+ 'network_mode',
259
+ 'ga_enhanced_excludesa',
260
+ 'ga_remarketing',
261
+ 'ga_event_bouncerate',
262
+ 'ga_author_dimindex',
263
+ 'ga_tag_dimindex',
264
+ 'ga_category_dimindex',
265
+ 'ga_user_dimindex',
266
+ 'ga_pubyear_dimindex',
267
+ 'ga_pubyearmonth_dimindex',
268
+ 'tm_author_var', // v5.0
269
+ 'tm_category_var', // v5.0
270
+ 'tm_tag_var', // v5.0
271
+ 'tm_user_var', // v5.0
272
+ 'tm_pubyear_var', // v5.0
273
+ 'tm_pubyearmonth_var', // v5.0
274
+ 'ga_crossdomain_tracking',
275
+ 'api_backoff', // v4.8.1.3
276
+ 'ga_aff_tracking',
277
+ 'ga_hash_tracking',
278
+ 'switch_profile', // V4.7
279
+ 'amp_tracking_analytics', //v5.0
280
+ 'amp_tracking_clientidapi', //v5.1.2
281
+ 'optimize_tracking', //v5.0
282
+ 'optimize_pagehiding', //v5.0
283
+ 'amp_tracking_tagmanager', //v5.0
284
+ 'trackingcode_infooter', //v5.0
285
+ 'trackingevents_infooter', //v5.0
286
+ 'ga_formsubmit_tracking', //v5.0
287
+ 'superadmin_tracking', //v5.0
288
+ 'ga_pagescrolldepth_tracking', //v5.0
289
+ 'tm_pagescrolldepth_tracking', //v5.0
290
+ 'ga_event_precision', //v5.1.1.1
291
+ 'ga_force_ssl', //v5.1.2
292
+ 'with_endpoint', //v5.2
293
+ 'backend_realtime_report', //v5.2
294
+ 'ga_optout', //v5.2.3
295
+ 'ga_dnt_optout', //v5.2.3
296
+ 'ga_with_gtag', //v5.3
297
+ 'frontend_item_reports',
298
+ );
299
+ foreach ( $zeros as $key ) {
300
+ if ( ! isset( $this->options[$key] ) ) {
301
+ $this->options[$key] = 0;
302
+ $flag = true;
303
+ }
304
+ }
305
+
306
+ if ( isset($this->options['ga_dash_tracking']) && 0 == $this->options['ga_dash_tracking'] ) { // v5.0.1
307
+ $this->options['tracking_type'] = 'disabled';
308
+ $flag = true;
309
+ }
310
+
311
+ $unsets = array( 'ga_dash_jailadmins', // v4.7
312
+ 'ga_tracking_code',
313
+ 'ga_dash_tableid', // v4.9
314
+ 'ga_dash_frontend_keywords', // v4.8
315
+ 'ga_dash_apikey', // v4.9.1.3
316
+ 'ga_dash_default_metric', // v4.8.1
317
+ 'ga_dash_default_dimension', // v4.8.1
318
+ 'ga_dash_adsense', // v5.0
319
+ 'ga_dash_frontend_stats', // v4.8
320
+ 'item_reports', // v4.8
321
+ 'ga_dash_tracking', // v5.0
322
+ 'ga_dash_cachetime', // v5.2
323
+ 'ga_dash_default_ua', // v5.2
324
+ 'ga_dash_hidden', // v5.2
325
+ );
326
+ foreach ( $unsets as $key ) {
327
+ if ( isset( $this->options[$key] ) ) {
328
+ unset( $this->options[$key] );
329
+ $flag = true;
330
+ }
331
+ }
332
+
333
+ $empties = array( 'ga_crossdomain_list',
334
+ 'ga_cookiedomain', // v4.9.4
335
+ 'ga_cookiename', // v4.9.4
336
+ 'ga_cookieexpires', // v4.9.4
337
+ 'maps_api_key', // v4.9.4
338
+ 'web_containerid', // v5.0
339
+ 'amp_containerid', // v5.0
340
+ 'optimize_containerid', // v5.0
341
+ );
342
+ foreach ( $empties as $key ) {
343
+ if ( ! isset( $this->options[$key] ) ) {
344
+ $this->options[$key] = '';
345
+ $flag = true;
346
+ }
347
+ }
348
+
349
+ $ones = array( 'ga_speed_samplerate',
350
+ 'automatic_updates_minorversion',
351
+ 'backend_item_reports', // v4.8
352
+ 'dashboard_widget', // v4.7
353
+ );
354
+ foreach ( $ones as $key ) {
355
+ if ( ! isset( $this->options[$key] ) ) {
356
+ $this->options[$key] = 1;
357
+ $flag = true;
358
+ }
359
+ }
360
+
361
+ $arrays = array( 'access_front',
362
+ 'access_back',
363
+ 'ga_profiles_list',
364
+ 'track_exclude',
365
+ );
366
+ foreach ( $arrays as $key ) {
367
+ if ( ! is_array( $this->options[$key] ) ) {
368
+ $this->options[$key] = array();
369
+ $flag = true;
370
+ }
371
+ }
372
+ if ( empty( $this->options['access_front'] ) ) {
373
+ $this->options['access_front'][] = 'administrator';
374
+ }
375
+ if ( empty( $this->options['access_back'] ) ) {
376
+ $this->options['access_back'][] = 'administrator';
377
+ }
378
+ /* @formatter:on */
379
+
380
+ if ( ! isset( $this->options['ga_event_affiliates'] ) ) {
381
+ $this->options['ga_event_affiliates'] = '/out/';
382
+ $flag = true;
383
+ }
384
+
385
+ if ( ! isset( $this->options['ga_user_samplerate'] ) ) {
386
+ $this->options['ga_user_samplerate'] = 100;
387
+ }
388
+
389
+ if ( ! isset( $this->options['ga_event_downloads'] ) ) {
390
+ $this->options['ga_event_downloads'] = 'zip|mp3*|mpe*g|pdf|docx*|pptx*|xlsx*|rar*';
391
+ $flag = true;
392
+ }
393
+
394
+ if ( ! isset( $this->options['pagetitle_404'] ) ) { // v4.9.4
395
+ $this->options['pagetitle_404'] = 'Page Not Found';
396
+ $flag = true;
397
+ }
398
+
399
+ if ( ! isset( $this->options['ecommerce_mode'] ) ) { // v5.0
400
+ $this->options['ecommerce_mode'] = 'disabled';
401
+ $flag = true;
402
+ }
403
+
404
+ if ( isset( $this->options['ga_dash_tracking'] ) && 'classic' == $this->options['ga_dash_tracking'] ) { // v5.0
405
+ $this->options['tracking_type'] = 'universal';
406
+ $flag = true;
407
+ }
408
+
409
+ if ( $flag ) {
410
+ $this->set_plugin_options( false );
411
+ }
412
+ }
413
+
414
+ private function option_keys_rename() {
415
+
416
+ /* @formatter:off */
417
+ $batch = array( 'ga_dash_token' => 'token',
418
+ 'ga_dash_clientid' => 'client_id',
419
+ 'ga_dash_clientsecret' => 'client_secret',
420
+ 'ga_dash_access_front' => 'access_front',
421
+ 'ga_dash_access_back' => 'access_back',
422
+ 'ga_dash_tableid_jail' => 'tableid_jail',
423
+ 'ga_dash_tracking_type' => 'tracking_type',
424
+ 'ga_dash_userapi' => 'user_api',
425
+ 'ga_dash_network' => 'network_mode',
426
+ 'ga_dash_tableid_network' => 'network_tableid',
427
+ 'ga_dash_anonim' => 'ga_anonymize_ip',
428
+ 'ga_dash_profile_list' => 'ga_profiles_list',
429
+ 'ga_dash_remarketing' => 'ga_remarketing',
430
+ 'ga_dash_excludesa' => 'superadmin_tracking',
431
+ 'ga_track_exclude' => 'track_exclude',
432
+ 'ga_dash_style' => 'theme_color',
433
+ );
434
+ /* @formatter:on */
435
+
436
+ if ( is_multisite() ) {
437
+ $options = get_site_option( 'gadash_network_options' );
438
+ if ( $options ) {
439
+ $options = (array) json_decode( $options );
440
+ $options = GADWP_Tools::array_keys_rename( $options, $batch );
441
+ update_site_option( 'gadwp_network_options', json_encode( $this->validate_data( $options ) ) );
442
+ delete_site_option( 'gadash_network_options' );
443
+ }
444
+ }
445
+
446
+ $options = get_option( 'gadash_options' );
447
+ if ( $options ) {
448
+ $options = (array) json_decode( $options );
449
+ $options = GADWP_Tools::array_keys_rename( $options, $batch );
450
+ update_option( 'gadwp_options', json_encode( $this->validate_data( $options ) ) );
451
+ delete_option( 'gadash_options' );
452
+ }
453
+ }
454
+ }
455
+ }
456
+
tags/5.3.1.1/front/ajax-actions.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Frontend_Ajax' ) ) {
15
+
16
+ final class GADWP_Frontend_Ajax {
17
+
18
+ private $gadwp;
19
+
20
+ public function __construct() {
21
+ $this->gadwp = GADWP();
22
+
23
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_front'] ) && $this->gadwp->config->options['frontend_item_reports'] ) {
24
+ // Item Reports action
25
+ add_action( 'wp_ajax_gadwp_frontend_item_reports', array( $this, 'ajax_item_reports' ) );
26
+ }
27
+
28
+ // Frontend Widget actions
29
+ add_action( 'wp_ajax_ajax_frontwidget_report', array( $this, 'ajax_frontend_widget' ) );
30
+ add_action( 'wp_ajax_nopriv_ajax_frontwidget_report', array( $this, 'ajax_frontend_widget' ) );
31
+ }
32
+
33
+ /**
34
+ * Ajax handler for Item Reports
35
+ *
36
+ * @return string|int
37
+ */
38
+ public function ajax_item_reports() {
39
+ if ( ! isset( $_POST['gadwp_security_frontend_item_reports'] ) || ! wp_verify_nonce( $_POST['gadwp_security_frontend_item_reports'], 'gadwp_frontend_item_reports' ) ) {
40
+ wp_die( - 30 );
41
+ }
42
+
43
+ $from = $_POST['from'];
44
+ $to = $_POST['to'];
45
+ $query = $_POST['query'];
46
+ $uri = $_POST['filter'];
47
+ if ( isset( $_POST['metric'] ) ) {
48
+ $metric = $_POST['metric'];
49
+ } else {
50
+ $metric = 'pageviews';
51
+ }
52
+
53
+ $query = $_POST['query'];
54
+ if ( ob_get_length() ) {
55
+ ob_clean();
56
+ }
57
+
58
+ if ( ! GADWP_Tools::check_roles( $this->gadwp->config->options['access_front'] ) || 0 == $this->gadwp->config->options['frontend_item_reports'] ) {
59
+ wp_die( - 31 );
60
+ }
61
+
62
+ if ( $this->gadwp->config->options['token'] && $this->gadwp->config->options['tableid_jail'] ) {
63
+ if ( null === $this->gadwp->gapi_controller ) {
64
+ $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
65
+ }
66
+ } else {
67
+ wp_die( - 24 );
68
+ }
69
+
70
+ if ( $this->gadwp->config->options['tableid_jail'] ) {
71
+ $projectId = $this->gadwp->config->options['tableid_jail'];
72
+ } else {
73
+ wp_die( - 26 );
74
+ }
75
+
76
+ $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_profiles_list'], $projectId );
77
+
78
+ if ( isset( $profile_info[4] ) ) {
79
+ $this->gadwp->gapi_controller->timeshift = $profile_info[4];
80
+ } else {
81
+ $this->gadwp->gapi_controller->timeshift = (int) current_time( 'timestamp' ) - time();
82
+ }
83
+
84
+ $uri = '/' . ltrim( $uri, '/' );
85
+
86
+ // allow URL correction before sending an API request
87
+ $filter = apply_filters( 'gadwp_frontenditem_uri', $uri );
88
+
89
+ $lastchar = substr( $filter, - 1 );
90
+
91
+ if ( isset( $profile_info[6] ) && $profile_info[6] && '/' == $lastchar ) {
92
+ $filter = $filter . $profile_info[6];
93
+ }
94
+
95
+ // Encode URL
96
+ $filter = rawurlencode( rawurldecode( $filter ) );
97
+
98
+ $queries = explode( ',', $query );
99
+
100
+ $results = array();
101
+
102
+ foreach ( $queries as $value ) {
103
+ $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter, $metric );
104
+ }
105
+
106
+ wp_send_json( $results );
107
+ }
108
+
109
+ /**
110
+ * Ajax handler for getting analytics data for frontend Widget
111
+ *
112
+ * @return string|int
113
+ */
114
+ public function ajax_frontend_widget() {
115
+ if ( ! isset( $_POST['gadwp_number'] ) || ! isset( $_POST['gadwp_optionname'] ) || ! is_active_widget( false, false, 'gadwp-frontwidget-report' ) ) {
116
+ wp_die( - 30 );
117
+ }
118
+ $widget_index = $_POST['gadwp_number'];
119
+ $option_name = $_POST['gadwp_optionname'];
120
+ $options = get_option( $option_name );
121
+ if ( isset( $options[$widget_index] ) ) {
122
+ $instance = $options[$widget_index];
123
+ } else {
124
+ wp_die( - 32 );
125
+ }
126
+ switch ( $instance['period'] ) { // make sure we have a valid request
127
+ case '7daysAgo' :
128
+ $period = '7daysAgo';
129
+ break;
130
+ case '14daysAgo' :
131
+ $period = '14daysAgo';
132
+ break;
133
+ default :
134
+ $period = '30daysAgo';
135
+ break;
136
+ }
137
+ if ( ob_get_length() ) {
138
+ ob_clean();
139
+ }
140
+ if ( $this->gadwp->config->options['token'] && $this->gadwp->config->options['tableid_jail'] ) {
141
+ if ( null === $this->gadwp->gapi_controller ) {
142
+ $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
143
+ }
144
+ } else {
145
+ wp_die( - 24 );
146
+ }
147
+ $projectId = $this->gadwp->config->options['tableid_jail'];
148
+ $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_profiles_list'], $projectId );
149
+ if ( isset( $profile_info[4] ) ) {
150
+ $this->gadwp->gapi_controller->timeshift = $profile_info[4];
151
+ } else {
152
+ $this->gadwp->gapi_controller->timeshift = (int) current_time( 'timestamp' ) - time();
153
+ }
154
+ wp_send_json( $this->gadwp->gapi_controller->frontend_widget_stats( $projectId, $period, (int) $instance['anonim'] ) );
155
+ }
156
+ }
157
+ }
{front → tags/5.3.1.1/front}/css/item-reports.css RENAMED
File without changes
{front → tags/5.3.1.1/front}/css/widgets.css RENAMED
File without changes
tags/5.3.1.1/front/item-reports.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Frontend_Item_Reports' ) ) {
15
+
16
+ final class GADWP_Frontend_Item_Reports {
17
+
18
+ private $gadwp;
19
+
20
+ public function __construct() {
21
+ $this->gadwp = GADWP();
22
+
23
+ add_action( 'admin_bar_menu', array( $this, 'custom_adminbar_node' ), 999 );
24
+ }
25
+
26
+ function custom_adminbar_node( $wp_admin_bar ) {
27
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_front'] ) && $this->gadwp->config->options['frontend_item_reports'] ) {
28
+ /* @formatter:off */
29
+ $args = array( 'id' => 'gadwp-1',
30
+ 'title' => '<span class="ab-icon"></span><span class="">' . __( "Analytics", 'google-analytics-dashboard-for-wp' ) . '</span>',
31
+ 'href' => '#1',
32
+ );
33
+ /* @formatter:on */
34
+ $wp_admin_bar->add_node( $args );
35
+ }
36
+ }
37
+ }
38
+ }
{front → tags/5.3.1.1/front}/js/tracking-analytics-events.js RENAMED
File without changes
{front → tags/5.3.1.1/front}/js/tracking-scrolldepth.js RENAMED
File without changes
{front → tags/5.3.1.1/front}/js/widgets.js RENAMED
File without changes
tags/5.3.1.1/front/setup.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Frontend_Setup' ) ) {
15
+
16
+ final class GADWP_Frontend_Setup {
17
+
18
+ private $gadwp;
19
+
20
+ public function __construct() {
21
+ $this->gadwp = GADWP();
22
+
23
+ // Styles & Scripts
24
+ add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
25
+ }
26
+
27
+ /**
28
+ * Styles & Scripts conditional loading
29
+ *
30
+ * @param
31
+ * $hook
32
+ */
33
+ public function load_styles_scripts() {
34
+ $lang = get_bloginfo( 'language' );
35
+ $lang = explode( '-', $lang );
36
+ $lang = $lang[0];
37
+
38
+ /*
39
+ * Item reports Styles & Scripts
40
+ */
41
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_front'] ) && $this->gadwp->config->options['frontend_item_reports'] ) {
42
+
43
+ wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
44
+
45
+ wp_enqueue_style( 'gadwp-frontend-item-reports', GADWP_URL . 'front/css/item-reports.css', null, GADWP_CURRENT_VERSION );
46
+
47
+ $country_codes = GADWP_Tools::get_countrycodes();
48
+ if ( $this->gadwp->config->options['ga_target_geomap'] && isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
49
+ $region = $this->gadwp->config->options['ga_target_geomap'];
50
+ } else {
51
+ $region = false;
52
+ }
53
+
54
+ wp_enqueue_style( "wp-jquery-ui-dialog" );
55
+
56
+ wp_register_script( 'googlecharts', 'https://www.gstatic.com/charts/loader.js', array(), null );
57
+
58
+ wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
59
+
60
+ 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 );
61
+
62
+ /* @formatter:off */
63
+ wp_localize_script( 'gadwp-frontend-item-reports', 'gadwpItemData', array(
64
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
65
+ 'security' => wp_create_nonce( 'gadwp_frontend_item_reports' ),
66
+ 'dateList' => array(
67
+ 'today' => __( "Today", 'google-analytics-dashboard-for-wp' ),
68
+ 'yesterday' => __( "Yesterday", 'google-analytics-dashboard-for-wp' ),
69
+ '7daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 7 ),
70
+ '14daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 14 ),
71
+ '30daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 30 ),
72
+ '90daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 90 ),
73
+ '365daysAgo' => sprintf( _n( "%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp' ), __('One', 'google-analytics-dashboard-for-wp') ),
74
+ '1095daysAgo' => sprintf( _n( "%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp' ), __('Three', 'google-analytics-dashboard-for-wp') ),
75
+ ),
76
+ 'reportList' => array(
77
+ 'uniquePageviews' => __( "Unique Views", 'google-analytics-dashboard-for-wp' ),
78
+ 'users' => __( "Users", 'google-analytics-dashboard-for-wp' ),
79
+ 'organicSearches' => __( "Organic", 'google-analytics-dashboard-for-wp' ),
80
+ 'pageviews' => __( "Page Views", 'google-analytics-dashboard-for-wp' ),
81
+ 'visitBounceRate' => __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
82
+ 'locations' => __( "Location", 'google-analytics-dashboard-for-wp' ),
83
+ 'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
84
+ 'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
85
+ 'trafficdetails' => __( "Traffic", 'google-analytics-dashboard-for-wp' ),
86
+ 'technologydetails' => __( "Technology", 'google-analytics-dashboard-for-wp' ),
87
+ ),
88
+ 'i18n' => array(
89
+ __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
90
+ __( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ),
91
+ __( "Visitor Type", 'google-analytics-dashboard-for-wp' ),
92
+ __( "Search Engines", 'google-analytics-dashboard-for-wp' ),
93
+ __( "Social Networks", 'google-analytics-dashboard-for-wp' ),
94
+ __( "Unique Views", 'google-analytics-dashboard-for-wp' ),
95
+ __( "Users", 'google-analytics-dashboard-for-wp' ),
96
+ __( "Page Views", 'google-analytics-dashboard-for-wp' ),
97
+ __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
98
+ __( "Organic Search", 'google-analytics-dashboard-for-wp' ),
99
+ __( "Pages/Session", 'google-analytics-dashboard-for-wp' ),
100
+ __( "Invalid response", 'google-analytics-dashboard-for-wp' ),
101
+ __( "No Data", 'google-analytics-dashboard-for-wp' ),
102
+ __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
103
+ __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
104
+ __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <strong>' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</strong>!',
105
+ __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
106
+ __( "Operating System", 'google-analytics-dashboard-for-wp' ),
107
+ __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
108
+ __( "Mobile Brand", 'google-analytics-dashboard-for-wp' ),
109
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
110
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
111
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
112
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
113
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ),
114
+ __( "Future Use", 'google-analytics-dashboard-for-wp' ), //25
115
+ __( "Time on Page", 'google-analytics-dashboard-for-wp' ),
116
+ __( "Page Load Time", 'google-analytics-dashboard-for-wp' ),
117
+ __( "Exit Rate", 'google-analytics-dashboard-for-wp' ),
118
+ __( "Precision: ", 'google-analytics-dashboard-for-wp' ), //29
119
+ ),
120
+ 'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['theme_color'] ),
121
+ 'region' => $region,
122
+ 'mapsApiKey' => apply_filters( 'gadwp_maps_api_key', $this->gadwp->config->options['maps_api_key'] ),
123
+ 'language' => get_bloginfo( 'language' ),
124
+ 'filter' => $_SERVER["REQUEST_URI"],
125
+ 'viewList' => false,
126
+ 'scope' => 'front-item',
127
+ )
128
+ );
129
+ /* @formatter:on */
130
+ }
131
+ }
132
+ }
133
+ }
tags/5.3.1.1/front/tracking-analytics.php ADDED
@@ -0,0 +1,775 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2017 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Tracking_Analytics_Base' ) ) {
15
+
16
+ class GADWP_Tracking_Analytics_Base {
17
+
18
+ protected $gadwp;
19
+
20
+ protected $uaid;
21
+
22
+ public function __construct() {
23
+ $this->gadwp = GADWP();
24
+
25
+ $profile = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_profiles_list'], $this->gadwp->config->options['tableid_jail'] );
26
+
27
+ $this->uaid = esc_html( $profile[2] );
28
+ }
29
+
30
+ protected function build_custom_dimensions() {
31
+ $custom_dimensions = array();
32
+
33
+ if ( $this->gadwp->config->options['ga_author_dimindex'] && ( is_single() || is_page() ) ) {
34
+ global $post;
35
+ $author_id = $post->post_author;
36
+ $author_name = get_the_author_meta( 'display_name', $author_id );
37
+ $index = (int) $this->gadwp->config->options['ga_author_dimindex'];
38
+ $custom_dimensions[$index] = esc_attr( $author_name );
39
+ }
40
+
41
+ if ( $this->gadwp->config->options['ga_pubyear_dimindex'] && is_single() ) {
42
+ global $post;
43
+ $date = get_the_date( 'Y', $post->ID );
44
+ $index = (int) $this->gadwp->config->options['ga_pubyear_dimindex'];
45
+ $custom_dimensions[$index] = (int) $date;
46
+ }
47
+
48
+ if ( $this->gadwp->config->options['ga_pubyearmonth_dimindex'] && is_single() ) {
49
+ global $post;
50
+ $date = get_the_date( 'Y-m', $post->ID );
51
+ $index = (int) $this->gadwp->config->options['ga_pubyearmonth_dimindex'];
52
+ $custom_dimensions[$index] = esc_attr( $date );
53
+ }
54
+
55
+ if ( $this->gadwp->config->options['ga_category_dimindex'] && is_category() ) {
56
+ $fields = array();
57
+ $index = (int) $this->gadwp->config->options['ga_category_dimindex'];
58
+ $custom_dimensions[$index] = esc_attr( single_tag_title( '', false ) );
59
+ }
60
+
61
+ if ( $this->gadwp->config->options['ga_category_dimindex'] && is_single() ) {
62
+ global $post;
63
+ $categories = get_the_category( $post->ID );
64
+ foreach ( $categories as $category ) {
65
+ $index = (int) $this->gadwp->config->options['ga_category_dimindex'];
66
+ $custom_dimensions[$index] = esc_attr( $category->name );
67
+ break;
68
+ }
69
+ }
70
+
71
+ if ( $this->gadwp->config->options['ga_tag_dimindex'] && is_single() ) {
72
+ global $post;
73
+ $fields = array();
74
+ $post_tags_list = '';
75
+ $post_tags_array = get_the_tags( $post->ID );
76
+ if ( $post_tags_array ) {
77
+ foreach ( $post_tags_array as $tag ) {
78
+ $post_tags_list .= $tag->name . ', ';
79
+ }
80
+ }
81
+ $post_tags_list = rtrim( $post_tags_list, ', ' );
82
+ if ( $post_tags_list ) {
83
+ $index = (int) $this->gadwp->config->options['ga_tag_dimindex'];
84
+ $custom_dimensions[$index] = esc_attr( $post_tags_list );
85
+ }
86
+ }
87
+
88
+ if ( $this->gadwp->config->options['ga_user_dimindex'] ) {
89
+ $fields = array();
90
+ $index = (int) $this->gadwp->config->options['ga_user_dimindex'];
91
+ $custom_dimensions[$index] = is_user_logged_in() ? 'registered' : 'guest';
92
+ }
93
+
94
+ return $custom_dimensions;
95
+ }
96
+
97
+ protected function is_event_tracking( $opt, $with_pagescrolldepth = true ) {
98
+ if ( $this->gadwp->config->options['ga_event_tracking'] || $this->gadwp->config->options['ga_aff_tracking'] || $this->gadwp->config->options['ga_hash_tracking'] || $this->gadwp->config->options['ga_formsubmit_tracking'] ) {
99
+ return true;
100
+ }
101
+
102
+ if ( $this->gadwp->config->options['ga_pagescrolldepth_tracking'] && $with_pagescrolldepth ) {
103
+ return true;
104
+ }
105
+ return false;
106
+ }
107
+ }
108
+ }
109
+
110
+ if ( ! class_exists( 'GADWP_Tracking_Analytics_Common' ) ) {
111
+
112
+ class GADWP_Tracking_Analytics_Common extends GADWP_Tracking_Analytics_Base {
113
+
114
+ protected $commands;
115
+
116
+ public function __construct() {
117
+ parent::__construct();
118
+
119
+ $this->load_scripts();
120
+
121
+ if ( $this->gadwp->config->options['optimize_tracking'] && $this->gadwp->config->options['optimize_pagehiding'] && $this->gadwp->config->options['optimize_containerid'] ) {
122
+ add_action( 'wp_head', array( $this, 'optimize_output' ), 99 );
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Styles & Scripts load
128
+ */
129
+ private function load_scripts() {
130
+ if ( $this->is_event_tracking( true ) ) {
131
+
132
+ $root_domain = GADWP_Tools::get_root_domain();
133
+
134
+ wp_enqueue_script( 'gadwp-tracking-analytics-events', GADWP_URL . 'front/js/tracking-analytics-events.js', array( 'jquery' ), GADWP_CURRENT_VERSION, $this->gadwp->config->options['trackingevents_infooter'] );
135
+
136
+ if ( $this->gadwp->config->options['ga_pagescrolldepth_tracking'] ) {
137
+ wp_enqueue_script( 'gadwp-pagescrolldepth-tracking', GADWP_URL . 'front/js/tracking-scrolldepth.js', array( 'jquery' ), GADWP_CURRENT_VERSION, $this->gadwp->config->options['trackingevents_infooter'] );
138
+ }
139
+
140
+ /* @formatter:off */
141
+ wp_localize_script( 'gadwp-tracking-analytics-events', 'gadwpUAEventsData', array(
142
+ 'options' => array(
143
+ 'event_tracking' => $this->gadwp->config->options['ga_event_tracking'],
144
+ 'event_downloads' => esc_js($this->gadwp->config->options['ga_event_downloads']),
145
+ 'event_bouncerate' => $this->gadwp->config->options['ga_event_bouncerate'],
146
+ 'aff_tracking' => $this->gadwp->config->options['ga_aff_tracking'],
147
+ 'event_affiliates' => esc_js($this->gadwp->config->options['ga_event_affiliates']),
148
+ 'hash_tracking' => $this->gadwp->config->options ['ga_hash_tracking'],
149
+ 'root_domain' => $root_domain,
150
+ 'event_timeout' => apply_filters( 'gadwp_analyticsevents_timeout', 100 ),
151
+ 'event_precision' => $this->gadwp->config->options['ga_event_precision'],
152
+ 'event_formsubmit' => $this->gadwp->config->options ['ga_formsubmit_tracking'],
153
+ 'ga_pagescrolldepth_tracking' => $this->gadwp->config->options['ga_pagescrolldepth_tracking'],
154
+ 'ga_with_gtag' => $this->gadwp->config->options ['ga_with_gtag'],
155
+ ),
156
+ )
157
+ );
158
+ /* @formatter:on */
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Outputs the Google Optimize tracking code
164
+ */
165
+ public function optimize_output() {
166
+ GADWP_Tools::load_view( 'front/views/optimize-code.php', array( 'containerid' => $this->gadwp->config->options['optimize_containerid'] ) );
167
+ }
168
+
169
+ /**
170
+ * Sanitizes the output of commands in the tracking code
171
+ * @param string $value
172
+ * @return string
173
+ */
174
+ protected function filter( $value, $is_dim = false ) {
175
+ if ( 'true' == $value || 'false' == $value || ( is_numeric( $value ) && ! $is_dim ) ) {
176
+ return $value;
177
+ }
178
+
179
+ if ( substr( $value, 0, 1 ) == '[' && substr( $value, - 1 ) == ']' || substr( $value, 0, 1 ) == '{' && substr( $value, - 1 ) == '}' ) {
180
+ return $value;
181
+ }
182
+
183
+ return "'" . $value . "'";
184
+ }
185
+
186
+ /**
187
+ * Retrieves the commands
188
+ */
189
+ public function get() {
190
+ return $this->commands;
191
+ }
192
+
193
+ /**
194
+ * Stores the commands
195
+ * @param array $commands
196
+ */
197
+ public function set( $commands ) {
198
+ $this->commands = $commands;
199
+ }
200
+
201
+ /**
202
+ * Formats the command before being added to the commands
203
+ * @param string $command
204
+ * @param array $fields
205
+ * @param string $fieldsobject
206
+ * @return array
207
+ */
208
+ public function prepare( $command, $fields, $fieldsobject = null ) {
209
+ return array( 'command' => $command, 'fields' => $fields, 'fieldsobject' => $fieldsobject );
210
+ }
211
+
212
+ /**
213
+ * Adds a formatted command to commands
214
+ * @param string $command
215
+ * @param array $fields
216
+ * @param string $fieldsobject
217
+ */
218
+ protected function add( $command, $fields, $fieldsobject = null ) {
219
+ $this->commands[] = $this->prepare( $command, $fields, $fieldsobject );
220
+ }
221
+ }
222
+ }
223
+
224
+ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
225
+
226
+ class GADWP_Tracking_Analytics extends GADWP_Tracking_Analytics_Common {
227
+
228
+ public function __construct() {
229
+ parent::__construct();
230
+
231
+ if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
232
+ add_action( 'wp_footer', array( $this, 'output' ), 99 );
233
+ } else {
234
+ add_action( 'wp_head', array( $this, 'output' ), 99 );
235
+ }
236
+ }
237
+
238
+ /**
239
+ * Builds the commands based on user's options
240
+ */
241
+ private function build_commands() {
242
+ $fields = array();
243
+ $fieldsobject = array();
244
+ $fields['trackingId'] = $this->uaid;
245
+ if ( 1 != $this->gadwp->config->options['ga_speed_samplerate'] ) {
246
+ $fieldsobject['siteSpeedSampleRate'] = (int) $this->gadwp->config->options['ga_speed_samplerate'];
247
+ }
248
+ if ( 100 != $this->gadwp->config->options['ga_user_samplerate'] ) {
249
+ $fieldsobject['sampleRate'] = (int) $this->gadwp->config->options['ga_user_samplerate'];
250
+ }
251
+ if ( $this->gadwp->config->options['ga_crossdomain_tracking'] && '' != $this->gadwp->config->options['ga_crossdomain_list'] ) {
252
+ $fieldsobject['allowLinker'] = 'true';
253
+ }
254
+ if ( ! empty( $this->gadwp->config->options['ga_cookiedomain'] ) ) {
255
+ $fieldsobject['cookieDomain'] = $this->gadwp->config->options['ga_cookiedomain'];
256
+ } else {
257
+ $fields['cookieDomain'] = 'auto';
258
+ }
259
+ if ( ! empty( $this->gadwp->config->options['ga_cookiename'] ) ) {
260
+ $fieldsobject['cookieName'] = $this->gadwp->config->options['ga_cookiename'];
261
+ }
262
+ if ( ! empty( $this->gadwp->config->options['ga_cookieexpires'] ) ) {
263
+ $fieldsobject['cookieExpires'] = (int) $this->gadwp->config->options['ga_cookieexpires'];
264
+ }
265
+ if ( $this->gadwp->config->options['amp_tracking_clientidapi'] ) {
266
+ $fieldsobject['useAmpClientId'] = 'true';
267
+ }
268
+ $this->add( 'create', $fields, $fieldsobject );
269
+
270
+ if ( $this->gadwp->config->options['ga_crossdomain_tracking'] && '' != $this->gadwp->config->options['ga_crossdomain_list'] ) {
271
+ $fields = array();
272
+ $fields['plugin'] = 'linker';
273
+ $this->add( 'require', $fields );
274
+
275
+ $fields = array();
276
+ $domains = '';
277
+ $domains = explode( ',', $this->gadwp->config->options['ga_crossdomain_list'] );
278
+ $domains = array_map( 'trim', $domains );
279
+ $domains = strip_tags( implode( "','", $domains ) );
280
+ $domains = "['" . $domains . "']";
281
+ $fields['domains'] = $domains;
282
+ $this->add( 'linker:autoLink', $fields );
283
+ }
284
+
285
+ if ( $this->gadwp->config->options['ga_remarketing'] ) {
286
+ $fields = array();
287
+ $fields['plugin'] = 'displayfeatures';
288
+ $this->add( 'require', $fields );
289
+ }
290
+
291
+ if ( $this->gadwp->config->options['ga_enhanced_links'] ) {
292
+ $fields = array();
293
+ $fields['plugin'] = 'linkid';
294
+ $this->add( 'require', $fields );
295
+ }
296
+
297
+ if ( $this->gadwp->config->options['ga_force_ssl'] ) {
298
+ $fields = array();
299
+ $fields['option'] = 'forceSSL';
300
+ $fields['value'] = 'true';
301
+ $this->add( 'set', $fields );
302
+ }
303
+
304
+ $custom_dimensions = $this->build_custom_dimensions();
305
+ if ( ! empty( $custom_dimensions ) ) {
306
+ foreach ( $custom_dimensions as $index => $value ) {
307
+ $fields = array();
308
+ $fields['gadwp_dimension'] = 'dimension' . $index;
309
+ $fields['gadwp_dim_value'] = $value;
310
+ $this->add( 'set', $fields );
311
+ }
312
+ }
313
+
314
+ if ( $this->gadwp->config->options['ga_anonymize_ip'] ) {
315
+ $fields = array();
316
+ $fields['option'] = 'anonymizeIp';
317
+ $fields['value'] = 'true';
318
+ $this->add( 'set', $fields );
319
+ }
320
+
321
+ if ( 'enhanced' == $this->gadwp->config->options['ecommerce_mode'] ) {
322
+ $fields = array();
323
+ $fields['plugin'] = 'ec';
324
+ $this->add( 'require', $fields );
325
+ } else if ( 'standard' == $this->gadwp->config->options['ecommerce_mode'] ) {
326
+ $fields = array();
327
+ $fields['plugin'] = 'ecommerce';
328
+ $this->add( 'require', $fields );
329
+ }
330
+
331
+ if ( $this->gadwp->config->options['optimize_tracking'] && $this->gadwp->config->options['optimize_containerid'] ) {
332
+ $fields = array();
333
+ $fields['plugin'] = esc_attr( $this->gadwp->config->options['optimize_containerid'] );
334
+ $this->add( 'require', $fields );
335
+ }
336
+
337
+ $fields = array();
338
+ $fields['hitType'] = 'pageview';
339
+ $this->add( 'send', $fields );
340
+
341
+ do_action( 'gadwp_analytics_commands', $this );
342
+ }
343
+
344
+ /**
345
+ * Outputs the Google Analytics tracking code
346
+ */
347
+ public function output() {
348
+ $this->commands = array();
349
+
350
+ $this->build_commands();
351
+
352
+ $trackingcode = '';
353
+
354
+ foreach ( $this->commands as $set ) {
355
+ $command = $set['command'];
356
+
357
+ $fields = '';
358
+ foreach ( $set['fields'] as $fieldkey => $fieldvalue ) {
359
+ if ( false === strpos( $fieldkey, 'gadwp_dim_value' ) ) {
360
+ $fieldvalue = $this->filter( $fieldvalue );
361
+ } else {
362
+ $fieldvalue = $this->filter( $fieldvalue, true );
363
+ }
364
+ $fields .= ", " . $fieldvalue;
365
+ }
366
+
367
+ if ( $set['fieldsobject'] ) {
368
+ $fieldsobject = ", {";
369
+ foreach ( $set['fieldsobject'] as $fieldkey => $fieldvalue ) {
370
+ $fieldvalue = $this->filter( $fieldvalue );
371
+ $fieldkey = $this->filter( $fieldkey );
372
+ $fieldsobject .= $fieldkey . ": " . $fieldvalue . ", ";
373
+ }
374
+ $fieldsobject = rtrim( $fieldsobject, ", " );
375
+ $fieldsobject .= "}";
376
+ $trackingcode .= " ga('" . $command . "'" . $fields . $fieldsobject . ");\n";
377
+ } else {
378
+ $trackingcode .= " ga('" . $command . "'" . $fields . ");\n";
379
+ }
380
+ }
381
+
382
+ $tracking_script_path = apply_filters( 'gadwp_analytics_script_path', 'https://www.google-analytics.com/analytics.js' );
383
+
384
+ if ( $this->gadwp->config->options['ga_optout'] || $this->gadwp->config->options['ga_dnt_optout'] ) {
385
+ GADWP_Tools::load_view( 'front/views/analytics-optout-code.php', array( 'uaid' => $this->uaid, 'gaDntOptout' => $this->gadwp->config->options['ga_dnt_optout'], 'gaOptout' => $this->gadwp->config->options['ga_optout'] ) );
386
+ }
387
+
388
+ GADWP_Tools::load_view( 'front/views/analytics-code.php', array( 'trackingcode' => $trackingcode, 'tracking_script_path' => $tracking_script_path, 'ga_with_gtag' => $this->gadwp->config->options['ga_with_gtag'] , 'uaid' => $this->uaid ) );
389
+ }
390
+ }
391
+ }
392
+
393
+
394
+ if ( ! class_exists( 'GADWP_Tracking_GlobalSiteTag' ) ) {
395
+
396
+ class GADWP_Tracking_GlobalSiteTag extends GADWP_Tracking_Analytics_Common {
397
+
398
+ public function __construct() {
399
+ parent::__construct();
400
+
401
+ if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
402
+ add_action( 'wp_footer', array( $this, 'output' ), 99 );
403
+ } else {
404
+ add_action( 'wp_head', array( $this, 'output' ), 99 );
405
+ }
406
+ }
407
+
408
+ /**
409
+ * Builds the commands based on user's options
410
+ */
411
+ private function build_commands() {
412
+ $fields = array();
413
+ $fieldsobject = array();
414
+ $fields['trackingId'] = $this->uaid;
415
+ $custom_dimensions = $this->build_custom_dimensions();
416
+ /*
417
+ * if ( 1 != $this->gadwp->config->options['ga_speed_samplerate'] ) {
418
+ * $fieldsobject['siteSpeedSampleRate'] = (int) $this->gadwp->config->options['ga_speed_samplerate'];
419
+ * }
420
+ */
421
+ if ( ! empty( $this->gadwp->config->options['ga_cookiedomain'] ) ) {
422
+ $fieldsobject['cookie_domain'] = $this->gadwp->config->options['ga_cookiedomain'];
423
+ }
424
+ if ( ! empty( $this->gadwp->config->options['ga_cookiename'] ) ) {
425
+ $fieldsobject['cookie_name'] = $this->gadwp->config->options['ga_cookiename'];
426
+ }
427
+ if ( ! empty( $this->gadwp->config->options['ga_cookieexpires'] ) ) {
428
+ $fieldsobject['cookie_expires'] = (int) $this->gadwp->config->options['ga_cookieexpires'];
429
+ }
430
+ /*
431
+ * if ( $this->gadwp->config->options['amp_tracking_clientidapi'] ) {
432
+ * $fieldsobject['useAmpClientId'] = 'true';
433
+ * }
434
+ */
435
+ if ( $this->gadwp->config->options['ga_crossdomain_tracking'] && '' != $this->gadwp->config->options['ga_crossdomain_list'] ) {
436
+ $domains = '';
437
+ $domains = explode( ',', $this->gadwp->config->options['ga_crossdomain_list'] );
438
+ $domains = array_map( 'trim', $domains );
439
+ $domains = strip_tags( implode( "','", $domains ) );
440
+ $domains = "['" . $domains . "']";
441
+ $fieldsobject['linker'] = "{ 'domains' : " . $domains . " }";
442
+ }
443
+ if ( ! $this->gadwp->config->options['ga_remarketing'] ) {
444
+ $fieldsobject['allow_display_features'] = 'false';
445
+ }
446
+ if ( $this->gadwp->config->options['ga_enhanced_links'] ) {
447
+ $fieldsobject['link_attribution'] = 'true';
448
+ }
449
+ if ( $this->gadwp->config->options['ga_anonymize_ip'] ) {
450
+ $fieldsobject['anonymize_ip'] = 'true';
451
+ }
452
+ if ( $this->gadwp->config->options['optimize_tracking'] && $this->gadwp->config->options['optimize_containerid'] ) {
453
+ $fieldsobject['optimize_id'] = esc_attr( $this->gadwp->config->options['optimize_containerid'] );
454
+ }
455
+ if ( 100 != $this->gadwp->config->options['ga_user_samplerate'] ) {
456
+ $fieldsobject['sample_rate'] = (int) $this->gadwp->config->options['ga_user_samplerate'];
457
+ }
458
+ if ( ! empty( $custom_dimensions ) ) {
459
+ $fieldsobject['custom_map'] = "{\n\t\t";
460
+ foreach ( $custom_dimensions as $index => $value ) {
461
+ $fieldsobject['custom_map'] .= "'dimension" . $index . "': '" . "gadwp_dim_" . $index . "', \n\t\t";
462
+ }
463
+ $fieldsobject['custom_map'] = rtrim( $fieldsobject['custom_map'], ", \n\t\t" );
464
+ $fieldsobject['custom_map'] .= "\n\t}";
465
+ }
466
+ $this->add( 'config', $fields, $fieldsobject );
467
+
468
+ if ( ! empty( $custom_dimensions ) ) {
469
+ $fields = array();
470
+ $fieldsobject = array();
471
+ $fields['event_name'] = 'gadwp_dimensions';
472
+ foreach ( $custom_dimensions as $index => $value ) {
473
+ $fieldsobject['gadwp_dim_' . $index] = $value;
474
+ }
475
+ $this->add( 'event', $fields, $fieldsobject );
476
+ }
477
+
478
+ do_action( 'gadwp_analytics_commands', $this );
479
+ }
480
+
481
+ /**
482
+ * Outputs the Google Analytics tracking code
483
+ */
484
+ public function output() {
485
+ $this->commands = array();
486
+
487
+ $this->build_commands();
488
+
489
+ $trackingcode = '';
490
+
491
+ foreach ( $this->commands as $set ) {
492
+ $command = $set['command'];
493
+
494
+ $fields = '';
495
+ foreach ( $set['fields'] as $fieldkey => $fieldvalue ) {
496
+ $fieldvalue = $this->filter( $fieldvalue );
497
+ $fields .= ", " . $fieldvalue;
498
+ }
499
+
500
+ if ( $set['fieldsobject'] ) {
501
+ $fieldsobject = ", {\n\t";
502
+ foreach ( $set['fieldsobject'] as $fieldkey => $fieldvalue ) {
503
+ if ( false === strpos( $fieldkey, 'gadwp_' ) ) {
504
+ $fieldvalue = $this->filter( $fieldvalue );
505
+ } else {
506
+ $fieldvalue = $this->filter( $fieldvalue, true );
507
+ }
508
+ $fieldkey = $this->filter( $fieldkey );
509
+ $fieldsobject .= $fieldkey . ": " . $fieldvalue . ", \n\t";
510
+ }
511
+ $fieldsobject = rtrim( $fieldsobject, ", \n\t" );
512
+ $fieldsobject .= "\n }";
513
+ $trackingcode .= " gtag('" . $command . "'" . $fields . $fieldsobject . ");\n";
514
+ } else {
515
+ $trackingcode .= " gtag('" . $command . "'" . $fields . ");\n";
516
+ }
517
+ }
518
+
519
+ $tracking_script_path = apply_filters( 'gadwp_analytics_script_path', 'https://www.googletagmanager.com/gtag/js' );
520
+
521
+ if ( $this->gadwp->config->options['ga_optout'] || $this->gadwp->config->options['ga_dnt_optout'] ) {
522
+ GADWP_Tools::load_view( 'front/views/analytics-optout-code.php', array( 'uaid' => $this->uaid, 'gaDntOptout' => $this->gadwp->config->options['ga_dnt_optout'], 'gaOptout' => $this->gadwp->config->options['ga_optout'] ) );
523
+ }
524
+
525
+ GADWP_Tools::load_view( 'front/views/analytics-code.php', array( 'trackingcode' => $trackingcode, 'tracking_script_path' => $tracking_script_path, 'ga_with_gtag' => $this->gadwp->config->options['ga_with_gtag'] , 'uaid' => $this->uaid ) );
526
+ }
527
+ }
528
+ }
529
+
530
+ if ( ! class_exists( 'GADWP_Tracking_Analytics_AMP' ) ) {
531
+
532
+ class GADWP_Tracking_Analytics_AMP extends GADWP_Tracking_Analytics_Base {
533
+
534
+ private $config;
535
+
536
+ public function __construct() {
537
+ parent::__construct();
538
+
539
+ add_filter( 'amp_post_template_data', array( $this, 'load_scripts' ) );
540
+ add_action( 'amp_post_template_footer', array( $this, 'output' ) );
541
+ add_filter( 'the_content', array( $this, 'add_data_attributes' ), 999, 1 );
542
+ if ( $this->gadwp->config->options['amp_tracking_clientidapi'] ) {
543
+ add_action( 'amp_post_template_head', array( $this, 'add_amp_client_id' ) );
544
+ }
545
+ }
546
+
547
+ private function get_link_event_data( $link ) {
548
+ if ( empty( $link ) ) {
549
+ return false;
550
+ }
551
+ if ( $this->gadwp->config->options['ga_event_tracking'] ) {
552
+ // on changes adjust the substr() length parameter
553
+ if ( substr( $link, 0, 7 ) === "mailto:" ) {
554
+ return array( 'email', 'send', $link );
555
+ }
556
+
557
+ // on changes adjust the substr() length parameter
558
+ if ( substr( $link, 0, 4 ) === "tel:" ) {
559
+ return array( 'telephone', 'call', $link );
560
+ }
561
+
562
+ // Add download data-vars
563
+ if ( $this->gadwp->config->options['ga_event_downloads'] && preg_match( '/.*\.(' . $this->gadwp->config->options['ga_event_downloads'] . ')(\?.*)?$/i', $link, $matches ) ) {
564
+ return array( 'download', 'click', $link );
565
+ }
566
+ }
567
+ if ( $this->gadwp->config->options['ga_hash_tracking'] ) {
568
+ // Add hashmark data-vars
569
+ $root_domain = GADWP_Tools::get_root_domain();
570
+ if ( $root_domain && ( strpos( $link, $root_domain ) > - 1 || strpos( $link, '://' ) === false ) && strpos( $link, '#' ) > - 1 ) {
571
+ return array( 'hashmark', 'click', $link );
572
+ }
573
+ }
574
+ if ( $this->gadwp->config->options['ga_aff_tracking'] ) {
575
+ // Add affiliate data-vars
576
+ if ( strpos( $link, $this->gadwp->config->options['ga_event_affiliates'] ) > - 1 ) {
577
+ return array( 'affiliates', 'click', $link );
578
+ }
579
+ }
580
+ if ( $this->gadwp->config->options['ga_event_tracking'] ) {
581
+ // Add outbound data-vars
582
+ $root_domain = GADWP_Tools::get_root_domain();
583
+ if ( $root_domain && strpos( $link, $root_domain ) === false && strpos( $link, '://' ) > - 1 ) {
584
+ return array( 'outbound', 'click', $link );
585
+ }
586
+ }
587
+ return false;
588
+ }
589
+
590
+ public function add_data_attributes( $content ) {
591
+ if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() && $this->is_event_tracking( false ) ) {
592
+
593
+ $dom = GADWP_Tools::get_dom_from_content( $content );
594
+
595
+ if ( $dom ) {
596
+
597
+ $links = $dom->getElementsByTagName( 'a' );
598
+
599
+ foreach ( $links as $item ) {
600
+
601
+ $data_attributes = $this->get_link_event_data( $item->getAttribute( 'href' ) );
602
+
603
+ if ( $data_attributes ) {
604
+ if ( ! $item->hasAttribute( 'data-vars-ga-category' ) ) {
605
+ $item->setAttribute( 'data-vars-ga-category', $data_attributes[0] );
606
+ }
607
+ if ( ! $item->hasAttribute( 'data-vars-ga-action' ) ) {
608
+ $item->setAttribute( 'data-vars-ga-action', $data_attributes[1] );
609
+ }
610
+ if ( ! $item->hasAttribute( 'data-vars-ga-label' ) ) {
611
+ $item->setAttribute( 'data-vars-ga-label', $data_attributes[2] );
612
+ }
613
+ }
614
+ }
615
+
616
+ if ( $this->gadwp->config->options['ga_formsubmit_tracking'] ) {
617
+ $form_submits = $dom->getElementsByTagName( 'input' );
618
+ foreach ( $form_submits as $item ) {
619
+ if ( $item->getAttribute( 'type' ) == 'submit' ) {
620
+ if ( ! $item->hasAttribute( 'data-vars-ga-category' ) ) {
621
+ $item->setAttribute( 'data-vars-ga-category', 'form' );
622
+ }
623
+ if ( ! $item->hasAttribute( 'data-vars-ga-action' ) ) {
624
+ $item->setAttribute( 'data-vars-ga-action', 'submit' );
625
+ }
626
+ if ( ! $item->hasAttribute( 'data-vars-ga-label' ) ) {
627
+ if ( $item->getAttribute( 'value' ) ) {
628
+ $label = $item->getAttribute( 'value' );
629
+ }
630
+ if ( $item->getAttribute( 'name' ) ) {
631
+ $label = $item->getAttribute( 'name' );
632
+ }
633
+ $item->setAttribute( 'data-vars-ga-label', $label );
634
+ }
635
+ }
636
+ }
637
+ }
638
+ return GADWP_Tools::get_content_from_dom( $dom );
639
+ }
640
+ }
641
+
642
+ return $content;
643
+ }
644
+
645
+ /**
646
+ * Inserts the Analytics AMP script in the head section
647
+ */
648
+ public function load_scripts( $data ) {
649
+ if ( ! isset( $data['amp_component_scripts'] ) ) {
650
+ $data['amp_component_scripts'] = array();
651
+ }
652
+
653
+ $data['amp_component_scripts']['amp-analytics'] = 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js';
654
+
655
+ return $data;
656
+ }
657
+
658
+ /**
659
+ * Retrieves the AMP config array
660
+ */
661
+ public function get() {
662
+ return $this->config;
663
+ }
664
+
665
+ /**
666
+ * Stores the AMP config array
667
+ * @param array $config
668
+ */
669
+ public function set( $config ) {
670
+ $this->config = $config;
671
+ }
672
+
673
+ private function build_json() {
674
+ $this->config = array();
675
+
676
+ // Set the Tracking ID
677
+ /* @formatter:off */
678
+ $this->config['vars'] = array(
679
+ 'account' => $this->uaid,
680
+ 'documentLocation' => '${canonicalUrl}',
681
+ );
682
+ /* @formatter:on */
683
+
684
+ // Set Custom Dimensions as extraUrlParams
685
+ $custom_dimensions = $this->build_custom_dimensions();
686
+
687
+ if ( ! empty( $custom_dimensions ) ) {
688
+ foreach ( $custom_dimensions as $index => $value ) {
689
+ $dimension = 'cd' . $index;
690
+ $this->config['extraUrlParams'][$dimension] = $value;
691
+ }
692
+ }
693
+
694
+ // Set Triggers
695
+ /* @formatter:off */
696
+ $this->config['triggers']['gadwpTrackPageview'] = array(
697
+ 'on' => 'visible',
698
+ 'request' => 'pageview',
699
+ );
700
+ /* @formatter:on */
701
+
702
+ // Set Sampling Rate only if lower than 100%
703
+ if ( 100 != $this->gadwp->config->options['ga_user_samplerate'] ) {
704
+ /* @formatter:off */
705
+ $this->config['triggers']['gadwpTrackPageview']['sampleSpec'] = array(
706
+ 'sampleOn' => '${clientId}',
707
+ 'threshold' => (int) $this->gadwp->config->options['ga_user_samplerate'],
708
+ );
709
+ /* @formatter:on */
710
+ }
711
+
712
+ // Set Scroll events
713
+ if ( $this->gadwp->config->options['ga_pagescrolldepth_tracking'] ) {
714
+ /* @formatter:off */
715
+ $this->config['triggers']['gadwpScrollPings'] = array (
716
+ 'on' => 'scroll',
717
+ 'scrollSpec' => array(
718
+ 'verticalBoundaries' => '&#91;25, 50, 75, 100&#93;',
719
+ ),
720
+ 'request' => 'event',
721
+ 'vars' => array(
722
+ 'eventCategory' => 'Scroll Depth',
723
+ 'eventAction' => 'Percentage',
724
+ 'eventLabel' => '${verticalScrollBoundary}%',
725
+ ),
726
+ );
727
+ /* @formatter:on */
728
+ $this->config['triggers']['gadwpScrollPings']['extraUrlParams'] = array( 'ni' => true );
729
+ }
730
+
731
+ if ( $this->is_event_tracking( false ) ) {
732
+ // Set downloads, outbound links, affiliate links, hashmarks, e-mails, telephones, form submits events
733
+ /* @formatter:off */
734
+ $this->config['triggers']['gadwpEventTracking'] = array (
735
+ 'on' => 'click',
736
+ 'selector' => '[data-vars-ga-category][data-vars-ga-action][data-vars-ga-label]',
737
+ 'request' => 'event',
738
+ 'vars' => array(
739
+ 'eventCategory' => '${gaCategory}',
740
+ 'eventAction' => '${gaAction}',
741
+ 'eventLabel' => '${gaLabel}',
742
+ ),
743
+ );
744
+ /* @formatter:on */
745
+ if ( $this->gadwp->config->options['ga_event_bouncerate'] ) {
746
+ $this->config['triggers']['gadwpEventTracking']['extraUrlParams'] = array( 'ni' => (bool) $this->gadwp->config->options['ga_event_bouncerate'] );
747
+ }
748
+ }
749
+ do_action( 'gadwp_analytics_amp_config', $this );
750
+ }
751
+
752
+ public function add_amp_client_id() {
753
+ GADWP_Tools::load_view( 'front/views/analytics-amp-clientidapi.php' );
754
+ }
755
+
756
+ /**
757
+ * Outputs the Google Analytics tracking code for AMP
758
+ */
759
+ public function output() {
760
+ $this->build_json();
761
+
762
+ if ( version_compare( phpversion(), '5.4.0', '<' ) ) {
763
+ $json = json_encode( $this->config );
764
+ } else {
765
+ $json = json_encode( $this->config, JSON_PRETTY_PRINT );
766
+ }
767
+
768
+ $json = str_replace( array( '"&#91;', '&#93;"' ), array( '[', ']' ), $json ); // make verticalBoundaries a JavaScript array
769
+
770
+ $data = array( 'json' => $json );
771
+
772
+ GADWP_Tools::load_view( 'front/views/analytics-amp-code.php', $data );
773
+ }
774
+ }
775
+ }
tags/5.3.1.1/front/tracking-tagmanager.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2017 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Tracking_TagManager' ) ) {
15
+
16
+ class GADWP_Tracking_TagManager {
17
+
18
+ private $gadwp;
19
+
20
+ private $datalayer;
21
+
22
+ public function __construct() {
23
+ $this->gadwp = GADWP();
24
+
25
+ if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
26
+ add_action( 'wp_footer', array( $this, 'output' ), 99 );
27
+ } else {
28
+ add_action( 'wp_head', array( $this, 'output' ), 99 );
29
+ }
30
+
31
+ if ( $this->gadwp->config->options['amp_tracking_tagmanager'] && $this->gadwp->config->options['amp_containerid'] ) {
32
+ add_filter( 'amp_post_template_data', array( $this, 'amp_add_analytics_script' ) );
33
+ add_action( 'amp_post_template_footer', array( $this, 'amp_output' ) );
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Retrieves the datalayer variables
39
+ */
40
+ public function get() {
41
+ return $this->datalayer;
42
+ }
43
+
44
+ /**
45
+ * Stores the datalayer variables
46
+ * @param array $datalayer
47
+ */
48
+ public function set( $datalayer ) {
49
+ $this->datalayer = $datalayer;
50
+ }
51
+
52
+ /**
53
+ * Adds a variable to the datalayer
54
+ * @param string $name
55
+ * @param string $value
56
+ */
57
+ private function add_var( $name, $value ) {
58
+ $this->datalayer[$name] = $value;
59
+ }
60
+
61
+ /**
62
+ * Builds the datalayer based on user's options
63
+ */
64
+ private function build_custom_dimensions() {
65
+ global $post;
66
+
67
+ if ( $this->gadwp->config->options['tm_author_var'] && ( is_single() || is_page() ) ) {
68
+ global $post;
69
+ $author_id = $post->post_author;
70
+ $author_name = get_the_author_meta( 'display_name', $author_id );
71
+ $this->add_var( 'gadwpAuthor', esc_attr( $author_name ) );
72
+ }
73
+
74
+ if ( $this->gadwp->config->options['tm_pubyear_var'] && is_single() ) {
75
+ global $post;
76
+ $date = get_the_date( 'Y', $post->ID );
77
+ $this->add_var( 'gadwpPublicationYear', (int) $date );
78
+ }
79
+
80
+ if ( $this->gadwp->config->options['tm_pubyearmonth_var'] && is_single() ) {
81
+ global $post;
82
+ $date = get_the_date( 'Y-m', $post->ID );
83
+ $this->add_var( 'gadwpPublicationYearMonth', esc_attr( $date ) );
84
+ }
85
+
86
+ if ( $this->gadwp->config->options['tm_category_var'] && is_category() ) {
87
+ $this->add_var( 'gadwpCategory', esc_attr( single_tag_title( '', false ) ) );
88
+ }
89
+ if ( $this->gadwp->config->options['tm_category_var'] && is_single() ) {
90
+ global $post;
91
+ $categories = get_the_category( $post->ID );
92
+ foreach ( $categories as $category ) {
93
+ $this->add_var( 'gadwpCategory', esc_attr( $category->name ) );
94
+ break;
95
+ }
96
+ }
97
+
98
+ if ( $this->gadwp->config->options['tm_tag_var'] && is_single() ) {
99
+ global $post;
100
+ $post_tags_list = '';
101
+ $post_tags_array = get_the_tags( $post->ID );
102
+ if ( $post_tags_array ) {
103
+ foreach ( $post_tags_array as $tag ) {
104
+ $post_tags_list .= $tag->name . ', ';
105
+ }
106
+ }
107
+ $post_tags_list = rtrim( $post_tags_list, ', ' );
108
+ if ( $post_tags_list ) {
109
+ $this->add_var( 'gadwpTag', esc_attr( $post_tags_list ) );
110
+ }
111
+ }
112
+
113
+ if ( $this->gadwp->config->options['tm_user_var'] ) {
114
+ $usertype = is_user_logged_in() ? 'registered' : 'guest';
115
+ $this->add_var( 'gadwpUser', $usertype );
116
+ }
117
+
118
+ do_action( 'gadwp_tagmanager_datalayer', $this );
119
+ }
120
+
121
+ /**
122
+ * Outputs the Google Tag Manager tracking code
123
+ */
124
+ public function output() {
125
+ $this->build_custom_dimensions();
126
+
127
+ if ( is_array( $this->datalayer ) ) {
128
+ $vars = "{";
129
+ foreach ( $this->datalayer as $var => $value ) {
130
+ $vars .= "'" . $var . "': '" . $value . "', ";
131
+ }
132
+ $vars = rtrim( $vars, ", " );
133
+ $vars .= "}";
134
+ } else {
135
+ $vars = "{}";
136
+ }
137
+
138
+ GADWP_Tools::load_view( 'front/views/tagmanager-code.php', array( 'containerid' => $this->gadwp->config->options['web_containerid'], 'vars' => $vars ) );
139
+ }
140
+
141
+ /**
142
+ * Inserts the Analytics AMP script in the head section
143
+ */
144
+ public function amp_add_analytics_script( $data ) {
145
+ if ( ! isset( $data['amp_component_scripts'] ) ) {
146
+ $data['amp_component_scripts'] = array();
147
+ }
148
+
149
+ $data['amp_component_scripts']['amp-analytics'] = 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js';
150
+
151
+ return $data;
152
+ }
153
+
154
+ /**
155
+ * Outputs the Tag Manager code for AMP
156
+ */
157
+ public function amp_output() {
158
+
159
+ $this->build_custom_dimensions();
160
+
161
+ $vars = array( 'vars' => $this->datalayer );
162
+
163
+ if ( version_compare( phpversion(), '5.4.0', '<' ) ) {
164
+ $json = json_encode( $vars );
165
+ } else {
166
+ $json = json_encode( $vars, JSON_PRETTY_PRINT );
167
+ }
168
+
169
+ $amp_containerid = $this->gadwp->config->options['amp_containerid'];
170
+
171
+ $json = str_replace( array( '"&#91;', '&#93;"' ), array( '[', ']' ), $json ); // make verticalBoundaries a JavaScript array
172
+
173
+ GADWP_Tools::load_view( 'front/views/tagmanager-amp-code.php', array ( 'json' => $json, 'containerid' => $amp_containerid ) );
174
+
175
+ }
176
+ }
177
+ }
tags/5.3.1.1/front/tracking.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2017 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Tracking' ) ) {
15
+
16
+ class GADWP_Tracking {
17
+
18
+ private $gadwp;
19
+
20
+ public $analytics;
21
+
22
+ public $analytics_amp;
23
+
24
+ public $tagmanager;
25
+
26
+ public function __construct() {
27
+ $this->gadwp = GADWP();
28
+
29
+ $this->init();
30
+ }
31
+
32
+ public function tracking_code() { // Removed since 5.0
33
+ GADWP_Tools::doing_it_wrong( __METHOD__, __( "This method is deprecated, read the documentation!", 'google-analytics-dashboard-for-wp' ), '5.0' );
34
+ }
35
+
36
+ public function init() {
37
+ // excluded roles
38
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['track_exclude'], true ) || ( $this->gadwp->config->options['superadmin_tracking'] && current_user_can( 'manage_network' ) ) ) {
39
+ return;
40
+ }
41
+
42
+ if ( 'universal' == $this->gadwp->config->options['tracking_type'] && $this->gadwp->config->options['tableid_jail'] ) {
43
+
44
+ // Analytics
45
+ require_once 'tracking-analytics.php';
46
+
47
+ if ( 1 == $this->gadwp->config->options['ga_with_gtag'] ) {
48
+ $this->analytics = new GADWP_Tracking_GlobalSiteTag();
49
+ } else {
50
+ $this->analytics = new GADWP_Tracking_Analytics();
51
+ }
52
+
53
+ if ( $this->gadwp->config->options['amp_tracking_analytics'] ) {
54
+ $this->analytics_amp = new GADWP_Tracking_Analytics_AMP();
55
+ }
56
+ }
57
+
58
+ if ( 'tagmanager' == $this->gadwp->config->options['tracking_type'] && $this->gadwp->config->options['web_containerid'] ) {
59
+
60
+ // Tag Manager
61
+ require_once 'tracking-tagmanager.php';
62
+ $this->tagmanager = new GADWP_Tracking_TagManager();
63
+ }
64
+ }
65
+ }
66
+ }
tags/5.3.1.1/front/views/analytics-amp-clientidapi.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Copyright 2017 Alin Marcu
5
+ * Author URI: https://deconf.com
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+ ?>
10
+
11
+ <meta name="amp-google-client-id-api" content="googleanalytics">
tags/5.3.1.1/front/views/analytics-amp-code.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Copyright 2017 Alin Marcu
5
+ * Author URI: https://deconf.com
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+ ?>
10
+ <amp-analytics type="googleanalytics" id="gadwp-googleanalytics">
11
+ <script type="application/json">
12
+ <?php echo $data['json']; ?>
13
+ </script>
14
+ </amp-analytics>
tags/5.3.1.1/front/views/analytics-code.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Copyright 2017 Alin Marcu
5
+ * Author URI: https://deconf.com
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+ ?>
10
+
11
+ <?php if ( 0 == $data['ga_with_gtag'] ):?>
12
+ <!-- BEGIN GADWP v<?php echo GADWP_CURRENT_VERSION; ?> Universal Analytics - https://deconf.com/google-analytics-dashboard-wordpress/ -->
13
+ <script>
14
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
15
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
16
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
17
+ })(window,document,'script','<?php echo $data['tracking_script_path']?>','ga');
18
+ <?php echo $data['trackingcode']?>
19
+ </script>
20
+ <!-- END GADWP Universal Analytics -->
21
+ <?php else:?>
22
+ <!-- BEGIN GADWP v<?php echo GADWP_CURRENT_VERSION; ?> Global Site Tag - https://deconf.com/google-analytics-dashboard-wordpress/ -->
23
+ <script async src="<?php echo $data['tracking_script_path']?>?id=<?php echo $data['uaid']?>"></script>
24
+ <script>
25
+ window.dataLayer = window.dataLayer || [];
26
+ function gtag(){dataLayer.push(arguments);}
27
+ gtag('js', new Date());
28
+ <?php echo $data['trackingcode']?>
29
+
30
+ if (window.performance) {
31
+ var timeSincePageLoad = Math.round(performance.now());
32
+ gtag('event', 'timing_complete', {
33
+ 'name': 'load',
34
+ 'value': timeSincePageLoad,
35
+ 'event_category': 'JS Dependencies'
36
+ });
37
+ }
38
+ </script>
39
+ <!-- END GADWP Global Site Tag -->
40
+ <?php endif;?>
tags/5.3.1.1/front/views/analytics-optout-code.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Copyright 2018 Alin Marcu
5
+ * Author URI: https://deconf.com
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+ ?>
10
+ <script>
11
+ var dnt = false;
12
+ var gaProperty = '<?php echo $data['uaid']?>';
13
+ var gaDntOptout = '<?php echo $data['gaDntOptout']?>';
14
+ var gaOptout = '<?php echo $data['gaOptout']?>';
15
+ var disableStr = 'ga-disable-' + gaProperty;
16
+ if(gaDntOptout && (window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1")) {
17
+ dnt = true;
18
+ }
19
+ if (dnt || (document.cookie.indexOf(disableStr + '=true') > -1 && gaOptout)) {
20
+ window[disableStr] = true;
21
+ }
22
+ function gaOptout() {
23
+ document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
24
+ window[disableStr] = true;
25
+ }
26
+ </script>
tags/5.3.1.1/front/views/optimize-code.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Copyright 2017 Alin Marcu
5
+ * Author URI: https://deconf.com
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+ ?>
10
+ <style>
11
+ .async-hide {
12
+ opacity: 0 !important
13
+ }
14
+ </style>
15
+ <script>
16
+ (function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
17
+ h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
18
+ (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
19
+ })(window,document.documentElement,'async-hide','dataLayer',4000,
20
+ {'<?php echo $data['containerid']; ?>':true});
21
+ </script>
tags/5.3.1.1/front/views/tagmanager-amp-code.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Copyright 2018 Alin Marcu
5
+ * Author URI: https://deconf.com
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+ ?>
10
+ <amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo $data['containerid']; ?>&gtm.url=SOURCE_URL" data-credentials="include">
11
+ <script type="application/json">
12
+ <?php echo $data['json']; ?>
13
+ </script>
14
+ </amp-analytics>
tags/5.3.1.1/front/views/tagmanager-code.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Copyright 2017 Alin Marcu
5
+ * Author URI: https://deconf.com
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+ ?>
10
+ <!-- BEGIN GADWP v<?php echo GADWP_CURRENT_VERSION; ?> Tag Manager - https://deconf.com/google-analytics-dashboard-wordpress/ -->
11
+ <script>
12
+ window.dataLayer = window.dataLayer || [];
13
+ window.dataLayer.push(<?php echo $data['vars']; ?>);
14
+ </script>
15
+
16
+ <script>
17
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
18
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
19
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
20
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
21
+ })(window,document,'script','dataLayer','<?php echo $data['containerid']; ?>');
22
+ </script>
23
+ <!-- END GADWP Tag Manager -->
24
+
tags/5.3.1.1/front/widgets.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ final class GADWP_Frontend_Widget extends WP_Widget {
15
+
16
+ private $gadwp;
17
+
18
+ public function __construct() {
19
+ $this->gadwp = GADWP();
20
+
21
+ parent::__construct( 'gadwp-frontwidget-report', __( 'Google Analytics Dashboard', 'google-analytics-dashboard-for-wp' ), array( 'description' => __( "Will display your google analytics stats in a widget", 'google-analytics-dashboard-for-wp' ) ) );
22
+ // Frontend Styles
23
+ if ( is_active_widget( false, false, $this->id_base, true ) ) {
24
+ add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
25
+ }
26
+ }
27
+
28
+ public function load_styles_scripts() {
29
+ $lang = get_bloginfo( 'language' );
30
+ $lang = explode( '-', $lang );
31
+ $lang = $lang[0];
32
+
33
+ wp_enqueue_style( 'gadwp-front-widget', GADWP_URL . 'front/css/widgets.css', null, GADWP_CURRENT_VERSION );
34
+ wp_enqueue_script( 'gadwp-front-widget', GADWP_URL . 'front/js/widgets.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
35
+ wp_enqueue_script( 'googlecharts', 'https://www.gstatic.com/charts/loader.js', array(), null );
36
+ }
37
+
38
+ public function widget( $args, $instance ) {
39
+ $widget_title = apply_filters( 'widget_title', $instance['title'] );
40
+ $title = __( "Sessions", 'google-analytics-dashboard-for-wp' );
41
+ echo "\n<!-- BEGIN GADWP v" . GADWP_CURRENT_VERSION . " Widget - https://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
42
+ echo $args['before_widget'];
43
+ if ( ! empty( $widget_title ) ) {
44
+ echo $args['before_title'] . $widget_title . $args['after_title'];
45
+ }
46
+
47
+ if ( isset( $this->gadwp->config->options['theme_color'] ) ) {
48
+ $css = "colors:['" . $this->gadwp->config->options['theme_color'] . "','" . GADWP_Tools::colourVariator( $this->gadwp->config->options['theme_color'], - 20 ) . "'],";
49
+ $color = $this->gadwp->config->options['theme_color'];
50
+ } else {
51
+ $css = "";
52
+ $color = "#3366CC";
53
+ }
54
+ ob_start();
55
+ if ( $instance['anonim'] ) {
56
+ $formater = "var formatter = new google.visualization.NumberFormat({
57
+ suffix: '%',
58
+ fractionDigits: 2
59
+ });
60
+
61
+ formatter.format(data, 1);";
62
+ } else {
63
+ $formater = '';
64
+ }
65
+ $periodtext = "";
66
+ switch ( $instance['period'] ) {
67
+ case '7daysAgo' :
68
+ $periodtext = sprintf( __( 'Last %d Days', 'google-analytics-dashboard-for-wp' ), 7 );
69
+ break;
70
+ case '14daysAgo' :
71
+ $periodtext = sprintf( __( 'Last %d Days', 'google-analytics-dashboard-for-wp' ), 14 );
72
+ break;
73
+ case '30daysAgo' :
74
+ $periodtext = sprintf( __( 'Last %d Days', 'google-analytics-dashboard-for-wp' ), 30 );
75
+ break;
76
+ default :
77
+ $periodtext = "";
78
+ break;
79
+ }
80
+ switch ( $instance['display'] ) {
81
+ case '1' :
82
+ echo '<div id="gadwp-widget"><div id="gadwp-widgetchart"></div><div id="gadwp-widgettotals"></div></div>';
83
+ break;
84
+ case '2' :
85
+ echo '<div id="gadwp-widget"><div id="gadwp-widgetchart"></div></div>';
86
+ break;
87
+ case '3' :
88
+ echo '<div id="gadwp-widget"><div id="gadwp-widgettotals"></div></div>';
89
+ break;
90
+ }
91
+ ?>
92
+ <script type="text/javascript">
93
+ google.charts.load('current', {'packages':['corechart']});
94
+ google.charts.setOnLoadCallback( GADWPWidgetLoad );
95
+ function GADWPWidgetLoad (){
96
+ jQuery.post("<?php echo admin_url( 'admin-ajax.php' ); ?>", {action: "ajax_frontwidget_report", gadwp_number: "<?php echo $this->number; ?>", gadwp_optionname: "<?php echo $this->option_name; ?>" }, function(response){
97
+ if (!jQuery.isNumeric(response) && jQuery.isArray(response)){
98
+ if (jQuery("#gadwp-widgetchart")[0]){
99
+ gadwpFrontWidgetData = response[0];
100
+ gadwp_drawFrontWidgetChart(gadwpFrontWidgetData);
101
+ }
102
+ if (jQuery("#gadwp-widgettotals")[0]){
103
+ gadwp_drawFrontWidgetTotals(response[1]);
104
+ }
105
+ }else{
106
+ jQuery("#gadwp-widgetchart").css({"background-color":"#F7F7F7","height":"auto","padding-top":"50px","padding-bottom":"50px","color":"#000","text-align":"center"});
107
+ jQuery("#gadwp-widgetchart").html("<?php __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ); ?> ("+response+")");
108
+ }
109
+ });
110
+ }
111
+ function gadwp_drawFrontWidgetChart(response) {
112
+ var data = google.visualization.arrayToDataTable(response);
113
+ var options = {
114
+ legend: { position: "none" },
115
+ pointSize: "3",
116
+ <?php echo $css; ?>
117
+ title: "<?php echo $title; ?>",
118
+ titlePosition: "in",
119
+ chartArea: { width: "95%", height: "75%" },
120
+ hAxis: { textPosition: "none"},
121
+ vAxis: { textPosition: "none", minValue: 0, gridlines: { color: "transparent" }, baselineColor: "transparent"}
122
+ }
123
+ var chart = new google.visualization.AreaChart(document.getElementById("gadwp-widgetchart"));
124
+ <?php echo $formater; ?>
125
+ chart.draw(data, options);
126
+ }
127
+ function gadwp_drawFrontWidgetTotals(response) {
128
+ if ( null == response ){
129
+ response = 0;
130
+ }
131
+ jQuery("#gadwp-widgettotals").html('<div class="gadwp-left"><?php _e( "Period:", 'google-analytics-dashboard-for-wp' ); ?></div> <div class="gadwp-right"><?php echo $periodtext; ?> </div><div class="gadwp-left"><?php _e( "Sessions:", 'google-analytics-dashboard-for-wp' ); ?></div> <div class="gadwp-right">'+response+'</div>');
132
+ }
133
+ </script>
134
+ <?php
135
+ if ( 1 == $instance['give_credits'] ) :
136
+ ?>
137
+ <div style="text-align: right; width: 100%; font-size: 0.8em; clear: both; margin-right: 5px;"><?php _e( 'generated by', 'google-analytics-dashboard-for-wp' ); ?> <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=front_widget&utm_campaign=gadwp" rel="nofollow" style="text-decoration: none; font-size: 1em;">GADWP</a>&nbsp;
138
+ </div>
139
+
140
+ <?php
141
+ endif;
142
+ $widget_content = ob_get_contents();
143
+ if ( ob_get_length() ) {
144
+ ob_end_clean();
145
+ }
146
+ echo $widget_content;
147
+ echo $args['after_widget'];
148
+ echo "\n<!-- END GADWP Widget -->\n";
149
+ }
150
+
151
+ public function form( $instance ) {
152
+ $widget_title = ( isset( $instance['title'] ) ? $instance['title'] : __( "Google Analytics Stats", 'google-analytics-dashboard-for-wp' ) );
153
+ $period = ( isset( $instance['period'] ) ? $instance['period'] : '7daysAgo' );
154
+ $display = ( isset( $instance['display'] ) ? $instance['display'] : 1 );
155
+ $give_credits = ( isset( $instance['give_credits'] ) ? $instance['give_credits'] : 1 );
156
+ $anonim = ( isset( $instance['anonim'] ) ? $instance['anonim'] : 0 );
157
+ /* @formatter:off */
158
+ ?>
159
+ <p>
160
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( "Title:",'google-analytics-dashboard-for-wp' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $widget_title ); ?>">
161
+ </p>
162
+ <p>
163
+ <label for="<?php echo $this->get_field_id( 'display' ); ?>"><?php _e( "Display:",'google-analytics-dashboard-for-wp' ); ?></label> <select id="<?php echo $this->get_field_id('display'); ?>" class="widefat" name="<?php echo $this->get_field_name( 'display' ); ?>">
164
+ <option value="1" <?php selected( $display, 1 ); ?>><?php _e('Chart & Totals', 'google-analytics-dashboard-for-wp');?></option>
165
+ <option value="2" <?php selected( $display, 2 ); ?>><?php _e('Chart', 'google-analytics-dashboard-for-wp');?></option>
166
+ <option value="3" <?php selected( $display, 3 ); ?>><?php _e('Totals', 'google-analytics-dashboard-for-wp');?></option>
167
+ </select>
168
+ </p>
169
+ <p>
170
+ <label for="<?php echo $this->get_field_id( 'anonim' ); ?>"><?php _e( "Anonymize stats:",'google-analytics-dashboard-for-wp' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'anonim' ); ?>" name="<?php echo $this->get_field_name( 'anonim' ); ?>" type="checkbox" <?php checked( $anonim, 1 ); ?> value="1">
171
+ </p>
172
+ <p>
173
+ <label for="<?php echo $this->get_field_id( 'period' ); ?>"><?php _e( "Stats for:",'google-analytics-dashboard-for-wp' ); ?></label> <select id="<?php echo $this->get_field_id('period'); ?>" class="widefat" name="<?php echo $this->get_field_name( 'period' ); ?>">
174
+ <option value="7daysAgo" <?php selected( $period, '7daysAgo' ); ?>><?php printf( __('Last %d Days', 'google-analytics-dashboard-for-wp'), 7 );?></option>
175
+ <option value="14daysAgo" <?php selected( $period, '14daysAgo' ); ?>><?php printf( __('Last %d Days', 'google-analytics-dashboard-for-wp'), 14 );?></option>
176
+ <option value="30daysAgo" <?php selected( $period, '30daysAgo' ); ?>><?php printf( __('Last %d Days', 'google-analytics-dashboard-for-wp'), 30 );?></option>
177
+ </select>
178
+ </p>
179
+ <p>
180
+ <label for="<?php echo $this->get_field_id( 'give_credits' ); ?>"><?php _e( "Give credits:",'google-analytics-dashboard-for-wp' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'give_credits' ); ?>" name="<?php echo $this->get_field_name( 'give_credits' ); ?>" type="checkbox" <?php checked( $give_credits, 1 ); ?> value="1">
181
+ </p>
182
+ <?php
183
+ /* @formatter:on */
184
+ }
185
+
186
+ public function update( $new_instance, $old_instance ) {
187
+ $instance = array();
188
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : 'Analytics Stats';
189
+ $instance['period'] = ( ! empty( $new_instance['period'] ) ) ? strip_tags( $new_instance['period'] ) : '7daysAgo';
190
+ $instance['display'] = ( ! empty( $new_instance['display'] ) ) ? strip_tags( $new_instance['display'] ) : 1;
191
+ $instance['give_credits'] = ( ! empty( $new_instance['give_credits'] ) ) ? strip_tags( $new_instance['give_credits'] ) : 0;
192
+ $instance['anonim'] = ( ! empty( $new_instance['anonim'] ) ) ? strip_tags( $new_instance['anonim'] ) : 0;
193
+ return $instance;
194
+ }
195
+ }
tags/5.3.1.1/gadwp.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Google Analytics Dashboard for WP (GADWP)
4
+ * Plugin URI: https://deconf.com
5
+ * Description: Displays Google Analytics Reports and Real-Time Statistics in your Dashboard. Automatically inserts the tracking code in every page of your website.
6
+ * Author: Alin Marcu
7
+ * Version: 5.3.1.1
8
+ * Author URI: https://deconf.com
9
+ * Text Domain: google-analytics-dashboard-for-wp
10
+ * Domain Path: /languages
11
+ */
12
+
13
+ // Exit if accessed directly
14
+ if ( ! defined( 'ABSPATH' ) )
15
+ exit();
16
+
17
+ // Plugin Version
18
+ if ( ! defined( 'GADWP_CURRENT_VERSION' ) ) {
19
+ define( 'GADWP_CURRENT_VERSION', '5.3.1.1' );
20
+ }
21
+
22
+ if ( ! defined( 'GADWP_ENDPOINT_URL' ) ) {
23
+ define( 'GADWP_ENDPOINT_URL', 'https://gadwp.deconf.com/' );
24
+ }
25
+
26
+
27
+ if ( ! class_exists( 'GADWP_Manager' ) ) {
28
+
29
+ final class GADWP_Manager {
30
+
31
+ private static $instance = null;
32
+
33
+ public $config = null;
34
+
35
+ public $frontend_actions = null;
36
+
37
+ public $common_actions = null;
38
+
39
+ public $backend_actions = null;
40
+
41
+ public $tracking = null;
42
+
43
+ public $frontend_item_reports = null;
44
+
45
+ public $backend_setup = null;
46
+
47
+ public $frontend_setup = null;
48
+
49
+ public $backend_widgets = null;
50
+
51
+ public $backend_item_reports = null;
52
+
53
+ public $gapi_controller = null;
54
+
55
+ /**
56
+ * Construct forbidden
57
+ */
58
+ private function __construct() {
59
+ if ( null !== self::$instance ) {
60
+ _doing_it_wrong( __FUNCTION__, __( "This is not allowed, read the documentation!", 'google-analytics-dashboard-for-wp' ), '4.6' );
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Clone warning
66
+ */
67
+ private function __clone() {
68
+ _doing_it_wrong( __FUNCTION__, __( "This is not allowed, read the documentation!", 'google-analytics-dashboard-for-wp' ), '4.6' );
69
+ }
70
+
71
+ /**
72
+ * Wakeup warning
73
+ */
74
+ private function __wakeup() {
75
+ _doing_it_wrong( __FUNCTION__, __( "This is not allowed, read the documentation!", 'google-analytics-dashboard-for-wp' ), '4.6' );
76
+ }
77
+
78
+ /**
79
+ * Creates a single instance for GADWP and makes sure only one instance is present in memory.
80
+ *
81
+ * @return GADWP_Manager
82
+ */
83
+ public static function instance() {
84
+ if ( null === self::$instance ) {
85
+ self::$instance = new self();
86
+ self::$instance->setup();
87
+ self::$instance->config = new GADWP_Config();
88
+ }
89
+ return self::$instance;
90
+ }
91
+
92
+ /**
93
+ * Defines constants and loads required resources
94
+ */
95
+ private function setup() {
96
+
97
+ // Plugin Path
98
+ if ( ! defined( 'GADWP_DIR' ) ) {
99
+ define( 'GADWP_DIR', plugin_dir_path( __FILE__ ) );
100
+ }
101
+
102
+ // Plugin URL
103
+ if ( ! defined( 'GADWP_URL' ) ) {
104
+ define( 'GADWP_URL', plugin_dir_url( __FILE__ ) );
105
+ }
106
+
107
+ // Plugin main File
108
+ if ( ! defined( 'GADWP_FILE' ) ) {
109
+ define( 'GADWP_FILE', __FILE__ );
110
+ }
111
+
112
+ /*
113
+ * Load Tools class
114
+ */
115
+ include_once ( GADWP_DIR . 'tools/tools.php' );
116
+
117
+ /*
118
+ * Load Config class
119
+ */
120
+ include_once ( GADWP_DIR . 'config.php' );
121
+
122
+ /*
123
+ * Load GAPI Controller class
124
+ */
125
+ include_once ( GADWP_DIR . 'tools/gapi.php' );
126
+
127
+ /*
128
+ * Plugin i18n
129
+ */
130
+ add_action( 'init', array( self::$instance, 'load_i18n' ) );
131
+
132
+ /*
133
+ * Plugin Init
134
+ */
135
+ add_action( 'init', array( self::$instance, 'load' ) );
136
+
137
+ /*
138
+ * Include Install
139
+ */
140
+ include_once ( GADWP_DIR . 'install/install.php' );
141
+ register_activation_hook( GADWP_FILE, array( 'GADWP_Install', 'install' ) );
142
+
143
+ /*
144
+ * Include Uninstall
145
+ */
146
+ include_once ( GADWP_DIR . 'install/uninstall.php' );
147
+ register_uninstall_hook( GADWP_FILE, array( 'GADWP_Uninstall', 'uninstall' ) );
148
+
149
+ /*
150
+ * Load Frontend Widgets
151
+ * (needed during ajax)
152
+ */
153
+ include_once ( GADWP_DIR . 'front/widgets.php' );
154
+
155
+ /*
156
+ * Add Frontend Widgets
157
+ * (needed during ajax)
158
+ */
159
+ add_action( 'widgets_init', array( self::$instance, 'add_frontend_widget' ) );
160
+ }
161
+
162
+ /**
163
+ * Load i18n
164
+ */
165
+ public function load_i18n() {
166
+ load_plugin_textdomain( 'google-analytics-dashboard-for-wp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
167
+ }
168
+
169
+ /**
170
+ * Register Frontend Widgets
171
+ */
172
+ public function add_frontend_widget() {
173
+ register_widget( 'GADWP_Frontend_Widget' );
174
+ }
175
+
176
+ /**
177
+ * Conditional load
178
+ */
179
+ public function load() {
180
+ if ( is_admin() ) {
181
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
182
+ if ( GADWP_Tools::check_roles( self::$instance->config->options['access_back'] ) ) {
183
+ /*
184
+ * Load Backend ajax actions
185
+ */
186
+ include_once ( GADWP_DIR . 'admin/ajax-actions.php' );
187
+ self::$instance->backend_actions = new GADWP_Backend_Ajax();
188
+ }
189
+
190
+ /*
191
+ * Load Frontend ajax actions
192
+ */
193
+ include_once ( GADWP_DIR . 'front/ajax-actions.php' );
194
+ self::$instance->frontend_actions = new GADWP_Frontend_Ajax();
195
+
196
+ /*
197
+ * Load Common ajax actions
198
+ */
199
+ include_once ( GADWP_DIR . 'common/ajax-actions.php' );
200
+ self::$instance->common_actions = new GADWP_Common_Ajax();
201
+
202
+ if ( self::$instance->config->options['backend_item_reports'] ) {
203
+ /*
204
+ * Load Backend Item Reports for Quick Edit
205
+ */
206
+ include_once ( GADWP_DIR . 'admin/item-reports.php' );
207
+ self::$instance->backend_item_reports = new GADWP_Backend_Item_Reports();
208
+ }
209
+ } else if ( GADWP_Tools::check_roles( self::$instance->config->options['access_back'] ) ) {
210
+
211
+ /*
212
+ * Load Backend Setup
213
+ */
214
+ include_once ( GADWP_DIR . 'admin/setup.php' );
215
+ self::$instance->backend_setup = new GADWP_Backend_Setup();
216
+
217
+ if ( self::$instance->config->options['dashboard_widget'] ) {
218
+ /*
219
+ * Load Backend Widget
220
+ */
221
+ include_once ( GADWP_DIR . 'admin/widgets.php' );
222
+ self::$instance->backend_widgets = new GADWP_Backend_Widgets();
223
+ }
224
+
225
+ if ( self::$instance->config->options['backend_item_reports'] ) {
226
+ /*
227
+ * Load Backend Item Reports
228
+ */
229
+ include_once ( GADWP_DIR . 'admin/item-reports.php' );
230
+ self::$instance->backend_item_reports = new GADWP_Backend_Item_Reports();
231
+ }
232
+ }
233
+ } else {
234
+ if ( GADWP_Tools::check_roles( self::$instance->config->options['access_front'] ) ) {
235
+ /*
236
+ * Load Frontend Setup
237
+ */
238
+ include_once ( GADWP_DIR . 'front/setup.php' );
239
+ self::$instance->frontend_setup = new GADWP_Frontend_Setup();
240
+
241
+ if ( self::$instance->config->options['frontend_item_reports'] ) {
242
+ /*
243
+ * Load Frontend Item Reports
244
+ */
245
+ include_once ( GADWP_DIR . 'front/item-reports.php' );
246
+ self::$instance->frontend_item_reports = new GADWP_Frontend_Item_Reports();
247
+ }
248
+ }
249
+
250
+ if ( ! GADWP_Tools::check_roles( self::$instance->config->options['track_exclude'], true ) && 'disabled' != self::$instance->config->options['tracking_type'] ) {
251
+ /*
252
+ * Load tracking class
253
+ */
254
+ include_once ( GADWP_DIR . 'front/tracking.php' );
255
+ self::$instance->tracking = new GADWP_Tracking();
256
+ }
257
+ }
258
+ }
259
+ }
260
+ }
261
+
262
+ /**
263
+ * Returns a unique instance of GADWP
264
+ */
265
+ function GADWP() {
266
+ return GADWP_Manager::instance();
267
+ }
268
+
269
+ /*
270
+ * Start GADWP
271
+ */
272
+ GADWP();
tags/5.3.1.1/install/install.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ class GADWP_Install {
15
+
16
+ public static function install() {
17
+ if ( ! get_option( 'ga_dash_token' ) ) {
18
+ $options = array();
19
+ $options['client_id'] = '';
20
+ $options['client_secret'] = '';
21
+ $options['access_front'][] = 'administrator';
22
+ $options['access_back'][] = 'administrator';
23
+ $options['tableid_jail'] = '';
24
+ $options['theme_color'] = '#1e73be';
25
+ $options['switch_profile'] = 0;
26
+ $options['tracking_type'] = 'universal';
27
+ $options['ga_anonymize_ip'] = 0;
28
+ $options['user_api'] = 0;
29
+ $options['ga_event_tracking'] = 0;
30
+ $options['ga_event_downloads'] = 'zip|mp3*|mpe*g|pdf|docx*|pptx*|xlsx*|rar*';
31
+ $options['track_exclude'] = array();
32
+ $options['ga_target_geomap'] = '';
33
+ $options['ga_realtime_pages'] = 10;
34
+ $options['token'] = '';
35
+ $options['ga_profiles_list'] = array();
36
+ $options['ga_tracking_code'] = '';
37
+ $options['ga_enhanced_links'] = 0;
38
+ $options['ga_remarketing'] = 0;
39
+ $options['network_mode'] = 0;
40
+ $options['ga_speed_samplerate'] = 1;
41
+ $options['ga_user_samplerate'] = 100;
42
+ $options['ga_event_bouncerate'] = 0;
43
+ $options['ga_crossdomain_tracking'] = 0;
44
+ $options['ga_crossdomain_list'] = '';
45
+ $options['ga_author_dimindex'] = 0;
46
+ $options['ga_category_dimindex'] = 0;
47
+ $options['ga_tag_dimindex'] = 0;
48
+ $options['ga_user_dimindex'] = 0;
49
+ $options['ga_pubyear_dimindex'] = 0;
50
+ $options['ga_pubyearmonth_dimindex'] = 0;
51
+ $options['ga_aff_tracking'] = 0;
52
+ $options['ga_event_affiliates'] = '/out/';
53
+ $options['automatic_updates_minorversion'] = 1;
54
+ $options['backend_item_reports'] = 1;
55
+ $options['backend_realtime_report'] = 0;
56
+ $options['frontend_item_reports'] = 0;
57
+ $options['dashboard_widget'] = 1;
58
+ $options['api_backoff'] = 0;
59
+ $options['ga_cookiedomain'] = '';
60
+ $options['ga_cookiename'] = '';
61
+ $options['ga_cookieexpires'] = '';
62
+ $options['pagetitle_404'] = 'Page Not Found';
63
+ $options['maps_api_key'] = '';
64
+ $options['tm_author_var'] = 0;
65
+ $options['tm_category_var'] = 0;
66
+ $options['tm_tag_var'] = 0;
67
+ $options['tm_user_var'] = 0;
68
+ $options['tm_pubyear_var'] = 0;
69
+ $options['tm_pubyearmonth_var'] = 0;
70
+ $options['web_containerid'] = '';
71
+ $options['amp_containerid'] = '';
72
+ $options['amp_tracking_tagmanager'] = 0;
73
+ $options['amp_tracking_analytics'] = 0;
74
+ $options['amp_tracking_clientidapi'] = 0;
75
+ $options['trackingcode_infooter'] = 0;
76
+ $options['trackingevents_infooter'] = 0;
77
+ $options['ecommerce_mode'] = 'disabled';
78
+ $options['ga_formsubmit_tracking'] = 0;
79
+ $options['optimize_tracking'] = 0;
80
+ $options['optimize_containerid'] = '';
81
+ $options['optimize_pagehiding'] = '';
82
+ $options['superadmin_tracking'] = 0;
83
+ $options['ga_pagescrolldepth_tracking'] = 0;
84
+ $options['tm_pagescrolldepth_tracking'] = 0;
85
+ $options['ga_event_precision'] = 0;
86
+ $options['ga_force_ssl'] = 0;
87
+ $options['with_endpoint'] = 1;
88
+ $options['ga_optout'] = 0;
89
+ $options['ga_dnt_optout'] = 0;
90
+ $options['ga_with_gtag'] = 0;
91
+ } else {
92
+ $options = array();
93
+ $options['client_id'] = get_option( 'ga_dash_clientid' );
94
+ $options['client_secret'] = get_option( 'ga_dash_clientsecret' );
95
+ $options['access_front'][] = 'administrator';
96
+ $options['access_back'][] = 'administrator';
97
+ $options['tableid_jail'] = get_option( 'ga_dash_tableid_jail' );
98
+ $options['frontend_item_reports'] = get_option( 'ga_dash_frontend' );
99
+ $options['theme_color'] = '#1e73be';
100
+ $options['switch_profile'] = get_option( 'ga_dash_jailadmins' );
101
+ $options['tracking_type'] = get_option( 'ga_dash_tracking_type' );
102
+ $options['ga_anonymize_ip'] = get_option( 'ga_dash_anonim' );
103
+ $options['user_api'] = get_option( 'ga_dash_userapi' );
104
+ $options['ga_event_tracking'] = get_option( 'ga_event_tracking' );
105
+ $options['ga_event_downloads'] = get_option( 'ga_event_downloads' );
106
+ $options['track_exclude'] = array();
107
+ $options['ga_target_geomap'] = get_option( 'ga_target_geomap' );
108
+ $options['ga_realtime_pages'] = get_option( 'ga_realtime_pages' );
109
+ $options['token'] = get_option( 'ga_dash_token' );
110
+ $options['ga_profiles_list'] = get_option( 'ga_dash_profile_list' );
111
+ $options['ga_enhanced_links'] = 0;
112
+ $options['ga_remarketing'] = 0;
113
+ $options['network_mode'] = 0;
114
+ $options['ga_event_bouncerate'] = 0;
115
+ $options['ga_crossdomain_tracking'] = 0;
116
+ $options['ga_crossdomain_list'] = '';
117
+ $options['ga_author_dimindex'] = 0;
118
+ $options['ga_category_dimindex'] = 0;
119
+ $options['ga_tag_dimindex'] = 0;
120
+ $options['ga_user_dimindex'] = 0;
121
+ $options['ga_pubyear_dimindex'] = 0;
122
+ $options['ga_pubyearmonth_dimindex'] = 0;
123
+ $options['ga_event_affiliates'] = '/out/';
124
+ $options['ga_aff_tracking'] = 0;
125
+ $options['automatic_updates_minorversion'] = 1;
126
+ $options['backend_item_reports'] = 1;
127
+ $options['backend_realtime_report'] = 0;
128
+ $options['dashboard_widget'] = 1;
129
+ $options['api_backoff'] = 0;
130
+ $options['ga_cookiedomain'] = '';
131
+ $options['ga_cookiename'] = '';
132
+ $options['ga_cookieexpires'] = '';
133
+ $options['pagetitle_404'] = 'Page Not Found';
134
+ $options['maps_api_key'] = '';
135
+ $options['tm_author_var'] = 0;
136
+ $options['tm_category_var'] = 0;
137
+ $options['tm_tag_var'] = 0;
138
+ $options['tm_user_var'] = 0;
139
+ $options['tm_pubyear_var'] = 0;
140
+ $options['tm_pubyearmonth_var'] = 0;
141
+ $options['web_containerid'] = '';
142
+ $options['amp_containerid'] = '';
143
+ $options['amp_tracking_tagmanager'] = 0;
144
+ $options['amp_tracking_analytics'] = 0;
145
+ $options['amp_tracking_clientidapi'] = 0;
146
+ $options['trackingcode_infooter'] = 0;
147
+ $options['trackingevents_infooter'] = 0;
148
+ $options['ecommerce_mode'] = 'disabled';
149
+ $options['ga_formsubmit_tracking'] = 0;
150
+ $options['optimize_tracking'] = 0;
151
+ $options['optimize_containerid'] = '';
152
+ $options['optimize_pagehiding'] = '';
153
+ $options['superadmin_tracking'] = 0;
154
+ $options['ga_pagescrolldepth_tracking'] = 0;
155
+ $options['tm_pagescrolldepth_tracking'] = 0;
156
+ $options['ga_speed_samplerate'] = 1;
157
+ $options['ga_user_samplerate'] = 100;
158
+ $options['ga_event_precision'] = 0;
159
+ $options['ga_force_ssl'] = 0;
160
+ $options['with_endpoint'] = 1;
161
+ $options['ga_optout'] = 0;
162
+ $options['ga_dnt_optout'] = 0;
163
+ $options['ga_with_gtag'] = 0;
164
+
165
+ delete_option( 'ga_dash_clientid' );
166
+ delete_option( 'ga_dash_clientsecret' );
167
+ delete_option( 'ga_dash_access' );
168
+ delete_option( 'ga_dash_access_front' );
169
+ delete_option( 'ga_dash_access_back' );
170
+ delete_option( 'ga_dash_tableid_jail' );
171
+ delete_option( 'ga_dash_frontend' );
172
+ delete_option( 'ga_dash_style' );
173
+ delete_option( 'ga_dash_jailadmins' );
174
+
175
+ delete_option( 'ga_dash_tracking' );
176
+ delete_option( 'ga_dash_tracking_type' );
177
+ delete_option( 'ga_dash_anonim' );
178
+ delete_option( 'ga_dash_userapi' );
179
+ delete_option( 'ga_event_tracking' );
180
+ delete_option( 'ga_event_downloads' );
181
+ delete_option( 'track_exclude' );
182
+ delete_option( 'ga_target_geomap' );
183
+ delete_option( 'ga_realtime_pages' );
184
+ delete_option( 'ga_dash_token' );
185
+ delete_option( 'ga_dash_refresh_token' );
186
+ delete_option( 'ga_dash_profile_list' );
187
+ }
188
+ add_option( 'gadwp_options', json_encode( $options ) );
189
+ }
190
+ }
tags/5.3.1.1/install/uninstall.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ class GADWP_Uninstall {
15
+
16
+ public static function uninstall() {
17
+ global $wpdb;
18
+ if ( is_multisite() ) { // Cleanup Network install
19
+ foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
20
+ switch_to_blog( $blog['blog_id'] );
21
+ $sqlquery = $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'gadwp_cache_%%'" );
22
+ delete_option( 'gadwp_options' );
23
+ restore_current_blog();
24
+ }
25
+ delete_site_option( 'gadwp_network_options' );
26
+ } else { // Cleanup Single install
27
+ $sqlquery = $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'gadwp_cache_%%'" );
28
+ delete_option( 'gadwp_options' );
29
+ }
30
+ GADWP_Tools::unset_cookie( 'default_metric' );
31
+ GADWP_Tools::unset_cookie( 'default_dimension' );
32
+ GADWP_Tools::unset_cookie( 'default_view' );
33
+ }
34
+ }
tags/5.3.1.1/readme.txt ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Google Analytics Dashboard for WP (GADWP) ===
2
+ Contributors: deconf
3
+ Donate link: https://deconf.com/donate/
4
+ Tags: analytics,google analytics,google analytics dashboard,google analytics plugin,google analytics widget
5
+ Requires at least: 3.5
6
+ Tested up to: 4.9.4
7
+ Stable tag: 5.3.1.1
8
+ Requires PHP: 5.2.4
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ Connects Google Analytics with your WordPress site. Displays stats to help you understand your users and site content on a whole new level!
13
+
14
+ == Description ==
15
+ This Google Analytics for WordPress plugin enables you to track your site using the latest Google Analytics tracking code and allows you to view key Google Analytics stats in your WordPress install.
16
+
17
+ In addition to a set of general Google Analytics stats, in-depth Page reports and in-depth Post reports allow further segmentation of your analytics data, providing performance details for each post or page from your website.
18
+
19
+ The Google Analytics tracking code is fully customizable through options and hooks, allowing advanced data collection like custom dimensions and events.
20
+
21
+ = Google Analytics Real-Time Stats =
22
+
23
+ Google Analytics reports, in real-time, in your dashboard screen:
24
+
25
+ - Real-time number of visitors
26
+ - Real-time acquisition channels
27
+ - Real-time traffic sources details
28
+
29
+ = Google Analytics Reports =
30
+
31
+ The Google Analytics reports you need, on your dashboard, in your All Posts and All Pages screens, and on site's frontend:
32
+
33
+ - Sessions, organic searches, page views, bounce rate analytics stats
34
+ - Locations, pages, referrers, keywords, 404 errors analytics stats
35
+ - Traffic channels, social networks, traffic mediums, search engines analytics stats
36
+ - Device categories, browsers, operating systems, screen resolutions, mobile brands analytics stats
37
+
38
+ In addition, you can control who can view specific Google Analytics reports by setting permissions based on user roles.
39
+
40
+ = Google Analytics Tracking =
41
+
42
+ Installs the latest Google Analytics tracking code and allows full code customization:
43
+
44
+ - Universal Google Analytics (analytics.js) tracking code
45
+ - Global Site Tag (gtag.js) tracking code
46
+ - Enhanced link attribution
47
+ - Remarketing, demographics and interests tracking
48
+ - Page Speed sampling rate control
49
+ - User sampling rate control
50
+ - Cross domain tracking
51
+ - Exclude user roles from tracking
52
+ - Accelerated Mobile Pages (AMP) support for Google Analytics
53
+ - Ecommerce support for Google Analytics
54
+
55
+ User privacy oriented features:
56
+
57
+ - IP address anonymization
58
+ - option to follow Do Not Track (DNT) sent by browsers
59
+ - support for user tracking opt-out
60
+
61
+ Google Analytics Dashboard for WP enables you to easily track events like:
62
+
63
+ - Downloads
64
+ - Emails
65
+ - Outbound links
66
+ - Affiliate links
67
+ - Fragment identifiers
68
+ - Telephone
69
+ - Page Scrolling Depth
70
+ - Custom event categories, actions and labels using annotated HTML elements
71
+
72
+ With Google Analytics Dashboard for WP you can use custom dimensions to track:
73
+
74
+ - Authors
75
+ - Publication year
76
+ - Publication month
77
+ - Categories
78
+ - Tags
79
+ - User engagement
80
+
81
+ Actions and filters are available for further Google Analytics tracking code customization.
82
+
83
+ = Google Tag Manager Tracking =
84
+
85
+ As an alternative to Google Analytics tracking code, you can use Google Tag Manager for tracking:
86
+
87
+ - Google Tag Manager code
88
+ - Data Layer variables: authors, publication year, publication month, categories, tags, user type
89
+ - Exclude user roles from tracking
90
+ - Accelerated Mobile Pages (AMP) support for Google Tag Manager
91
+
92
+ = Accelerated Mobile Pages (AMP) features =
93
+
94
+ - Google Tag Manager basic tracking
95
+ - Google Analytics basic tracking
96
+ - Automatically removes <em>amp/</em> from Google Analytics tracking page URL
97
+ - Scrolling depth tracking
98
+ - Custom dimensions tracking
99
+ - User sampling rate control
100
+ - Form submit tracking
101
+ - File downloads tracking
102
+ - Affiliate links tracking
103
+ - Hashmarks, outbound links, telephones and e-mails tracking
104
+ - Custom event categories, actions and labels using annotated HTML elements
105
+
106
+ = Google Analytics Dashboard for WP on Multisite =
107
+
108
+ This plugin is fully compatible with multisite network installs, allowing three setup modes:
109
+
110
+ - Mode 1: network activated using multiple Google Analytics accounts
111
+ - Mode 2: network activated using a single Google Analytics account
112
+ - Mode 3: network deactivated using multiple Google Analytics accounts
113
+
114
+ > <strong>Google Analytics Dashboard for WP on GitHub</strong><br>
115
+ > You can submit feature requests or bugs on [Google Analytics Dashboard for WP](https://github.com/deconf/Google-Analytics-Dashboard-for-WP) repository.
116
+
117
+ = Further reading =
118
+
119
+ * Homepage of [Google Analytics Dashboard for WP](https://deconf.com/google-analytics-dashboard-wordpress/)
120
+ * Other [WordPress Plugins](https://deconf.com/wordpress/) by same author
121
+ * [Google Analytics | Partners](https://www.google.com/analytics/partners/company/5127525902581760/gadp/5629499534213120/app/5707702298738688/listing/5639274879778816) Gallery
122
+
123
+ == Installation ==
124
+
125
+ 1. Upload the full google-analytics-dashboard-for-wp directory into your wp-content/plugins directory.
126
+ 2. In WordPress select Plugins from your sidebar menu and activate the Google Analytics Dashboard for WP plugin.
127
+ 3. Open the plugin configuration page, which is located under Google Analytics menu.
128
+ 4. Authorize the plugin to connect to Google Analytics using the Authorize Plugin button.
129
+ 5. Go back to the plugin configuration page, which is located under Google Analytics menu to update/set your settings.
130
+ 6. Go to Google Analytics -> Tracking Code to configure/enable/disable tracking.
131
+
132
+ == Frequently Asked Questions ==
133
+
134
+ = Do I have to insert the Google Analytics tracking code manually? =
135
+
136
+ No, once the plugin is authorized and a default domain is selected the Google Analytics tracking code is automatically inserted in all webpages.
137
+
138
+ = Some settings are missing in the video tutorial =
139
+
140
+ We are constantly improving Google Analytics Dashboard for WP, sometimes the video tutorial may be a little outdated.
141
+
142
+ = How can I suggest a new feature, contribute or report a bug? =
143
+
144
+ You can submit pull requests, feature requests and bug reports on [our GitHub repository](https://github.com/deconf/Google-Analytics-Dashboard-for-WP).
145
+
146
+ = Documentation, Tutorials and FAQ =
147
+
148
+ For documentation, tutorials, FAQ and videos check out: [Google Analytics Dashboard for WP documentation](https://deconf.com/google-analytics-dashboard-wordpress/).
149
+
150
+ == Screenshots ==
151
+
152
+ 1. Google Analytics Dashboard for WP Blue Color
153
+ 2. Google Analytics Dashboard for WP Real-Time
154
+ 3. Google Analytics Dashboard for WP reports per Posts/Pages
155
+ 4. Google Analytics Dashboard for WP Geo Map
156
+ 5. Google Analytics Dashboard for WP Top Pages, Top Referrers and Top Searches
157
+ 6. Google Analytics Dashboard for WP Traffic Overview
158
+ 7. Google Analytics Dashboard for WP statistics per page on Frontend
159
+ 8. Google Analytics Dashboard for WP cities on region map
160
+ 9. Google Analytics Dashboard for WP Widget
161
+
162
+ == Localization ==
163
+
164
+ You can translate Google Analytics Dashboard for WP on [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/google-analytics-dashboard-for-wp).
165
+
166
+ == License ==
167
+
168
+ Google Analytics Dashboard for WP it's released under the GPLv2, you can use it free of charge on your personal or commercial website.
169
+
170
+ == Upgrade Notice ==
171
+
172
+ == Changelog ==
173
+
174
+ [GADWP v5.3 release notes](https://deconf.com/adding-gtag-js-to-your-site/)
175
+
176
+ = 5.3.1.1 =
177
+ * Bug Fixes:
178
+ * avoid tracking issues by not clearing the profiles list on automatic token resets
179
+
180
+ = 5.3.1 =
181
+ * Bug Fixes:
182
+ * frontend_item_reports PHP notice when upgrading from a version lower than v4.8.0.1
183
+
184
+ = 5.3 =
185
+ * Enhancements:
186
+ * adds full support for Global Site Tag (gtag.js)
187
+ * remove Scroll Depth functionality, since this is now available as a trigger on Google Tag Manager
188
+ * adds custom dimensions support for AMP pages with Google Tag Manager tracking
189
+ * adds support for button submits
190
+ * Bug Fixes:
191
+ * form submit events were not following the non-interaction settings
192
+
193
+ = 5.2.3.1 =
194
+ * Bug Fixes:
195
+ * fixing a small reporting issue
196
+
197
+ = 5.2.3 =
198
+ * Enhancements:
199
+ * add Google Analytics user opt-out support
200
+ * add option to exclude tracking for users sending the <em>Do Not Track</em> header
201
+ * add System tab to Errors & Debug screen
202
+ * check to avoid using a redeemed access code
203
+ * Bug Fixes:
204
+ * remove a debugging message
205
+ * cURL options were overwritten during regular API calls
206
+
207
+ = 5.2.2 =
208
+ * Enhancements:
209
+ * more informative alerts and suggestions on the authorization screen
210
+ * disable autocomplete for the access code input field to avoid reuse of the same unique authorization code
211
+ * GADWP Endpoint improvements
212
+ * Error reporting improvements
213
+ * introducing the gadwp_maps_api_key filter
214
+ * Bug Fixes:
215
+ * use the theme color palette for the frontend widget
216
+
217
+ = 5.2.1 =
218
+ * Enhancements:
219
+ * avoid submitting empty error reports
220
+ * Bug Fixes:
221
+ * fixes a bug for custom PHP cURL options
222
+
223
+ = 5.2 =
224
+ * Enhancements:
225
+ * improvements on exponential backoff system
226
+ * introduces a new authentication method with endpoints
227
+ * multiple updates of plugin's options
228
+ * code cleanup
229
+ * improvements on error reporting system
230
+ * option to report errors to developer
231
+ * move the upgrade notice from the Dashboard to plugin's settings page
232
+ * enable PHP cURL proxy support using WordPress settings, props by [Joe Hobson](https://github.com/joehobson)
233
+ * hide unusable options based on plugin's settings
234
+ * Bug Fixes:
235
+ * some thrown errors were not displayed on Errors & Debug screen
236
+ * analytics icon disappears from post list after quick edit, props by [karex](https://github.com/karex)
237
+ * fix for inline SVG links, props by [Andrew Minion](https://github.com/macbookandrew)
238
+ * fixes a bug on affiliate events tracking
239
+
240
+ The full changelog is [available here](https://deconf.com/changelog-google-analytics-dashboard-for-wp/).
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_flat_75_ffffff_40x100.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_65_ffffff_1x400.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_75_dadada_1x400.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_glass_95_fef1ec_1x400.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_222222_256x240.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_2e83ff_256x240.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_454545_256x240.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_888888_256x240.png RENAMED
File without changes
{realtime → tags/5.3.1.1/realtime}/jquery/images/ui-icons_cd0a0a_256x240.png RENAMED
File without changes
tags/5.3.1.1/realtime/jquery/jquery.ui.tooltip.html.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ /*! jQuery UI - v1.9.2 - 2013-09-22
2
+ * http://jqueryui.com
3
+ * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */.ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}* html .ui-tooltip{background-image:none}body .ui-tooltip{border-width:2px}.ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}.ui-widget-content{border:1px solid #aaa;background:#fff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;color:#222}.ui-widget-content a{color:#222}.ui-widget-header{border:1px solid #aaa;background:#ccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;color:#222;font-weight:bold}.ui-widget-header a{color:#222}
{realtime → tags/5.3.1.1/realtime}/jquery/jquery.ui.tooltip.html.js RENAMED
File without changes
tags/5.3.1.1/tools/gapi.php ADDED
@@ -0,0 +1,961 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
15
+
16
+ final class GADWP_GAPI_Controller {
17
+
18
+ public $client;
19
+
20
+ public $service;
21
+
22
+ public $timeshift;
23
+
24
+ public $managequota;
25
+
26
+ private $gadwp;
27
+
28
+ private $access = array( '65556128672.apps.googleusercontent.com', 'Kc7888wgbc_JbeCmApbFjnYpwE' );
29
+
30
+ public function __construct() {
31
+ $this->gadwp = GADWP();
32
+
33
+ include_once ( GADWP_DIR . 'tools/src/Deconf/autoload.php' );
34
+ $config = new Deconf_Config();
35
+ $config->setCacheClass( 'Deconf_Cache_Null' );
36
+ if ( function_exists( 'curl_version' ) ) {
37
+ $curlversion = curl_version();
38
+ $curl_options = array();
39
+ if ( isset( $curlversion['version'] ) ) {
40
+ $rightversion = ( version_compare( PHP_VERSION, '5.3.0' ) >= 0 ) && version_compare( $curlversion['version'], '7.10.8' ) >= 0;
41
+ } else {
42
+ $rightversion = false;
43
+ }
44
+
45
+ if ( $rightversion && defined( 'GADWP_IP_VERSION' ) && GADWP_IP_VERSION ) {
46
+ $curl_options[CURLOPT_IPRESOLVE] = GADWP_IP_VERSION; // Force CURL_IPRESOLVE_V4 or CURL_IPRESOLVE_V6
47
+ }
48
+
49
+ // add Proxy server settings to curl, if defined
50
+ if ( defined( 'WP_PROXY_HOST' ) && defined( 'WP_PROXY_PORT' ) ) {
51
+ $curl_options[CURLOPT_PROXY] = WP_PROXY_HOST;
52
+ $curl_options[CURLOPT_PROXYPORT] = WP_PROXY_PORT;
53
+ }
54
+
55
+ if ( defined( 'WP_PROXY_USERNAME' ) && defined( 'WP_PROXY_PASSWORD' ) ) {
56
+ $curl_options[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
57
+ $curl_options[CURLOPT_PROXYUSERPWD] = WP_PROXY_USERNAME . ':' . WP_PROXY_PASSWORD;
58
+ }
59
+
60
+ $curl_options = apply_filters( 'gadwp_curl_options', $curl_options );
61
+ if ( ! empty( $curl_options ) ) {
62
+ $config->setClassConfig( 'Deconf_IO_Curl', 'options', $curl_options );
63
+ }
64
+ }
65
+ $this->client = new Deconf_Client( $config );
66
+ $this->client->setScopes( array( 'https://www.googleapis.com/auth/analytics.readonly' ) );
67
+ $this->client->setAccessType( 'offline' );
68
+ $this->client->setApplicationName( 'GADWP ' . GADWP_CURRENT_VERSION );
69
+ $this->client->setRedirectUri( 'urn:ietf:wg:oauth:2.0:oob' );
70
+ $this->managequota = 'u' . get_current_user_id() . 's' . get_current_blog_id();
71
+ $this->access = array_map( array( $this, 'map' ), $this->access );
72
+ if ( $this->gadwp->config->options['user_api'] ) {
73
+ $this->client->setClientId( $this->gadwp->config->options['client_id'] );
74
+ $this->client->setClientSecret( $this->gadwp->config->options['client_secret'] );
75
+ } else {
76
+ $this->client->setClientId( $this->access[0] );
77
+ $this->client->setClientSecret( $this->access[1] );
78
+ }
79
+
80
+ /**
81
+ * GADWP Endpoint support
82
+ */
83
+ add_action( 'gadwp_endpoint_support', array( $this, 'add_endpoint_support' ) );
84
+
85
+ $this->service = new Deconf_Service_Analytics( $this->client );
86
+ if ( $this->gadwp->config->options['token'] ) {
87
+ $token = $this->gadwp->config->options['token'];
88
+ if ( $token ) {
89
+ try {
90
+ $this->client->setAccessToken( $token );
91
+ if ( $this->client->isAccessTokenExpired() ) {
92
+ $refreshtoken = $this->client->getRefreshToken();
93
+ $this->client->refreshToken( $refreshtoken );
94
+ }
95
+ $this->gadwp->config->options['token'] = $this->client->getAccessToken();
96
+ } catch ( Deconf_IO_Exception $e ) {
97
+ $timeout = $this->get_timeouts( 'midnight' );
98
+ GADWP_Tools::set_error( $e, $timeout );
99
+ } catch ( Deconf_Service_Exception $e ) {
100
+ $timeout = $this->get_timeouts( 'midnight' );
101
+ GADWP_Tools::set_error( $e, $timeout );
102
+ $this->reset_token();
103
+ } catch ( Exception $e ) {
104
+ $timeout = $this->get_timeouts( 'midnight' );
105
+ GADWP_Tools::set_error( $e, $timeout );
106
+ $this->reset_token();
107
+ }
108
+ if ( is_multisite() && $this->gadwp->config->options['network_mode'] ) {
109
+ $this->gadwp->config->set_plugin_options( true );
110
+ } else {
111
+ $this->gadwp->config->set_plugin_options();
112
+ }
113
+ }
114
+ }
115
+ }
116
+
117
+ public function add_endpoint_support( $request ) {
118
+ if ( $this->gadwp->config->options['with_endpoint'] && ! $this->gadwp->config->options['user_api'] ) {
119
+
120
+ $url = $request->getUrl();
121
+
122
+ if ( in_array( $url, array( 'https://accounts.google.com/o/oauth2/token', 'https://accounts.google.com/o/oauth2/revoke' ) ) ) {
123
+ if ( get_class( $this->client->getIo() ) != 'Deconf_IO_Stream' ) {
124
+ $curl_old_options = $this->client->getClassConfig( 'Deconf_IO_Curl' );
125
+ $curl_options = $curl_old_options['options'];
126
+ $curl_options[CURLOPT_SSL_VERIFYPEER] = 0;
127
+ $this->client->setClassConfig( 'Deconf_IO_Curl', 'options', $curl_options );
128
+ } else {
129
+ add_filter( 'gadwp_endpoint_stream_options', array( $this, 'add_endpoint_stream_ssl' ), 10 );
130
+ }
131
+ } else {
132
+ if ( get_class( $this->client->getIo() ) != 'Deconf_IO_Stream' ) {
133
+ $curl_old_options = $this->client->getClassConfig( 'Deconf_IO_Curl' );
134
+ $curl_options = $curl_old_options['options'];
135
+ if ( isset( $curl_options[CURLOPT_SSL_VERIFYPEER] ) ) {
136
+ unset( $curl_options[CURLOPT_SSL_VERIFYPEER] );
137
+ if ( empty( $curl_options ) ) {
138
+ $this->client->setClassConfig( 'Deconf_IO_Curl', 'options', '' );
139
+ } else {
140
+ $this->client->setClassConfig( 'Deconf_IO_Curl', 'options', $curl_options );
141
+ }
142
+ }
143
+ }
144
+ }
145
+
146
+ $url = str_replace( 'https://accounts.google.com/o/oauth2/token', GADWP_ENDPOINT_URL . 'gadwp-token.php', $url );
147
+
148
+ $url = str_replace( 'https://accounts.google.com/o/oauth2/revoke', GADWP_ENDPOINT_URL . 'gadwp-revoke.php', $url );
149
+
150
+ $request->setUrl( $url );
151
+
152
+ if ( ! $request->getUserAgent() ) {
153
+ $request->setUserAgent( $this->client->getApplicationName() );
154
+ }
155
+ }
156
+ }
157
+
158
+ public function add_endpoint_stream_ssl( $requestSslContext ) {
159
+ return array( "verify_peer" => false );
160
+ }
161
+
162
+ /**
163
+ * Handles errors returned by GAPI Library
164
+ *
165
+ * @return boolean
166
+ */
167
+ public function gapi_errors_handler() {
168
+ $errors = GADWP_Tools::get_cache( 'gapi_errors' );
169
+
170
+ if ( false === $errors || ! isset( $errors[0] ) ) { // invalid error
171
+ return false;
172
+ }
173
+
174
+ if ( isset( $errors[1][0]['reason'] ) && ( 'invalidParameter' == $errors[1][0]['reason'] || 'badRequest' == $errors[1][0]['reason'] || 'invalidCredentials' == $errors[1][0]['reason'] || 'insufficientPermissions' == $errors[1][0]['reason'] || 'required' == $errors[1][0]['reason'] ) ) {
175
+ $this->reset_token();
176
+ return true;
177
+ }
178
+
179
+ /** Back-off system for subsequent requests - an Auth error generated after a Service request
180
+ * The native back-off system for Service requests is covered by the GAPI PHP Client
181
+ */
182
+ if ( isset( $errors[1][0]['reason'] ) && ( 'authError' == $errors[1][0]['reason'] ) ) {
183
+ if ( $this->gadwp->config->options['api_backoff'] <= 5 ) {
184
+ usleep( $this->gadwp->config->options['api_backoff'] * 1000000 + rand( 100000, 1000000 ) );
185
+ $this->gadwp->config->options['api_backoff'] = $this->gadwp->config->options['api_backoff'] + 1;
186
+ $this->gadwp->config->set_plugin_options();
187
+ return false;
188
+ } else {
189
+ return true;
190
+ }
191
+ }
192
+
193
+ if ( 500 == $errors[0] || 503 == $errors[0] || 400 == $errors[0] || 401 == $errors[0] || 403 == $errors[0] || $errors[0] < - 50 ) {
194
+ return true;
195
+ }
196
+
197
+ return false;
198
+ }
199
+
200
+ /**
201
+ * Calculates proper timeouts for each GAPI query
202
+ *
203
+ * @param
204
+ * $interval
205
+ * @return number
206
+ */
207
+ public function get_timeouts( $interval = '' ) {
208
+ $local_time = time() + $this->timeshift;
209
+ if ( 'daily' == $interval ) {
210
+ $nextday = explode( '-', date( 'n-j-Y', strtotime( ' +1 day', $local_time ) ) );
211
+ $midnight = mktime( 0, 0, 0, $nextday[0], $nextday[1], $nextday[2] );
212
+ return $midnight - $local_time;
213
+ } else if ( 'midnight' == $interval ) {
214
+ $midnight = strtotime( "tomorrow 00:00:00" ); // UTC midnight
215
+ $midnight = $midnight + 8 * 3600; // UTC 8 AM
216
+ return $midnight - time();
217
+ } else if ( 'hourly' == $interval ) {
218
+ $nexthour = explode( '-', date( 'H-n-j-Y', strtotime( ' +1 hour', $local_time ) ) );
219
+ $newhour = mktime( $nexthour[0], 0, 0, $nexthour[1], $nexthour[2], $nexthour[3] );
220
+ return $newhour - $local_time;
221
+ } else {
222
+ $newtime = strtotime( ' +5 minutes', $local_time );
223
+ return $newtime - $local_time;
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Generates and retrieves the Access Code
229
+ */
230
+ public function token_request() {
231
+ $data['authUrl'] = $this->client->createAuthUrl();
232
+ GADWP_Tools::load_view( 'admin/views/access-code.php', $data );
233
+ }
234
+
235
+ /**
236
+ * Retrieves all Google Analytics Views with details
237
+ *
238
+ * @return array
239
+ */
240
+ public function refresh_profiles() {
241
+ try {
242
+
243
+ $ga_profiles_list = array();
244
+ $startindex = 1;
245
+ $totalresults = 65535; // use something big
246
+
247
+ while ( $startindex < $totalresults ) {
248
+
249
+ $profiles = $this->service->management_profiles->listManagementProfiles( '~all', '~all', array( 'start-index' => $startindex ) );
250
+
251
+ $items = $profiles->getItems();
252
+
253
+ $totalresults = $profiles->getTotalResults();
254
+
255
+ if ( $totalresults > 0 ) {
256
+
257
+ foreach ( $items as $profile ) {
258
+ $timetz = new DateTimeZone( $profile->getTimezone() );
259
+ $localtime = new DateTime( 'now', $timetz );
260
+ $timeshift = strtotime( $localtime->format( 'Y-m-d H:i:s' ) ) - time();
261
+ $ga_profiles_list[] = array( $profile->getName(), $profile->getId(), $profile->getwebPropertyId(), $profile->getwebsiteUrl(), $timeshift, $profile->getTimezone(), $profile->getDefaultPage() );
262
+ $startindex++;
263
+ }
264
+ }
265
+ }
266
+
267
+ if ( empty( $ga_profiles_list ) ) {
268
+ $timeout = $this->get_timeouts( 'midnight' );
269
+ GADWP_Tools::set_error( 'No properties were found in this account!', $timeout );
270
+ } else {
271
+ GADWP_Tools::delete_cache( 'last_error' );
272
+ }
273
+ return $ga_profiles_list;
274
+ } catch ( Deconf_IO_Exception $e ) {
275
+ $timeout = $this->get_timeouts( 'midnight' );
276
+ GADWP_Tools::set_error( $e, $timeout );
277
+ return $ga_profiles_list;
278
+ } catch ( Deconf_Service_Exception $e ) {
279
+ $timeout = $this->get_timeouts( 'midnight' );
280
+ GADWP_Tools::set_error( $e, $timeout );
281
+ } catch ( Exception $e ) {
282
+ $timeout = $this->get_timeouts( 'midnight' );
283
+ GADWP_Tools::set_error( $e, $timeout );
284
+ }
285
+ }
286
+
287
+ /**
288
+ * Handles the token reset process
289
+ *
290
+ * @param
291
+ * $all
292
+ */
293
+ public function reset_token( $all = false ) {
294
+ $this->gadwp->config->options['token'] = "";
295
+ if ( $all ) {
296
+ $this->gadwp->config->options['tableid_jail'] = "";
297
+ $this->gadwp->config->options['ga_profiles_list'] = array();
298
+ try {
299
+ $this->client->revokeToken();
300
+ } catch ( Exception $e ) {
301
+ if ( is_multisite() && $this->gadwp->config->options['network_mode'] ) {
302
+ $this->gadwp->config->set_plugin_options( true );
303
+ } else {
304
+ $this->gadwp->config->set_plugin_options();
305
+ }
306
+ }
307
+ }
308
+ if ( is_multisite() && $this->gadwp->config->options['network_mode'] ) {
309
+ $this->gadwp->config->set_plugin_options( true );
310
+ } else {
311
+ $this->gadwp->config->set_plugin_options();
312
+ }
313
+ }
314
+
315
+ /**
316
+ * Get and cache Core Reports
317
+ *
318
+ * @param
319
+ * $projecId
320
+ * @param
321
+ * $from
322
+ * @param
323
+ * $to
324
+ * @param
325
+ * $metrics
326
+ * @param
327
+ * $options
328
+ * @param
329
+ * $serial
330
+ * @return int|Deconf_Service_Analytics_GaData
331
+ */
332
+ private function handle_corereports( $projectId, $from, $to, $metrics, $options, $serial ) {
333
+ try {
334
+ if ( 'today' == $from ) {
335
+ $interval = 'hourly';
336
+ } else {
337
+ $interval = 'daily';
338
+ }
339
+ $transient = GADWP_Tools::get_cache( $serial );
340
+ if ( false === $transient ) {
341
+ if ( $this->gapi_errors_handler() ) {
342
+ return - 23;
343
+ }
344
+ $options['samplingLevel'] = 'HIGHER_PRECISION';
345
+ $data = $this->service->data_ga->get( 'ga:' . $projectId, $from, $to, $metrics, $options );
346
+ if ( method_exists( $data, 'getContainsSampledData' ) && $data->getContainsSampledData() ) {
347
+ $sampling['date'] = date( 'Y-m-d H:i:s' );
348
+ $sampling['percent'] = number_format( ( $data->getSampleSize() / $data->getSampleSpace() ) * 100, 2 ) . '%';
349
+ $sampling['sessions'] = $data->getSampleSize() . ' / ' . $data->getSampleSpace();
350
+ GADWP_Tools::set_cache( 'sampleddata', $sampling, 30 * 24 * 3600 );
351
+ GADWP_Tools::set_cache( $serial, $data, $this->get_timeouts( 'hourly' ) ); // refresh every hour if data is sampled
352
+ } else {
353
+ GADWP_Tools::set_cache( $serial, $data, $this->get_timeouts( $interval ) );
354
+ }
355
+ } else {
356
+ $data = $transient;
357
+ }
358
+ } catch ( Deconf_Service_Exception $e ) {
359
+ $timeout = $this->get_timeouts( 'midnight' );
360
+ GADWP_Tools::set_error( $e, $timeout );
361
+ return $e->getCode();
362
+ } catch ( Exception $e ) {
363
+ $timeout = $this->get_timeouts( 'midnight' );
364
+ GADWP_Tools::set_error( $e, $timeout );
365
+ return $e->getCode();
366
+ }
367
+
368
+ $this->gadwp->config->options['api_backoff'] = 0;
369
+ $this->gadwp->config->set_plugin_options();
370
+
371
+ if ( $data->getRows() > 0 ) {
372
+ return $data;
373
+ } else {
374
+ $data->rows = array();
375
+ return $data;
376
+ }
377
+ }
378
+
379
+ /**
380
+ * Generates serials for transients
381
+ *
382
+ * @param
383
+ * $serial
384
+ * @return string
385
+ */
386
+ public function get_serial( $serial ) {
387
+ return sprintf( "%u", crc32( $serial ) );
388
+ }
389
+
390
+ /**
391
+ * Analytics data for Area Charts (Admin Dashboard Widget report)
392
+ *
393
+ * @param
394
+ * $projectId
395
+ * @param
396
+ * $from
397
+ * @param
398
+ * $to
399
+ * @param
400
+ * $query
401
+ * @param
402
+ * $filter
403
+ * @return array|int
404
+ */
405
+ private function get_areachart_data( $projectId, $from, $to, $query, $filter = '' ) {
406
+ switch ( $query ) {
407
+ case 'users' :
408
+ $title = __( "Users", 'google-analytics-dashboard-for-wp' );
409
+ break;
410
+ case 'pageviews' :
411
+ $title = __( "Page Views", 'google-analytics-dashboard-for-wp' );
412
+ break;
413
+ case 'visitBounceRate' :
414
+ $title = __( "Bounce Rate", 'google-analytics-dashboard-for-wp' );
415
+ break;
416
+ case 'organicSearches' :
417
+ $title = __( "Organic Searches", 'google-analytics-dashboard-for-wp' );
418
+ break;
419
+ case 'uniquePageviews' :
420
+ $title = __( "Unique Page Views", 'google-analytics-dashboard-for-wp' );
421
+ break;
422
+ default :
423
+ $title = __( "Sessions", 'google-analytics-dashboard-for-wp' );
424
+ }
425
+ $metrics = 'ga:' . $query;
426
+ if ( 'today' == $from || 'yesterday' == $from ) {
427
+ $dimensions = 'ga:hour';
428
+ $dayorhour = __( "Hour", 'google-analytics-dashboard-for-wp' );
429
+ } else if ( '365daysAgo' == $from || '1095daysAgo' == $from ) {
430
+ $dimensions = 'ga:yearMonth, ga:month';
431
+ $dayorhour = __( "Date", 'google-analytics-dashboard-for-wp' );
432
+ } else {
433
+ $dimensions = 'ga:date,ga:dayOfWeekName';
434
+ $dayorhour = __( "Date", 'google-analytics-dashboard-for-wp' );
435
+ }
436
+ $options = array( 'dimensions' => $dimensions, 'quotaUser' => $this->managequota . 'p' . $projectId );
437
+ if ( $filter ) {
438
+ $options['filters'] = 'ga:pagePath==' . $filter;
439
+ }
440
+ $serial = 'qr2_' . $this->get_serial( $projectId . $from . $metrics . $filter );
441
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
442
+ if ( is_numeric( $data ) ) {
443
+ return $data;
444
+ }
445
+ if ( empty( $data->rows ) ) {
446
+ // unable to render it as an Area Chart, returns a numeric value to be handled by reportsx.js
447
+ return - 21;
448
+ }
449
+ $gadwp_data = array( array( $dayorhour, $title ) );
450
+ if ( 'today' == $from || 'yesterday' == $from ) {
451
+ foreach ( $data->getRows() as $row ) {
452
+ $gadwp_data[] = array( (int) $row[0] . ':00', round( $row[1], 2 ) );
453
+ }
454
+ } else if ( '365daysAgo' == $from || '1095daysAgo' == $from ) {
455
+ foreach ( $data->getRows() as $row ) {
456
+ /*
457
+ * translators:
458
+ * Example: 'F, Y' will become 'November, 2015'
459
+ * For details see: http://php.net/manual/en/function.date.php#refsect1-function.date-parameters
460
+ */
461
+ $gadwp_data[] = array( date_i18n( __( 'F, Y', 'google-analytics-dashboard-for-wp' ), strtotime( $row[0] . '01' ) ), round( $row[2], 2 ) );
462
+ }
463
+ } else {
464
+ foreach ( $data->getRows() as $row ) {
465
+ /*
466
+ * translators:
467
+ * Example: 'l, F j, Y' will become 'Thusday, November 17, 2015'
468
+ * For details see: http://php.net/manual/en/function.date.php#refsect1-function.date-parameters
469
+ */
470
+ $gadwp_data[] = array( date_i18n( __( 'l, F j, Y', 'google-analytics-dashboard-for-wp' ), strtotime( $row[0] ) ), round( $row[2], 2 ) );
471
+ }
472
+ }
473
+
474
+ return $gadwp_data;
475
+ }
476
+
477
+ /**
478
+ * Analytics data for Bottom Stats (bottom stats on main report)
479
+ *
480
+ * @param
481
+ * $projectId
482
+ * @param
483
+ * $from
484
+ * @param
485
+ * $to
486
+ * @param
487
+ * $filter
488
+ * @return array|int
489
+ */
490
+ private function get_bottomstats( $projectId, $from, $to, $filter = '' ) {
491
+ $options = array( 'dimensions' => null, 'quotaUser' => $this->managequota . 'p' . $projectId );
492
+ if ( $filter ) {
493
+ $options['filters'] = 'ga:pagePath==' . $filter;
494
+ $metrics = 'ga:uniquePageviews,ga:users,ga:pageviews,ga:BounceRate,ga:organicSearches,ga:pageviewsPerSession,ga:avgTimeOnPage,ga:avgPageLoadTime,ga:exitRate';
495
+ } else {
496
+ $metrics = 'ga:sessions,ga:users,ga:pageviews,ga:BounceRate,ga:organicSearches,ga:pageviewsPerSession,ga:avgTimeOnPage,ga:avgPageLoadTime,ga:avgSessionDuration';
497
+ }
498
+ $serial = 'qr3_' . $this->get_serial( $projectId . $from . $filter );
499
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
500
+ if ( is_numeric( $data ) ) {
501
+ return $data;
502
+ }
503
+ $gadwp_data = array();
504
+ foreach ( $data->getRows() as $row ) {
505
+ $gadwp_data = array_map( 'floatval', $row );
506
+ }
507
+
508
+ // i18n support
509
+ $gadwp_data[0] = isset( $gadwp_data[0] ) ? number_format_i18n( $gadwp_data[0] ) : 0;
510
+ $gadwp_data[1] = isset( $gadwp_data[1] ) ? number_format_i18n( $gadwp_data[1] ) : 0;
511
+ $gadwp_data[2] = isset( $gadwp_data[2] ) ? number_format_i18n( $gadwp_data[2] ) : 0;
512
+ $gadwp_data[3] = isset( $gadwp_data[3] ) ? number_format_i18n( $gadwp_data[3], 2 ) . '%' : '0%';
513
+ $gadwp_data[4] = isset( $gadwp_data[4] ) ? number_format_i18n( $gadwp_data[4] ) : 0;
514
+ $gadwp_data[5] = isset( $gadwp_data[5] ) ? number_format_i18n( $gadwp_data[5], 2 ) : 0;
515
+ $gadwp_data[6] = isset( $gadwp_data[6] ) ? gmdate( "H:i:s", $gadwp_data[6] ) : '00:00:00';
516
+ $gadwp_data[7] = isset( $gadwp_data[7] ) ? number_format_i18n( $gadwp_data[7], 2 ) : 0;
517
+ if ( $filter ) {
518
+ $gadwp_data[8] = isset( $gadwp_data[8] ) ? number_format_i18n( $gadwp_data[8], 2 ) . '%' : '0%';
519
+ } else {
520
+ $gadwp_data[8] = isset( $gadwp_data[8] ) ? gmdate( "H:i:s", $gadwp_data[8] ) : '00:00:00';
521
+ }
522
+
523
+ return $gadwp_data;
524
+ }
525
+
526
+ /**
527
+ * Analytics data for Table Charts (content pages)
528
+ *
529
+ * @param
530
+ * $projectId
531
+ * @param
532
+ * $from
533
+ * @param
534
+ * $to
535
+ * @param
536
+ * $filter
537
+ * @return array|int
538
+ */
539
+ private function get_contentpages( $projectId, $from, $to, $filter = '', $metric ) {
540
+ $metrics = 'ga:' . $metric;
541
+ $dimensions = 'ga:pageTitle';
542
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
543
+ if ( $filter ) {
544
+ $options['filters'] = 'ga:pagePath==' . $filter;
545
+ }
546
+ $serial = 'qr4_' . $this->get_serial( $projectId . $from . $filter . $metric );
547
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
548
+ if ( is_numeric( $data ) ) {
549
+ return $data;
550
+ }
551
+ $gadwp_data = array( array( __( "Pages", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
552
+ foreach ( $data->getRows() as $row ) {
553
+ $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
554
+ }
555
+ return $gadwp_data;
556
+ }
557
+
558
+ /**
559
+ * Analytics data for 404 Errors
560
+ *
561
+ * @param
562
+ * $projectId
563
+ * @param
564
+ * $from
565
+ * @param
566
+ * $to
567
+ * @return array|int
568
+ */
569
+ private function get_404errors( $projectId, $from, $to, $filter = "Page Not Found", $metric ) {
570
+ $metrics = 'ga:' . $metric;
571
+ $dimensions = 'ga:pagePath,ga:fullReferrer';
572
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
573
+ $options['filters'] = 'ga:pageTitle=@' . $filter;
574
+ $serial = 'qr4_' . $this->get_serial( $projectId . $from . $filter . $metric );
575
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
576
+ if ( is_numeric( $data ) ) {
577
+ return $data;
578
+ }
579
+ $gadwp_data = array( array( __( "404 Errors", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
580
+ foreach ( $data->getRows() as $row ) {
581
+ $path = esc_html( $row[0] );
582
+ $source = esc_html( $row[1] );
583
+ $gadwp_data[] = array( "<strong>" . __( "URI:", 'google-analytics-dashboard-for-wp' ) . "</strong> " . $path . "<br><strong>" . __( "Source:", 'google-analytics-dashboard-for-wp' ) . "</strong> " . $source, (int) $row[2] );
584
+ }
585
+ return $gadwp_data;
586
+ }
587
+
588
+ /**
589
+ * Analytics data for Table Charts (referrers)
590
+ *
591
+ * @param
592
+ * $projectId
593
+ * @param
594
+ * $from
595
+ * @param
596
+ * $to
597
+ * @param
598
+ * $filter
599
+ * @return array|int
600
+ */
601
+ private function get_referrers( $projectId, $from, $to, $filter = '', $metric ) {
602
+ $metrics = 'ga:' . $metric;
603
+ $dimensions = 'ga:source';
604
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
605
+ if ( $filter ) {
606
+ $options['filters'] = 'ga:medium==referral;ga:pagePath==' . $filter;
607
+ } else {
608
+ $options['filters'] = 'ga:medium==referral';
609
+ }
610
+ $serial = 'qr5_' . $this->get_serial( $projectId . $from . $filter . $metric );
611
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
612
+ if ( is_numeric( $data ) ) {
613
+ return $data;
614
+ }
615
+ $gadwp_data = array( array( __( "Referrers", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
616
+ foreach ( $data->getRows() as $row ) {
617
+ $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
618
+ }
619
+ return $gadwp_data;
620
+ }
621
+
622
+ /**
623
+ * Analytics data for Table Charts (searches)
624
+ *
625
+ * @param
626
+ * $projectId
627
+ * @param
628
+ * $from
629
+ * @param
630
+ * $to
631
+ * @param
632
+ * $filter
633
+ * @return array|int
634
+ */
635
+ private function get_searches( $projectId, $from, $to, $filter = '', $metric ) {
636
+ $metrics = 'ga:' . $metric;
637
+ $dimensions = 'ga:keyword';
638
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
639
+ if ( $filter ) {
640
+ $options['filters'] = 'ga:keyword!=(not set);ga:pagePath==' . $filter;
641
+ } else {
642
+ $options['filters'] = 'ga:keyword!=(not set)';
643
+ }
644
+ $serial = 'qr6_' . $this->get_serial( $projectId . $from . $filter . $metric );
645
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
646
+ if ( is_numeric( $data ) ) {
647
+ return $data;
648
+ }
649
+
650
+ $gadwp_data = array( array( __( "Searches", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
651
+ foreach ( $data->getRows() as $row ) {
652
+ $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
653
+ }
654
+ return $gadwp_data;
655
+ }
656
+
657
+ /**
658
+ * Analytics data for Table Charts (location reports)
659
+ *
660
+ * @param
661
+ * $projectId
662
+ * @param
663
+ * $from
664
+ * @param
665
+ * $to
666
+ * @param
667
+ * $filter
668
+ * @return array|int
669
+ */
670
+ private function get_locations( $projectId, $from, $to, $filter = '', $metric ) {
671
+ $metrics = 'ga:' . $metric;
672
+ $options = "";
673
+ $title = __( "Countries", 'google-analytics-dashboard-for-wp' );
674
+ $serial = 'qr7_' . $this->get_serial( $projectId . $from . $filter . $metric );
675
+ $dimensions = 'ga:country';
676
+ $local_filter = '';
677
+ if ( $this->gadwp->config->options['ga_target_geomap'] ) {
678
+ $dimensions = 'ga:city, ga:region';
679
+
680
+ $country_codes = GADWP_Tools::get_countrycodes();
681
+ if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
682
+ $local_filter = 'ga:country==' . ( $country_codes[$this->gadwp->config->options['ga_target_geomap']] );
683
+ $title = __( "Cities from", 'google-analytics-dashboard-for-wp' ) . ' ' . __( $country_codes[$this->gadwp->config->options['ga_target_geomap']] );
684
+ $serial = 'qr7_' . $this->get_serial( $projectId . $from . $this->gadwp->config->options['ga_target_geomap'] . $filter . $metric );
685
+ }
686
+ }
687
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
688
+ if ( $filter ) {
689
+ $options['filters'] = 'ga:pagePath==' . $filter;
690
+ if ( $local_filter ) {
691
+ $options['filters'] .= ';' . $local_filter;
692
+ }
693
+ } else {
694
+ if ( $local_filter ) {
695
+ $options['filters'] = $local_filter;
696
+ }
697
+ }
698
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
699
+ if ( is_numeric( $data ) ) {
700
+ return $data;
701
+ }
702
+
703
+ $gadwp_data = array( array( $title, __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
704
+ foreach ( $data->getRows() as $row ) {
705
+ if ( isset( $row[2] ) ) {
706
+ $gadwp_data[] = array( esc_html( $row[0] ) . ', ' . esc_html( $row[1] ), (int) $row[2] );
707
+ } else {
708
+ $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
709
+ }
710
+ }
711
+ return $gadwp_data;
712
+ }
713
+
714
+ /**
715
+ * Analytics data for Org Charts (traffic channels, device categories)
716
+ *
717
+ * @param
718
+ * $projectId
719
+ * @param
720
+ * $from
721
+ * @param
722
+ * $to
723
+ * @param
724
+ * $query
725
+ * @param
726
+ * $filter
727
+ * @return array|int
728
+ */
729
+ private function get_orgchart_data( $projectId, $from, $to, $query, $filter = '', $metric ) {
730
+ $metrics = 'ga:' . $metric;
731
+ $dimensions = 'ga:' . $query;
732
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
733
+ if ( $filter ) {
734
+ $options['filters'] = 'ga:pagePath==' . $filter;
735
+ }
736
+ $serial = 'qr8_' . $this->get_serial( $projectId . $from . $query . $filter . $metric );
737
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
738
+ if ( is_numeric( $data ) ) {
739
+ return $data;
740
+ }
741
+ if ( empty( $data->rows ) ) {
742
+ // unable to render as an Org Chart, returns a numeric value to be handled by reportsx.js
743
+ return - 21;
744
+ }
745
+ $block = ( 'channelGrouping' == $query ) ? __( "Channels", 'google-analytics-dashboard-for-wp' ) : __( "Devices", 'google-analytics-dashboard-for-wp' );
746
+ $gadwp_data = array( array( '<div style="color:black; font-size:1.1em">' . $block . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults'][$metrics] . '</div>', "" ) );
747
+ foreach ( $data->getRows() as $row ) {
748
+ $shrink = explode( " ", $row[0] );
749
+ $gadwp_data[] = array( '<div style="color:black; font-size:1.1em">' . esc_html( $shrink[0] ) . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $row[1] . '</div>', '<div style="color:black; font-size:1.1em">' . $block . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults'][$metrics] . '</div>' );
750
+ }
751
+ return $gadwp_data;
752
+ }
753
+
754
+ /**
755
+ * Analytics data for Pie Charts (traffic mediums, serach engines, social networks, browsers, screen rsolutions, etc.)
756
+ *
757
+ * @param
758
+ * $projectId
759
+ * @param
760
+ * $from
761
+ * @param
762
+ * $to
763
+ * @param
764
+ * $query
765
+ * @param
766
+ * $filter
767
+ * @return array|int
768
+ */
769
+ private function get_piechart_data( $projectId, $from, $to, $query, $filter = '', $metric ) {
770
+ $metrics = 'ga:' . $metric;
771
+ $dimensions = 'ga:' . $query;
772
+
773
+ if ( 'source' == $query ) {
774
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
775
+ if ( $filter ) {
776
+ $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set);ga:pagePath==' . $filter;
777
+ } else {
778
+ $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set)';
779
+ }
780
+ } else {
781
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
782
+ if ( $filter ) {
783
+ $options['filters'] = 'ga:' . $query . '!=(not set);ga:pagePath==' . $filter;
784
+ } else {
785
+ $options['filters'] = 'ga:' . $query . '!=(not set)';
786
+ }
787
+ }
788
+ $serial = 'qr10_' . $this->get_serial( $projectId . $from . $query . $filter . $metric );
789
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
790
+ if ( is_numeric( $data ) ) {
791
+ return $data;
792
+ }
793
+ $gadwp_data = array( array( __( "Type", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
794
+ $i = 0;
795
+ $included = 0;
796
+ foreach ( $data->getRows() as $row ) {
797
+ if ( $i < 20 ) {
798
+ $gadwp_data[] = array( str_replace( "(none)", "direct", esc_html( $row[0] ) ), (int) $row[1] );
799
+ $included += $row[1];
800
+ $i++;
801
+ } else {
802
+ break;
803
+ }
804
+ }
805
+ $totals = $data->getTotalsForAllResults();
806
+ $others = $totals[$metrics] - $included;
807
+ if ( $others > 0 ) {
808
+ $gadwp_data[] = array( __( 'Other', 'google-analytics-dashboard-for-wp' ), $others );
809
+ }
810
+
811
+ return $gadwp_data;
812
+ }
813
+
814
+ /**
815
+ * Analytics data for Frontend Widget (chart data and totals)
816
+ *
817
+ * @param
818
+ * $projectId
819
+ * @param
820
+ * $period
821
+ * @param
822
+ * $anonim
823
+ * @return array|int
824
+ */
825
+ public function frontend_widget_stats( $projectId, $from, $anonim ) {
826
+ $content = '';
827
+ $to = 'yesterday';
828
+ $metrics = 'ga:sessions';
829
+ $dimensions = 'ga:date,ga:dayOfWeekName';
830
+ $options = array( 'dimensions' => $dimensions, 'quotaUser' => $this->managequota . 'p' . $projectId );
831
+ $serial = 'qr2_' . $this->get_serial( $projectId . $from . $metrics );
832
+ $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
833
+ if ( is_numeric( $data ) ) {
834
+ return $data;
835
+ }
836
+ $gadwp_data = array( array( __( "Date", 'google-analytics-dashboard-for-wp' ), __( "Sessions", 'google-analytics-dashboard-for-wp' ) ) );
837
+ if ( $anonim ) {
838
+ $max_array = array();
839
+ foreach ( $data->getRows() as $item ) {
840
+ $max_array[] = $item[2];
841
+ }
842
+ $max = max( $max_array ) ? max( $max_array ) : 1;
843
+ }
844
+ foreach ( $data->getRows() as $row ) {
845
+ $gadwp_data[] = array( date_i18n( __( 'l, F j, Y', 'google-analytics-dashboard-for-wp' ), strtotime( $row[0] ) ), ( $anonim ? round( $row[2] * 100 / $max, 2 ) : (int) $row[2] ) );
846
+ }
847
+ $totals = $data->getTotalsForAllResults();
848
+ return array( $gadwp_data, $anonim ? 0 : number_format_i18n( $totals['ga:sessions'] ) );
849
+ }
850
+
851
+ /**
852
+ * Analytics data for Realtime component (the real-time report)
853
+ *
854
+ * @param
855
+ * $projectId
856
+ * @return array|int
857
+ */
858
+ private function get_realtime( $projectId ) {
859
+ $metrics = 'rt:activeUsers';
860
+ $dimensions = 'rt:pagePath,rt:source,rt:keyword,rt:trafficType,rt:visitorType,rt:pageTitle';
861
+ try {
862
+ $serial = 'qr_realtimecache_' . $this->get_serial( $projectId );
863
+ $transient = GADWP_Tools::get_cache( $serial );
864
+ if ( false === $transient ) {
865
+ if ( $this->gapi_errors_handler() ) {
866
+ return - 23;
867
+ }
868
+ $data = $this->service->data_realtime->get( 'ga:' . $projectId, $metrics, array( 'dimensions' => $dimensions, 'quotaUser' => $this->managequota . 'p' . $projectId ) );
869
+ GADWP_Tools::set_cache( $serial, $data, 55 );
870
+ } else {
871
+ $data = $transient;
872
+ }
873
+ } catch ( Deconf_Service_Exception $e ) {
874
+ $timeout = $this->get_timeouts( 'midnight' );
875
+ GADWP_Tools::set_error( $e, $timeout );
876
+ return $e->getCode();
877
+ } catch ( Exception $e ) {
878
+ $timeout = $this->get_timeouts( 'midnight' );
879
+ GADWP_Tools::set_error( $e, $timeout );
880
+ return $e->getCode();
881
+ }
882
+ if ( $data->getRows() < 1 ) {
883
+ return - 21;
884
+ }
885
+ $i = 0;
886
+ $gadwp_data = $data;
887
+ foreach ( $data->getRows() as $row ) {
888
+ $strip = array_map( 'wp_kses_data', $row );
889
+ $gadwp_data->rows[$i] = array_map( 'esc_html', $strip );
890
+ $i++;
891
+ }
892
+
893
+ $this->gadwp->config->options['api_backoff'] = 0;
894
+ $this->gadwp->config->set_plugin_options();
895
+
896
+ return array( $gadwp_data );
897
+ }
898
+
899
+ private function map( $map ) {
900
+ $map = explode( '.', $map );
901
+ if ( isset( $map[1] ) ) {
902
+ $map[0] += ord( 'map' );
903
+ return implode( '.', $map );
904
+ } else {
905
+ return str_ireplace( 'map', chr( 112 ), $map[0] );
906
+ }
907
+ }
908
+
909
+ /**
910
+ * Handles ajax requests and calls the needed methods
911
+ * @param
912
+ * $projectId
913
+ * @param
914
+ * $query
915
+ * @param
916
+ * $from
917
+ * @param
918
+ * $to
919
+ * @param
920
+ * $filter
921
+ * @return number|Deconf_Service_Analytics_GaData
922
+ */
923
+ public function get( $projectId, $query, $from = false, $to = false, $filter = '', $metric = 'sessions' ) {
924
+ if ( empty( $projectId ) || ! is_numeric( $projectId ) ) {
925
+ wp_die( - 26 );
926
+ }
927
+ if ( in_array( $query, array( 'sessions', 'users', 'organicSearches', 'visitBounceRate', 'pageviews', 'uniquePageviews' ) ) ) {
928
+ return $this->get_areachart_data( $projectId, $from, $to, $query, $filter );
929
+ }
930
+ if ( 'bottomstats' == $query ) {
931
+ return $this->get_bottomstats( $projectId, $from, $to, $filter );
932
+ }
933
+ if ( 'locations' == $query ) {
934
+ return $this->get_locations( $projectId, $from, $to, $filter, $metric );
935
+ }
936
+ if ( 'referrers' == $query ) {
937
+ return $this->get_referrers( $projectId, $from, $to, $filter, $metric );
938
+ }
939
+ if ( 'contentpages' == $query ) {
940
+ return $this->get_contentpages( $projectId, $from, $to, $filter, $metric );
941
+ }
942
+ if ( '404errors' == $query ) {
943
+ $filter = $this->gadwp->config->options['pagetitle_404'];
944
+ return $this->get_404errors( $projectId, $from, $to, $filter, $metric );
945
+ }
946
+ if ( 'searches' == $query ) {
947
+ return $this->get_searches( $projectId, $from, $to, $filter, $metric );
948
+ }
949
+ if ( 'realtime' == $query ) {
950
+ return $this->get_realtime( $projectId );
951
+ }
952
+ if ( 'channelGrouping' == $query || 'deviceCategory' == $query ) {
953
+ return $this->get_orgchart_data( $projectId, $from, $to, $query, $filter, $metric );
954
+ }
955
+ if ( in_array( $query, array( 'medium', 'visitorType', 'socialNetwork', 'source', 'browser', 'operatingSystem', 'screenResolution', 'mobileDeviceBranding' ) ) ) {
956
+ return $this->get_piechart_data( $projectId, $from, $to, $query, $filter, $metric );
957
+ }
958
+ wp_die( - 27 );
959
+ }
960
+ }
961
+ }
tags/5.3.1.1/tools/iso3166.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ /* @formatter:off */
15
+ $country_codes = array(
16
+ 'AD' => 'Andorra',
17
+ 'AE' => 'United Arab Emirates',
18
+ 'AF' => 'Afghanistan',
19
+ 'AG' => 'Antigua and Barbuda',
20
+ 'AI' => 'Anguilla',
21
+ 'AL' => 'Albania',
22
+ 'AM' => 'Armenia',
23
+ 'AN' => 'Netherlands Antilles',
24
+ 'AO' => 'Angola',
25
+ 'AQ' => 'Antarctica',
26
+ 'AR' => 'Argentina',
27
+ 'AS' => 'American Samoa',
28
+ 'AT' => 'Austria',
29
+ 'AU' => 'Australia',
30
+ 'AW' => 'Aruba',
31
+ 'AZ' => 'Azerbaijan',
32
+ 'BA' => 'Bosnia and Herzegovina',
33
+ 'BB' => 'Barbados',
34
+ 'BD' => 'Bangladesh',
35
+ 'BE' => 'Belgium',
36
+ 'BF' => 'Burkina Faso',
37
+ 'BG' => 'Bulgaria',
38
+ 'BH' => 'Bahrain',
39
+ 'BI' => 'Burundi',
40
+ 'BJ' => 'Benin',
41
+ 'BM' => 'Bermuda',
42
+ 'BN' => 'Brunei',
43
+ 'BO' => 'Bolivia',
44
+ 'BR' => 'Brazil',
45
+ 'BS' => 'Bahamas',
46
+ 'BT' => 'Bhutan',
47
+ 'BV' => 'Bouvet Island',
48
+ 'BW' => 'Botswana',
49
+ 'BY' => 'Belarus',
50
+ 'BZ' => 'Belize',
51
+ 'CA' => 'Canada',
52
+ 'CC' => 'Cocos (Keeling) Islands',
53
+ 'CD' => 'Congo, The Democratic Republic of the',
54
+ 'CF' => 'Central African Republic',
55
+ 'CG' => 'Congo',
56
+ 'CH' => 'Switzerland',
57
+ 'CI' => 'C�te d?Ivoire',
58
+ 'CK' => 'Cook Islands',
59
+ 'CL' => 'Chile',
60
+ 'CM' => 'Cameroon',
61
+ 'CN' => 'China',
62
+ 'CO' => 'Colombia',
63
+ 'CR' => 'Costa Rica',
64
+ 'CU' => 'Cuba',
65
+ 'CV' => 'Cape Verde',
66
+ 'CX' => 'Christmas Island',
67
+ 'CY' => 'Cyprus',
68
+ 'CZ' => 'Czech Republic',
69
+ 'DE' => 'Germany',
70
+ 'DJ' => 'Djibouti',
71
+ 'DK' => 'Denmark',
72
+ 'DM' => 'Dominica',
73
+ 'DO' => 'Dominican Republic',
74
+ 'DZ' => 'Algeria',
75
+ 'EC' => 'Ecuador',
76
+ 'EE' => 'Estonia',
77
+ 'EG' => 'Egypt',
78
+ 'EH' => 'Western Sahara',
79
+ 'ER' => 'Eritrea',
80
+ 'ES' => 'Spain',
81
+ 'ET' => 'Ethiopia',
82
+ 'FI' => 'Finland',
83
+ 'FJ' => 'Fiji Islands',
84
+ 'FK' => 'Falkland Islands',
85
+ 'FM' => 'Micronesia, Federated States of',
86
+ 'FO' => 'Faroe Islands',
87
+ 'FR' => 'France',
88
+ 'GA' => 'Gabon',
89
+ 'GB' => 'United Kingdom',
90