Yandex Metrica - Version 1.7

Version Description

  • switched to new metrica tracking code by default
    • added an option for new Yandex's tracking code (props @ildarkhasanshin)
    • Better tracker-address handling. (Don't save default addresses.)
    • tested with WordPress 5.x
Download this release

Release Info

Developer m_uysl
Plugin Icon 128x128 Yandex Metrica
Version 1.7
Comparing to
See all releases

Code changes from version 1.6.3 to 1.7

README.md CHANGED
@@ -1,10 +1,10 @@
1
  # Yandex Metrica #
2
 
3
- Contributors: m_uysl
4
  Tags: yandex,metrica,stats,statistics,tools,analytics,analytics tool,metrika
5
  Requires at least: 3.8
6
- Tested up to: 4.9
7
- Stable tag: 1.6.3
8
  License: GPLv2 (or later)
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -17,7 +17,7 @@ Best Metrica plugin for the using Yandex Metrica in your WordPress site.
17
 
18
  ### What is Metrica ###
19
 
20
- Metrica is an analytics tool like as google analytics.If you didn't hear metrica yet, you can [check official metrica](http://metrica.yandex.com/) page.
21
 
22
 
23
  ### Features ###
@@ -72,6 +72,12 @@ Extract the zip file and just drop the contents in the `wp-content/plugins/` dir
72
 
73
  ## Changelog ##
74
 
 
 
 
 
 
 
75
  ### 1.6.3 ###
76
  - now users are able to change Tracker JS address
77
  - new filter `yandex_metrica_noscript_img_base` added
@@ -169,4 +175,8 @@ Including major changes, recommended update!
169
 
170
  ### 1.5 ###
171
 
172
- Metrica api upgraded, if you get authentication related problems reset plugin settings and connect to API again (that will generate new token)
 
 
 
 
1
  # Yandex Metrica #
2
 
3
+ Contributors: m_uysl, ildarkhasanshin
4
  Tags: yandex,metrica,stats,statistics,tools,analytics,analytics tool,metrika
5
  Requires at least: 3.8
6
+ Tested up to: 5.0.1
7
+ Stable tag: 1.7
8
  License: GPLv2 (or later)
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
17
 
18
  ### What is Metrica ###
19
 
20
+ Metrica is an analytics tool like as google analytics.If you didn't hear metrica yet, you can [check official metrica](https://metrica.yandex.com/) page.
21
 
22
 
23
  ### Features ###
72
 
73
  ## Changelog ##
74
 
75
+ ### 1.7 ###
76
+ - switched to new metrica tracking code by default
77
+ - added an option for [new Yandex's tracking code](https://yandex.com/support/metrika/code/counter-initialize.html) (props @ildarkhasanshin)
78
+ - Better tracker-address handling. (Don't save default addresses.)
79
+ - tested with WordPress 5.x
80
+
81
  ### 1.6.3 ###
82
  - now users are able to change Tracker JS address
83
  - new filter `yandex_metrica_noscript_img_base` added
175
 
176
  ### 1.5 ###
177
 
178
+ Metrica api upgraded, if you get authentication related problems reset plugin settings and connect to API again (that will generate new token)
179
+
180
+ ### 1.7 ###
181
+
182
+ Switched to the new tracking code by default. You can turn off from the options.
languages/yandex-metrica-ru_RU.mo CHANGED
Binary file
languages/yandex-metrica-ru_RU.po CHANGED
@@ -370,3 +370,7 @@ msgstr ""
370
  #: ../templates/settings.php:183
371
  msgid "If you want to change watcher js address, use the field above."
372
  msgstr ""
 
 
 
 
370
  #: ../templates/settings.php:183
371
  msgid "If you want to change watcher js address, use the field above."
372
  msgstr ""
373
+
374
+ #: ../templates/settings.php:126
375
+ msgid "Use new counter code"
376
+ msgstr "Использовать новый код счетчика"
languages/yandex-metrica.pot CHANGED
@@ -353,3 +353,7 @@ msgstr ""
353
  msgid "If you want to change watcher js address, use the field above."
354
  msgstr ""
355
 
 
 
 
 
353
  msgid "If you want to change watcher js address, use the field above."
354
  msgstr ""
355
 
356
+ #: ../templates/settings.php:126
357
+ msgid "Use new counter code"
358
+ msgstr ""
359
+
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Yandex Metrica ===
2
 
3
- Contributors: m_uysl
4
  Tags: yandex,metrica,stats,statistics,tools,analytics,analytics tool,metrika
5
  Requires at least: 3.8
6
- Tested up to: 4.9
7
- Stable tag: 1.6.3
8
  License: GPLv2 (or later)
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -17,7 +17,7 @@ Best Metrica plugin for the using Yandex Metrica in your WordPress site.
17
 
18
  = What is Metrica =
19
 
20
- Metrica is an analytics tool like as google analytics.If you didn't hear metrica yet, you can [check official metrica](http://metrica.yandex.com/) page.
21
 
22
 
23
  = Features =
@@ -65,6 +65,12 @@ Yandex Metrica plugin uses wp_footer hook for the adds necessary tracking code.
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
68
  = 1.6.3 =
69
  - now users are able to change Tracker JS address
70
  - new filter `yandex_metrica_noscript_img_base` added
@@ -162,4 +168,8 @@ Including major changes, recommended update!
162
 
163
  = 1.5 =
164
 
165
- Metrica api upgraded, if you get authentication related problems reset plugin settings and connect to API again (that will generate new token)
 
 
 
 
1
  === Yandex Metrica ===
2
 
3
+ Contributors: m_uysl, ildarkhasanshin
4
  Tags: yandex,metrica,stats,statistics,tools,analytics,analytics tool,metrika
5
  Requires at least: 3.8
6
+ Tested up to: 5.0.1
7
+ Stable tag: 1.7
8
  License: GPLv2 (or later)
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
17
 
18
  = What is Metrica =
19
 
20
+ Metrica is an analytics tool like as google analytics.If you didn't hear metrica yet, you can [check official metrica](https://metrica.yandex.com/) page.
21
 
22
 
23
  = Features =
65
 
66
  == Changelog ==
67
 
68
+ = 1.7 =
69
+ - switched to new metrica tracking code by default
70
+ - added an option for [new Yandex's tracking code](https://yandex.com/support/metrika/code/counter-initialize.html) (props @ildarkhasanshin)
71
+ - Better tracker-address handling. (Don't save default addresses.)
72
+ - tested with WordPress 5.x
73
+
74
  = 1.6.3 =
75
  - now users are able to change Tracker JS address
76
  - new filter `yandex_metrica_noscript_img_base` added
168
 
169
  = 1.5 =
170
 
171
+ Metrica api upgraded, if you get authentication related problems reset plugin settings and connect to API again (that will generate new token)
172
+
173
+ = 1.7 =
174
+
175
+ Switched to the new tracking code by default. You can turn off from the options.
templates/settings.php CHANGED
@@ -34,7 +34,17 @@ if ( isset( $_POST["yandex-metrica-save"] ) ) {
34
  $this->options['track-logged-in'] = ( $_POST['track-logged-in'] == "no" ) ? false : true;
35
  $this->options["untrack-roles"] = ! empty( $_POST["tracker_role"] ) ? array_map( 'esc_attr', $_POST["tracker_role"] ) : "";
36
  $this->options["widget-access-roles"] = ! empty( $_POST["widget_access"] ) ? array_map( 'esc_attr', $_POST["widget_access"] ) : "";
37
- $this->options["tracker-address"] = ! empty( $_POST["tracker-address"] ) ? esc_url_raw( $_POST['tracker-address'] ) : "https://mc.yandex.ru/metrika/watch.js";
 
 
 
 
 
 
 
 
 
 
38
 
39
  if ( is_numeric( $_POST["metrica-counter"] ) ) {
40
  echo '<div class="updated"><p>' . __( 'Options Saved!', 'yandex-metrica' ) . '</p></div>';
@@ -121,6 +131,8 @@ if ( isset( $_POST["reset"] ) ) {
121
  </label><br>
122
  <label><input type="checkbox" <?php checked( $this->options['track_hash'] ); ?> name="track_hash" value="1"> <?php _e( "Hash tracking in the browser's address bar", 'yandex-metrica' ); ?>
123
  </label><br>
 
 
124
  </td>
125
  </tr>
126
 
34
  $this->options['track-logged-in'] = ( $_POST['track-logged-in'] == "no" ) ? false : true;
35
  $this->options["untrack-roles"] = ! empty( $_POST["tracker_role"] ) ? array_map( 'esc_attr', $_POST["tracker_role"] ) : "";
36
  $this->options["widget-access-roles"] = ! empty( $_POST["widget_access"] ) ? array_map( 'esc_attr', $_POST["widget_access"] ) : "";
37
+ $this->options['new_yandex_code'] = empty( $_POST['new_yandex_code'] ) ? false : true;
38
+ $this->options["tracker-address"] = ! empty( $_POST["tracker-address"] ) ? esc_url_raw( $_POST['tracker-address'] ) : "";
39
+
40
+ $default_trackers[] = 'https://mc.yandex.ru/metrika/watch.js';
41
+ $default_trackers[] = 'https://mc.yandex.ru/metrika/tag.js';
42
+
43
+ // don't save when it's default address
44
+ if ( in_array( $this->options["tracker-address"], $default_trackers ) ) {
45
+ $this->options["tracker-address"] = "";
46
+ }
47
+
48
 
49
  if ( is_numeric( $_POST["metrica-counter"] ) ) {
50
  echo '<div class="updated"><p>' . __( 'Options Saved!', 'yandex-metrica' ) . '</p></div>';
131
  </label><br>
132
  <label><input type="checkbox" <?php checked( $this->options['track_hash'] ); ?> name="track_hash" value="1"> <?php _e( "Hash tracking in the browser's address bar", 'yandex-metrica' ); ?>
133
  </label><br>
134
+ <label><input type="checkbox" <?php checked( $this->options['new_yandex_code'] ); ?> name="new_yandex_code" value="1"> <?php _e( "Use new counter code", 'yandex-metrica' ); ?>
135
+ </label>(<a href="https://yandex.com/support/metrika/code/counter-initialize.html" target="_blank">?</a>)<br>
136
  </td>
137
  </tr>
138
 
templates/tracker-js-new.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or die(); ?>
2
+ <!-- Yandex.Metrika counter by Yandex Metrica Plugin -->
3
+ <script type="text/javascript" >
4
+ (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
5
+ m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
6
+ (window, document, "script", "<?php echo( $this->options["tracker-address"] ? $this->options["tracker-address"] : "https://mc.yandex.ru/metrika/tag.js" ); ?>", "ym");
7
+
8
+ ym(<?php echo $this->options["counter_id"];?>, "init", {
9
+ id:<?php echo $this->options["counter_id"];?>,
10
+ clickmap:<?php echo $this->options["clickmap"]?"true":"false";?>,
11
+ trackLinks:<?php echo $this->options["tracklinks"]?"true":"false";?>,
12
+ accurateTrackBounce:<?php echo $this->options["accurate_track"]?"true":"false";?>,
13
+ webvisor:<?php echo $this->options["webvisor"]?"true":"false";?>
14
+ });
15
+ </script>
16
+ <noscript><div><img src="<?php printf( "%s%s", apply_filters( 'yandex_metrica_noscript_img_base', "https://mc.yandex.ru/watch/" ), $this->options["counter_id"] ); ?>" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
17
+ <!-- /Yandex.Metrika counter -->
yandex-metrica.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Yandex Metrica
4
  Plugin URI: http://uysalmustafa.com/plugins/yandex-metrica
5
  Description: Best metrica plugin for the use Yandex Metrica in your WordPress site.
6
  Author: Mustafa Uysal
7
- Version: 1.6.3
8
  Text Domain: yandex-metrica
9
  Domain Path: /languages/
10
  Author URI: http://uysalmustafa.com
@@ -78,6 +78,8 @@ class WP_Yandex_Metrica extends WP_Stack_Plugin {
78
  'untrack-roles' => array( "administrator" ),
79
  'widget-access-roles' => array( "administrator" ),
80
  'backward' => false,
 
 
81
  );
82
  return wp_parse_args( get_option( self::OPTION ), $defaults );
83
  }
@@ -247,11 +249,13 @@ class WP_Yandex_Metrica extends WP_Stack_Plugin {
247
  public function wp_footer() {
248
  if ( ! empty( $this->options['counter_id'] ) ) {
249
 
 
 
250
  if ( $this->options["track-logged-in"] === true && ( is_user_logged_in() && ! $this->current_user_has_access( $this->options["untrack-roles"] ) ) || ( ! is_user_logged_in() ) ) {
251
- include( dirname( __FILE__ ) . '/templates/tracker-js.php' );
252
  }
253
  elseif ( $this->options["track-logged-in"] === false && ! is_user_logged_in() ) {
254
- include( dirname( __FILE__ ) . '/templates/tracker-js.php' );
255
  }
256
  }
257
  }
4
  Plugin URI: http://uysalmustafa.com/plugins/yandex-metrica
5
  Description: Best metrica plugin for the use Yandex Metrica in your WordPress site.
6
  Author: Mustafa Uysal
7
+ Version: 1.7
8
  Text Domain: yandex-metrica
9
  Domain Path: /languages/
10
  Author URI: http://uysalmustafa.com
78
  'untrack-roles' => array( "administrator" ),
79
  'widget-access-roles' => array( "administrator" ),
80
  'backward' => false,
81
+ 'new_yandex_code' => true, // @since 1.7,
82
+ 'tracker-address' => ""
83
  );
84
  return wp_parse_args( get_option( self::OPTION ), $defaults );
85
  }
249
  public function wp_footer() {
250
  if ( ! empty( $this->options['counter_id'] ) ) {
251
 
252
+ $tracker_file = $this->options["new_yandex_code"] === true ? "tracker-js-new.php" : "tracker-js.php";
253
+
254
  if ( $this->options["track-logged-in"] === true && ( is_user_logged_in() && ! $this->current_user_has_access( $this->options["untrack-roles"] ) ) || ( ! is_user_logged_in() ) ) {
255
+ include( dirname( __FILE__ ) . '/templates/' . $tracker_file );
256
  }
257
  elseif ( $this->options["track-logged-in"] === false && ! is_user_logged_in() ) {
258
+ include( dirname( __FILE__ ) . '/templates/' . $tracker_file );
259
  }
260
  }
261
  }