Google Pagespeed Insights - Version 1.0.2

Version Description

  • Tweaked styles to look better in the new WordPress 3.8 admin theme.
  • Fixed accidental use of some php shorttags (<? instead of <?php) that was causing activation errors for some. (Thank you bekar09 for first finding this error)
  • Tweaked ajax.js for better performance (Thanks to Pippin for the suggestion)
  • Tweaked use of get_pages() for better performance (Thanks to Pippin for the suggestion)
  • Fixed a number of php notices
Download this release

Release Info

Developer mattkeys
Plugin Icon 128x128 Google Pagespeed Insights
Version 1.0.2
Comparing to
See all releases

Code changes from version 1.0.1 to 1.0.2

core/admin.php CHANGED
@@ -13,7 +13,7 @@ if(!class_exists('WP_List_Table')){
13
  class GPI_List_Table extends WP_List_Table {
14
 
15
  function __construct(){
16
- global $status, $page;
17
 
18
  //Set parent defaults
19
  parent::__construct( array(
@@ -141,6 +141,7 @@ class GPI_List_Table extends WP_List_Table {
141
  }
142
 
143
  if(!empty($typestocheck)) {
 
144
  foreach($typestocheck as $type)
145
  {
146
  if(!is_array($type)) {
@@ -271,7 +272,7 @@ class GPI_List_Table extends WP_List_Table {
271
  }
272
 
273
  // Setup available column types
274
- function get_columns($ignored = false, $strategy){
275
  if($ignored) {
276
  $columns = array(
277
  'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
@@ -368,24 +369,24 @@ class GPI_List_Table extends WP_List_Table {
368
  // Custom URLs Filter
369
  global $wpdb;
370
 
371
- $post_per_page = ($_GET['post-per-page']) ? $_GET['post-per-page'] : 25 ;
372
 
373
  if ( 'top' == $which ) {
374
  ?>
375
 
376
  <div class="alignleft actions">
377
- <?php if($_GET['render'] == "list" || $_GET['render'] == "summary") { ?>
378
  <select name="filter" id="filter">
379
  <option value="all"><?php _e('All Reports', 'gpagespeedi'); ?></option>
380
  <?php if($gpi_options['check_pages']) { ?>
381
  <option <?php if($report_filter == 'pages') { echo 'selected="selected"'; } ?> value="pages"><?php _e('Pages', 'gpagespeedi'); ?></option>
382
- <? } ?>
383
  <?php if($gpi_options['check_posts']) { ?>
384
  <option <?php if($report_filter == 'posts') { echo 'selected="selected"'; } ?> value="posts"><?php _e('Posts', 'gpagespeedi'); ?></option>
385
- <? } ?>
386
  <?php if($gpi_options['check_categories']) { ?>
387
  <option <?php if($report_filter == 'categories') { echo 'selected="selected"'; } ?> value="categories"><?php _e('Categories', 'gpagespeedi'); ?></option>
388
- <? } ?>
389
  <?php if($gpi_options['cpt_whitelist']) {
390
 
391
  $cpt_whitelist_arr = false;
@@ -414,7 +415,7 @@ class GPI_List_Table extends WP_List_Table {
414
  } ?>
415
  </select>
416
  <?php } ?>
417
- <?php if($_GET['render'] != "summary") { ?>
418
  <select name="post-per-page" id="post-per-page">
419
  <option value="25" <?php if($post_per_page == 25) {echo 'selected="selected"';} ?>><?php _e('25 Results/Page', 'gpagespeedi'); ?></option>
420
  <option value="50" <?php if($post_per_page == 50) {echo 'selected="selected"';} ?>><?php _e('50 Results/Page', 'gpagespeedi'); ?></option>
@@ -439,7 +440,7 @@ class GPI_List_Table extends WP_List_Table {
439
  $gpi_options = $this->getOptions();
440
 
441
  // Setup Columns
442
- $columns = $this->get_columns($ignored_query, $gpi_options['strategy']);
443
  $hidden = array();
444
  $sortable = $this->get_sortable_columns($ignored_query);
445
  $this->_column_headers = array($columns, $hidden, $sortable);
@@ -554,7 +555,7 @@ class GPI_List_Table extends WP_List_Table {
554
 
555
  function do_gpi_actions() {
556
 
557
- if($_GET['page'] != 'google-pagespeed-insights') {
558
  return;
559
  }
560
 
@@ -616,7 +617,7 @@ function do_gpi_actions() {
616
  }
617
  }
618
 
619
- $default_strategy = $_GET['strategy'];
620
  if(!empty($default_strategy)) {
621
  if($default_strategy == 'mobile' || $default_strategy == 'desktop') {
622
  require_once GPI_DIRECTORY . '/core/core.php';
13
  class GPI_List_Table extends WP_List_Table {
14
 
15
  function __construct(){
16
+ global $status, $page, $hook_suffix;
17
 
18
  //Set parent defaults
19
  parent::__construct( array(
141
  }
142
 
143
  if(!empty($typestocheck)) {
144
+ $types[0] = '';
145
  foreach($typestocheck as $type)
146
  {
147
  if(!is_array($type)) {
272
  }
273
 
274
  // Setup available column types
275
+ function gpi_get_columns($ignored = false, $strategy){
276
  if($ignored) {
277
  $columns = array(
278
  'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
369
  // Custom URLs Filter
370
  global $wpdb;
371
 
372
+ $post_per_page = ( isset($_GET['post-per-page']) ) ? $_GET['post-per-page'] : 25 ;
373
 
374
  if ( 'top' == $which ) {
375
  ?>
376
 
377
  <div class="alignleft actions">
378
+ <?php if( isset( $_GET['render'] ) && ( $_GET['render'] == "list" || $_GET['render'] == "summary") ) { ?>
379
  <select name="filter" id="filter">
380
  <option value="all"><?php _e('All Reports', 'gpagespeedi'); ?></option>
381
  <?php if($gpi_options['check_pages']) { ?>
382
  <option <?php if($report_filter == 'pages') { echo 'selected="selected"'; } ?> value="pages"><?php _e('Pages', 'gpagespeedi'); ?></option>
383
+ <?php } ?>
384
  <?php if($gpi_options['check_posts']) { ?>
385
  <option <?php if($report_filter == 'posts') { echo 'selected="selected"'; } ?> value="posts"><?php _e('Posts', 'gpagespeedi'); ?></option>
386
+ <?php } ?>
387
  <?php if($gpi_options['check_categories']) { ?>
388
  <option <?php if($report_filter == 'categories') { echo 'selected="selected"'; } ?> value="categories"><?php _e('Categories', 'gpagespeedi'); ?></option>
389
+ <?php } ?>
390
  <?php if($gpi_options['cpt_whitelist']) {
391
 
392
  $cpt_whitelist_arr = false;
415
  } ?>
416
  </select>
417
  <?php } ?>
418
+ <?php if( isset( $_GET['render'] ) && $_GET['render'] != "summary") { ?>
419
  <select name="post-per-page" id="post-per-page">
420
  <option value="25" <?php if($post_per_page == 25) {echo 'selected="selected"';} ?>><?php _e('25 Results/Page', 'gpagespeedi'); ?></option>
421
  <option value="50" <?php if($post_per_page == 50) {echo 'selected="selected"';} ?>><?php _e('50 Results/Page', 'gpagespeedi'); ?></option>
440
  $gpi_options = $this->getOptions();
441
 
442
  // Setup Columns
443
+ $columns = $this->gpi_get_columns($ignored_query, $gpi_options['strategy']);
444
  $hidden = array();
445
  $sortable = $this->get_sortable_columns($ignored_query);
446
  $this->_column_headers = array($columns, $hidden, $sortable);
555
 
556
  function do_gpi_actions() {
557
 
558
+ if(!isset($_GET['page']) || $_GET['page'] != 'google-pagespeed-insights') {
559
  return;
560
  }
561
 
617
  }
618
  }
619
 
620
+ $default_strategy = ( isset($_GET['strategy']) ) ? $_GET['strategy'] : false;
621
  if(!empty($default_strategy)) {
622
  if($default_strategy == 'mobile' || $default_strategy == 'desktop') {
623
  require_once GPI_DIRECTORY . '/core/core.php';
core/core.php CHANGED
@@ -158,7 +158,10 @@ if (!class_exists('googlePagespeedInsights')) {
158
  WHERE $where_column = $object_id
159
  ");
160
  if($strategy == "desktop" || $strategy == "both") {
161
- if((!empty($desktop_existing_url_info->desktop_last_modified) && ($time - $desktop_existing_url_info->desktop_last_modified) > $recheck_interval) || (empty($desktop_existing_url_info->desktop_last_modified) && (!empty($desktop_existing_url_info)) ) || !empty($urls_to_recheck) || $desktop_existing_url_info->force_recheck == 1 ) {
 
 
 
162
  try{
163
  $result = $service->pagespeedapi->runpagespeed($object_url, array('locale' => $this->gpi_options['response_language'], 'strategy' => 'desktop'));
164
  if(!empty($result)) {
@@ -168,7 +171,6 @@ if (!class_exists('googlePagespeedInsights')) {
168
  $result['type'] = $url_group_type;
169
  $result[$where_column] = $object_id;
170
  $result['last_modified'] = $time;
171
- $result['force_recheck'] = 0;
172
  $this->google_pagespeed_insights_Save_Values($result, $where_column, $object_id, $object_url, true, 'desktop');
173
  }
174
  }
@@ -199,7 +201,10 @@ if (!class_exists('googlePagespeedInsights')) {
199
  WHERE $where_column = $object_id
200
  ");
201
  if($strategy == "mobile" || $strategy == "both") {
202
- if((!empty($mobile_existing_url_info->mobile_last_modified) && ($time - $mobile_existing_url_info->mobile_last_modified) > $recheck_interval) || (empty($mobile_existing_url_info->mobile_last_modified) && (!empty($mobile_existing_url_info)) ) || !empty($urls_to_recheck) || $mobile_existing_url_info->force_recheck == 1 ) {
 
 
 
203
  try{
204
  $result = $service->pagespeedapi->runpagespeed($object_url, array('locale' => $this->gpi_options['response_language'], 'strategy' => 'mobile'));
205
  if(!empty($result)) {
@@ -209,7 +214,6 @@ if (!class_exists('googlePagespeedInsights')) {
209
  $result['type'] = $url_group_type;
210
  $result[$where_column] = $object_id;
211
  $result['last_modified'] = $time;
212
- $result['force_recheck'] = 0;
213
  $this->google_pagespeed_insights_Save_Values($result, $where_column, $object_id, $object_url, true, 'mobile');
214
  }
215
  }
@@ -263,7 +267,7 @@ if (!class_exists('googlePagespeedInsights')) {
263
  $gpi_page_stats_values[$where_column] = $result[$where_column];
264
  $last_modified_column = $strategy . '_last_modified';
265
  $gpi_page_stats_values[$last_modified_column] = $result['last_modified'];
266
- $gpi_page_stats_values['force_recheck'] = $result['force_recheck'];
267
  //Store Score, Response Code, and Page Statistics
268
  if(isset($result['score'])) {
269
  $score_column = $strategy . '_score';
@@ -300,7 +304,6 @@ if (!class_exists('googlePagespeedInsights')) {
300
  $gpi_page_reports_values['strategy'] = $strategy;
301
  $gpi_page_reports_values['rule_key'] = $rulename;
302
  $gpi_page_reports_values['rule_name'] = $ruleset['localizedRuleName'];
303
- $gpi_page_reports_values['rule_score'] = $ruleset['ruleScore'];
304
  $gpi_page_reports_values['rule_impact'] = $ruleset['ruleImpact'];
305
  if(isset($ruleset['urlBlocks'])) {
306
  $gpi_page_reports_values['rule_blocks'] = serialize($ruleset['urlBlocks']);
@@ -389,13 +392,13 @@ if (!class_exists('googlePagespeedInsights')) {
389
 
390
  if($cpt_whitelist_arr && in_array($custom_post_type, $cpt_whitelist_arr)) {
391
  $x=0;
392
- $custom_posts_array = get_posts( array('post_status' => 'publish', 'post_type' => $custom_post_type, 'posts_per_page' => -1) );
393
  foreach($custom_posts_array as $custom_post) {
394
- $url = get_permalink($custom_post->ID);
395
  $blacklisted = $this->google_pagespeed_insights_Check_Blacklist($url, $blacklist_urls);
396
  if(!$blacklisted) {
397
  $urls_to_check[$custom_post_type][$x]['url'] = $url;
398
- $urls_to_check[$custom_post_type][$x]['objectid'] = $custom_post->ID;
399
  $x++;
400
  }
401
  }
@@ -408,13 +411,13 @@ if (!class_exists('googlePagespeedInsights')) {
408
  if($this->gpi_options['check_posts']) {
409
 
410
  $x=0;
411
- $builtin_posts_array = get_posts( array('post_status' => 'publish', 'post_type' => 'post', 'posts_per_page' => -1) );
412
  foreach($builtin_posts_array as $standard_post) {
413
- $url = get_permalink($standard_post->ID);
414
  $blacklisted = $this->google_pagespeed_insights_Check_Blacklist($url, $blacklist_urls);
415
  if(!$blacklisted) {
416
  $urls_to_check['post'][$x]['url'] = $url;
417
- $urls_to_check['post'][$x]['objectid'] = $standard_post->ID;
418
  $x++;
419
  }
420
  }
158
  WHERE $where_column = $object_id
159
  ");
160
  if($strategy == "desktop" || $strategy == "both") {
161
+ if((!empty($desktop_existing_url_info->desktop_last_modified) && ($time - $desktop_existing_url_info->desktop_last_modified) > $recheck_interval)
162
+ || (empty($desktop_existing_url_info->desktop_last_modified) && (!empty($desktop_existing_url_info)) )
163
+ || !empty($urls_to_recheck)
164
+ || (!empty($desktop_existing_url_info->force_recheck) && $desktop_existing_url_info->force_recheck == 1 ) ) {
165
  try{
166
  $result = $service->pagespeedapi->runpagespeed($object_url, array('locale' => $this->gpi_options['response_language'], 'strategy' => 'desktop'));
167
  if(!empty($result)) {
171
  $result['type'] = $url_group_type;
172
  $result[$where_column] = $object_id;
173
  $result['last_modified'] = $time;
 
174
  $this->google_pagespeed_insights_Save_Values($result, $where_column, $object_id, $object_url, true, 'desktop');
175
  }
176
  }
201
  WHERE $where_column = $object_id
202
  ");
203
  if($strategy == "mobile" || $strategy == "both") {
204
+ if((!empty($mobile_existing_url_info->mobile_last_modified) && ($time - $mobile_existing_url_info->mobile_last_modified) > $recheck_interval)
205
+ || (empty($mobile_existing_url_info->mobile_last_modified) && (!empty($mobile_existing_url_info)) )
206
+ || !empty($urls_to_recheck)
207
+ || (!empty($mobile_existing_url_info->force_recheck) && $mobile_existing_url_info->force_recheck == 1 ) ) {
208
  try{
209
  $result = $service->pagespeedapi->runpagespeed($object_url, array('locale' => $this->gpi_options['response_language'], 'strategy' => 'mobile'));
210
  if(!empty($result)) {
214
  $result['type'] = $url_group_type;
215
  $result[$where_column] = $object_id;
216
  $result['last_modified'] = $time;
 
217
  $this->google_pagespeed_insights_Save_Values($result, $where_column, $object_id, $object_url, true, 'mobile');
218
  }
219
  }
267
  $gpi_page_stats_values[$where_column] = $result[$where_column];
268
  $last_modified_column = $strategy . '_last_modified';
269
  $gpi_page_stats_values[$last_modified_column] = $result['last_modified'];
270
+ $gpi_page_stats_values['force_recheck'] = 0;
271
  //Store Score, Response Code, and Page Statistics
272
  if(isset($result['score'])) {
273
  $score_column = $strategy . '_score';
304
  $gpi_page_reports_values['strategy'] = $strategy;
305
  $gpi_page_reports_values['rule_key'] = $rulename;
306
  $gpi_page_reports_values['rule_name'] = $ruleset['localizedRuleName'];
 
307
  $gpi_page_reports_values['rule_impact'] = $ruleset['ruleImpact'];
308
  if(isset($ruleset['urlBlocks'])) {
309
  $gpi_page_reports_values['rule_blocks'] = serialize($ruleset['urlBlocks']);
392
 
393
  if($cpt_whitelist_arr && in_array($custom_post_type, $cpt_whitelist_arr)) {
394
  $x=0;
395
+ $custom_posts_array = get_posts( array('post_status' => 'publish', 'post_type' => $custom_post_type, 'posts_per_page' => -1, 'fields' => 'ids') );
396
  foreach($custom_posts_array as $custom_post) {
397
+ $url = get_permalink($custom_post);
398
  $blacklisted = $this->google_pagespeed_insights_Check_Blacklist($url, $blacklist_urls);
399
  if(!$blacklisted) {
400
  $urls_to_check[$custom_post_type][$x]['url'] = $url;
401
+ $urls_to_check[$custom_post_type][$x]['objectid'] = $custom_post;
402
  $x++;
403
  }
404
  }
411
  if($this->gpi_options['check_posts']) {
412
 
413
  $x=0;
414
+ $builtin_posts_array = get_posts( array('post_status' => 'publish', 'post_type' => 'post', 'posts_per_page' => -1, 'fields' => 'ids') );
415
  foreach($builtin_posts_array as $standard_post) {
416
+ $url = get_permalink($standard_post);
417
  $blacklisted = $this->google_pagespeed_insights_Check_Blacklist($url, $blacklist_urls);
418
  if(!$blacklisted) {
419
  $urls_to_check['post'][$x]['url'] = $url;
420
+ $urls_to_check['post'][$x]['objectid'] = $standard_post;
421
  $x++;
422
  }
423
  }
core/init.php CHANGED
@@ -81,7 +81,7 @@ function gpi_register_languages_dir() {
81
 
82
  $lang_dir = GPI_DIRECTORY . '/languages';
83
 
84
- load_plugin_textdomain('gpagespeedi', $lang_dir);
85
 
86
  }
87
  add_action('plugins_loaded', 'gpi_register_languages_dir');
@@ -109,7 +109,7 @@ function gpi_admin_notice(){
109
 
110
  global $gpi_options;
111
 
112
- if(!$gpi_options['new_activation_message'])
113
  return;
114
  ?>
115
  <div id="message" class="updated">
81
 
82
  $lang_dir = GPI_DIRECTORY . '/languages';
83
 
84
+ load_plugin_textdomain('gpagespeedi', '', $lang_dir);
85
 
86
  }
87
  add_action('plugins_loaded', 'gpi_register_languages_dir');
109
 
110
  global $gpi_options;
111
 
112
+ if($gpi_options['new_activation_message'] == false)
113
  return;
114
  ?>
115
  <div id="message" class="updated">
css/gpagespeedi_styles.css CHANGED
@@ -14,6 +14,8 @@
14
  background-image: url(../images/button_icons.png);
15
  background-position: 9px 2px;
16
  background-repeat: no-repeat;
 
 
17
  }
18
  .button-gpi.view:hover {
19
  background-position: -174px 2px;
@@ -117,6 +119,7 @@ p.submit input[type="submit"] {
117
  color: #454547;
118
  font-size: 14px;
119
  font-family: Arial, sans-serif;
 
120
  }
121
 
122
  .toolbar {
14
  background-image: url(../images/button_icons.png);
15
  background-position: 9px 2px;
16
  background-repeat: no-repeat;
17
+ transition: none;
18
+ -webkit-transition: none;
19
  }
20
  .button-gpi.view:hover {
21
  background-position: -174px 2px;
119
  color: #454547;
120
  font-size: 14px;
121
  font-family: Arial, sans-serif;
122
+ background: #ffffff;
123
  }
124
 
125
  .toolbar {
google-pagespeed-insights.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
  /**
3
  * @package google_pagespeed_insights
4
- * @version 1.0.1
5
  */
6
  /*
7
  Plugin Name: Google Pagespeed Insights
8
  Plugin URI: http://mattkeys.me
9
  Description: Google Pagespeed Insights
10
  Author: Matt Keys
11
- Version: 1.0.1
12
  Author URI: http://mattkeys.me
13
  */
14
 
1
  <?php
2
  /**
3
  * @package google_pagespeed_insights
4
+ * @version 1.0.2
5
  */
6
  /*
7
  Plugin Name: Google Pagespeed Insights
8
  Plugin URI: http://mattkeys.me
9
  Description: Google Pagespeed Insights
10
  Author: Matt Keys
11
+ Version: 1.0.2
12
  Author URI: http://mattkeys.me
13
  */
14
 
images/pagespeed_gauge.png CHANGED
Binary file
includes/activation.php CHANGED
@@ -74,7 +74,6 @@ function gpi_setup_db(){
74
  strategy varchar(20) NOT NULL,
75
  rule_key varchar(200) NOT NULL,
76
  rule_name varchar(200) DEFAULT NULL,
77
- rule_score decimal(5,2) DEFAULT NULL,
78
  rule_impact decimal(5,2) DEFAULT NULL,
79
  rule_blocks longtext,
80
  PRIMARY KEY (ID),
74
  strategy varchar(20) NOT NULL,
75
  rule_key varchar(200) NOT NULL,
76
  rule_name varchar(200) DEFAULT NULL,
 
77
  rule_impact decimal(5,2) DEFAULT NULL,
78
  rule_blocks longtext,
79
  PRIMARY KEY (ID),
includes/admin/details.php CHANGED
@@ -15,7 +15,7 @@ function gpi_render_details_page($default_strategy, $page_id){
15
 
16
  $gpi_options = $GPI_ListTable->getOptions();
17
 
18
- $strategy = ($_GET['strategy']) ? $_GET['strategy'] : $default_strategy ;
19
  $page_stats_column = $strategy . '_page_stats';
20
  $score_column = $strategy . '_score';
21
  $last_checked_column = $strategy . '_last_modified';
@@ -56,7 +56,7 @@ function gpi_render_details_page($default_strategy, $page_id){
56
 
57
  $gpi_page_reports = $wpdb->base_prefix . 'gpi_page_reports';
58
  $query2 = "
59
- SELECT rule_key, rule_name, rule_score, rule_impact, rule_blocks
60
  FROM $gpi_page_reports
61
  WHERE page_id = $page_id
62
  AND strategy = '$strategy'
@@ -82,8 +82,10 @@ function gpi_render_details_page($default_strategy, $page_id){
82
  }
83
  }
84
  $report['rule_blocks'][$rule_key]['description'] = $report['rule_blocks'][$rule_key]['header']['format'];
85
- $report['rule_blocks'][$rule_key]['hyperlink']['url'] = $report['rule_blocks'][$rule_key]['header']['hyperlink'];
86
- $report['rule_blocks'][$rule_key]['hyperlink']['name'] = $report['rule_name'];
 
 
87
  unset($report['rule_blocks'][$rule_key]['header']);
88
 
89
  //Format description for each instance of broken rule
@@ -175,7 +177,8 @@ function gpi_render_details_page($default_strategy, $page_id){
175
  'legend': 'none',
176
  'tooltip': {trigger:'none'},
177
  'backgroundColor':'transparent',
178
- 'colors': ["#3366cc","#dc3912","#ff9900","#109618","#990099","#0099c6","#dd4477","#66aa00","#b82e2e","#316395","#994499","#22aa99","#aaaa11","#6633cc","#e67300","#8b0707","#651067","#329262","#5574a6","#3b3eac","#b77322","#16d620","#b91383","#f4359e","#9c5935","#a9c413","#2a778d","#668d1c","#bea413","#0c5922","#743411"]
 
179
  };
180
 
181
  // Instantiate and draw our chart, passing in some options.
@@ -248,7 +251,7 @@ function gpi_render_details_page($default_strategy, $page_id){
248
  }
249
  html = html + '</ul>';
250
  }
251
- if(rule_blocks[i].hyperlink.url != null) {
252
  html = html + '<a class="rule_docs" href="' + rule_blocks[i].hyperlink.url + '" target="_blank" alt="<?php _e("Read Documentation", "gpagespeedi"); ?>" ><?php _e("Read Documentation", "gpagespeedi"); ?></a>';
253
  }
254
  }
15
 
16
  $gpi_options = $GPI_ListTable->getOptions();
17
 
18
+ $strategy = ( isset($_GET['strategy']) ) ? $_GET['strategy'] : $default_strategy ;
19
  $page_stats_column = $strategy . '_page_stats';
20
  $score_column = $strategy . '_score';
21
  $last_checked_column = $strategy . '_last_modified';
56
 
57
  $gpi_page_reports = $wpdb->base_prefix . 'gpi_page_reports';
58
  $query2 = "
59
+ SELECT rule_key, rule_name, rule_impact, rule_blocks
60
  FROM $gpi_page_reports
61
  WHERE page_id = $page_id
62
  AND strategy = '$strategy'
82
  }
83
  }
84
  $report['rule_blocks'][$rule_key]['description'] = $report['rule_blocks'][$rule_key]['header']['format'];
85
+ if( isset( $report['rule_blocks'][$rule_key]['header']['hyperlink'] ) ) {
86
+ $report['rule_blocks'][$rule_key]['hyperlink']['url'] = $report['rule_blocks'][$rule_key]['header']['hyperlink'];
87
+ $report['rule_blocks'][$rule_key]['hyperlink']['name'] = $report['rule_name'];
88
+ }
89
  unset($report['rule_blocks'][$rule_key]['header']);
90
 
91
  //Format description for each instance of broken rule
177
  'legend': 'none',
178
  'tooltip': {trigger:'none'},
179
  'backgroundColor':'transparent',
180
+ 'colors': ["#3366cc","#dc3912","#ff9900","#109618","#990099","#0099c6","#dd4477","#66aa00","#b82e2e","#316395","#994499","#22aa99","#aaaa11","#6633cc","#e67300","#8b0707","#651067","#329262","#5574a6","#3b3eac","#b77322","#16d620","#b91383","#f4359e","#9c5935","#a9c413","#2a778d","#668d1c","#bea413","#0c5922","#743411"],
181
+ 'pieSliceTextStyle': {color: 'black', fontSize: 14}
182
  };
183
 
184
  // Instantiate and draw our chart, passing in some options.
251
  }
252
  html = html + '</ul>';
253
  }
254
+ if(typeof rule_blocks[i].hyperlink != 'undefined') {
255
  html = html + '<a class="rule_docs" href="' + rule_blocks[i].hyperlink.url + '" target="_blank" alt="<?php _e("Read Documentation", "gpagespeedi"); ?>" ><?php _e("Read Documentation", "gpagespeedi"); ?></a>';
256
  }
257
  }
includes/admin/ignored-urls.php CHANGED
@@ -9,7 +9,7 @@ function gpi_render_ignored_urls_page(){
9
  $GPI_ListTable = new GPI_List_Table();
10
  $gpi_options = $GPI_ListTable->getOptions();
11
 
12
- $post_per_page = ($_GET['post-per-page']) ? $_GET['post-per-page'] : 25 ;
13
 
14
  $GPI_ListTable->prepare_items(true, 'ignored', $post_per_page);
15
 
9
  $GPI_ListTable = new GPI_List_Table();
10
  $gpi_options = $GPI_ListTable->getOptions();
11
 
12
+ $post_per_page = ( isset($_GET['post-per-page']) ) ? $_GET['post-per-page'] : 25 ;
13
 
14
  $GPI_ListTable->prepare_items(true, 'ignored', $post_per_page);
15
 
includes/admin/list.php CHANGED
@@ -15,7 +15,7 @@ function gpi_render_list_page(){
15
  $GPI_ListTable = new GPI_List_Table();
16
  $gpi_options = $GPI_ListTable->getOptions();
17
 
18
- $post_per_page = ($_GET['post-per-page']) ? $_GET['post-per-page'] : 25 ;
19
 
20
  $GPI_ListTable->prepare_items(false, $report_filter, $post_per_page);
21
 
15
  $GPI_ListTable = new GPI_List_Table();
16
  $gpi_options = $GPI_ListTable->getOptions();
17
 
18
+ $post_per_page = ( isset($_GET['post-per-page']) ) ? $_GET['post-per-page'] : 25 ;
19
 
20
  $GPI_ListTable->prepare_items(false, $report_filter, $post_per_page);
21
 
includes/admin/options.php CHANGED
@@ -64,7 +64,8 @@ function gpi_render_options_page() {
64
  'bad_api_key' => false,
65
  'pagespeed_disabled' => false,
66
  'new_ignored_items' => false,
67
- 'backend_error' => false
 
68
  );
69
  update_option( 'gpagespeedi_options', $new_values );
70
 
@@ -94,10 +95,10 @@ function gpi_render_options_page() {
94
  $cpt_whitelist_arr = unserialize($options['cpt_whitelist']);
95
  ?>
96
  <?php if($_POST) {
97
- if(!$options['first_run_complete'] || $_POST['check_new_pages'] || $_POST['recheck_all_pages']) {
98
  ?>
99
  <div id="message" class="updated">
100
- <?php if($options['alt_pagespeed_scan']) { ?>
101
  <p><?php _e('Settings Saved. Google Pagespeed Insights will now begin generating page reports. This page may appear to still be loading, however report generation will continue when you navigate away.', 'gpagespeedi'); ?></p>
102
  <?php } else { ?>
103
  <p><?php _e('Settings Saved. Google Pagespeed Insights will now begin generating page reports. Click the "Report List" tab to watch the progress', 'gpagespeedi'); ?></p>
@@ -139,7 +140,7 @@ function gpi_render_options_page() {
139
  </div>
140
  <div class="padded">
141
  <p><?php _e('Google API Key:', 'gpagespeedi'); ?></p>
142
- <input type="text" name="google_developer_key" id="google_developer_key" value="<?=$options['google_developer_key'];?>" class="googleapi code" />
143
  <p class="description"><span style="color:red;"><?php _e('This is required', 'gpagespeedi'); ?></span>: <?php _e('if you do not have an API key you can create a new one for free from', 'gpagespeedi'); ?>: <a href="https://code.google.com/apis/console" target="_blank">https://code.google.com/apis/console</a></p>
144
 
145
  <p><?php _e('Google Response Language:', 'gpagespeedi'); ?></p>
64
  'bad_api_key' => false,
65
  'pagespeed_disabled' => false,
66
  'new_ignored_items' => false,
67
+ 'backend_error' => false,
68
+ 'new_activation_message' => false
69
  );
70
  update_option( 'gpagespeedi_options', $new_values );
71
 
95
  $cpt_whitelist_arr = unserialize($options['cpt_whitelist']);
96
  ?>
97
  <?php if($_POST) {
98
+ if(!$options['first_run_complete'] || isset($_POST['check_new_pages']) || isset($_POST['recheck_all_pages']) ) {
99
  ?>
100
  <div id="message" class="updated">
101
+ <?php if($options['scan_method'] == "session_flush") { ?>
102
  <p><?php _e('Settings Saved. Google Pagespeed Insights will now begin generating page reports. This page may appear to still be loading, however report generation will continue when you navigate away.', 'gpagespeedi'); ?></p>
103
  <?php } else { ?>
104
  <p><?php _e('Settings Saved. Google Pagespeed Insights will now begin generating page reports. Click the "Report List" tab to watch the progress', 'gpagespeedi'); ?></p>
140
  </div>
141
  <div class="padded">
142
  <p><?php _e('Google API Key:', 'gpagespeedi'); ?></p>
143
+ <input type="text" name="google_developer_key" id="google_developer_key" value="<?php echo $options['google_developer_key'];?>" class="googleapi code" />
144
  <p class="description"><span style="color:red;"><?php _e('This is required', 'gpagespeedi'); ?></span>: <?php _e('if you do not have an API key you can create a new one for free from', 'gpagespeedi'); ?>: <a href="https://code.google.com/apis/console" target="_blank">https://code.google.com/apis/console</a></p>
145
 
146
  <p><?php _e('Google Response Language:', 'gpagespeedi'); ?></p>
includes/admin/summary.php CHANGED
@@ -16,7 +16,7 @@ function gpi_render_summary_page($default_strategy) {
16
  $gpi_options = $GPI_ListTable->getOptions();
17
 
18
  // Mobile or Desktop reports?
19
- $strategy = ($_GET['strategy']) ? $_GET['strategy'] : $default_strategy;
20
  $score_column = $strategy . '_score';
21
  $page_stats_column = $strategy . '_page_stats';
22
 
@@ -50,11 +50,7 @@ function gpi_render_summary_page($default_strategy) {
50
  // Page Reports Query
51
  $reports_typestocheck = $GPI_ListTable->getTypesToCheck($filter);
52
  $gpi_page_reports = $wpdb->base_prefix . 'gpi_page_reports';
53
- $reportsquery = "
54
- SELECT r.rule_key, r.rule_name, r.rule_impact
55
- FROM $gpi_page_stats as d, $gpi_page_reports as r
56
- WHERE $reports_typestocheck
57
- ";
58
  if(!empty($reports_typestocheck)) {
59
 
60
  $allpagereports = $wpdb->get_results(
16
  $gpi_options = $GPI_ListTable->getOptions();
17
 
18
  // Mobile or Desktop reports?
19
+ $strategy = ( isset($_GET['strategy']) ) ? $_GET['strategy'] : $default_strategy;
20
  $score_column = $strategy . '_score';
21
  $page_stats_column = $strategy . '_page_stats';
22
 
50
  // Page Reports Query
51
  $reports_typestocheck = $GPI_ListTable->getTypesToCheck($filter);
52
  $gpi_page_reports = $wpdb->base_prefix . 'gpi_page_reports';
53
+
 
 
 
 
54
  if(!empty($reports_typestocheck)) {
55
 
56
  $allpagereports = $wpdb->get_results(
js/ajax.js CHANGED
@@ -1,7 +1,9 @@
1
  (function($) {
2
  $(document).ready(function(){
3
 
4
- if($('#gpi_status_ajax').length > 0) {
 
 
5
  $.fn.gpiCheckStatus = function() {
6
  $.post(
7
  GPI_Ajax.ajaxurl,
@@ -17,18 +19,18 @@
17
  return;
18
  }
19
  if(response == 'done') {
20
- $('#gpi_status_ajax').hide();
21
  $('#gpi_status_finished').show();
22
  clearInterval(gpi_interval_id);
23
  } else {
24
- $('#gpi_status_ajax').html('<div class="loading_bar_shell"><div class="reportscore_outter_bar"><div class="reportscore_inner_bar" style="width:' + response + '%;"></div></div><span>' + response + '%</span></div>');
25
  }
26
  }
27
  );
28
  return false;
29
- }
30
  var gpi_interval_id = setInterval(function() {
31
- $('#gpi_status_ajax').gpiCheckStatus();
32
  }, 2000);
33
  }
34
 
1
  (function($) {
2
  $(document).ready(function(){
3
 
4
+ var gpi_check_status = $('#gpi_status_ajax');
5
+
6
+ if(gpi_check_status.length > 0) {
7
  $.fn.gpiCheckStatus = function() {
8
  $.post(
9
  GPI_Ajax.ajaxurl,
19
  return;
20
  }
21
  if(response == 'done') {
22
+ gpi_check_status.hide();
23
  $('#gpi_status_finished').show();
24
  clearInterval(gpi_interval_id);
25
  } else {
26
+ gpi_check_status.html('<div class="loading_bar_shell"><div class="reportscore_outter_bar"><div class="reportscore_inner_bar" style="width:' + response + '%;"></div></div><span>' + response + '%</span></div>');
27
  }
28
  }
29
  );
30
  return false;
31
+ };
32
  var gpi_interval_id = setInterval(function() {
33
+ gpi_check_status.gpiCheckStatus();
34
  }, 2000);
35
  }
36
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mattkeys
3
  Donate link: http://mattkeys.me/
4
  Tags: SEO, seo, performance, speed, google, search engine optimization, pagespeed, google page speed, page speed, pagespeed insights, google pagespeed insights
5
  Requires at least: 3.3
6
- Tested up to: 3.6.1
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -131,6 +131,13 @@ Google Pagespeed Insights requires a Google API Key. Keys are free and can be ob
131
 
132
  == Changelog ==
133
 
 
 
 
 
 
 
 
134
  = 1.0.1 =
135
  * Fixed a potential conflict with other plugins that also utilize the Google API PHP library. The API is now only included if the Google_Client class does not already exist.
136
  * Added additional checking during plugin activation to fail fast if the server does not meet the minimum plugin requirements.
@@ -140,6 +147,9 @@ Google Pagespeed Insights requires a Google API Key. Keys are free and can be ob
140
 
141
  == Upgrade Notice ==
142
 
 
 
 
143
  = 1.0.1 =
144
  This version fixes a potential conflict with other Wordpress plugins that are also using the Google API PHP library.
145
 
3
  Donate link: http://mattkeys.me/
4
  Tags: SEO, seo, performance, speed, google, search engine optimization, pagespeed, google page speed, page speed, pagespeed insights, google pagespeed insights
5
  Requires at least: 3.3
6
+ Tested up to: 3.8
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
131
 
132
  == Changelog ==
133
 
134
+ = 1.0.2 =
135
+ * Tweaked styles to look better in the new WordPress 3.8 admin theme.
136
+ * Fixed accidental use of some php shorttags (<? instead of <?php) that was causing activation errors for some. (Thank you bekar09 for first finding this error)
137
+ * Tweaked ajax.js for better performance (Thanks to Pippin for the suggestion)
138
+ * Tweaked use of get_pages() for better performance (Thanks to Pippin for the suggestion)
139
+ * Fixed a number of php notices
140
+
141
  = 1.0.1 =
142
  * Fixed a potential conflict with other plugins that also utilize the Google API PHP library. The API is now only included if the Google_Client class does not already exist.
143
  * Added additional checking during plugin activation to fail fast if the server does not meet the minimum plugin requirements.
147
 
148
  == Upgrade Notice ==
149
 
150
+ = 1.0.2 =
151
+ Added better style support for Wordpress 3.8. Fixed a handful of bugs that were creating PHP notices and in some cases preventing activation.
152
+
153
  = 1.0.1 =
154
  This version fixes a potential conflict with other Wordpress plugins that are also using the Google API PHP library.
155