Version Description
- Added snapshot comments to the view snapshot / compare snapshot templates
- Fixed bug with snapshot report type label reading 'both' when it should read either desktop or mobile
- Fixed bug with snapshot report description label not loading translatable string
- Fixed bug preventing snapshot comments from being displayed in snapshots list table
- Improved hardening against authenticated XSS attacks
- Improved adherence to WordPress coding standards and best practices
Download this release
Release Info
Developer | mattkeys |
Plugin | Google Pagespeed Insights |
Version | 3.0.1 |
Comparing to | |
See all releases |
Code changes from version 3.0.0 to 3.0.1
- assets/css/gpagespeedi_styles.css +4 -0
- assets/js/view-snapshot.js +6 -0
- classes/class-GPI-Actions.php +26 -26
- classes/class-GPI-Admin.php +26 -20
- classes/class-GPI-List-Table.php +33 -33
- google-pagespeed-insights.php +1 -1
- readme.txt +16 -0
- templates/add-custom-urls-bulk.php +1 -1
- templates/add-custom-urls.php +2 -2
- templates/custom-urls.php +1 -1
- templates/ignored-urls.php +1 -1
- templates/options.php +1 -1
- templates/parts/messages.php +11 -9
- templates/parts/navigation.php +14 -12
- templates/report-list.php +1 -1
- templates/snapshots.php +1 -1
- templates/summary.php +6 -6
- templates/view-snapshot.php +8 -8
assets/css/gpagespeedi_styles.css
CHANGED
@@ -131,6 +131,9 @@ input[type="submit"] + input[type="submit"] {
|
|
131 |
display: inline-block;
|
132 |
margin: 1px 8px 0 0;
|
133 |
}
|
|
|
|
|
|
|
134 |
.row {
|
135 |
width: 100%;
|
136 |
overflow: auto;
|
@@ -487,6 +490,7 @@ div#no_results {
|
|
487 |
vertical-align: top;
|
488 |
width: 21px;
|
489 |
display: inline-block;
|
|
|
490 |
}
|
491 |
.impact_chart_div {
|
492 |
width: 463px;
|
131 |
display: inline-block;
|
132 |
margin: 1px 8px 0 0;
|
133 |
}
|
134 |
+
.tablenav.top.snapshots {
|
135 |
+
height: auto;
|
136 |
+
}
|
137 |
.row {
|
138 |
width: 100%;
|
139 |
overflow: auto;
|
490 |
vertical-align: top;
|
491 |
width: 21px;
|
492 |
display: inline-block;
|
493 |
+
word-wrap: normal;
|
494 |
}
|
495 |
.impact_chart_div {
|
496 |
width: 463px;
|
assets/js/view-snapshot.js
CHANGED
@@ -10,6 +10,12 @@
|
|
10 |
|
11 |
|
12 |
$( document ).ready( function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
$('.pagespeed_needle').each( function( index ) {
|
15 |
var selector = $(this).data('selector');
|
10 |
|
11 |
|
12 |
$( document ).ready( function() {
|
13 |
+
if ( GPI_View_Snapshot.comments.snapshot ) {
|
14 |
+
$('.comment[data-selector="snapshot"]').html( '<strong>' + GPI_View_Snapshot.strings.comment + ':</strong>' + GPI_View_Snapshot.comments.snapshot );
|
15 |
+
}
|
16 |
+
if ( GPI_View_Snapshot.comments.compare ) {
|
17 |
+
$('.comment[data-selector="compare"]').html( '<strong>' + GPI_View_Snapshot.strings.comment + ':</strong>' + GPI_View_Snapshot.comments.compare );
|
18 |
+
}
|
19 |
|
20 |
$('.pagespeed_needle').each( function( index ) {
|
21 |
var selector = $(this).data('selector');
|
classes/class-GPI-Actions.php
CHANGED
@@ -31,11 +31,11 @@ class GPI_Actions
|
|
31 |
{
|
32 |
global $wpdb;
|
33 |
|
34 |
-
$this->action = $_REQUEST['action'];
|
35 |
$this->gpi_options = get_option( 'gpagespeedi_options' );
|
36 |
$this->gpi_ui_options = get_option( 'gpagespeedi_ui_options' );
|
37 |
$this->page_id = isset( $_GET['page_id'] ) ? intval( $_GET['page_id'] ) : false;
|
38 |
-
$this->bulk_pages = isset( $_GET['gpi_page_report'] ) ? $_GET['gpi_page_report'] : false;
|
39 |
$this->bulk_pages_count = count( $this->bulk_pages );
|
40 |
|
41 |
$this->gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
|
@@ -166,7 +166,7 @@ class GPI_Actions
|
|
166 |
if ( 'purge_reports' == $_POST['purge_all_data'] ) {
|
167 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_stats" );
|
168 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_reports" );
|
169 |
-
} else if ( $_POST['purge_all_data']
|
170 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_stats" );
|
171 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_reports" );
|
172 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_blacklist" );
|
@@ -181,19 +181,19 @@ class GPI_Actions
|
|
181 |
$old_options = $this->gpi_options;
|
182 |
|
183 |
$gpagespeedi_options = array(
|
184 |
-
'google_developer_key' => ! empty( $_POST['google_developer_key'] ) ? $_POST['google_developer_key']
|
185 |
-
'response_language' => ! empty( $_POST['response_language'] ) ? $_POST['response_language']
|
186 |
-
'strategy' => ! empty( $_POST['strategy'] ) ? $_POST['strategy']
|
187 |
-
'max_execution_time' => ! empty( $_POST['max_execution_time'] ) ? $_POST['max_execution_time']
|
188 |
-
'max_run_time' => ! empty( $_POST['max_run_time'] ) ? $_POST['max_run_time']
|
189 |
-
'sleep_time' => isset( $_POST['sleep_time'] ) ? $_POST['sleep_time']
|
190 |
-
'recheck_interval' => ! empty( $_POST['recheck_interval'] ) ? $_POST['recheck_interval']
|
191 |
-
'use_schedule' => isset( $_POST['use_schedule'] ) ? true
|
192 |
-
'check_pages' => isset( $_POST['check_pages'] ) ? true
|
193 |
-
'check_posts' => isset( $_POST['check_posts'] ) ? true
|
194 |
-
'cpt_whitelist' => isset( $_POST['cpt_whitelist'] ) ? serialize( $_POST['cpt_whitelist'] ) : false,
|
195 |
-
'check_categories' => isset( $_POST['check_categories'] ) ? true
|
196 |
-
'check_custom_urls' => isset( $_POST['check_custom_urls'] ) ? true
|
197 |
'first_run_complete' => $this->gpi_options['first_run_complete'],
|
198 |
'last_run_finished' => $this->gpi_options['last_run_finished'],
|
199 |
'bad_api_key' => false,
|
@@ -201,9 +201,9 @@ class GPI_Actions
|
|
201 |
'api_restriction' => false,
|
202 |
'new_ignored_items' => false,
|
203 |
'backend_error' => false,
|
204 |
-
'log_api_errors' => isset( $_POST['log_api_errors'] ) ? true
|
205 |
'new_activation_message' => false,
|
206 |
-
'heartbeat' => isset( $_POST['heartbeat'] ) ? $_POST['heartbeat']
|
207 |
'version' => GPI_VERSION
|
208 |
);
|
209 |
update_option( 'gpagespeedi_options', $gpagespeedi_options );
|
@@ -211,7 +211,7 @@ class GPI_Actions
|
|
211 |
|
212 |
$gpagespeedi_ui_options = array(
|
213 |
'action_message' => false,
|
214 |
-
'view_preference' => 'both' != $_POST['strategy'] ? $_POST['strategy'] : $this->gpi_ui_options['view_preference']
|
215 |
);
|
216 |
|
217 |
update_option( 'gpagespeedi_ui_options', $gpagespeedi_ui_options );
|
@@ -456,10 +456,10 @@ class GPI_Actions
|
|
456 |
global $wpdb;
|
457 |
|
458 |
$snapshot_data = array(
|
459 |
-
'strategy' => $this->
|
460 |
-
'type' => isset( $_GET['filter'] ) ? $_GET['filter'] : 'all',
|
461 |
'snaptime' => current_time( 'timestamp' ),
|
462 |
-
'comment' => isset( $_POST['comment'] ) ? $_POST['comment'] : false,
|
463 |
'summary_stats' => json_encode( apply_filters( 'gpi_summary_stats', array() ) ),
|
464 |
'summary_reports' => json_encode( apply_filters( 'gpi_summary_reports', array() ) )
|
465 |
);
|
@@ -491,8 +491,8 @@ class GPI_Actions
|
|
491 |
);
|
492 |
}
|
493 |
|
494 |
-
if ( empty( $this->bulk_pages ) && ( isset( $_GET['snapshot_id'] ) && ! empty( $_GET['snapshot_id'] ) ) ) {
|
495 |
-
$this->bulk_pages = array( $_GET['snapshot_id'] );
|
496 |
}
|
497 |
|
498 |
if ( empty( $this->bulk_pages ) ) {
|
@@ -531,7 +531,7 @@ class GPI_Actions
|
|
531 |
$custom_url_label = 'custom';
|
532 |
} else {
|
533 |
$custom_url_label = preg_replace( '/[^a-zA-Z0-9\s]/', '', $custom_url_label );
|
534 |
-
$custom_url_label = str_replace(' ', '_', $custom_url_label);
|
535 |
$custom_url_label = substr( $custom_url_label, 0, 20 );
|
536 |
}
|
537 |
|
@@ -642,8 +642,8 @@ class GPI_Actions
|
|
642 |
if ( ! $custom_url_label ) {
|
643 |
$custom_url_label = 'custom';
|
644 |
} else {
|
|
|
645 |
$custom_url_label = str_replace( ' ', '_', $custom_url_label );
|
646 |
-
$custom_url_label = preg_replace( '/[^\w\d ]/ui', '', $custom_url_label );
|
647 |
$custom_url_label = substr( $custom_url_label, 0, 20 );
|
648 |
}
|
649 |
|
31 |
{
|
32 |
global $wpdb;
|
33 |
|
34 |
+
$this->action = sanitize_text_field( $_REQUEST['action'] );
|
35 |
$this->gpi_options = get_option( 'gpagespeedi_options' );
|
36 |
$this->gpi_ui_options = get_option( 'gpagespeedi_ui_options' );
|
37 |
$this->page_id = isset( $_GET['page_id'] ) ? intval( $_GET['page_id'] ) : false;
|
38 |
+
$this->bulk_pages = isset( $_GET['gpi_page_report'] ) ? array_map( 'intval', $_GET['gpi_page_report'] ) : false;
|
39 |
$this->bulk_pages_count = count( $this->bulk_pages );
|
40 |
|
41 |
$this->gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
|
166 |
if ( 'purge_reports' == $_POST['purge_all_data'] ) {
|
167 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_stats" );
|
168 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_reports" );
|
169 |
+
} else if ( 'purge_everything' == $_POST['purge_all_data'] ) {
|
170 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_stats" );
|
171 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_reports" );
|
172 |
$wpdb->query( "TRUNCATE TABLE $this->gpi_page_blacklist" );
|
181 |
$old_options = $this->gpi_options;
|
182 |
|
183 |
$gpagespeedi_options = array(
|
184 |
+
'google_developer_key' => ! empty( $_POST['google_developer_key'] ) ? sanitize_text_field( $_POST['google_developer_key'] ) : $this->gpi_options['google_developer_key'],
|
185 |
+
'response_language' => ! empty( $_POST['response_language'] ) ? sanitize_text_field( $_POST['response_language'] ) : $this->gpi_options['response_language'],
|
186 |
+
'strategy' => ! empty( $_POST['strategy'] ) ? sanitize_text_field( $_POST['strategy'] ) : $this->gpi_options['strategy'],
|
187 |
+
'max_execution_time' => ! empty( $_POST['max_execution_time'] ) ? intval( $_POST['max_execution_time'] ) : $this->gpi_options['max_execution_time'],
|
188 |
+
'max_run_time' => ! empty( $_POST['max_run_time'] ) ? intval( $_POST['max_run_time'] ) : $this->gpi_options['max_run_time'],
|
189 |
+
'sleep_time' => isset( $_POST['sleep_time'] ) ? intval( $_POST['sleep_time'] ) : $this->gpi_options['sleep_time'],
|
190 |
+
'recheck_interval' => ! empty( $_POST['recheck_interval'] ) ? intval( $_POST['recheck_interval'] ) : $this->gpi_options['recheck_interval'],
|
191 |
+
'use_schedule' => isset( $_POST['use_schedule'] ) ? true : false,
|
192 |
+
'check_pages' => isset( $_POST['check_pages'] ) ? true : false,
|
193 |
+
'check_posts' => isset( $_POST['check_posts'] ) ? true : false,
|
194 |
+
'cpt_whitelist' => isset( $_POST['cpt_whitelist'] ) ? serialize( array_map( 'sanitize_text_field', $_POST['cpt_whitelist'] ) ) : false,
|
195 |
+
'check_categories' => isset( $_POST['check_categories'] ) ? true : false,
|
196 |
+
'check_custom_urls' => isset( $_POST['check_custom_urls'] ) ? true : false,
|
197 |
'first_run_complete' => $this->gpi_options['first_run_complete'],
|
198 |
'last_run_finished' => $this->gpi_options['last_run_finished'],
|
199 |
'bad_api_key' => false,
|
201 |
'api_restriction' => false,
|
202 |
'new_ignored_items' => false,
|
203 |
'backend_error' => false,
|
204 |
+
'log_api_errors' => isset( $_POST['log_api_errors'] ) ? true : false,
|
205 |
'new_activation_message' => false,
|
206 |
+
'heartbeat' => isset( $_POST['heartbeat'] ) ? sanitize_text_field( $_POST['heartbeat'] ) : 'standard',
|
207 |
'version' => GPI_VERSION
|
208 |
);
|
209 |
update_option( 'gpagespeedi_options', $gpagespeedi_options );
|
211 |
|
212 |
$gpagespeedi_ui_options = array(
|
213 |
'action_message' => false,
|
214 |
+
'view_preference' => 'both' != $_POST['strategy'] ? sanitize_text_field( $_POST['strategy'] ) : $this->gpi_ui_options['view_preference']
|
215 |
);
|
216 |
|
217 |
update_option( 'gpagespeedi_ui_options', $gpagespeedi_ui_options );
|
456 |
global $wpdb;
|
457 |
|
458 |
$snapshot_data = array(
|
459 |
+
'strategy' => $this->gpi_ui_options['view_preference'],
|
460 |
+
'type' => isset( $_GET['filter'] ) ? sanitize_text_field( $_GET['filter'] ) : 'all',
|
461 |
'snaptime' => current_time( 'timestamp' ),
|
462 |
+
'comment' => isset( $_POST['comment'] ) ? sanitize_text_field( $_POST['comment'] ) : false,
|
463 |
'summary_stats' => json_encode( apply_filters( 'gpi_summary_stats', array() ) ),
|
464 |
'summary_reports' => json_encode( apply_filters( 'gpi_summary_reports', array() ) )
|
465 |
);
|
491 |
);
|
492 |
}
|
493 |
|
494 |
+
if ( empty( $this->bulk_pages ) && ( isset( $_GET['snapshot_id'] ) && ! empty( intval( $_GET['snapshot_id'] ) ) ) ) {
|
495 |
+
$this->bulk_pages = array( intval( $_GET['snapshot_id'] ) );
|
496 |
}
|
497 |
|
498 |
if ( empty( $this->bulk_pages ) ) {
|
531 |
$custom_url_label = 'custom';
|
532 |
} else {
|
533 |
$custom_url_label = preg_replace( '/[^a-zA-Z0-9\s]/', '', $custom_url_label );
|
534 |
+
$custom_url_label = str_replace( ' ', '_', $custom_url_label );
|
535 |
$custom_url_label = substr( $custom_url_label, 0, 20 );
|
536 |
}
|
537 |
|
642 |
if ( ! $custom_url_label ) {
|
643 |
$custom_url_label = 'custom';
|
644 |
} else {
|
645 |
+
$custom_url_label = preg_replace( '/[^a-zA-Z0-9\s]/', '', $custom_url_label );
|
646 |
$custom_url_label = str_replace( ' ', '_', $custom_url_label );
|
|
|
647 |
$custom_url_label = substr( $custom_url_label, 0, 20 );
|
648 |
}
|
649 |
|
classes/class-GPI-Admin.php
CHANGED
@@ -23,7 +23,7 @@ class GPI_Admin
|
|
23 |
{
|
24 |
$this->gpi_options = get_option( 'gpagespeedi_options' );
|
25 |
$this->gpi_ui_options = get_option( 'gpagespeedi_ui_options' );
|
26 |
-
$this->strategy = ( isset( $_GET['strategy'] ) ) ? $_GET['strategy'] : $this->gpi_ui_options['view_preference'];
|
27 |
|
28 |
add_action( 'admin_init', array( $this, 'upgrade_check' ), 10 );
|
29 |
add_action( 'pre_uninstall_plugin', array( $this, 'backup_addon_tables' ), 10, 1 );
|
@@ -125,26 +125,26 @@ class GPI_Admin
|
|
125 |
|
126 |
public function render_admin_page()
|
127 |
{
|
128 |
-
$admin_page = ( isset( $_GET['render'] ) ) ? $_GET['render'] : 'report-list';
|
129 |
?>
|
130 |
<div class="wrap">
|
131 |
<div id="icon-gpi" class="icon32"><br/></div>
|
132 |
<h2>
|
133 |
-
Google Pagespeed Insights
|
134 |
<?php
|
135 |
if ( $worker_status = apply_filters( 'gpi_check_status', false ) ) :
|
136 |
if ( ! get_option( 'gpi_abort_scan' ) ) :
|
137 |
?>
|
138 |
-
<a href="?page=<?php echo $_REQUEST['page']
|
139 |
<?php
|
140 |
else :
|
141 |
?>
|
142 |
-
<a href="?page=<?php echo $_REQUEST['page']
|
143 |
<?php
|
144 |
endif;
|
145 |
elseif ( $this->gpi_options['google_developer_key'] ) :
|
146 |
?>
|
147 |
-
<a id="start_scan" href="?page=<?php echo $_REQUEST['page']
|
148 |
<input type="checkbox" name="recheck_all_pages" id="recheck_all_pages" />
|
149 |
<label for="recheck_all_pages"><?php _e( 'Recheck All', 'gpagespeedi' ); ?> <span class="tooltip" title="<?php _e( 'Ignore last checked date to generate new reports for all pages', 'gpagespeedi' ); ?>">(?)</span></label>
|
150 |
<?php
|
@@ -191,7 +191,7 @@ class GPI_Admin
|
|
191 |
return;
|
192 |
}
|
193 |
|
194 |
-
wp_enqueue_style( 'gpagespeedi_css', plugins_url( '/assets/css/gpagespeedi_styles.css', GPI_PLUGIN_FILE ), false, '
|
195 |
|
196 |
wp_register_script( 'gpagespeedi_google_charts', 'https://www.gstatic.com/charts/loader.js' );
|
197 |
}
|
@@ -206,12 +206,12 @@ class GPI_Admin
|
|
206 |
return;
|
207 |
}
|
208 |
|
209 |
-
$recheck_url = admin_url( '/tools.php?page=google-pagespeed-insights&render=details&page_id=' . $_GET['page_id'] . '&action=single-recheck' );
|
210 |
|
211 |
wp_enqueue_script( 'gpagespeedi_details_js', plugins_url( '/assets/js/details.js', GPI_PLUGIN_FILE ), array( 'jquery', 'gpagespeedi_google_charts', 'wp-util' ), '2.0.2' );
|
212 |
wp_localize_script( 'gpagespeedi_details_js', 'GPI_Details', array(
|
213 |
-
'page_stats' => $this->get_page_stats( $_GET['page_id'] ),
|
214 |
-
'page_reports' => $this->get_page_reports( $_GET['page_id'] ),
|
215 |
'recheck_url' => wp_nonce_url( $recheck_url, 'gpi-single-recheck' ),
|
216 |
'strings' => array(
|
217 |
'hosts' => __( 'Number of Hosts', 'gpagespeedi' ),
|
@@ -266,12 +266,16 @@ class GPI_Admin
|
|
266 |
$strings = array(
|
267 |
'strings' => array(
|
268 |
'comment' => __('Comment', 'gpagespeedi')
|
|
|
|
|
|
|
|
|
269 |
)
|
270 |
);
|
271 |
|
272 |
$localize_data = array_merge( $snapshot_data, $strings );
|
273 |
|
274 |
-
wp_enqueue_script( 'gpagespeedi_view_snapshot_js', plugins_url( '/assets/js/view-snapshot.js', GPI_PLUGIN_FILE ), array( 'jquery', 'gpagespeedi_google_charts', 'wp-util' ), '
|
275 |
wp_localize_script( 'gpagespeedi_view_snapshot_js', 'GPI_View_Snapshot', $localize_data );
|
276 |
}
|
277 |
|
@@ -291,7 +295,7 @@ class GPI_Admin
|
|
291 |
|
292 |
public function js_templates()
|
293 |
{
|
294 |
-
if ( ! isset( $_GET['page'] ) || $_GET['page']
|
295 |
return;
|
296 |
}
|
297 |
|
@@ -299,7 +303,9 @@ class GPI_Admin
|
|
299 |
return;
|
300 |
}
|
301 |
|
302 |
-
|
|
|
|
|
303 |
case 'details':
|
304 |
include_once GPI_DIRECTORY . '/assets/js/templates/details/statistics.php';
|
305 |
include_once GPI_DIRECTORY . '/assets/js/templates/details/legend.php';
|
@@ -317,23 +323,23 @@ class GPI_Admin
|
|
317 |
include_once GPI_DIRECTORY . '/assets/js/templates/view-snapshot/comment.php';
|
318 |
break;
|
319 |
|
320 |
-
case apply_filters( 'gpi_custom_js_templates', $
|
321 |
-
do_action( 'gpi_load_custom_js_template', $
|
322 |
break;
|
323 |
}
|
324 |
}
|
325 |
|
326 |
public function redirect()
|
327 |
{
|
328 |
-
if ( ! isset( $_GET['page'] ) || $_GET['page']
|
329 |
return;
|
330 |
}
|
331 |
|
332 |
if ( ! isset( $_GET['render'] ) ) {
|
333 |
if ( empty( $this->gpi_options['google_developer_key'] ) ) {
|
334 |
-
wp_redirect( '?page=
|
335 |
} else {
|
336 |
-
wp_redirect( '?page=
|
337 |
}
|
338 |
exit;
|
339 |
}
|
@@ -516,7 +522,7 @@ class GPI_Admin
|
|
516 |
$all_types = $this->get_filter_options( array(), true );
|
517 |
|
518 |
$gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
|
519 |
-
$filter = isset( $_GET['filter'] ) ? $_GET['filter'] : 'all';
|
520 |
$filter = 'all' != $filter ? $filter : implode( '|', $all_types );
|
521 |
|
522 |
if ( 'gpi_custom_urls' == $filter ) {
|
@@ -612,7 +618,7 @@ class GPI_Admin
|
|
612 |
|
613 |
$gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
|
614 |
$gpi_page_reports = $wpdb->prefix . 'gpi_page_reports';
|
615 |
-
$filter = isset( $_GET['filter'] ) ? $_GET['filter'] : 'all';
|
616 |
$filter = 'all' != $filter ? $filter : implode( '|', $all_types );
|
617 |
|
618 |
if ( 'gpi_custom_urls' == $filter ) {
|
23 |
{
|
24 |
$this->gpi_options = get_option( 'gpagespeedi_options' );
|
25 |
$this->gpi_ui_options = get_option( 'gpagespeedi_ui_options' );
|
26 |
+
$this->strategy = ( isset( $_GET['strategy'] ) ) ? sanitize_text_field( $_GET['strategy'] ) : $this->gpi_ui_options['view_preference'];
|
27 |
|
28 |
add_action( 'admin_init', array( $this, 'upgrade_check' ), 10 );
|
29 |
add_action( 'pre_uninstall_plugin', array( $this, 'backup_addon_tables' ), 10, 1 );
|
125 |
|
126 |
public function render_admin_page()
|
127 |
{
|
128 |
+
$admin_page = ( isset( $_GET['render'] ) ) ? sanitize_text_field( $_GET['render'] ) : 'report-list';
|
129 |
?>
|
130 |
<div class="wrap">
|
131 |
<div id="icon-gpi" class="icon32"><br/></div>
|
132 |
<h2>
|
133 |
+
<?php _e( 'Google Pagespeed Insights', 'gpagespeedi' ); ?>
|
134 |
<?php
|
135 |
if ( $worker_status = apply_filters( 'gpi_check_status', false ) ) :
|
136 |
if ( ! get_option( 'gpi_abort_scan' ) ) :
|
137 |
?>
|
138 |
+
<a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&render=<?php echo $admin_page; ?>&action=abort-scan" class="button-gpi abort"><?php _e( 'Abort Current Scan', 'gpagespeedi' ); ?></a>
|
139 |
<?php
|
140 |
else :
|
141 |
?>
|
142 |
+
<a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&render=<?php echo $admin_page; ?>" class="button-gpi abort" disabled><?php _e( 'Abort Current Scan', 'gpagespeedi' ); ?></a>
|
143 |
<?php
|
144 |
endif;
|
145 |
elseif ( $this->gpi_options['google_developer_key'] ) :
|
146 |
?>
|
147 |
+
<a id="start_scan" href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&render=<?php echo $admin_page; ?>&action=start-scan" class="button-gpi run"><?php _e( 'Start Reporting', 'gpagespeedi' ); ?></a>
|
148 |
<input type="checkbox" name="recheck_all_pages" id="recheck_all_pages" />
|
149 |
<label for="recheck_all_pages"><?php _e( 'Recheck All', 'gpagespeedi' ); ?> <span class="tooltip" title="<?php _e( 'Ignore last checked date to generate new reports for all pages', 'gpagespeedi' ); ?>">(?)</span></label>
|
150 |
<?php
|
191 |
return;
|
192 |
}
|
193 |
|
194 |
+
wp_enqueue_style( 'gpagespeedi_css', plugins_url( '/assets/css/gpagespeedi_styles.css', GPI_PLUGIN_FILE ), false, '3.0.0' );
|
195 |
|
196 |
wp_register_script( 'gpagespeedi_google_charts', 'https://www.gstatic.com/charts/loader.js' );
|
197 |
}
|
206 |
return;
|
207 |
}
|
208 |
|
209 |
+
$recheck_url = admin_url( '/tools.php?page=google-pagespeed-insights&render=details&page_id=' . intval( $_GET['page_id'] ) . '&action=single-recheck' );
|
210 |
|
211 |
wp_enqueue_script( 'gpagespeedi_details_js', plugins_url( '/assets/js/details.js', GPI_PLUGIN_FILE ), array( 'jquery', 'gpagespeedi_google_charts', 'wp-util' ), '2.0.2' );
|
212 |
wp_localize_script( 'gpagespeedi_details_js', 'GPI_Details', array(
|
213 |
+
'page_stats' => $this->get_page_stats( intval( $_GET['page_id'] ) ),
|
214 |
+
'page_reports' => $this->get_page_reports( intval( $_GET['page_id'] ) ),
|
215 |
'recheck_url' => wp_nonce_url( $recheck_url, 'gpi-single-recheck' ),
|
216 |
'strings' => array(
|
217 |
'hosts' => __( 'Number of Hosts', 'gpagespeedi' ),
|
266 |
$strings = array(
|
267 |
'strings' => array(
|
268 |
'comment' => __('Comment', 'gpagespeedi')
|
269 |
+
),
|
270 |
+
'comments' => array(
|
271 |
+
'snapshot' => isset( $snapshot_data['snapshot']['comment'] ) ? sanitize_text_field( $snapshot_data['snapshot']['comment'] ) : false,
|
272 |
+
'compare' => isset( $snapshot_data['compare']['comment'] ) ? sanitize_text_field( $snapshot_data['compare']['comment'] ) : false
|
273 |
)
|
274 |
);
|
275 |
|
276 |
$localize_data = array_merge( $snapshot_data, $strings );
|
277 |
|
278 |
+
wp_enqueue_script( 'gpagespeedi_view_snapshot_js', plugins_url( '/assets/js/view-snapshot.js', GPI_PLUGIN_FILE ), array( 'jquery', 'gpagespeedi_google_charts', 'wp-util' ), '3.0.0' );
|
279 |
wp_localize_script( 'gpagespeedi_view_snapshot_js', 'GPI_View_Snapshot', $localize_data );
|
280 |
}
|
281 |
|
295 |
|
296 |
public function js_templates()
|
297 |
{
|
298 |
+
if ( ! isset( $_GET['page'] ) || 'google-pagespeed-insights' != $_GET['page'] ) {
|
299 |
return;
|
300 |
}
|
301 |
|
303 |
return;
|
304 |
}
|
305 |
|
306 |
+
$render = sanitize_text_field( $_GET['render'] );
|
307 |
+
|
308 |
+
switch ( $render ) {
|
309 |
case 'details':
|
310 |
include_once GPI_DIRECTORY . '/assets/js/templates/details/statistics.php';
|
311 |
include_once GPI_DIRECTORY . '/assets/js/templates/details/legend.php';
|
323 |
include_once GPI_DIRECTORY . '/assets/js/templates/view-snapshot/comment.php';
|
324 |
break;
|
325 |
|
326 |
+
case apply_filters( 'gpi_custom_js_templates', $render ):
|
327 |
+
do_action( 'gpi_load_custom_js_template', $render );
|
328 |
break;
|
329 |
}
|
330 |
}
|
331 |
|
332 |
public function redirect()
|
333 |
{
|
334 |
+
if ( ! isset( $_GET['page'] ) || 'google-pagespeed-insights' != $_GET['page'] ) {
|
335 |
return;
|
336 |
}
|
337 |
|
338 |
if ( ! isset( $_GET['render'] ) ) {
|
339 |
if ( empty( $this->gpi_options['google_developer_key'] ) ) {
|
340 |
+
wp_redirect( '?page=google-pagespeed-insights&render=options' );
|
341 |
} else {
|
342 |
+
wp_redirect( '?page=google-pagespeed-insights&render=report-list' );
|
343 |
}
|
344 |
exit;
|
345 |
}
|
522 |
$all_types = $this->get_filter_options( array(), true );
|
523 |
|
524 |
$gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
|
525 |
+
$filter = isset( $_GET['filter'] ) ? sanitize_text_field( $_GET['filter'] ) : 'all';
|
526 |
$filter = 'all' != $filter ? $filter : implode( '|', $all_types );
|
527 |
|
528 |
if ( 'gpi_custom_urls' == $filter ) {
|
618 |
|
619 |
$gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
|
620 |
$gpi_page_reports = $wpdb->prefix . 'gpi_page_reports';
|
621 |
+
$filter = isset( $_GET['filter'] ) ? sanitize_text_field( $_GET['filter'] ) : 'all';
|
622 |
$filter = 'all' != $filter ? $filter : implode( '|', $all_types );
|
623 |
|
624 |
if ( 'gpi_custom_urls' == $filter ) {
|
classes/class-GPI-List-Table.php
CHANGED
@@ -44,10 +44,10 @@ class GPI_List_Table extends WP_List_Table
|
|
44 |
$this->strategy = $this->gpi_options['strategy'];
|
45 |
$this->columns = $this->get_columns();
|
46 |
$this->sortable = $this->get_sortable_columns();
|
47 |
-
$this->per_page = isset( $_GET['post-per-page']) ? $_GET['post-per-page'] : 25;
|
48 |
$this->_column_headers = array( $this->columns, array(), $this->sortable );
|
49 |
-
$this->orderby = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'ID';
|
50 |
-
$this->order = isset( $_GET['order'] ) ? $_GET['order'] : 'asc';
|
51 |
|
52 |
switch ( $type ) {
|
53 |
case 'ignored-urls':
|
@@ -142,16 +142,16 @@ class GPI_List_Table extends WP_List_Table
|
|
142 |
|
143 |
public function no_items()
|
144 |
{
|
145 |
-
$pagetype = $_GET['render'];
|
146 |
|
147 |
switch( $pagetype )
|
148 |
{
|
149 |
case 'ignored-urls':
|
150 |
-
_e( 'No Ignored URLs found. A URL can be ignored from the <a href="?page=' . $_REQUEST['page'] . '&render=report-list">Report List</a> page if you would like to remove it from report pages', 'gpagespeedi' );
|
151 |
break;
|
152 |
|
153 |
case 'snapshots':
|
154 |
-
_e( 'No Snapshots found. Snapshots can be created from the', 'gpagespeedi' ) . ' ' . '<a href="?page=' . $_REQUEST['page'] . '&render=summary">' . __( 'Report Summary', 'gpagespeedi' ) . '</a>' . ' ' . __( 'page', 'gpagespeedi' ) . '.';
|
155 |
break;
|
156 |
|
157 |
case 'custom-urls':
|
@@ -178,7 +178,7 @@ class GPI_List_Table extends WP_List_Table
|
|
178 |
_e( 'No Pagespeed Reports Found. Google Pagespeed may still be checking your pages. If problems persist, see the following possible solutions:', 'gpagespeedi' );
|
179 |
?>
|
180 |
<ol class="no-items">
|
181 |
-
<li><?php _e( 'Make sure that you have entered your Google API key on the ', 'gpagespeedi' );?><a href="?page=<?php echo $_REQUEST['page']; ?>&render=options"><?php _e( 'Options', 'gpagespeedi' ); ?></a> <?php _e( 'page', 'gpagespeedi' ); ?>.</li>
|
182 |
<li><?php _e( 'Make sure that you have enabled "PageSpeed Insights API" from the Services page of the ', 'gpagespeedi' );?><a href="https://code.google.com/apis/console/">Google Console</a>.</li>
|
183 |
<li><?php _e( 'Make sure that your URLs are publicly accessible', 'gpagespeedi' ); ?>.</li>
|
184 |
</ol>
|
@@ -216,11 +216,11 @@ class GPI_List_Table extends WP_List_Table
|
|
216 |
return $formatted_time;
|
217 |
|
218 |
case 'type':
|
219 |
-
return $item[ $column_name ];
|
220 |
|
221 |
case 'custom_url':
|
222 |
$actions = array(
|
223 |
-
'delete' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', $_REQUEST['page'], 'custom-urls', 'delete', $item['ID'] ),
|
224 |
'visit' => sprintf( '<a href="%s" target="_blank">%s</a>', $item['URL'], __( 'View URL', 'gpagespeedi' ) )
|
225 |
);
|
226 |
|
@@ -237,8 +237,8 @@ class GPI_List_Table extends WP_List_Table
|
|
237 |
$date = date( 'M d, Y - h:i a', $date );
|
238 |
|
239 |
$actions = array(
|
240 |
-
'delete' => sprintf( '?page=%s&render=%s&action=%s&snapshot_id=%s'
|
241 |
-
'view' => sprintf( '<a href="?page=%s&render=%s&snapshot_id=%s">%s</a>' , $_REQUEST['page'], 'view-snapshot', $item['ID'], __( 'View Snapshot', 'gpagespeedi' ) )
|
242 |
);
|
243 |
|
244 |
$nonced_url = wp_nonce_url( $actions['delete'], 'bulk-gpi_page_reports' );
|
@@ -246,7 +246,7 @@ class GPI_List_Table extends WP_List_Table
|
|
246 |
|
247 |
|
248 |
return sprintf( '<a href="?page=%1$s&render=%2$s&snapshot_id=%3$s">%4$s</a> %5$s',
|
249 |
-
$_REQUEST['page'],
|
250 |
'view-snapshot',
|
251 |
$item['ID'],
|
252 |
$date,
|
@@ -255,17 +255,17 @@ class GPI_List_Table extends WP_List_Table
|
|
255 |
|
256 |
case 'snapfilter':
|
257 |
$filter = $item['type'];
|
258 |
-
$filter_search = array( '
|
259 |
-
$filter_replace = array( __( 'All
|
260 |
$cleaned_filter = str_replace( $filter_search, $filter_replace, $filter );
|
261 |
|
262 |
-
return $cleaned_filter;
|
263 |
|
264 |
-
case apply_filters( 'gpi_custom_column', $column_name ):
|
265 |
return apply_filters( 'gpi_custom_column_config', $column_name, $item );
|
266 |
|
267 |
default:
|
268 |
-
return $item[ $column_name ];
|
269 |
}
|
270 |
}
|
271 |
|
@@ -274,9 +274,9 @@ class GPI_List_Table extends WP_List_Table
|
|
274 |
$cleaned_url = $this->strip_domain( $item['URL'] );
|
275 |
|
276 |
$actions = array(
|
277 |
-
'view_details' => sprintf( '<a href="?page=%s&render=%s&page_id=%s">%s</a>', $_REQUEST['page'], 'details', $item['ID'], __( 'Details', 'gpagespeedi' ) ),
|
278 |
-
'ignore' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', $_REQUEST['page'], 'report-list', 'ignore', $item['ID'] ),
|
279 |
-
'delete_report' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', $_REQUEST['page'], 'report-list', 'delete_report', $item['ID'] ),
|
280 |
'visit' => sprintf( '<a href="%s" target="_blank">%s</a>', $item['URL'], __( 'View URL', 'gpagespeedi' ) )
|
281 |
);
|
282 |
|
@@ -286,7 +286,7 @@ class GPI_List_Table extends WP_List_Table
|
|
286 |
return sprintf( '<a href="?page=%3$s&render=%4$s&page_id=%5$s">%1$s</a> %2$s',
|
287 |
$cleaned_url,
|
288 |
$this->row_actions( $actions ),
|
289 |
-
$_REQUEST['page'],
|
290 |
'details',
|
291 |
$item['ID']
|
292 |
);
|
@@ -297,8 +297,8 @@ class GPI_List_Table extends WP_List_Table
|
|
297 |
$cleaned_url = $this->strip_domain( $item['URL'] );
|
298 |
|
299 |
$actions = array(
|
300 |
-
'reactivate' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', $_REQUEST['page'], 'ignored-urls', 'reactivate', $item['ID'] ),
|
301 |
-
'delete_blacklist' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', $_REQUEST['page'], 'ignored-urls', 'delete_blacklist', $item['ID'] ),
|
302 |
'visit' => sprintf( '<a href="%s" target="_blank">%s</a>', $item['URL'], __( 'View URL', 'gpagespeedi' ) )
|
303 |
);
|
304 |
|
@@ -427,7 +427,7 @@ class GPI_List_Table extends WP_List_Table
|
|
427 |
|
428 |
public function get_sortable_columns()
|
429 |
{
|
430 |
-
$filter = ( isset( $_GET['filter'] ) ) ? $_GET['filter'] : 'all';
|
431 |
|
432 |
switch ( $this->type ) {
|
433 |
case 'ignored-urls':
|
@@ -487,7 +487,7 @@ class GPI_List_Table extends WP_List_Table
|
|
487 |
|
488 |
public function get_bulk_actions()
|
489 |
{
|
490 |
-
$render = ( isset( $_GET['render'] ) ) ? $_GET['render'] : '';
|
491 |
|
492 |
switch ( $render ) {
|
493 |
case 'ignored-urls':
|
@@ -540,19 +540,19 @@ class GPI_List_Table extends WP_List_Table
|
|
540 |
{
|
541 |
global $wpdb;
|
542 |
|
543 |
-
$post_per_page = ( isset( $_GET['post-per-page'] ) ) ? $_GET['post-per-page'] : 25;
|
544 |
|
545 |
if ( 'top' == $which ) {
|
546 |
?>
|
547 |
<div class="alignleft actions">
|
548 |
-
<?php if ( isset( $_GET['render'] ) && ( $_GET['render']
|
549 |
<select name="filter" id="filter">
|
550 |
<?php
|
551 |
$filter_options = apply_filters( 'gpi_filter_options', array(), false );
|
552 |
|
553 |
if ( $filter_options ) :
|
554 |
foreach ( $filter_options as $value => $label ) :
|
555 |
-
$current_filter = isset( $_GET['filter'] ) ? $_GET['filter'] : 'all';
|
556 |
|
557 |
if ( is_array( $label ) ) :
|
558 |
?>
|
@@ -576,7 +576,7 @@ class GPI_List_Table extends WP_List_Table
|
|
576 |
?>
|
577 |
</select>
|
578 |
<?php endif; ?>
|
579 |
-
<?php if ( isset( $_GET['render'] ) && $_GET['render']
|
580 |
<select name="post-per-page" id="post-per-page">
|
581 |
<option value="25" <?php selected( $post_per_page, 25 ); ?>><?php _e( '25 Results/Page', 'gpagespeedi' ); ?></option>
|
582 |
<option value="50" <?php selected( $post_per_page, 50 ); ?>><?php _e( '50 Results/Page', 'gpagespeedi' ); ?></option>
|
@@ -590,11 +590,11 @@ class GPI_List_Table extends WP_List_Table
|
|
590 |
?>
|
591 |
|
592 |
<?php if ( 'custom-urls' == $_GET['render'] ) : ?>
|
593 |
-
<a href="?page=<?php echo $_REQUEST['page']; ?>&render=add-custom-urls" class="button-secondary"><?php _e( 'Add New URLs', 'gpagespeedi' ); ?></a>
|
594 |
-
<a href="?page=<?php echo $_REQUEST['page']; ?>&render=add-custom-urls-bulk" class="button-secondary"><?php _e( 'Bulk Upload New URLs', 'gpagespeedi' ); ?></a>
|
595 |
<?php endif; ?>
|
596 |
|
597 |
-
<?php do_action( 'gpi_after_tablenav', $_GET['render'] ); ?>
|
598 |
|
599 |
</div>
|
600 |
<?php
|
@@ -612,7 +612,7 @@ class GPI_List_Table extends WP_List_Table
|
|
612 |
$all_types = apply_filters( 'gpi_filter_options', array(), true );
|
613 |
|
614 |
if ( 'default' == $this->type ) {
|
615 |
-
$filter = isset( $_GET['filter'] ) ? $_GET['filter'] : 'all';
|
616 |
$filter = 'all' != $filter ? $filter : implode( '|', $all_types );
|
617 |
$filter = 'gpi_custom_urls' != $filter ? $filter : apply_filters( 'gpi_custom_url_labels', $filter );
|
618 |
|
44 |
$this->strategy = $this->gpi_options['strategy'];
|
45 |
$this->columns = $this->get_columns();
|
46 |
$this->sortable = $this->get_sortable_columns();
|
47 |
+
$this->per_page = isset( $_GET['post-per-page']) ? intval( $_GET['post-per-page'] ) : 25;
|
48 |
$this->_column_headers = array( $this->columns, array(), $this->sortable );
|
49 |
+
$this->orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'ID';
|
50 |
+
$this->order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'asc';
|
51 |
|
52 |
switch ( $type ) {
|
53 |
case 'ignored-urls':
|
142 |
|
143 |
public function no_items()
|
144 |
{
|
145 |
+
$pagetype = sanitize_text_field( $_GET['render'] );
|
146 |
|
147 |
switch( $pagetype )
|
148 |
{
|
149 |
case 'ignored-urls':
|
150 |
+
_e( 'No Ignored URLs found. A URL can be ignored from the <a href="?page=' . sanitize_text_field( $_REQUEST['page'] ) . '&render=report-list">Report List</a> page if you would like to remove it from report pages', 'gpagespeedi' );
|
151 |
break;
|
152 |
|
153 |
case 'snapshots':
|
154 |
+
_e( 'No Snapshots found. Snapshots can be created from the', 'gpagespeedi' ) . ' ' . '<a href="?page=' . sanitize_text_field( $_REQUEST['page'] ) . '&render=summary">' . __( 'Report Summary', 'gpagespeedi' ) . '</a>' . ' ' . __( 'page', 'gpagespeedi' ) . '.';
|
155 |
break;
|
156 |
|
157 |
case 'custom-urls':
|
178 |
_e( 'No Pagespeed Reports Found. Google Pagespeed may still be checking your pages. If problems persist, see the following possible solutions:', 'gpagespeedi' );
|
179 |
?>
|
180 |
<ol class="no-items">
|
181 |
+
<li><?php _e( 'Make sure that you have entered your Google API key on the ', 'gpagespeedi' );?><a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&render=options"><?php _e( 'Options', 'gpagespeedi' ); ?></a> <?php _e( 'page', 'gpagespeedi' ); ?>.</li>
|
182 |
<li><?php _e( 'Make sure that you have enabled "PageSpeed Insights API" from the Services page of the ', 'gpagespeedi' );?><a href="https://code.google.com/apis/console/">Google Console</a>.</li>
|
183 |
<li><?php _e( 'Make sure that your URLs are publicly accessible', 'gpagespeedi' ); ?>.</li>
|
184 |
</ol>
|
216 |
return $formatted_time;
|
217 |
|
218 |
case 'type':
|
219 |
+
return sanitize_text_field( $item[ $column_name ] );
|
220 |
|
221 |
case 'custom_url':
|
222 |
$actions = array(
|
223 |
+
'delete' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', sanitize_text_field( $_REQUEST['page'] ), 'custom-urls', 'delete', $item['ID'] ),
|
224 |
'visit' => sprintf( '<a href="%s" target="_blank">%s</a>', $item['URL'], __( 'View URL', 'gpagespeedi' ) )
|
225 |
);
|
226 |
|
237 |
$date = date( 'M d, Y - h:i a', $date );
|
238 |
|
239 |
$actions = array(
|
240 |
+
'delete' => sprintf( '?page=%s&render=%s&action=%s&snapshot_id=%s' ,sanitize_text_field( $_REQUEST['page'] ), 'snapshots', 'delete-snapshot', $item['ID'] ),
|
241 |
+
'view' => sprintf( '<a href="?page=%s&render=%s&snapshot_id=%s">%s</a>' , sanitize_text_field( $_REQUEST['page'] ), 'view-snapshot', $item['ID'], __( 'View Snapshot', 'gpagespeedi' ) )
|
242 |
);
|
243 |
|
244 |
$nonced_url = wp_nonce_url( $actions['delete'], 'bulk-gpi_page_reports' );
|
246 |
|
247 |
|
248 |
return sprintf( '<a href="?page=%1$s&render=%2$s&snapshot_id=%3$s">%4$s</a> %5$s',
|
249 |
+
sanitize_text_field( $_REQUEST['page'] ),
|
250 |
'view-snapshot',
|
251 |
$item['ID'],
|
252 |
$date,
|
255 |
|
256 |
case 'snapfilter':
|
257 |
$filter = $item['type'];
|
258 |
+
$filter_search = array( 'gpi_custom_posts-', 'gpi_custom_urls-', 'gpi_custom_posts', 'gpi_custom_urls', 'all', 'page', 'post', 'category' );
|
259 |
+
$filter_replace = array( '', '', __( 'All Custom Post Types', 'gpagespeedi' ), __( 'All Custom URLs', 'gpagespeedi' ), __( 'All Reports', 'gpagespeedi' ), __( 'Pages', 'gpagespeedi' ), __( 'Posts', 'gpagespeedi' ), __( 'Categories', 'gpagespeedi' ) );
|
260 |
$cleaned_filter = str_replace( $filter_search, $filter_replace, $filter );
|
261 |
|
262 |
+
return sanitize_text_field( $cleaned_filter );
|
263 |
|
264 |
+
case apply_filters( 'gpi_custom_column', false, $column_name ):
|
265 |
return apply_filters( 'gpi_custom_column_config', $column_name, $item );
|
266 |
|
267 |
default:
|
268 |
+
return sanitize_text_field( $item[ $column_name ] );
|
269 |
}
|
270 |
}
|
271 |
|
274 |
$cleaned_url = $this->strip_domain( $item['URL'] );
|
275 |
|
276 |
$actions = array(
|
277 |
+
'view_details' => sprintf( '<a href="?page=%s&render=%s&page_id=%s">%s</a>', sanitize_text_field( $_REQUEST['page'] ), 'details', $item['ID'], __( 'Details', 'gpagespeedi' ) ),
|
278 |
+
'ignore' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', sanitize_text_field( $_REQUEST['page'] ), 'report-list', 'ignore', $item['ID'] ),
|
279 |
+
'delete_report' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', sanitize_text_field( $_REQUEST['page'] ), 'report-list', 'delete_report', $item['ID'] ),
|
280 |
'visit' => sprintf( '<a href="%s" target="_blank">%s</a>', $item['URL'], __( 'View URL', 'gpagespeedi' ) )
|
281 |
);
|
282 |
|
286 |
return sprintf( '<a href="?page=%3$s&render=%4$s&page_id=%5$s">%1$s</a> %2$s',
|
287 |
$cleaned_url,
|
288 |
$this->row_actions( $actions ),
|
289 |
+
sanitize_text_field( $_REQUEST['page'] ),
|
290 |
'details',
|
291 |
$item['ID']
|
292 |
);
|
297 |
$cleaned_url = $this->strip_domain( $item['URL'] );
|
298 |
|
299 |
$actions = array(
|
300 |
+
'reactivate' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', sanitize_text_field( $_REQUEST['page'] ), 'ignored-urls', 'reactivate', $item['ID'] ),
|
301 |
+
'delete_blacklist' => sprintf( '?page=%s&render=%s&action=%s&page_id=%s', sanitize_text_field( $_REQUEST['page'] ), 'ignored-urls', 'delete_blacklist', $item['ID'] ),
|
302 |
'visit' => sprintf( '<a href="%s" target="_blank">%s</a>', $item['URL'], __( 'View URL', 'gpagespeedi' ) )
|
303 |
);
|
304 |
|
427 |
|
428 |
public function get_sortable_columns()
|
429 |
{
|
430 |
+
$filter = ( isset( $_GET['filter'] ) ) ? sanitize_text_field( $_GET['filter'] ) : 'all';
|
431 |
|
432 |
switch ( $this->type ) {
|
433 |
case 'ignored-urls':
|
487 |
|
488 |
public function get_bulk_actions()
|
489 |
{
|
490 |
+
$render = ( isset( $_GET['render'] ) ) ? sanitize_text_field( $_GET['render'] ) : '';
|
491 |
|
492 |
switch ( $render ) {
|
493 |
case 'ignored-urls':
|
540 |
{
|
541 |
global $wpdb;
|
542 |
|
543 |
+
$post_per_page = ( isset( $_GET['post-per-page'] ) ) ? intval( $_GET['post-per-page'] ) : 25;
|
544 |
|
545 |
if ( 'top' == $which ) {
|
546 |
?>
|
547 |
<div class="alignleft actions">
|
548 |
+
<?php if ( isset( $_GET['render'] ) && ( 'report-list' == $_GET['render'] || 'summary' == $_GET['render'] ) ) : ?>
|
549 |
<select name="filter" id="filter">
|
550 |
<?php
|
551 |
$filter_options = apply_filters( 'gpi_filter_options', array(), false );
|
552 |
|
553 |
if ( $filter_options ) :
|
554 |
foreach ( $filter_options as $value => $label ) :
|
555 |
+
$current_filter = isset( $_GET['filter'] ) ? sanitize_text_field( $_GET['filter'] ) : 'all';
|
556 |
|
557 |
if ( is_array( $label ) ) :
|
558 |
?>
|
576 |
?>
|
577 |
</select>
|
578 |
<?php endif; ?>
|
579 |
+
<?php if ( isset( $_GET['render'] ) && 'summary' != $_GET['render'] ) : ?>
|
580 |
<select name="post-per-page" id="post-per-page">
|
581 |
<option value="25" <?php selected( $post_per_page, 25 ); ?>><?php _e( '25 Results/Page', 'gpagespeedi' ); ?></option>
|
582 |
<option value="50" <?php selected( $post_per_page, 50 ); ?>><?php _e( '50 Results/Page', 'gpagespeedi' ); ?></option>
|
590 |
?>
|
591 |
|
592 |
<?php if ( 'custom-urls' == $_GET['render'] ) : ?>
|
593 |
+
<a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&render=add-custom-urls" class="button-secondary"><?php _e( 'Add New URLs', 'gpagespeedi' ); ?></a>
|
594 |
+
<a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&render=add-custom-urls-bulk" class="button-secondary"><?php _e( 'Bulk Upload New URLs', 'gpagespeedi' ); ?></a>
|
595 |
<?php endif; ?>
|
596 |
|
597 |
+
<?php do_action( 'gpi_after_tablenav', sanitize_text_field( $_GET['render'] ) ); ?>
|
598 |
|
599 |
</div>
|
600 |
<?php
|
612 |
$all_types = apply_filters( 'gpi_filter_options', array(), true );
|
613 |
|
614 |
if ( 'default' == $this->type ) {
|
615 |
+
$filter = isset( $_GET['filter'] ) ? sanitize_text_field( $_GET['filter'] ) : 'all';
|
616 |
$filter = 'all' != $filter ? $filter : implode( '|', $all_types );
|
617 |
$filter = 'gpi_custom_urls' != $filter ? $filter : apply_filters( 'gpi_custom_url_labels', $filter );
|
618 |
|
google-pagespeed-insights.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Google Pagespeed Insights
|
|
4 |
Plugin URI: http://mattkeys.me
|
5 |
Description: Google Pagespeed Insights
|
6 |
Author: Matt Keys
|
7 |
-
Version: 3.0.
|
8 |
Author URI: http://mattkeys.me
|
9 |
*/
|
10 |
|
4 |
Plugin URI: http://mattkeys.me
|
5 |
Description: Google Pagespeed Insights
|
6 |
Author: Matt Keys
|
7 |
+
Version: 3.0.1
|
8 |
Author URI: http://mattkeys.me
|
9 |
*/
|
10 |
|
readme.txt
CHANGED
@@ -136,6 +136,14 @@ Google Pagespeed Insights requires a Google API Key. Keys are free and can be ob
|
|
136 |
|
137 |
== Changelog ==
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
= 3.0.0 =
|
140 |
* Includes all previously "premium" functionality for free. This includes report snapshots, snapshot comparison tool, custom URL reporting, and scheduled report checks.
|
141 |
* Added in URL hotlinking in report details for paths to assets (images/scripts/etc)
|
@@ -190,6 +198,14 @@ Google Pagespeed Insights requires a Google API Key. Keys are free and can be ob
|
|
190 |
|
191 |
== Upgrade Notice ==
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
= 3.0.0 =
|
194 |
* Includes all previously "premium" functionality for free. This includes report snapshots, snapshot comparison tool, custom URL reporting, and scheduled report checks.
|
195 |
* Added in URL hotlinking in report details for paths to assets (images/scripts/etc)
|
136 |
|
137 |
== Changelog ==
|
138 |
|
139 |
+
= 3.0.1 =
|
140 |
+
* Added snapshot comments to the view snapshot / compare snapshot templates
|
141 |
+
* Fixed bug with snapshot report type label reading 'both' when it should read either desktop or mobile
|
142 |
+
* Fixed bug with snapshot report description label not loading translatable string
|
143 |
+
* Fixed bug preventing snapshot comments from being displayed in snapshots list table
|
144 |
+
* Improved hardening against authenticated XSS attacks
|
145 |
+
* Improved adherence to WordPress coding standards and best practices
|
146 |
+
|
147 |
= 3.0.0 =
|
148 |
* Includes all previously "premium" functionality for free. This includes report snapshots, snapshot comparison tool, custom URL reporting, and scheduled report checks.
|
149 |
* Added in URL hotlinking in report details for paths to assets (images/scripts/etc)
|
198 |
|
199 |
== Upgrade Notice ==
|
200 |
|
201 |
+
= 3.0.1 =
|
202 |
+
* Added snapshot comments to the view snapshot / compare snapshot templates
|
203 |
+
* Fixed bug with snapshot report type label reading 'both' when it should read either desktop or mobile
|
204 |
+
* Fixed bug with snapshot report description label not loading translatable string
|
205 |
+
* Fixed bug preventing snapshot comments from being displayed in snapshots list table
|
206 |
+
* Improved hardening against authenticated XSS attacks
|
207 |
+
* Improved adherence to WordPress coding standards and best practices
|
208 |
+
|
209 |
= 3.0.0 =
|
210 |
* Includes all previously "premium" functionality for free. This includes report snapshots, snapshot comparison tool, custom URL reporting, and scheduled report checks.
|
211 |
* Added in URL hotlinking in report details for paths to assets (images/scripts/etc)
|
templates/add-custom-urls-bulk.php
CHANGED
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
10 |
?>
|
11 |
|
12 |
<form method="post" action="" enctype="multipart/form-data">
|
13 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']
|
14 |
<input type="hidden" name="render" value="add-custom-urls-bulk" />
|
15 |
<input type="hidden" name="action" value="add-custom-urls-bulk" />
|
16 |
|
10 |
?>
|
11 |
|
12 |
<form method="post" action="" enctype="multipart/form-data">
|
13 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
14 |
<input type="hidden" name="render" value="add-custom-urls-bulk" />
|
15 |
<input type="hidden" name="action" value="add-custom-urls-bulk" />
|
16 |
|
templates/add-custom-urls.php
CHANGED
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
10 |
?>
|
11 |
|
12 |
<form method="post" action="">
|
13 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']
|
14 |
<input type="hidden" name="render" value="add-custom-urls" />
|
15 |
<input type="hidden" name="action" value="add-custom-urls" />
|
16 |
|
@@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
22 |
</div>
|
23 |
<div class="padded">
|
24 |
|
25 |
-
<p><?php _e( 'Add any valid URL, even from sites outside of WordPress. Enter up to 10 URLs below. If you need to enter a lot of URLs check out the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $_REQUEST['page'];?>&render=add-custom-urls-bulk"><?php _e( 'Bulk URL uploader', 'gpagespeedi' ); ?></a>.</p>
|
26 |
|
27 |
<table class="form-table">
|
28 |
<tbody>
|
10 |
?>
|
11 |
|
12 |
<form method="post" action="">
|
13 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
14 |
<input type="hidden" name="render" value="add-custom-urls" />
|
15 |
<input type="hidden" name="action" value="add-custom-urls" />
|
16 |
|
22 |
</div>
|
23 |
<div class="padded">
|
24 |
|
25 |
+
<p><?php _e( 'Add any valid URL, even from sites outside of WordPress. Enter up to 10 URLs below. If you need to enter a lot of URLs check out the', 'gpagespeedi' ); ?> <a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ) ;?>&render=add-custom-urls-bulk"><?php _e( 'Bulk URL uploader', 'gpagespeedi' ); ?></a>.</p>
|
26 |
|
27 |
<table class="form-table">
|
28 |
<tbody>
|
templates/custom-urls.php
CHANGED
@@ -14,7 +14,7 @@ $GPI_List_Table->prepare_items();
|
|
14 |
?>
|
15 |
|
16 |
<form id="reports-filter" action="" method="get">
|
17 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
|
18 |
<input type="hidden" name="render" value="custom-urls" />
|
19 |
|
20 |
<?php $GPI_List_Table->display(); ?>
|
14 |
?>
|
15 |
|
16 |
<form id="reports-filter" action="" method="get">
|
17 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
18 |
<input type="hidden" name="render" value="custom-urls" />
|
19 |
|
20 |
<?php $GPI_List_Table->display(); ?>
|
templates/ignored-urls.php
CHANGED
@@ -14,7 +14,7 @@ $GPI_List_Table->prepare_items();
|
|
14 |
?>
|
15 |
|
16 |
<form id="reports-filter" action="" method="get">
|
17 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
|
18 |
<input type="hidden" name="render" value="ignored-urls" />
|
19 |
|
20 |
<?php $GPI_List_Table->display(); ?>
|
14 |
?>
|
15 |
|
16 |
<form id="reports-filter" action="" method="get">
|
17 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
18 |
<input type="hidden" name="render" value="ignored-urls" />
|
19 |
|
20 |
<?php $GPI_List_Table->display(); ?>
|
templates/options.php
CHANGED
@@ -225,7 +225,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
225 |
<input type="checkbox" name="log_api_errors" id="log_api_errors" <?php checked( $this->gpi_options['log_api_errors'] ); ?>/>
|
226 |
<label for="log_api_errors"><?php _e( 'Log API Exceptions', 'gpagespeedi' ); ?></label>
|
227 |
</p>
|
228 |
-
<p class="description"><?php _e( 'API error logs will be stored for up to 7 days.', 'gpagespeedi' ); ?> <a href="?page=<?php echo $_REQUEST['page']
|
229 |
|
230 |
<p><label for="sleep_time"><?php _e( 'Delete Data', 'gpagespeedi' ); ?>:</label></p>
|
231 |
<select name="purge_all_data" id="purge_all_data">
|
225 |
<input type="checkbox" name="log_api_errors" id="log_api_errors" <?php checked( $this->gpi_options['log_api_errors'] ); ?>/>
|
226 |
<label for="log_api_errors"><?php _e( 'Log API Exceptions', 'gpagespeedi' ); ?></label>
|
227 |
</p>
|
228 |
+
<p class="description"><?php _e( 'API error logs will be stored for up to 7 days.', 'gpagespeedi' ); ?> <a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&render=logs"><?php _e( 'View Logs', 'gpagespeedi' ); ?></a></p>
|
229 |
|
230 |
<p><label for="sleep_time"><?php _e( 'Delete Data', 'gpagespeedi' ); ?>:</label></p>
|
231 |
<select name="purge_all_data" id="purge_all_data">
|
templates/parts/messages.php
CHANGED
@@ -7,6 +7,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
7 |
exit;
|
8 |
}
|
9 |
|
|
|
|
|
10 |
?>
|
11 |
|
12 |
<?php if ( get_option( 'gpagespeedi_upgrade_recheck_required' ) ) : ?>
|
@@ -26,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
26 |
<?php echo __( 'Version', 'gpagespeedi' ) . ' ' . GPI_VERSION . ' ' . __( 'requires some updates to the way Pagespeed reports are stored to take advantage of the latest plugin updates. You will notice some missing report functionality until all pages have been rechecked.', 'gpagespeedi' ); ?>
|
27 |
</p>
|
28 |
<p>
|
29 |
-
<a href="<?php echo admin_url( 'tools.php?page=google-pagespeed-insights&render=' . $_GET['render'] . '&action=reports_update' ); ?>" class="button button-primary"><?php _e( 'Recheck Pagespeed Reports Now', 'gpagespeedi' ); ?></a>
|
30 |
</p>
|
31 |
</div>
|
32 |
</div>
|
@@ -34,12 +36,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
34 |
<?php endif; ?>
|
35 |
<?php if ( $this->gpi_options['google_developer_key'] == '' && 'options' != $admin_page ) : ?>
|
36 |
<div id="message" class="error">
|
37 |
-
<p><strong><?php _e( 'You must enter your Google API key to use this plugin! Enter your API key in the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $
|
38 |
</div>
|
39 |
<?php endif; ?>
|
40 |
<?php if ( $this->gpi_options['bad_api_key'] && 'options' != $admin_page ) : ?>
|
41 |
<div id="message" class="error">
|
42 |
-
<p><strong><?php _e( 'The Google Pagespeed API Key you entered appears to be invalid. Please update your API key in the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $
|
43 |
</div>
|
44 |
<?php endif; ?>
|
45 |
<?php if ( $this->gpi_options['pagespeed_disabled'] && 'options' != $admin_page ) : ?>
|
@@ -70,17 +72,17 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
70 |
<?php endif; ?>
|
71 |
<?php if ( isset( $_GET['render'] ) && 'logs' == $_GET['render'] && ! $this->gpi_options['log_api_errors'] ) : ?>
|
72 |
<div id="message" class="error">
|
73 |
-
<p><strong><?php _e( 'API error logging is disabled. Enable "Log API Exceptions" to record new errors.', 'gpagespeedi' ); ?> <a href="?page=<?php echo $
|
74 |
</div>
|
75 |
<?php endif; ?>
|
76 |
<?php if ( $this->gpi_options['new_ignored_items'] ) : ?>
|
77 |
<div id="message" class="notice notice-error is-dismissible">
|
78 |
-
<p><strong><?php _e( 'One or more URLs could not be reached by Google Pagespeed Insights and have automatically been added to the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $
|
79 |
</div>
|
80 |
<?php endif; ?>
|
81 |
<?php if ( $this->gpi_options['backend_error'] ) : ?>
|
82 |
<div id="message" class="error">
|
83 |
-
<p><strong><?php _e( 'An error has been encountered while checking one or more URLs. Possible causes: <br /><br />Daily API Limit Exceeded <a href="https://code.google.com/apis/console" target="_blank">Check API Usage</a> <br />API Key user limit exceeded <a href="https://code.google.com/apis/console" target="_blank">Check API Usage</a> <br />the URL is not publicly accessible or is bad. <br /><br />The URL(s) have been added to the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $
|
84 |
</div>
|
85 |
<?php endif; ?>
|
86 |
<?php if ( $worker_status = apply_filters( 'gpi_check_status', false ) ) : ?>
|
@@ -88,7 +90,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
88 |
<?php if ( 'disabled' != $this->gpi_options['heartbeat'] ) : ?>
|
89 |
<span>
|
90 |
<p id="gpi_status_abort" style="font-size: 13px; display: none;"><?php _e( 'Google Pagespeed has successfully stopped checking pages due to a user requested abort.', 'gpagespeedi' ); ?></p>
|
91 |
-
<p id="gpi_status_finished" style="font-size: 13px; display: none;"><?php _e( 'Google Pagespeed has finished checking pagespeed scores.', 'gpagespeedi' );?> <a href="?page=<?php echo $
|
92 |
<p id="gpi_status_ajax" class="ellipsis" style="font-size: 13px;"><?php _e( 'Google Pagespeed is running in the background ', 'gpagespeedi' ); ?></p>
|
93 |
</span>
|
94 |
<?php else : ?>
|
@@ -105,9 +107,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
105 |
<?php if ( ! $worker_status && ! $this->gpi_options['last_run_finished'] ) : ?>
|
106 |
<div id="message" class="error">
|
107 |
<?php if ( apply_filters( 'gpi_set_time_limit_disabled', false ) ) : ?>
|
108 |
-
<p><strong><?php _e( 'The last pagespeed report scan failed to finish successfully. We have detected that your server may not allow the maximum execution time to be overridden by this plugin. If you continue to experience problems with pagespeed report scans failing to complete, try setting the Maximum Script Run Time in the Advanced Configuration section on the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $
|
109 |
<?php else : ?>
|
110 |
-
<p><strong><?php _e( 'The last pagespeed report scan failed to finish successfully. If you continue to experience problems with pagespeed report scans failing to complete, try increasing the Maximum Execution Time, or setting the Maximum Script Run Time in the Advanced Configuration section on the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $
|
111 |
<?php endif; ?>
|
112 |
</div>
|
113 |
<?php endif; ?>
|
7 |
exit;
|
8 |
}
|
9 |
|
10 |
+
$page = sanitize_text_field( $_REQUEST['page'] );
|
11 |
+
|
12 |
?>
|
13 |
|
14 |
<?php if ( get_option( 'gpagespeedi_upgrade_recheck_required' ) ) : ?>
|
28 |
<?php echo __( 'Version', 'gpagespeedi' ) . ' ' . GPI_VERSION . ' ' . __( 'requires some updates to the way Pagespeed reports are stored to take advantage of the latest plugin updates. You will notice some missing report functionality until all pages have been rechecked.', 'gpagespeedi' ); ?>
|
29 |
</p>
|
30 |
<p>
|
31 |
+
<a href="<?php echo admin_url( 'tools.php?page=google-pagespeed-insights&render=' . sanitize_text_field( $_GET['render'] ) . '&action=reports_update' ); ?>" class="button button-primary"><?php _e( 'Recheck Pagespeed Reports Now', 'gpagespeedi' ); ?></a>
|
32 |
</p>
|
33 |
</div>
|
34 |
</div>
|
36 |
<?php endif; ?>
|
37 |
<?php if ( $this->gpi_options['google_developer_key'] == '' && 'options' != $admin_page ) : ?>
|
38 |
<div id="message" class="error">
|
39 |
+
<p><strong><?php _e( 'You must enter your Google API key to use this plugin! Enter your API key in the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $page; ?>&render=options"><?php _e( 'Options', 'gpagespeedi' ); ?></a></strong>.</p>
|
40 |
</div>
|
41 |
<?php endif; ?>
|
42 |
<?php if ( $this->gpi_options['bad_api_key'] && 'options' != $admin_page ) : ?>
|
43 |
<div id="message" class="error">
|
44 |
+
<p><strong><?php _e( 'The Google Pagespeed API Key you entered appears to be invalid. Please update your API key in the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $page; ?>&render=options"><?php _e( 'Options', 'gpagespeedi' ); ?></a></strong>.</p>
|
45 |
</div>
|
46 |
<?php endif; ?>
|
47 |
<?php if ( $this->gpi_options['pagespeed_disabled'] && 'options' != $admin_page ) : ?>
|
72 |
<?php endif; ?>
|
73 |
<?php if ( isset( $_GET['render'] ) && 'logs' == $_GET['render'] && ! $this->gpi_options['log_api_errors'] ) : ?>
|
74 |
<div id="message" class="error">
|
75 |
+
<p><strong><?php _e( 'API error logging is disabled. Enable "Log API Exceptions" to record new errors.', 'gpagespeedi' ); ?> <a href="?page=<?php echo $page; ?>&render=options"><?php _e( 'Options', 'gpagespeedi' ); ?></a></strong></p>
|
76 |
</div>
|
77 |
<?php endif; ?>
|
78 |
<?php if ( $this->gpi_options['new_ignored_items'] ) : ?>
|
79 |
<div id="message" class="notice notice-error is-dismissible">
|
80 |
+
<p><strong><?php _e( 'One or more URLs could not be reached by Google Pagespeed Insights and have automatically been added to the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $page; ?>&render=ignored-urls"><?php _e( 'Ignored URLs', 'gpagespeedi' ); ?></a></strong>.</p>
|
81 |
</div>
|
82 |
<?php endif; ?>
|
83 |
<?php if ( $this->gpi_options['backend_error'] ) : ?>
|
84 |
<div id="message" class="error">
|
85 |
+
<p><strong><?php _e( 'An error has been encountered while checking one or more URLs. Possible causes: <br /><br />Daily API Limit Exceeded <a href="https://code.google.com/apis/console" target="_blank">Check API Usage</a> <br />API Key user limit exceeded <a href="https://code.google.com/apis/console" target="_blank">Check API Usage</a> <br />the URL is not publicly accessible or is bad. <br /><br />The URL(s) have been added to the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $page; ?>&render=ignored-urls"><?php _e( 'Ignored URLs', 'gpagespeedi' ); ?></a></strong></p>
|
86 |
</div>
|
87 |
<?php endif; ?>
|
88 |
<?php if ( $worker_status = apply_filters( 'gpi_check_status', false ) ) : ?>
|
90 |
<?php if ( 'disabled' != $this->gpi_options['heartbeat'] ) : ?>
|
91 |
<span>
|
92 |
<p id="gpi_status_abort" style="font-size: 13px; display: none;"><?php _e( 'Google Pagespeed has successfully stopped checking pages due to a user requested abort.', 'gpagespeedi' ); ?></p>
|
93 |
+
<p id="gpi_status_finished" style="font-size: 13px; display: none;"><?php _e( 'Google Pagespeed has finished checking pagespeed scores.', 'gpagespeedi' );?> <a href="?page=<?php echo $page; ?>&render=report-list"><?php _e( 'See new results', 'gpagespeedi' ); ?>.</a></p>
|
94 |
<p id="gpi_status_ajax" class="ellipsis" style="font-size: 13px;"><?php _e( 'Google Pagespeed is running in the background ', 'gpagespeedi' ); ?></p>
|
95 |
</span>
|
96 |
<?php else : ?>
|
107 |
<?php if ( ! $worker_status && ! $this->gpi_options['last_run_finished'] ) : ?>
|
108 |
<div id="message" class="error">
|
109 |
<?php if ( apply_filters( 'gpi_set_time_limit_disabled', false ) ) : ?>
|
110 |
+
<p><strong><?php _e( 'The last pagespeed report scan failed to finish successfully. We have detected that your server may not allow the maximum execution time to be overridden by this plugin. If you continue to experience problems with pagespeed report scans failing to complete, try setting the Maximum Script Run Time in the Advanced Configuration section on the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $page;?>&render=options"><?php _e( 'Options Page', 'gpagespeedi' ); ?></a></strong>.</p>
|
111 |
<?php else : ?>
|
112 |
+
<p><strong><?php _e( 'The last pagespeed report scan failed to finish successfully. If you continue to experience problems with pagespeed report scans failing to complete, try increasing the Maximum Execution Time, or setting the Maximum Script Run Time in the Advanced Configuration section on the', 'gpagespeedi' ); ?> <a href="?page=<?php echo $page; ?>&render=options"><?php _e( 'Options Page', 'gpagespeedi' ); ?></a></strong>.</p>
|
113 |
<?php endif; ?>
|
114 |
</div>
|
115 |
<?php endif; ?>
|
templates/parts/navigation.php
CHANGED
@@ -7,34 +7,36 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
7 |
exit;
|
8 |
}
|
9 |
|
|
|
|
|
10 |
?>
|
11 |
|
12 |
<h3 class="nav-tab-wrapper">
|
13 |
-
<a href="?page=<?php echo $
|
14 |
<?php if ( $admin_page == 'details' ) : ?>
|
15 |
-
<a href="?page=<?php echo $
|
16 |
<?php endif; ?>
|
17 |
-
<a href="?page=<?php echo $
|
18 |
|
19 |
-
<a href="?page=<?php echo $
|
20 |
<?php if ( $admin_page == 'view-snapshot' && ! isset( $_GET['compare_id'] ) ) : ?>
|
21 |
-
<a href="?page=<?php echo $
|
22 |
<?php endif; ?>
|
23 |
<?php if ( $admin_page == 'view-snapshot' && isset( $_GET['compare_id'] ) ) : ?>
|
24 |
-
<a href="?page=<?php echo $
|
25 |
<?php endif; ?>
|
26 |
-
<a href="?page=<?php echo $
|
27 |
<?php if($admin_page == 'add-custom-urls') : ?>
|
28 |
-
<a href="?page=<?php echo $
|
29 |
<?php endif ?>
|
30 |
<?php if ( $admin_page == 'add-custom-urls-bulk' ) : ?>
|
31 |
-
<a href="?page=<?php echo $
|
32 |
<?php endif; ?>
|
33 |
|
34 |
-
<a href="?page=<?php echo $
|
35 |
-
<a href="?page=<?php echo $
|
36 |
<?php if ( $admin_page == 'logs' ) : ?>
|
37 |
-
<a href="?page=<?php echo $
|
38 |
<?php endif; ?>
|
39 |
|
40 |
<?php do_action( 'gpi_navigation', $admin_page ); ?>
|
7 |
exit;
|
8 |
}
|
9 |
|
10 |
+
$page = sanitize_text_field( $_REQUEST['page'] );
|
11 |
+
|
12 |
?>
|
13 |
|
14 |
<h3 class="nav-tab-wrapper">
|
15 |
+
<a href="?page=<?php echo $page; ?>&render=report-list" class="nav-tab <?php if ( $admin_page == '' || $admin_page == 'report-list' || $admin_page == 'ignore' || $admin_page == 'recheck' ) { echo 'nav-tab-active'; } ?>"><?php _e( 'Report List', 'gpagespeedi' ); ?></a>
|
16 |
<?php if ( $admin_page == 'details' ) : ?>
|
17 |
+
<a href="?page=<?php echo $page; ?>&render=details&page_id=<?php echo intval( $_GET['page_id'] ); ?>" class="nav-tab nav-tab-active nav-tab-temp"><?php _e( 'Report Details', 'gpagespeedi' ); ?></a>
|
18 |
<?php endif; ?>
|
19 |
+
<a href="?page=<?php echo $page; ?>&render=summary" class="nav-tab <?php if ( $admin_page == 'summary' ) { echo 'nav-tab-active'; } ?>"><?php _e( 'Report Summary', 'gpagespeedi' ); ?></a>
|
20 |
|
21 |
+
<a href="?page=<?php echo $page; ?>&render=snapshots" class="nav-tab <?php if ( $admin_page == 'snapshots' ) { echo 'nav-tab-active'; } ?>"><?php _e( 'Snapshots', 'gpagespeedi' ); ?></a>
|
22 |
<?php if ( $admin_page == 'view-snapshot' && ! isset( $_GET['compare_id'] ) ) : ?>
|
23 |
+
<a href="?page=<?php echo $page; ?>&render=view-snapshot&snapshot_id=<?php echo intval( $_GET['snapshot_id'] ); ?>" class="nav-tab nav-tab-active nav-tab-temp"><?php _e( 'View Snapshot', 'gpagespeedi' ); ?></a>
|
24 |
<?php endif; ?>
|
25 |
<?php if ( $admin_page == 'view-snapshot' && isset( $_GET['compare_id'] ) ) : ?>
|
26 |
+
<a href="?page=<?php echo $page; ?>&render=view-snapshot&snapshot_id=<?php echo intval( $_GET['snapshot_id'] ); ?>&compare_id=<?php echo intval( $_GET['compare_id'] ); ?>" class="nav-tab nav-tab-active nav-tab-temp"><?php _e('Compare Snapshots', 'gpagespeedi'); ?></a>
|
27 |
<?php endif; ?>
|
28 |
+
<a href="?page=<?php echo $page; ?>&render=custom-urls" class="nav-tab <?php if ( $admin_page == 'custom-urls' || $admin_page == 'delete' ) { echo 'nav-tab-active'; } ?>"><?php _e( 'Custom URLs', 'gpagespeedi' ); ?></a>
|
29 |
<?php if($admin_page == 'add-custom-urls') : ?>
|
30 |
+
<a href="?page=<?php echo $page; ?>&render=add-custom-urls" class="nav-tab nav-tab-active nav-tab-temp"><?php _e( 'Add New URLs', 'gpagespeedi' ); ?></a>
|
31 |
<?php endif ?>
|
32 |
<?php if ( $admin_page == 'add-custom-urls-bulk' ) : ?>
|
33 |
+
<a href="?page=<?php echo $page; ?>&render=add-custom-urls-bulk" class="nav-tab nav-tab-active nav-tab-temp"><?php _e( 'Bulk Upload New URLs', 'gpagespeedi' ); ?></a>
|
34 |
<?php endif; ?>
|
35 |
|
36 |
+
<a href="?page=<?php echo $page; ?>&render=ignored-urls" class="nav-tab <?php if ( $admin_page == 'ignored-urls' || $admin_page == 'activate' ) { echo 'nav-tab-active'; } ?>"><?php _e( 'Ignored URLs', 'gpagespeedi' ); ?></a>
|
37 |
+
<a href="?page=<?php echo $page; ?>&render=options" class="nav-tab <?php if ( $admin_page == 'options' ) { echo 'nav-tab-active'; } ?>"><?php _e( 'Options', 'gpagespeedi' ); ?></a>
|
38 |
<?php if ( $admin_page == 'logs' ) : ?>
|
39 |
+
<a href="?page=<?php echo $page; ?>&render=logs" class="nav-tab nav-tab-active nav-tab-temp"><?php _e('Logs', 'gpagespeedi'); ?></a>
|
40 |
<?php endif; ?>
|
41 |
|
42 |
<?php do_action( 'gpi_navigation', $admin_page ); ?>
|
templates/report-list.php
CHANGED
@@ -14,7 +14,7 @@ $GPI_List_Table->prepare_items();
|
|
14 |
?>
|
15 |
|
16 |
<form id="reports-filter" action="" method="get">
|
17 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
|
18 |
<input type="hidden" name="render" value="report-list" />
|
19 |
|
20 |
<?php $GPI_List_Table->display(); ?>
|
14 |
?>
|
15 |
|
16 |
<form id="reports-filter" action="" method="get">
|
17 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
18 |
<input type="hidden" name="render" value="report-list" />
|
19 |
|
20 |
<?php $GPI_List_Table->display(); ?>
|
templates/snapshots.php
CHANGED
@@ -14,7 +14,7 @@ $GPI_List_Table->prepare_items();
|
|
14 |
?>
|
15 |
|
16 |
<form id="reports-filter" action="" method="get">
|
17 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
|
18 |
<input type="hidden" name="render" value="snapshots" />
|
19 |
|
20 |
<?php $GPI_List_Table->display(); ?>
|
14 |
?>
|
15 |
|
16 |
<form id="reports-filter" action="" method="get">
|
17 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
18 |
<input type="hidden" name="render" value="snapshots" />
|
19 |
|
20 |
<?php $GPI_List_Table->display(); ?>
|
templates/summary.php
CHANGED
@@ -12,15 +12,15 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
12 |
<div class="tablenav top">
|
13 |
<div class="alignleft actions">
|
14 |
<form method="get" action="" id="filter" name="filter">
|
15 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?>" />
|
16 |
<input type="hidden" name="render" value="summary" />
|
17 |
<select name="filter" id="filter">
|
18 |
<?php
|
19 |
$filter_options = apply_filters( 'gpi_filter_options', array(), false );
|
|
|
20 |
|
21 |
if ( $filter_options ) :
|
22 |
foreach ( $filter_options as $value => $label ) :
|
23 |
-
$current_filter = isset( $_GET['filter'] ) ? $_GET['filter'] : 'all';
|
24 |
|
25 |
if ( is_array( $label ) ) :
|
26 |
?>
|
@@ -50,7 +50,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
50 |
</div>
|
51 |
<div class="alignleft actions">
|
52 |
<form method="post" action="" id="savesnapshot" name="savesnapshot">
|
53 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?>" />
|
54 |
<input type="hidden" name="render" value="summary" />
|
55 |
<input type="hidden" name="action" value="save-snapshot" />
|
56 |
<input type="text" name="comment" placeholder="<?php _e( 'Report Description', 'gpagespeedi' ); ?>" value="" />
|
@@ -116,13 +116,13 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
116 |
<?php _e( 'No Pagespeed Reports Found. Google Pagespeed may still be checking your pages. If problems persist, see the following possible solutions:', 'gpagespeedi' ); ?>
|
117 |
</p>
|
118 |
<ol class="no-items">
|
119 |
-
<?php if ( isset( $
|
120 |
-
<li><?php _e( 'There may not be any results for the "' . $
|
121 |
<?php endif; ?>
|
122 |
<?php if ( $this->gpi_options['strategy'] == 'both' ) : ?>
|
123 |
<li><?php echo __( 'There may not be any', 'gpagespeedi' ) . ' ' . $this->gpi_ui_options['view_preference'] . ' ' . __( 'reports completed yet.', 'gpagespeedi' ) . ' ' . __( 'Try switching the report mode.', 'gpagespeedi' ); ?></li>
|
124 |
<?php endif; ?>
|
125 |
-
<li><?php _e( 'Make sure that you have entered your Google API key on the ', 'gpagespeedi' );?><a href="?page=<?php echo $_REQUEST['page']; ?>&render=options">Options</a> page.</li>
|
126 |
<li><?php _e( 'Make sure that you have enabled "PageSpeed Insights API" from the Services page of the ', 'gpagespeedi' );?><a href="https://code.google.com/apis/console/">Google Console</a>.</li>
|
127 |
<li><?php _e( 'Make sure that your URLs are publicly accessible', 'gpagespeedi' ); ?>.</li>
|
128 |
</ol>
|
12 |
<div class="tablenav top">
|
13 |
<div class="alignleft actions">
|
14 |
<form method="get" action="" id="filter" name="filter">
|
15 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
16 |
<input type="hidden" name="render" value="summary" />
|
17 |
<select name="filter" id="filter">
|
18 |
<?php
|
19 |
$filter_options = apply_filters( 'gpi_filter_options', array(), false );
|
20 |
+
$current_filter = isset( $_GET['filter'] ) ? sanitize_text_field( $_GET['filter'] ) : 'all';
|
21 |
|
22 |
if ( $filter_options ) :
|
23 |
foreach ( $filter_options as $value => $label ) :
|
|
|
24 |
|
25 |
if ( is_array( $label ) ) :
|
26 |
?>
|
50 |
</div>
|
51 |
<div class="alignleft actions">
|
52 |
<form method="post" action="" id="savesnapshot" name="savesnapshot">
|
53 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
54 |
<input type="hidden" name="render" value="summary" />
|
55 |
<input type="hidden" name="action" value="save-snapshot" />
|
56 |
<input type="text" name="comment" placeholder="<?php _e( 'Report Description', 'gpagespeedi' ); ?>" value="" />
|
116 |
<?php _e( 'No Pagespeed Reports Found. Google Pagespeed may still be checking your pages. If problems persist, see the following possible solutions:', 'gpagespeedi' ); ?>
|
117 |
</p>
|
118 |
<ol class="no-items">
|
119 |
+
<?php if ( isset( $current_filter ) && $current_filter != 'all' ) : ?>
|
120 |
+
<li><?php _e( 'There may not be any results for the "' . $current_filter . '" filter. Try another filter.', 'gpagespeedi' ); ?></li>
|
121 |
<?php endif; ?>
|
122 |
<?php if ( $this->gpi_options['strategy'] == 'both' ) : ?>
|
123 |
<li><?php echo __( 'There may not be any', 'gpagespeedi' ) . ' ' . $this->gpi_ui_options['view_preference'] . ' ' . __( 'reports completed yet.', 'gpagespeedi' ) . ' ' . __( 'Try switching the report mode.', 'gpagespeedi' ); ?></li>
|
124 |
<?php endif; ?>
|
125 |
+
<li><?php _e( 'Make sure that you have entered your Google API key on the ', 'gpagespeedi' );?><a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&render=options">Options</a> page.</li>
|
126 |
<li><?php _e( 'Make sure that you have enabled "PageSpeed Insights API" from the Services page of the ', 'gpagespeedi' );?><a href="https://code.google.com/apis/console/">Google Console</a>.</li>
|
127 |
<li><?php _e( 'Make sure that your URLs are publicly accessible', 'gpagespeedi' ); ?>.</li>
|
128 |
</ol>
|
templates/view-snapshot.php
CHANGED
@@ -12,16 +12,16 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
12 |
<div class="toolbar">
|
13 |
<div class="left">
|
14 |
<form method="get" action="" name="filter">
|
15 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']
|
16 |
<input type="hidden" name="render" value="view-snapshot" />
|
17 |
-
<div class="tablenav top">
|
18 |
<select name="snapshot_id">
|
19 |
<?php
|
20 |
-
$similar_snapshots = apply_filters( 'gpi_similar_snapshots', array(), $_GET['snapshot_id'] );
|
21 |
|
22 |
foreach( $similar_snapshots as $snapshot ) :
|
23 |
?>
|
24 |
-
<option value="<?php echo $snapshot['ID']; ?>" <?php selected( $snapshot['ID'], $_GET['snapshot_id'] ); ?>><?php echo date_i18n( 'M d Y g:ia', $snapshot['snaptime'] ); ?></option>
|
25 |
<?php
|
26 |
endforeach;
|
27 |
?>
|
@@ -36,17 +36,17 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
36 |
<?php if ( count( $similar_snapshots ) >= 2 ) : ?>
|
37 |
<div class="right">
|
38 |
<form method="get" action="" name="filter">
|
39 |
-
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']
|
40 |
<input type="hidden" name="render" value="view-snapshot" />
|
41 |
-
<input type="hidden" name="snapshot_id" value="<?php echo $_GET['snapshot_id']; ?>" />
|
42 |
-
<div class="tablenav top">
|
43 |
<select name="compare_id">
|
44 |
<?php
|
45 |
foreach( $similar_snapshots as $snapshot ) :
|
46 |
if ( $_GET['snapshot_id'] == $snapshot['ID'] ) :
|
47 |
continue;
|
48 |
endif;
|
49 |
-
$current_compare_id = isset( $_GET['compare_id'] ) ? $_GET['compare_id'] : false
|
50 |
?>
|
51 |
<option value="<?php echo $snapshot['ID']; ?>" <?php selected( $snapshot['ID'], $current_compare_id ); ?>><?php echo date_i18n( 'M d Y g:ia', $snapshot['snaptime'] ); ?></option>
|
52 |
<?php
|
12 |
<div class="toolbar">
|
13 |
<div class="left">
|
14 |
<form method="get" action="" name="filter">
|
15 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
16 |
<input type="hidden" name="render" value="view-snapshot" />
|
17 |
+
<div class="tablenav top snapshots">
|
18 |
<select name="snapshot_id">
|
19 |
<?php
|
20 |
+
$similar_snapshots = apply_filters( 'gpi_similar_snapshots', array(), intval( $_GET['snapshot_id'] ) );
|
21 |
|
22 |
foreach( $similar_snapshots as $snapshot ) :
|
23 |
?>
|
24 |
+
<option value="<?php echo $snapshot['ID']; ?>" <?php selected( $snapshot['ID'], intval( $_GET['snapshot_id'] ) ); ?>><?php echo date_i18n( 'M d Y g:ia', $snapshot['snaptime'] ); ?></option>
|
25 |
<?php
|
26 |
endforeach;
|
27 |
?>
|
36 |
<?php if ( count( $similar_snapshots ) >= 2 ) : ?>
|
37 |
<div class="right">
|
38 |
<form method="get" action="" name="filter">
|
39 |
+
<input type="hidden" name="page" value="<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>" />
|
40 |
<input type="hidden" name="render" value="view-snapshot" />
|
41 |
+
<input type="hidden" name="snapshot_id" value="<?php echo intval( $_GET['snapshot_id'] ); ?>" />
|
42 |
+
<div class="tablenav top snapshots">
|
43 |
<select name="compare_id">
|
44 |
<?php
|
45 |
foreach( $similar_snapshots as $snapshot ) :
|
46 |
if ( $_GET['snapshot_id'] == $snapshot['ID'] ) :
|
47 |
continue;
|
48 |
endif;
|
49 |
+
$current_compare_id = isset( $_GET['compare_id'] ) ? intval( $_GET['compare_id'] ) : false
|
50 |
?>
|
51 |
<option value="<?php echo $snapshot['ID']; ?>" <?php selected( $snapshot['ID'], $current_compare_id ); ?>><?php echo date_i18n( 'M d Y g:ia', $snapshot['snaptime'] ); ?></option>
|
52 |
<?php
|