Plugin Directory

Changeset 588445


Ignore:
Timestamp:
08/21/2012 05:08:05 PM (14 years ago)
Author:
GTmetrix
Message:

version 0.3

Location:
gtmetrix-for-wordpress/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gtmetrix-for-wordpress/trunk/gtmetrix-for-wordpress-src.js

    r556225 r588445  
    236236        success: function() {
    237237          removed = 'table.gfw-table tr#post-' + postId;
    238           if ($(removed + ' a').hasClass('report-expanded')) {
     238          if ($(removed).hasClass('report-expanded')) {
    239239            $(removed).next().hide();
    240240          }
    241241          $(removed).hide();
     242          $('#schedule-meta-box').hide();
    242243          $('table.gfw-table tr').removeClass('odd even');
    243244          $('table.gfw-table tr:visible:odd').addClass('odd');
     
    322323  });
    323324             
    324 
    325 
    326          
    327        
    328                
     325           
    329326});
  • gtmetrix-for-wordpress/trunk/gtmetrix-for-wordpress.js

    r556225 r588445  
    1 jQuery(function(a){function d(b){var c=a("#gfw-scanner"),f=c.height()?!0:!1;!f&&!c.height()?(setTimeout(function(){d()},500),f=!0):c.animate({top:(b?"-":"+")+"=221"},2E3,function(){a("#gfw-scan").overlay().isOpened()?d(!b):a("#gfw-scanner").css("top",-7)})}0<a.inArray(pagenow,["toplevel_page_gfw_settings","gfw_page_gfw_settings","toplevel_page_gfw_tests","gfw_page_gfw_schedule"])&&(a(".if-js-closed").removeClass("if-js-closed").addClass("closed"),postboxes.add_postbox_toggles(pagenow));a("#gfw_url").length&&
    2 a("#gfw_url").autocomplete({source:function(b,c){a.ajax({url:ajaxurl,dataType:"json",data:{action:"autocomplete",term:b.term},success:function(b){c(a.map(b,function(a){return{label:a.title,value:a.permalink}}))}})},minLength:2});"placeholder"in document.createElement("input")||a(".gfw-placeholder-alternative").show();a("#gfw-scan").length&&a("#gfw-scan").overlay({mask:{color:"#fff",loadSpeed:200,opacity:0.6},close:".gfw-modal-close",closeOnClick:!1,onLoad:function(){}});a("#gfw-graph").length&&a("#gfw-graph").overlay({mask:{color:"#fff",
    3 loadSpeed:200,opacity:0.6},close:".gfw-modal-close",closeOnClick:!1});a("#gfw-parameters").submit(function(){a("#gfw-screenshot").css("background-image","url(../wp-content/plugins/gtmetrix-for-wordpress/images/loading-screenshot.png)");a("#gfw-screenshot .gfw-message").text("").hide();a("#gfw-scanner").show();a("#gfw-scan").overlay().load();d(0);a.ajax({url:ajaxurl,dataType:"json",type:"POST",data:{action:"save_report",fields:a(this).serialize(),security:gfwObject.gfwnonce},cache:false,success:function(b){if(b.error){a("#gfw-scanner").hide();
    4 a("#gfw-screenshot").css("background-image","url(../wp-content/plugins/gtmetrix-for-wordpress/images/exclamation.png)");a("#gfw-screenshot .gfw-message").text(b.error).show()}else{a("#gfw_url").val()==a("#gfw-wpurl").val()&&location.reload();a("#gfw-screenshot").css("background-image","url("+b.screenshot+")");a("table.gfw-table > thead tr").show();a("table.gfw-table > tbody").prepend(b.row);a("table.gfw-table > tbody > tr").removeClass("odd even");a("table.gfw-table > tbody > tr:odd").addClass("odd");
    5 a("table.gfw-table > tbody > tr:even").addClass("even");a("p.gfw-no-posts").hide();window.setTimeout(function(){a("#gfw-scan").overlay().close()},1E3)}}});return false});a("table.gfw-table td.gfw-toggle").live("click",function(){if(a(this).parents("tr").hasClass("report-expanded"))a(this).parents("tr").removeClass("report-expanded").addClass("report-collapsed").next().hide();else if(a(this).parents("tr").hasClass("report-collapsed"))a(this).parents("tr").removeClass("report-collapsed").addClass("report-expanded").next().show();
    6 else{var b='<tr><td colspan="'+a(this).parents("tr").find("td").length+'" style="padding:0"></td></tr>';a(this).parents("tr").addClass("report-expanded").after(b);b=a(this).parents("tr").attr("id").substring(5);a(this).parents("tr").next().find("td").load(ajaxurl,{action:"expand_report",id:b})}return false});a(".gfw-open-graph").live("click",function(){var b=a(this).attr("href"),c=a(this).attr("id");a.ajax({url:ajaxurl,cache:false,dataType:"json",data:{action:"report_graph",id:b,graph:c},success:function(b){var e=
    7 {series:{lines:{show:true},points:{show:true}},xaxis:{mode:"time",timeformat:"%b %d %H:%M%P"},grid:{backgroundColor:{colors:["#fff","#eee"]}},legend:{container:"#gfw-graph-legend",noColumns:2}};switch(c){case "gfw-scores-graph":e.yaxis={ticks:5,min:0,max:100,tickFormatter:function(a){return a+"%"}};break;case "gfw-times-graph":e.yaxis={ticks:5,min:0,tickFormatter:function(a){return a.toFixed(1)+" s"}};break;case "gfw-sizes-graph":e.yaxis={ticks:5,min:0,tickFormatter:function(a){return a+" KB"}}}var d=
    8 a("#gfw-flot-placeholder");a("#gfw-graph").overlay().load();a.plot(d,b,e)}});return false});a("#gfw-confirm-delete a").click(function(b){b.preventDefault();if(a(this).hasClass("button-primary")){var c=a(this).data("postId");a(this).removeData("postId");a.ajax({url:ajaxurl,type:"POST",cache:false,data:{action:"delete_post",security:gfwObject.gfwnonce,id:c},success:function(){removed="table.gfw-table tr#post-"+c;a(removed+" a").hasClass("report-expanded")&&a(removed).next().hide();a(removed).hide();
    9 a("table.gfw-table tr").removeClass("odd even");a("table.gfw-table tr:visible:odd").addClass("odd");a("table.gfw-table tr:visible:even").addClass("even")}})}a("#gfw-confirm-delete .gfw-modal-close").click()});a(".gfw-delete-icon").live("click",function(b){b.preventDefault();a(this).overlay({mask:{color:"#fff",loadSpeed:200,opacity:0.6},close:".gfw-modal-close",load:true,onBeforeLoad:function(){var b=this.getTrigger().attr("id").substring(7);a("#gfw-confirm-delete a.button-primary").data("postId",
    10 b)}})});a('.gfw-conditions select[name^="gfw_condition"]').live("change",function(){a(this).siblings("select:not(."+a(this).val()+")").hide();a(this).siblings("select."+a(this).val()).show()});a("#gfw-add-condition a").bind("click",function(){a(".gfw-conditions:hidden:first").show().find(".gfw-condition").removeAttr("disabled").trigger("change");a(".gfw-conditions:visible").length==4&&a(this).parents("tr").hide()});a(".gfw-remove-condition").live("click",function(){a(this).parents("tr").hide().find(".gfw-condition").attr("disabled",
    11 "disabled");a("#gfw-add-condition").show()});a("#gfw-notifications").attr("checked")||a(".gfw-conditions select:visible").attr("disabled","disabled");a("input#gfw-notifications").bind("change",function(){if(a(this).is(":checked")){a(".gfw-conditions select:visible").removeAttr("disabled");a(".gfw-conditions:visible").length<4&&a("#gfw-add-condition").show()}else{a(".gfw-conditions select:visible").attr("disabled","disabled");a("#gfw-add-condition").hide()}return false});a("#gfw-test-front").bind("click",
    12 function(){a("#gfw_url").val(a("#gfw-wpurl").val());a("#gfw-parameters").submit();return false});a(".gfw-add-tooltip-right").tooltip({tipClass:"gfw-tooltip",position:"center right",offset:[0,16],delay:250,predelay:250});a(".gfw-add-tooltip-left").tooltip({tipClass:"gfw-tooltip",position:"center left",offset:[0,-16],delay:250,predelay:250})});
     1jQuery(function(e){function t(){var t=document.createElement("input"),n="placeholder"in t;n||e(".gfw-placeholder-alternative").show()}function n(t){var r=e("#gfw-scanner"),i=r.height()?!0:!1;!i&&!r.height()?(setTimeout(function(){n()},500),i=!0):r.animate({top:(t?"-":"+")+"=221"},2e3,function(){e("#gfw-scan").overlay().isOpened()?n(!t):e("#gfw-scanner").css("top",-7)})}e.inArray(pagenow,new Array("toplevel_page_gfw_settings","gfw_page_gfw_settings","toplevel_page_gfw_tests","gfw_page_gfw_schedule"))>0&&(e(".if-js-closed").removeClass("if-js-closed").addClass("closed"),postboxes.add_postbox_toggles(pagenow)),e("#gfw_url").length&&e("#gfw_url").autocomplete({source:function(t,n){e.ajax({url:ajaxurl,dataType:"json",data:{action:"autocomplete",term:t.term},success:function(t){n(e.map(t,function(e){return{label:e.title,value:e.permalink}}))}})},minLength:2}),t(),e("#gfw-scan").length&&e("#gfw-scan").overlay({mask:{color:"#fff",loadSpeed:200,opacity:.6},close:".gfw-modal-close",closeOnClick:!1,onLoad:function(){}}),e("#gfw-graph").length&&e("#gfw-graph").overlay({mask:{color:"#fff",loadSpeed:200,opacity:.6},close:".gfw-modal-close",closeOnClick:!1}),e("#gfw-parameters").submit(function(){return e("#gfw-screenshot").css("background-image","url(../wp-content/plugins/gtmetrix-for-wordpress/images/loading-screenshot.png)"),e("#gfw-screenshot .gfw-message").text("").hide(),e("#gfw-scanner").show(),e("#gfw-scan").overlay().load(),n(0),e.ajax({url:ajaxurl,dataType:"json",type:"POST",data:{action:"save_report",fields:e(this).serialize(),security:gfwObject.gfwnonce},cache:!1,success:function(t){t.error?(e("#gfw-scanner").hide(),e("#gfw-screenshot").css("background-image","url(../wp-content/plugins/gtmetrix-for-wordpress/images/exclamation.png)"),e("#gfw-screenshot .gfw-message").text(t.error).show()):(e("#gfw_url").val()==e("#gfw-wpurl").val()&&location.reload(),e("#gfw-screenshot").css("background-image","url("+t.screenshot+")"),e("table.gfw-table > thead tr").show(),e("table.gfw-table > tbody").prepend(t.row),e("table.gfw-table > tbody > tr").removeClass("odd even"),e("table.gfw-table > tbody > tr:odd").addClass("odd"),e("table.gfw-table > tbody > tr:even").addClass("even"),e("p.gfw-no-posts").hide(),window.setTimeout(function(){e("#gfw-scan").overlay().close()},1e3))}}),!1}),e("table.gfw-table td.gfw-toggle").live("click",function(){if(e(this).parents("tr").hasClass("report-expanded"))e(this).parents("tr").removeClass("report-expanded").addClass("report-collapsed").next().hide();else if(e(this).parents("tr").hasClass("report-collapsed"))e(this).parents("tr").removeClass("report-collapsed").addClass("report-expanded").next().show();else{var t='<tr><td colspan="'+e(this).parents("tr").find("td").length+'" style="padding:0"></td></tr>';e(this).parents("tr").addClass("report-expanded").after(t);var n=e(this).parents("tr").attr("id").substring(5);e(this).parents("tr").next().find("td").load(ajaxurl,{action:"expand_report",id:n})}return!1}),e(".gfw-open-graph").live("click",function(){var t=e(this).attr("href"),n=e(this).attr("id");return e.ajax({url:ajaxurl,cache:!1,dataType:"json",data:{action:"report_graph",id:t,graph:n},success:function(t){var r={series:{lines:{show:!0},points:{show:!0}},xaxis:{mode:"time",timeformat:"%b %d %H:%M%P"},grid:{backgroundColor:{colors:["#fff","#eee"]}},legend:{container:"#gfw-graph-legend",noColumns:2}};switch(n){case"gfw-scores-graph":r.yaxis={ticks:5,min:0,max:100,tickFormatter:function(e){return e+"%"}};break;case"gfw-times-graph":r.yaxis={ticks:5,min:0,tickFormatter:function(e){return e.toFixed(1)+" s"}};break;case"gfw-sizes-graph":r.yaxis={ticks:5,min:0,tickFormatter:function(e){return e+" KB"}}}var i=e("#gfw-flot-placeholder");e("#gfw-graph").overlay().load(),e.plot(i,t,r)}}),!1}),e("#gfw-confirm-delete a").click(function(t){t.preventDefault();if(e(this).hasClass("button-primary")){var n=e(this).data("postId");e(this).removeData("postId"),e.ajax({url:ajaxurl,type:"POST",cache:!1,data:{action:"delete_post",security:gfwObject.gfwnonce,id:n},success:function(){removed="table.gfw-table tr#post-"+n,e(removed).hasClass("report-expanded")&&e(removed).next().hide(),e(removed).hide(),e("#schedule-meta-box").hide(),e("table.gfw-table tr").removeClass("odd even"),e("table.gfw-table tr:visible:odd").addClass("odd"),e("table.gfw-table tr:visible:even").addClass("even")}})}e("#gfw-confirm-delete .gfw-modal-close").click()}),e(".gfw-delete-icon").live("click",function(t){t.preventDefault(),e(this).overlay({mask:{color:"#fff",loadSpeed:200,opacity:.6},close:".gfw-modal-close",load:!0,onBeforeLoad:function(){var t=this.getTrigger().attr("id").substring(7);e("#gfw-confirm-delete a.button-primary").data("postId",t)}})}),e('.gfw-conditions select[name^="gfw_condition"]').live("change",function(){e(this).siblings("select:not(."+e(this).val()+")").hide(),e(this).siblings("select."+e(this).val()).show()}),e("#gfw-add-condition a").bind("click",function(){e(".gfw-conditions:hidden:first").show().find(".gfw-condition").removeAttr("disabled").trigger("change"),e(".gfw-conditions:visible").length==4&&e(this).parents("tr").hide()}),e(".gfw-remove-condition").live("click",function(){e(this).parents("tr").hide().find(".gfw-condition").attr("disabled","disabled"),e("#gfw-add-condition").show()}),e("#gfw-notifications").attr("checked")||e(".gfw-conditions select:visible").attr("disabled","disabled"),e("input#gfw-notifications").bind("change",function(){return e(this).is(":checked")?(e(".gfw-conditions select:visible").removeAttr("disabled"),e(".gfw-conditions:visible").length<4&&e("#gfw-add-condition").show()):(e(".gfw-conditions select:visible").attr("disabled","disabled"),e("#gfw-add-condition").hide()),!1}),e("#gfw-test-front").bind("click",function(){return e("#gfw_url").val(e("#gfw-wpurl").val()),e("#gfw-parameters").submit(),!1}),e(".gfw-add-tooltip-right").tooltip({tipClass:"gfw-tooltip",position:"center right",offset:[0,16],delay:250,predelay:250}),e(".gfw-add-tooltip-left").tooltip({tipClass:"gfw-tooltip",position:"center left",offset:[0,-16],delay:250,predelay:250})})
  • gtmetrix-for-wordpress/trunk/gtmetrix-for-wordpress.php

    r565546 r588445  
    44  Plugin URI: http://gtmetrix.com/gtmetrix-for-wordpress-plugin.html
    55  Description: GTmetrix can help you develop a faster, more efficient, and all-around improved website experience for your users. Your users will love you for it.
    6   Version: 0.2.1
     6  Version: 0.3
    77  Author: GTmetrix
    88  Author URI: http://gtmetrix.com/
     
    6767
    6868    function add_to_toolbar( $wp_admin_bar ) {
    69         if ( GFW_AUTHORIZED && !is_admin() ) {
     69        if ( GFW_AUTHORIZED && !is_admin() && current_user_can( 'access_gtmetrix' ) ) {
    7070            $args = array(
    7171                'id' => 'gfw-test',
     
    8383        wp_schedule_event( mktime( date( 'H' ) + 1, 0, 0 ), 'monthly', 'gfw_monthly_event', array( 'monthly' ) );
    8484
     85
     86        $role = get_role('administrator');
     87        $role->add_cap('access_gtmetrix');
    8588
    8689        $options = get_option( 'gfw_options' );
     
    250253    public function add_dashboard_widget() {
    251254        $options = get_option( 'gfw_options' );
    252         if ( isset( $options['dashboard_widget'] ) && $options['dashboard_widget'] && GFW_AUTHORIZED ) {
     255        if ( isset( $options['dashboard_widget'] ) && $options['dashboard_widget'] && GFW_AUTHORIZED && current_user_can( 'access_gtmetrix' ) ) {
    253256            wp_add_dashboard_widget( 'gfw_dashboard_widget', 'GTmetrix for WordPress Analysis', array( &$this, 'dashboard_widget' ) );
    254257        }
     
    262265    public function add_menu_items() {
    263266        if ( GFW_AUTHORIZED ) {
    264             add_menu_page( 'GTmetrix', 'GTmetrix', 'manage_options', 'gfw_tests', array( $this, 'tests_page' ) );
    265             $this->tests_page_hook = add_submenu_page( 'gfw_tests', 'Tests', 'Tests', 'manage_options', 'gfw_tests', array( $this, 'tests_page' ) );
    266             $this->schedule_page_hook = add_submenu_page( 'gfw_tests', 'Schedule', 'Schedule', 'manage_options', 'gfw_schedule', array( $this, 'schedule_page' ) );
    267             $this->settings_page_hook = add_submenu_page( 'gfw_tests', 'Settings', 'Settings', 'manage_options', 'gfw_settings', array( $this, 'settings_page' ) );
     267            add_menu_page( 'GTmetrix', 'GTmetrix', 'access_gtmetrix', 'gfw_tests', array( $this, 'tests_page' ) );
     268            $this->tests_page_hook = add_submenu_page( 'gfw_tests', 'Tests', 'Tests', 'access_gtmetrix', 'gfw_tests', array( $this, 'tests_page' ) );
     269            $this->schedule_page_hook = add_submenu_page( 'gfw_tests', 'Schedule', 'Schedule', 'access_gtmetrix', 'gfw_schedule', array( $this, 'schedule_page' ) );
     270            $this->settings_page_hook = add_submenu_page( 'gfw_tests', 'Settings', 'Settings', 'access_gtmetrix', 'gfw_settings', array( $this, 'settings_page' ) );
    268271            add_action( 'load-' . $this->tests_page_hook, array( &$this, 'page_loading' ) );
    269272            add_action( 'load-' . $this->schedule_page_hook, array( &$this, 'page_loading' ) );
    270273        } else {
    271             $this->settings_page_hook = add_menu_page( 'GTmetrix', 'GTmetrix', 'manage_options', 'gfw_settings', array( $this, 'settings_page' ) );
     274            $this->settings_page_hook = add_menu_page( 'GTmetrix', 'GTmetrix', 'access_gtmetrix', 'gfw_settings', array( $this, 'settings_page' ) );
    272275        }
    273276        add_action( 'load-' . $this->settings_page_hook, array( &$this, 'page_loading' ) );
     
    293296            add_settings_field( 'default_adblock', 'Default Adblock status', array( &$this, 'set_default_adblock' ), 'gfw_settings', 'options_section' );
    294297            add_settings_field( 'notifications_email', 'Notifications Email', array( &$this, 'set_notifications_email' ), 'gfw_settings', 'options_section' );
    295 
    296298            add_settings_section( 'widget_section', '', array( &$this, 'section_text' ), 'gfw_settings' );
    297 
    298299            add_settings_field( 'widget_pagespeed', 'Show PageSpeed grade', array( &$this, 'set_widget_pagespeed' ), 'gfw_settings', 'widget_section' );
    299300            add_settings_field( 'widget_yslow', 'Show YSlow grade', array( &$this, 'set_widget_yslow' ), 'gfw_settings', 'widget_section' );
     
    682683    public function save_report( $data, $event_id = 0 ) {
    683684
    684         if ( !current_user_can( 'manage_options' ) ) {
    685             return $post_id;
    686         }
    687 
    688685        $post_id = wp_insert_post( array(
    689686            'post_type' => 'gfw_report',
     
    692689                ) );
    693690
    694         update_post_meta( $post_id, 'gfw_url', $data['gfw_url'] );
     691        update_post_meta( $post_id, 'gfw_url', $this->append_http( $data['gfw_url'] ) );
    695692        update_post_meta( $post_id, 'gfw_label', $data['gfw_label'] );
    696693        update_post_meta( $post_id, 'gfw_location', $data['gfw_location'] );
     
    14071404            $report_date = $this->wp_date( $post_date, true );
    14081405
    1409             $title = $gfw_label ? $gfw_label : $gfw_url;
     1406            $title = $gfw_label ? $gfw_label : $this->append_http($gfw_url);
    14101407
    14111408            $row = '<tr class="' . ($row_no % 2 ? 'even' : 'odd') . '" id="post-' . $post_id . '">';
  • gtmetrix-for-wordpress/trunk/readme.txt

    r565546 r588445  
    44Requires at least: 3.3.1
    55Tested up to: 3.4.1
    6 Stable tag: 0.2.1
     6Stable tag: 0.3
    77
    88GTmetrix can help you develop a faster, more efficient, and all-around improved website experience for your users. Your users will love you for it.
     
    3838== Changelog ==
    3939
     40= 0.3 =
     41* Added access_gtmetrix capability
     42* Fixed scheduling bug
     43* Minor bug fixes
     44
    4045= 0.2.1 =
    4146* Minor bug fix
Note: See TracChangeset for help on using the changeset viewer.