Plugin Directory

Changeset 910037


Ignore:
Timestamp:
05/07/2014 09:12:13 PM (12 years ago)
Author:
cwhitmore
Message:

v1.2.0

  • Added alert to walk you through setup
  • Added alert to let you know if the plugin is turned 'Off'
  • Settings page now refreshes after save
Location:
universal-analytics
Files:
27 added
3 edited

Legend:

Unmodified
Added
Removed
  • universal-analytics/trunk/assets/gua-main.js

    r908662 r910037  
    11jQuery(document).ready(function(e) {
    22
    3    
    4 
    5     jQuery('#classic_plugin_switch').bootstrapSwitch('size', 'small');
    6 
     3    jQuery('#classic_plugin_switch').bootstrapSwitch('size', 'small');
    74    jQuery('#classic_plugin_switch').bootstrapSwitch('onColor', 'success');
    8 
    95    jQuery('#classic_plugin_switch').bootstrapSwitch('offColor', 'danger');
    106
    11    
    12 
    137    jQuery('#plugin_switch').bootstrapSwitch('size', 'small');
    14 
    158    jQuery('#plugin_switch').bootstrapSwitch('onColor', 'success');
    16 
    179    jQuery('#plugin_switch').bootstrapSwitch('offColor', 'danger');
    1810
    19 
    20 
    2111    jQuery('#custom_plugin_switch').bootstrapSwitch('size', 'small');
    22 
    2312    jQuery('#custom_plugin_switch').bootstrapSwitch('onColor', 'success');
    24 
    2513    jQuery('#custom_plugin_switch').bootstrapSwitch('offColor', 'danger');
    2614
    27    
    28 
    2915    jQuery(function() {
    30 
    3116    jQuery('#save-gua-settings').click(function(e) {
    32 
    33             var property_id =   jQuery('#web_property_id').val();
    34 
     17      var property_id   =   jQuery('#web_property_id').val();
    3518            var tracking_off_for_this_role  =   jQuery('#tracking_off_for_this_role').val();
    36 
    3719            var ajax_url                      = jQuery('#ajax_url').val();
    3820
    3921            if(jQuery('#in_footer').is(':checked')){
    40 
    4122                var in_footer   =   'on';   
    42 
    4323            }else{
    44 
    4524                var in_footer   =   'off';
    46 
    4725            }
    4826
    49            
    50 
    5127            if(jQuery('#plugin_switch').is(':checked')){
    52 
    5328                var plugin_switch   =   'on';   
    54 
    5529            }else{
    56 
    5730                var plugin_switch   =   'off';
    58 
    5931            }
    6032
    61            
    62 
    6333            if(jQuery('#track_links').is(':checked')){
    64 
    6534                var track_links =   'on';   
    66 
    6735            }else{
    68 
    6936                var track_links =   'off';
    70 
    7137            }
    7238           
    7339            if(jQuery('#enable_display').is(':checked')){
     40                var enable_display  =   'on';   
     41            }else{
     42                var enable_display  =   'off';
     43            }           
    7444
    75                 var enable_display  =   'on';   
    76 
     45            if(jQuery('#anonymize_ip').is(':checked')){
     46                var anonymize_ip    =   'on';   
    7747            }else{
    78 
    79                 var enable_display  =   'off';
    80 
    81             }
    82            
    83             if(jQuery('#anonymize_ip').is(':checked')){
    84 
    85                 var anonymize_ip    =   'on';   
    86 
    87             }else{
    88 
    8948                var anonymize_ip    =   'off';
    90 
    9149            }
    9250
    9351            if(jQuery('#tracking_off_for_role').is(':checked')){
    94 
    9552                var tracking_off_for_role   =   'on';   
    96 
    9753            }else{
    98 
    9954                var tracking_off_for_role   =   'off';
    100 
    10155            }
    10256
    10357            if(property_id.indexOf('UA-') == -1){
    104 
    10558                jQuery('#web_property_id').parent('.col-sm-9').addClass('has-error');
    106 
    10759                jQuery('.error').css('color', '#F00').removeClass('hide');
    10860
    109                
     61            }else{
     62                //alert('ok proceed on ajax');
     63                jQuery.ajax({
     64                url: ajax_url,
     65                data: {
     66                'action':'mdg_save_google_universal_analytics_settings',
     67                'plugin_switch' : plugin_switch,
     68                        'in_footer' : in_footer,
     69                        'property_id' : property_id,
     70                        'track_links' : track_links,
     71                        'enable_display' : enable_display,                         
     72                        'anonymize_ip' : anonymize_ip,
     73                        'tracking_off_for_role'       : tracking_off_for_role,
     74                        'tracking_off_for_this_role' : tracking_off_for_this_role
     75                },
    11076
    111             }else{
     77                success:function(data) {
     78                jQuery('#web_property_id').parent('.has-error').removeClass('has-error');
     79                        jQuery('.error').addClass('hide');
     80                        jQuery('.form-horizontal .alert').fadeIn().removeClass('hide');
     81                        jQuery('.form-horizontal .alert').delay(3000).fadeOut(500);     
    11282
    113                 //alert('ok proceed on ajax');
    114 
    115                 jQuery.ajax({
    116 
    117                     url: ajax_url,
    118 
    119                     data: {
    120 
    121                             'action':'mdg_save_google_universal_analytics_settings',
    122 
    123                             'plugin_switch' : plugin_switch,
    124 
    125                             'in_footer' : in_footer,
    126 
    127                             'property_id' : property_id,
    128 
    129                             'track_links' : track_links,
    130                            
    131                             'enable_display' : enable_display,
    132                            
    133                             'anonymize_ip' : anonymize_ip,
    134 
    135                             'tracking_off_for_role'       : tracking_off_for_role,
    136 
    137                             'tracking_off_for_this_role' : tracking_off_for_this_role
    138 
    139                         },
    140 
    141                     success:function(data) {
    142 
    143                     jQuery('#web_property_id').parent('.has-error').removeClass('has-error');
    144 
    145                     jQuery('.error').addClass('hide');
    146 
    147                     jQuery('.form-horizontal .alert').fadeIn().removeClass('hide');
    148 
    149                     jQuery('.form-horizontal .alert').delay(3000).fadeOut(500);     
    150 
    151                        
    152 
    153                     },
     83                        // this allows the page to reload and show any additional WP alerts
     84                        location.reload();
     85                },
    15486
    15587                    error: function(errorThrown){
    15688
    157                        
    158 
    15989                    }
    160 
    161     });
    162 
    163                
    164 
    165            
    166 
     90            });
    16791            }
    168 
    169         });     
    170 
     92        });     
     93    });
    17194});
    172 
    173 
    174 
    175 
    176 
    177 jQuery(function() {
    178 
    179     jQuery('#save-custom-settings').click(function(e) {
    180 
    181             var custom_web_property_id                 =    jQuery('#custom_web_property_id').val();
    182 
    183             var custom_tracking_off_for_this_role   =   jQuery('#custom_tracking_off_for_this_role').val();
    184 
    185             var ajax_url                      = jQuery('#ajax_url').val();
    186 
    187             if(jQuery('#custom_in_footer').is(':checked')){
    188 
    189                 var custom_in_footer    =   'on';   
    190 
    191             }else{
    192 
    193                 var custom_in_footer    =   'off';
    194 
    195             }
    196 
    197            
    198 
    199             if(jQuery('#custom_plugin_switch').is(':checked')){
    200 
    201                 var custom_plugin_switch    =   'on';   
    202 
    203             }else{
    204 
    205                 var custom_plugin_switch    =   'off';
    206 
    207             }
    208 
    209            
    210 
    211             if(jQuery('#custom_tracking_off_for_role').is(':checked')){
    212 
    213                 var custom_tracking_off_for_role    =   'on';   
    214 
    215             }else{
    216 
    217                 var custom_tracking_off_for_role    =   'off';
    218 
    219             }
    220 
    221                 //alert('ok proceed on ajax');
    222 
    223                 jQuery.ajax({
    224 
    225                     url: ajax_url,
    226 
    227                     data: {
    228 
    229                             'action':'mdg_save_google_custom_analytics_settings',
    230 
    231                             'custom_in_footer' : custom_in_footer,
    232 
    233                             'custom_plugin_switch' : custom_plugin_switch,
    234 
    235                             'custom_web_property_id' : custom_web_property_id,
    236 
    237                             'custom_tracking_off_for_role'    : custom_tracking_off_for_role,
    238 
    239                             'custom_tracking_off_for_this_role' : custom_tracking_off_for_this_role
    240 
    241                         },
    242 
    243                     success:function(data) {
    244 
    245                     jQuery('.form-horizontal .alert').fadeIn().removeClass('hide');
    246 
    247                     jQuery('.form-horizontal .alert').delay(3000).fadeOut(500);     
    248 
    249                        
    250 
    251                     },
    252 
    253                     error: function(errorThrown){
    254 
    255                        
    256 
    257                     }
    258 
    259     });
    260 
    261                
    262 
    263            
    264 
    265            
    266 
    267         });     
    268 
    269 });
    270 
    271 
    272 
    273 jQuery(function(){
    274 
    275    
    276 
    277     //classic settings event
    278 
    279        
    280 
    281         jQuery('#save-classic-settings').click(function(e) {
    282 
    283            
    284 
    285             var classic_property_id =   jQuery('#classic_web_property_id').val();
    286 
    287             var classic_tracking_off_for_this_role  =   jQuery('#classic_tracking_off_for_this_role').val();
    288 
    289            
    290 
    291             var ajax_url    =   jQuery('#ajax_url').val();
    292 
    293             if(jQuery('#classic_in_footer').is(':checked')){
    294 
    295                 var classic_in_footer   =   'on';   
    296 
    297             }else{
    298 
    299                 var classic_in_footer   =   'off';
    300 
    301             }
    302 
    303            
    304 
    305             if(jQuery('#classic_plugin_switch').is(':checked')){
    306 
    307                 var classic_plugin_switch   =   'on';   
    308 
    309             }else{
    310 
    311                 var classic_plugin_switch   =   'off';
    312 
    313             }
    314 
    315            
    316 
    317             if(jQuery('#classic_tracking_off_for_role').is(':checked')){
    318 
    319                 var classic_tracking_off_for_role   =   'on';   
    320 
    321             }else{
    322 
    323                 var classic_tracking_off_for_role   =   'off';
    324 
    325             }
    326 
    327             if(classic_property_id.indexOf('UA-') == -1){
    328 
    329                 jQuery('#classic_web_property_id').parent('.col-sm-9').addClass('has-error');
    330 
    331                 jQuery('.error').css('color', '#F00').removeClass('hide');
    332 
    333                
    334 
    335             }else{
    336 
    337                 //alert('ok proceed on ajax');
    338 
    339                 jQuery.ajax({
    340 
    341                     url: ajax_url,
    342 
    343                     data: {
    344 
    345                             'action':'mdg_save_google_classic_analytics_settings',
    346 
    347                             'classic_plugin_switch' : classic_plugin_switch,
    348 
    349                             'classic_in_footer' : classic_in_footer,
    350 
    351                             'classic_property_id' : classic_property_id,
    352 
    353                             'classic_tracking_off_for_role' : classic_tracking_off_for_role,
    354 
    355                             'classic_tracking_off_for_this_role' : classic_tracking_off_for_this_role
    356 
    357                         },
    358 
    359                     success:function(data) {
    360 
    361                     jQuery('#classic_web_property_id').parent('.has-error').removeClass('has-error');
    362 
    363                     jQuery('.error').addClass('hide');
    364 
    365                     jQuery('.form-horizontal .alert').fadeIn().removeClass('hide');
    366 
    367                     jQuery('.form-horizontal .alert').delay(3000).fadeOut(500);     
    368 
    369                        
    370 
    371                     },
    372 
    373                     error: function(errorThrown){
    374 
    375                        
    376 
    377                     }
    378 
    379     });
    380 
    381                
    382 
    383            
    384 
    385             }
    386 
    387         });
    388 
    389 });
    390 
    391 
    392 
    393 
    394 
    395 });
  • universal-analytics/trunk/readme.txt

    r909009 r910037  
    44Requires at least: 3.0
    55Tested up to: 3.9
    6 Stable tag: 1.0.1
     6Stable tag: 1.2.0
    77License: GPLv2 or later
    88
     
    4242== Changelog ==
    4343
    44 = 1.0.0 =
    45 * Initial release.
     44= 1.2.0 =
     45* Added alert to walk you through setup
     46* Added alert to let you know if the plugin is turned 'Off'
    4647
    4748= 1.0.1 =
    4849* Fixed bug with plugin folder that didn't allow plugin to load.
    4950
     51= 1.0.0 =
     52* Initial release.
     53
    5054== Upgrade Notice ==
     55
     56= 1.2.0 =
     57* Added alert to walk you through setup
     58* Added alert to let you know if the plugin is turned 'Off'
     59
     60= 1.0.1 =
     61* Fixed bug with plugin folder that didn't allow plugin to load.
    5162
    5263= 1.0.0 =
    5364* Initial release.
    54 
    55 = 1.0.1 =
    56 * Fixed bug with plugin folder that didn't allow plugin to load.
  • universal-analytics/trunk/universalanalytics.php

    r909009 r910037  
    44Plugin URI: http://wordpress.org/extend/plugins/universal-analytics/
    55Description: A simple method to add Google's Universal Analytics JavaScript tracking code to your WordPress website.
    6 Version: 1.0.1
     6Version: 1.2.0
    77Author: Matchbox Design Group
    88Author URI: http://matchboxdesigngroup.com/
     
    148148
    149149add_action( 'wp_ajax_mdg_save_google_universal_analytics_settings', 'mdg_save_google_universal_analytics_settings' );
     150
     151
     152// Alerts
     153// Display an error message when Universal Analytics hasn't been setup.
     154function mdg_google_universal_analytics_check() {
     155    $plugin_switch  = get_option('plugin_switch')=='off';
     156    $property_id        = get_option('web_property_id');
     157   
     158        if (!$property_id){
     159            echo "<div id='message' class='error'>";
     160            echo "<p><strong>" . __( "Almost there: Now you need add your Tracking ID to Universal Analytics.", 'mdg-universal-analytics' ) . "</strong> " . sprintf( __( "Go to your %sGoogle Analytics Settings%s and add your information.", 'mdg-universal-analytics' ), "<a href='" . admin_url( 'options-general.php?page=mdg_google_universal_analytics' ) . "'>", "</a>" ) . "</p></div>";
     161        }elseif ($plugin_switch) {
     162            echo "<div id='message' class='error'>";
     163            echo "<p><strong>" . __( "Whoa there partner: Universal Analytics is turned off.", 'mdg-universal-analytics' ) . "</strong> " . sprintf( __( "This means you aren't tracking your site.  Go to your %sGoogle Analytics Settings%s and change the Status to ON", 'mdg-universal-analytics' ), "<a href='" . admin_url( 'options-general.php?page=mdg_google_universal_analytics' ) . "'>", "</a>" ) . "</p></div>";
     164        }
     165}
     166
     167function mdg_google_universal_analytics_admin_check() {
     168        mdg_google_universal_analytics_check();
     169}
     170add_action( 'admin_head', 'mdg_google_universal_analytics_admin_check' );
    150171?>
Note: See TracChangeset for help on using the changeset viewer.