Advertisement
Guest User

yandexmetrika WordPress plugin bugfix, v3.2.1

a guest
Aug 25th, 2012
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.01 KB | None | 0 0
  1. diff --git a/wp-content/plugins/yandexmetrika/yandexmetrika.php b/wp-content/plugins/yandexmetrika/yandexmetrika.php
  2. index 196d18a..cb12568 100644
  3. --- a/wp-content/plugins/yandexmetrika/yandexmetrika.php
  4. +++ b/wp-content/plugins/yandexmetrika/yandexmetrika.php
  5. @@ -21,7 +21,7 @@ if ( ! class_exists( 'YM_Admin' ) ) {
  6.     class YM_Admin {
  7.  
  8.         function add_config_page() {
  9. -           $plugin_page = add_submenu_page('options-general.php', 'Настройка Яндекс.Метрика', 'Яндекс.Метрика', 9, basename(__FILE__), array('YM_Admin','config_page'));
  10. +           $plugin_page = add_submenu_page('options-general.php', 'Настройка Яндекс.Метрика', 'Яндекс.Метрика', 'activate_plugins', basename(__FILE__), array('YM_Admin','config_page'));
  11.             add_action( 'admin_head-'. $plugin_page, array('YM_Admin','config_page_head') );
  12.             add_filter( 'plugin_action_links', array( 'YM_Admin', 'filter_plugin_actions'), 10, 2 );           
  13.         } // end add_YM_config_page()
  14. @@ -106,7 +106,7 @@ if ( ! class_exists( 'YM_Admin' ) ) {
  15.                             <small><a href="#" id="explain">Что это?</a></small>
  16.                         </th>
  17.                         <td>
  18. -                           <input id="uastring" name="uastring" type="text" size="20" maxlength="40" value="<?php echo $options['uastring']; ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /><br/>
  19. +                           <input id="uastring" name="uastring" type="text" size="20" maxlength="40" value="<?php echo ( isset($options['uastring']) ? $options['uastring'] : null ); ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /><br/>
  20.                         </td>
  21.                     </tr>
  22.                     <tr id="explanation">
  23. @@ -138,7 +138,7 @@ if ( ! class_exists( 'YM_Admin' ) ) {
  24.                             <label for="admintracking">Учитывать администраторов</label>
  25.                         </th>
  26.                         <td>
  27. -                           <input type="checkbox" id="admintracking" name="admintracking" <?php if ($options['admintracking']) echo ' checked="checked" '; ?>/>
  28. +                           <input type="checkbox" id="admintracking" name="admintracking" <?php if (isset($options['admintracking']) AND $options['admintracking']) echo ' checked="checked" '; ?>/>
  29.                         </td>
  30.                     </tr>  
  31.                     </table>
  32. @@ -191,13 +191,29 @@ if ( ! class_exists( 'YM_Filter' ) ) {
  33.            
  34.             if ($options["uastring"] != "" && (!current_user_can('edit_users') || $options["admintracking"]) && !is_preview() ) { ?>
  35.  
  36. -   <!-- Яндекс.Метрика -->
  37. -<script src="//mc.yandex.ru/resource/watch.js" type="text/javascript"></script>
  38. +<!-- Яндекс.Метрика -->
  39.  <script type="text/javascript">
  40. -try { var yaCounter<?php echo $options["uastring"]; ?> = new Ya.Metrika(<?php echo $options["uastring"]; ?>); } catch(e){}
  41. +(function (d, w, c) {
  42. +    (w[c] = w[c] || []).push(function() {
  43. +        try {
  44. +            w.yaCounter12714532 = new Ya.Metrika({id:<?php echo $options['uastring'];?>, enableAll: true, webvisor:true});
  45. +        } catch(e) { }
  46. +    });
  47. +
  48. +    var n = d.getElementsByTagName("script")[0],
  49. +        s = d.createElement("script"),
  50. +        f = function () { n.parentNode.insertBefore(s, n); };
  51. +    s.type = "text/javascript";
  52. +    s.async = true;
  53. +    s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";
  54. +
  55. +    if (w.opera == "[object Opera]") {
  56. +        d.addEventListener("DOMContentLoaded", f);
  57. +    } else { f(); }
  58. +})(document, window, "yandex_metrika_callbacks");
  59.  </script>
  60. -<noscript><div style="position: absolute;"><img src="//mc.yandex.ru/watch/<?php echo $options["uastring"]; ?>" alt="" /></div></noscript>
  61. -   <!-- Яндекс.Метрика -->
  62. +<noscript><div><img src="//mc.yandex.ru/watch/<?php echo $options['uastring'];?>" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
  63. +<!-- Яндекс.Метрика -->
  64.     <?php
  65.             } else if ((current_user_can('edit_users') && !$options["admintracking"])) {
  66.                 echo "<!-- Код счётчика Яндекс.Метрика не отображается, т.к. учёт администраторов запрещён -->";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement