@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (PHP_SAPI != 'cli') { |
|
2 | +if ( PHP_SAPI != 'cli' ) { |
|
3 | 3 | echo "<pre>"; |
4 | 4 | } |
5 | 5 | |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | |
19 | 19 | require_once __DIR__ . '/../autoload.php'; |
20 | 20 | $sentiment = new \PHPInsight\Sentiment(); |
21 | -foreach ($strings as $string) { |
|
21 | +foreach ( $strings as $string ) { |
|
22 | 22 | |
23 | 23 | // calculations: |
24 | - $scores = $sentiment->score($string); |
|
25 | - $class = $sentiment->categorise($string); |
|
24 | + $scores = $sentiment->score( $string ); |
|
25 | + $class = $sentiment->categorise( $string ); |
|
26 | 26 | |
27 | 27 | // output: |
28 | 28 | echo "String: $string\n"; |
29 | 29 | echo "Dominant: $class, scores: "; |
30 | - print_r($scores); |
|
30 | + print_r( $scores ); |
|
31 | 31 | echo "\n"; |
32 | 32 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ); |
56 | 56 | add_filter( "monsterinsights_is_autoupdate_setting_html_filtered_${plugin_file}", '__return_true' ); |
57 | 57 | } elseif ( $has_permission && |
58 | - ( $is_main_free || $is_main_pro || ( $is_addon && $is_pro ) ) |
|
58 | + ( $is_main_free || $is_main_pro || ( $is_addon && $is_pro ) ) |
|
59 | 59 | ) { |
60 | 60 | $text = __( 'Manage auto-updates', 'google-analytics-for-wordpress' ); |
61 | 61 | $html .= '<br>' . sprintf( '<a href="%s"">%s</a>', admin_url( 'admin.php?page=monsterinsights_settings#/advanced' ), $text ); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | // If this is multisite and is not on the main site, return early. |
126 | 126 | if ( is_multisite() && ! is_main_site() ) { |
127 | - return $update; |
|
127 | + return $update; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | // When used in the context of automatic plugin update routine, the $item |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | |
133 | 133 | // If we don't have everything we need, return early. |
134 | 134 | if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) { |
135 | - return $update; |
|
135 | + return $update; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | // If the plugin isn't ours, return early. |
139 | 139 | if ( ( ! $is_free && ! $is_paid ) || ( $is_free && ! defined( 'MONSTERINSIGHTS_LITE_VERSION' ) ) ) { |
140 | - return $update; |
|
140 | + return $update; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | $version = $is_free ? MONSTERINSIGHTS_LITE_VERSION : $item['old_version']; |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | |
147 | 147 | // If the opt in update allows major updates but there is no major version update, return early. |
148 | 148 | if ( $current_major < $new_major ) { |
149 | - if ( $automatic_updates === 'all' ) { |
|
150 | - return true; |
|
151 | - } else { |
|
152 | - return $update; |
|
153 | - } |
|
149 | + if ( $automatic_updates === 'all' ) { |
|
150 | + return true; |
|
151 | + } else { |
|
152 | + return $update; |
|
153 | + } |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // If the opt in update allows minor updates but there is no minor version update, return early. |
157 | 157 | if ( $current_major == $new_major ) { |
158 | - if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) { |
|
159 | - return true; |
|
160 | - } else { |
|
161 | - return $update; |
|
162 | - } |
|
158 | + if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) { |
|
159 | + return true; |
|
160 | + } else { |
|
161 | + return $update; |
|
162 | + } |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // All our checks have passed - this plugin can be updated! |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | function monsterinsights_get_major_version( $version ) { |
198 | 198 | $exploded_version = explode( '.', $version ); |
199 | 199 | if ( isset( $exploded_version[2] ) ) { |
200 | - return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2]; |
|
200 | + return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2]; |
|
201 | 201 | } else { |
202 | - return $exploded_version[0] . '.' . $exploded_version[1] . '.0'; |
|
202 | + return $exploded_version[0] . '.' . $exploded_version[1] . '.0'; |
|
203 | 203 | } |
204 | 204 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function __construct( $args = array() ) { |
27 | 27 | |
28 | - parent::__construct(); |
|
28 | + parent::__construct(); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function set_upgrader( &$upgrader ) { |
40 | 40 | |
41 | - if ( is_object( $upgrader ) ) { |
|
42 | - $this->upgrader =& $upgrader; |
|
43 | - } |
|
41 | + if ( is_object( $upgrader ) ) { |
|
42 | + $this->upgrader =& $upgrader; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function set_result( $result ) { |
55 | 55 | |
56 | - $this->result = $result; |
|
56 | + $this->result = $result; |
|
57 | 57 | |
58 | 58 | } |
59 | 59 |
@@ -39,7 +39,7 @@ |
||
39 | 39 | public function set_upgrader( &$upgrader ) { |
40 | 40 | |
41 | 41 | if ( is_object( $upgrader ) ) { |
42 | - $this->upgrader =& $upgrader; |
|
42 | + $this->upgrader = & $upgrader; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | } |
@@ -97,7 +97,8 @@ discard block |
||
97 | 97 | */ |
98 | 98 | $options = apply_filters( 'upgrader_package_options', $options ); |
99 | 99 | |
100 | - if ( ! $options['is_multi'] ) { // call $this->header separately if running multiple times |
|
100 | + if ( ! $options['is_multi'] ) { |
|
101 | +// call $this->header separately if running multiple times |
|
101 | 102 | $this->skin->header(); |
102 | 103 | } |
103 | 104 | |
@@ -288,7 +289,8 @@ discard block |
||
288 | 289 | return $reply; |
289 | 290 | } |
290 | 291 | |
291 | - if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { //Local file or remote? |
|
292 | + if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { |
|
293 | +//Local file or remote? |
|
292 | 294 | return $package; //must be a local file.. |
293 | 295 | } |
294 | 296 | |
@@ -443,11 +445,13 @@ discard block |
||
443 | 445 | $remote_destination = $wp_filesystem->find_folder( $local_destination ); |
444 | 446 | |
445 | 447 | //Locate which directory to copy to the new folder, This is based on the actual folder holding the files. |
446 | - if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents. |
|
448 | + if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { |
|
449 | +//Only one folder? Then we want its contents. |
|
447 | 450 | $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] ); |
448 | 451 | } elseif ( count( $source_files ) == 0 ) { |
449 | 452 | return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); // There are no files? |
450 | - } else { // It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename. |
|
453 | + } else { |
|
454 | +// It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename. |
|
451 | 455 | $source = trailingslashit( $args['source'] ); |
452 | 456 | } |
453 | 457 |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | |
99 | 99 | if ( $create && ! empty( $create ) && is_array( $create ) ) { |
100 | 100 | $create = json_encode( $create ); |
101 | - $create = str_replace( '"', "'", $create ); |
|
102 | - $options['create'] = "'create', '" . esc_js( $ua_code ). "', '" . esc_js( $domain ) . "', " . $create; |
|
101 | + $create = str_replace( '"', "'", $create ); |
|
102 | + $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "', " . $create; |
|
103 | 103 | } else { |
104 | 104 | $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "'"; |
105 | 105 | } |
@@ -191,37 +191,37 @@ discard block |
||
191 | 191 | * @return string Javascript to output. |
192 | 192 | */ |
193 | 193 | public function frontend_output( ) { |
194 | - $options = $this->frontend_tracking_options(); |
|
194 | + $options = $this->frontend_tracking_options(); |
|
195 | 195 | $src = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js' ); |
196 | - $compat_mode = monsterinsights_get_option( 'gatracker_compatibility_mode', false ); |
|
196 | + $compat_mode = monsterinsights_get_option( 'gatracker_compatibility_mode', false ); |
|
197 | 197 | $compat = $compat_mode ? 'window.ga = __gaTracker;' : ''; |
198 | 198 | $track_user = monsterinsights_track_user(); |
199 | 199 | $ua = monsterinsights_get_ua(); |
200 | 200 | $output = ''; |
201 | 201 | $reason = ''; |
202 | - $attr_string = monsterinsights_get_frontend_analytics_script_atts(); |
|
202 | + $attr_string = monsterinsights_get_frontend_analytics_script_atts(); |
|
203 | 203 | ob_start(); |
204 | 204 | ?> |
205 | 205 | <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ --> |
206 | 206 | <?php if ( ! $track_user ) { |
207 | 207 | if ( empty( $ua ) ) { |
208 | 208 | $reason = __( 'Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress' ); |
209 | - $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL; |
|
209 | + $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL; |
|
210 | 210 | } else if ( current_user_can( 'monsterinsights_save_settings' ) ) { |
211 | - $reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'. PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' ); |
|
212 | - $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL; |
|
211 | + $reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.' . PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' ); |
|
212 | + $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL; |
|
213 | 213 | } else { |
214 | 214 | $reason = __( 'Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress' ); |
215 | - $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL; |
|
215 | + $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL; |
|
216 | 216 | } |
217 | 217 | echo $output; |
218 | 218 | } ?> |
219 | 219 | <?php if ( $ua ) { ?> |
220 | -<script<?php echo $attr_string;?>> |
|
220 | +<script<?php echo $attr_string; ?>> |
|
221 | 221 | (window.gaDevIds=window.gaDevIds||[]).push("dZGIzZG"); |
222 | 222 | var mi_version = '<?php echo MONSTERINSIGHTS_VERSION; ?>'; |
223 | 223 | var mi_track_user = <?php echo ( $track_user ? 'true' : 'false' ); ?>; |
224 | - var mi_no_track_reason = <?php echo ( $reason ? "'" . esc_js( $reason) . "'": "''" ); ?>; |
|
224 | + var mi_no_track_reason = <?php echo ( $reason ? "'" . esc_js( $reason ) . "'" : "''" ); ?>; |
|
225 | 225 | <?php do_action( 'monsterinsights_tracking_analytics_frontend_output_after_mi_track_user' ); ?> |
226 | 226 | |
227 | 227 | <?php if ( $this->should_do_optout() ) { ?> |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | ?> |
276 | 276 | } else { |
277 | 277 | <?php if ( $this->should_do_optout() ) { ?> |
278 | - console.log( "<?php echo esc_js( $reason );?>" ); |
|
278 | + console.log( "<?php echo esc_js( $reason ); ?>" ); |
|
279 | 279 | (function() { |
280 | 280 | /* https://developers.google.com/analytics/devguides/collection/analyticsjs/ */ |
281 | 281 | var noopfn = function() { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | } |
299 | 299 | var f = arguments[len-1]; |
300 | 300 | if ( typeof f !== 'object' || f === null || typeof f.hitCallback !== 'function' ) { |
301 | - console.log( '<?php echo esc_js( __("Not running function", "google-analytics-for-wordpress" ) );?> __gaTracker(' + arguments[0] + " ....) <?php echo esc_js( __( "because you are not being tracked.", 'google-analytics-for-wordpress' ) );?> " + mi_no_track_reason ); |
|
301 | + console.log( '<?php echo esc_js( __( "Not running function", "google-analytics-for-wordpress" ) ); ?> __gaTracker(' + arguments[0] + " ....) <?php echo esc_js( __( "because you are not being tracked.", 'google-analytics-for-wordpress' ) ); ?> " + mi_no_track_reason ); |
|
302 | 302 | return; |
303 | 303 | } |
304 | 304 | try { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | if ( method_exists( $this, 'get_themes_' . $type ) ) { |
65 | 65 | $this->themes = call_user_func( array( $this, 'get_themes_' . $type ) ); |
66 | 66 | if ( ! empty( $theme ) ) { |
67 | - $this->theme = isset( $this->themes[ $theme ] ) ? $this->themes[ $theme ] : array(); |
|
67 | + $this->theme = isset( $this->themes[$theme] ) ? $this->themes[$theme] : array(); |
|
68 | 68 | |
69 | 69 | return $this->theme; |
70 | 70 | } else { |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | |
115 | 115 | $settings = $this->get_theme_stored_styles(); |
116 | 116 | |
117 | - if ( ! empty( $settings[ $type ] ) ) { |
|
117 | + if ( ! empty( $settings[$type] ) ) { |
|
118 | 118 | foreach ( $themes as $theme_key => $theme_values ) { |
119 | - if ( ! empty( $settings[ $type ][ $theme_key ] ) ) { |
|
120 | - foreach ( $themes[ $theme_key ]['styles'] as $object => $props ) { |
|
121 | - if ( ! empty( $settings[ $type ][ $theme_key ][ $object ] ) ) { |
|
119 | + if ( ! empty( $settings[$type][$theme_key] ) ) { |
|
120 | + foreach ( $themes[$theme_key]['styles'] as $object => $props ) { |
|
121 | + if ( ! empty( $settings[$type][$theme_key][$object] ) ) { |
|
122 | 122 | foreach ( $props as $style_key => $style_value ) { |
123 | - if ( ! empty( $settings[ $type ][ $theme_key ][ $object ][ $style_key ] ) ) { |
|
124 | - $themes[ $theme_key ]['styles'][ $object ][ $style_key ] = $settings[ $type ][ $theme_key ][ $object ][ $style_key ]; |
|
123 | + if ( ! empty( $settings[$type][$theme_key][$object][$style_key] ) ) { |
|
124 | + $themes[$theme_key]['styles'][$object][$style_key] = $settings[$type][$theme_key][$object][$style_key]; |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
@@ -521,13 +521,13 @@ discard block |
||
521 | 521 | continue; |
522 | 522 | } |
523 | 523 | |
524 | - if ( ! empty( $atts[ $atts_key ] ) ) { |
|
525 | - if ( is_bool( $atts[ $atts_key ] ) || 'on' === $atts[ $atts_key ] ) { |
|
524 | + if ( ! empty( $atts[$atts_key] ) ) { |
|
525 | + if ( is_bool( $atts[$atts_key] ) || 'on' === $atts[$atts_key] ) { |
|
526 | 526 | continue; |
527 | 527 | } |
528 | 528 | if ( 'size' === $style_key ) { |
529 | - $style_key = 'font-size'; |
|
530 | - $atts[ $atts_key ] .= 'px'; |
|
529 | + $style_key = 'font-size'; |
|
530 | + $atts[$atts_key] .= 'px'; |
|
531 | 531 | } |
532 | 532 | if ( 'background' === $style_key || 'background' === $element && 'color' === $style_key ) { |
533 | 533 | $style_key = 'background-color'; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | if ( 'border' === $element || 'border' === $style_key ) { |
536 | 536 | $style_key = 'border-color'; |
537 | 537 | } |
538 | - $style_css .= $style_key . ':' . $atts[ $atts_key ] . ';'; |
|
538 | + $style_css .= $style_key . ':' . $atts[$atts_key] . ';'; |
|
539 | 539 | } |
540 | 540 | } |
541 | 541 | } |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | |
559 | 559 | $class = get_called_class(); |
560 | 560 | |
561 | - if ( ! isset( self::$instances[ $class ] ) ) { |
|
562 | - self::$instances[ $class ] = new $class; |
|
561 | + if ( ! isset( self::$instances[$class] ) ) { |
|
562 | + self::$instances[$class] = new $class; |
|
563 | 563 | } |
564 | 564 | |
565 | - return self::$instances[ $class ]; |
|
565 | + return self::$instances[$class]; |
|
566 | 566 | |
567 | 567 | } |
568 | 568 | |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | public function get_themes_styles_for_output() { |
724 | 724 | |
725 | 725 | $stored_styles = $this->get_theme_props()->get_theme_stored_styles(); |
726 | - $themes = ! empty( $stored_styles[ $this->type ] ) && is_array( $stored_styles[ $this->type ] ) ? $stored_styles[ $this->type ] : array(); |
|
726 | + $themes = ! empty( $stored_styles[$this->type] ) && is_array( $stored_styles[$this->type] ) ? $stored_styles[$this->type] : array(); |
|
727 | 727 | |
728 | 728 | return $themes; |
729 | 729 |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $this->save_progress( $page, $this->more_pages ); |
156 | 156 | |
157 | 157 | if ( $this->more_pages ) { |
158 | - $page ++; |
|
158 | + $page++; |
|
159 | 159 | $this->schedule_next_page( $page ); |
160 | 160 | } |
161 | 161 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function get_post_urls( $page = 1 ) { |
194 | 194 | |
195 | - $posts_args = array( |
|
195 | + $posts_args = array( |
|
196 | 196 | 'posts_per_page' => 100, // Don't try to load more than 500 posts at once. |
197 | 197 | 'fields' => 'ids', // Load just the ids. |
198 | 198 | 'paged' => $page, |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | while ( $posts_query->have_posts() ) { |
206 | 206 | $posts_query->the_post(); |
207 | 207 | |
208 | - $urls[ get_the_ID() ] = get_permalink( get_the_ID() ); |
|
208 | + $urls[get_the_ID()] = get_permalink( get_the_ID() ); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | $urls_as_keys = array(); |
233 | 233 | foreach ( $urls as $id => $url ) { |
234 | - $urls_as_keys[ $url ] = $id; |
|
234 | + $urls_as_keys[$url] = $id; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | return $urls_as_keys; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | public function store_bulk_data( $bulk_data, $urls_as_keys ) { |
370 | 370 | if ( ! empty( $bulk_data['data'] ) && is_array( $bulk_data['data'] ) ) { |
371 | 371 | foreach ( $bulk_data['data'] as $url => $values ) { |
372 | - $post_id = array_key_exists( $url, $urls_as_keys ) ? $urls_as_keys[ $url ] : false; |
|
372 | + $post_id = array_key_exists( $url, $urls_as_keys ) ? $urls_as_keys[$url] : false; |
|
373 | 373 | |
374 | 374 | if ( $post_id ) { |
375 | 375 | $this->store_post_counts( $post_id, $values ); |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | */ |
607 | 607 | public static function query_popular_posts( $count = 5 ) { |
608 | 608 | |
609 | - $popular_posts_args = array( |
|
609 | + $popular_posts_args = array( |
|
610 | 610 | 'posts_per_page' => $count, |
611 | 611 | 'meta_value' => 'monsterinsights_sharedcount_total', |
612 | 612 | 'orderby' => 'meta_value_num', |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | if ( $popular_posts_query->have_posts() ) { |
619 | 619 | while ( $popular_posts_query->have_posts() ) { |
620 | 620 | $popular_posts_query->the_post(); |
621 | - $popular_posts[ get_the_ID() ] = array( |
|
621 | + $popular_posts[get_the_ID()] = array( |
|
622 | 622 | 'post_title' => get_the_title(), |
623 | 623 | 'permalink' => get_permalink(), |
624 | 624 | 'thumbnail' => get_the_post_thumbnail_url( get_the_ID(), 'medium' ), |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | $cached_data = get_option( $this->get_cache_key(), array() ); |
64 | 64 | $args_key = $this->get_args_key( $args ); // Generate an unique key based on the instance settings. |
65 | 65 | |
66 | - if ( isset( $cached_data[ $args_key ] ) && isset( $cached_data[ $args_key ]['saved_at'] ) ) { |
|
67 | - $time_since = time() - $cached_data[ $args_key ]['saved_at']; |
|
66 | + if ( isset( $cached_data[$args_key] ) && isset( $cached_data[$args_key]['saved_at'] ) ) { |
|
67 | + $time_since = time() - $cached_data[$args_key]['saved_at']; |
|
68 | 68 | |
69 | 69 | if ( $time_since < intval( $cache_refresh_days ) * DAY_IN_SECONDS ) { |
70 | - return $cached_data[ $args_key ]['posts']; |
|
70 | + return $cached_data[$args_key]['posts']; |
|
71 | 71 | } else { |
72 | 72 | // It's expired so let's delete it. |
73 | - unset( $cached_data[ $args_key ] ); |
|
73 | + unset( $cached_data[$args_key] ); |
|
74 | 74 | update_option( $this->get_cache_key(), $cached_data ); |
75 | 75 | } |
76 | 76 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $args_key = md5( wp_json_encode( $args ) ); // Generate an unique key based on the instance settings. |
113 | 113 | $cached_data = get_option( $this->get_cache_key(), array() ); |
114 | 114 | |
115 | - $cached_data[ $args_key ] = array( |
|
115 | + $cached_data[$args_key] = array( |
|
116 | 116 | 'saved_at' => time(), |
117 | 117 | 'posts' => $posts, |
118 | 118 | ); |