@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | +if ( ! defined( 'ABSPATH' )) { |
|
5 | 5 | exit; |
6 | 6 | } |
7 | 7 | |
8 | 8 | function ppp_upgrade_notices() { |
9 | 9 | |
10 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'ppp-about' || $_GET['page'] == 'ppp-upgrades' ) ) { |
|
10 | + if (isset($_GET['page']) && ($_GET['page'] == 'ppp-about' || $_GET['page'] == 'ppp-upgrades')) { |
|
11 | 11 | return; // Don't show notices on the upgrades page |
12 | 12 | } |
13 | 13 | |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | |
16 | 16 | // Sequential Orders was the first stepped upgrade, so check if we have a stalled upgrade |
17 | 17 | $resume_upgrade = ppp_maybe_resume_upgrade(); |
18 | - if ( ! empty( $resume_upgrade ) ) { |
|
18 | + if ( ! empty($resume_upgrade)) { |
|
19 | 19 | |
20 | 20 | $resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) ); |
21 | 21 | printf( |
22 | - '<div class="error"><p>' . __( 'Post Promoter Pro needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'ppp-txt' ) . '</p></div>', |
|
22 | + '<div class="error"><p>'.__( 'Post Promoter Pro needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'ppp-txt' ).'</p></div>', |
|
23 | 23 | esc_url( $resume_url ) |
24 | 24 | ); |
25 | 25 | |
@@ -28,16 +28,16 @@ discard block |
||
28 | 28 | // Include all 'Stepped' upgrade process notices in this else statement, |
29 | 29 | // to avoid having a pending, and new upgrade suggested at the same time |
30 | 30 | |
31 | - if ( version_compare( $ppp_version, '2.2', '<' ) || ! ppp_has_upgrade_completed( 'upgrade_post_meta' ) ) { |
|
31 | + if (version_compare( $ppp_version, '2.2', '<' ) || ! ppp_has_upgrade_completed( 'upgrade_post_meta' )) { |
|
32 | 32 | printf( |
33 | - '<div class="notice notice-info"><p>' . __( 'Post Promoter Pro needs to upgrade share override data, click <a href="%s">here</a> to start the upgrade.', 'ppp-txt' ) . '</p></div>', |
|
33 | + '<div class="notice notice-info"><p>'.__( 'Post Promoter Pro needs to upgrade share override data, click <a href="%s">here</a> to start the upgrade.', 'ppp-txt' ).'</p></div>', |
|
34 | 34 | esc_url( admin_url( 'index.php?page=ppp-upgrades&ppp-upgrade=upgrade_post_meta' ) ) |
35 | 35 | ); |
36 | 36 | } |
37 | 37 | |
38 | - if ( version_compare( $ppp_version, '2.3.19', '<' ) || ! ppp_has_upgrade_completed( 'fix_scheduled_shares_2319' ) ) { |
|
38 | + if (version_compare( $ppp_version, '2.3.19', '<' ) || ! ppp_has_upgrade_completed( 'fix_scheduled_shares_2319' )) { |
|
39 | 39 | printf( |
40 | - '<div class="notice notice-info"><p>' . __( 'Post Promoter Pro needs to fix an issue with scheduled shares, click <a href="%s">here</a> to start the upgrade.', 'ppp-txt' ) . '</p></div>', |
|
40 | + '<div class="notice notice-info"><p>'.__( 'Post Promoter Pro needs to fix an issue with scheduled shares, click <a href="%s">here</a> to start the upgrade.', 'ppp-txt' ).'</p></div>', |
|
41 | 41 | esc_url( admin_url( 'index.php?page=ppp-upgrades&ppp-upgrade=fix_scheduled_shares_2319' ) ) |
42 | 42 | ); |
43 | 43 | } |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | $upgrades_executed = false; |
60 | 60 | |
61 | 61 | // We don't have a version yet, so we need to run the upgrader |
62 | - if ( !$ppp_version && PPP_VERSION == '1.3' ) { |
|
62 | + if ( ! $ppp_version && PPP_VERSION == '1.3') { |
|
63 | 63 | ppp_v13_upgrades(); |
64 | 64 | $upgrades_executed = true; |
65 | 65 | } |
66 | 66 | |
67 | - if ( version_compare( $ppp_version, 2.1, '<' ) ) { |
|
67 | + if (version_compare( $ppp_version, 2.1, '<' )) { |
|
68 | 68 | ppp_v21_upgrades(); |
69 | 69 | $upgrades_executed = true; |
70 | 70 | } |
71 | 71 | |
72 | - if ( $upgrades_executed || version_compare( $ppp_version, PPP_VERSION, '<' ) ) { |
|
72 | + if ($upgrades_executed || version_compare( $ppp_version, PPP_VERSION, '<' )) { |
|
73 | 73 | set_transient( '_ppp_activation_redirect', '1', 60 ); |
74 | 74 | update_option( 'ppp_version', PPP_VERSION ); |
75 | 75 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | $doing_upgrade = get_option( 'ppp_doing_upgrade', false ); |
89 | 89 | |
90 | - if ( empty( $doing_upgrade ) ) { |
|
90 | + if (empty($doing_upgrade)) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
@@ -103,22 +103,22 @@ discard block |
||
103 | 103 | */ |
104 | 104 | function ppp_v13_upgrades() { |
105 | 105 | global $ppp_share_settings; |
106 | - $uq_status = ( isset( $ppp_share_settings['ppp_unique_links'] ) && $ppp_share_settings['ppp_unique_links'] == '1' ) ? $ppp_share_settings['ppp_unique_links'] : 0; |
|
107 | - $ga_status = ( isset( $ppp_share_settings['ppp_ga_tags'] ) && $ppp_share_settings['ppp_ga_tags'] == '1' ) ? $ppp_share_settings['ppp_ga_tags'] : 0; |
|
106 | + $uq_status = (isset($ppp_share_settings['ppp_unique_links']) && $ppp_share_settings['ppp_unique_links'] == '1') ? $ppp_share_settings['ppp_unique_links'] : 0; |
|
107 | + $ga_status = (isset($ppp_share_settings['ppp_ga_tags']) && $ppp_share_settings['ppp_ga_tags'] == '1') ? $ppp_share_settings['ppp_ga_tags'] : 0; |
|
108 | 108 | |
109 | - if ( $uq_status ) { |
|
109 | + if ($uq_status) { |
|
110 | 110 | $ppp_share_settings['analytics'] = 'unique_links'; |
111 | - unset( $ppp_share_settings['ppp_unique_links'] ); |
|
112 | - } elseif ( $ga_status ) { |
|
111 | + unset($ppp_share_settings['ppp_unique_links']); |
|
112 | + } elseif ($ga_status) { |
|
113 | 113 | $ppp_share_settings['analytics'] = 'google_analytics'; |
114 | - unset( $ppp_share_settings['ppp_ga_tags'] ); |
|
114 | + unset($ppp_share_settings['ppp_ga_tags']); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | update_option( 'ppp_share_settings', $ppp_share_settings ); |
118 | 118 | |
119 | 119 | global $ppp_options; |
120 | 120 | $ppp_options['default_text'] = '{post_title}'; |
121 | - $ppp_options['days'] = array( 'day1' => 'on', 'day2' => 'on', 'day3' => 'on', 'day4' => 'on', 'day5' => 'on', 'day6' => 'on'); |
|
121 | + $ppp_options['days'] = array( 'day1' => 'on', 'day2' => 'on', 'day3' => 'on', 'day4' => 'on', 'day5' => 'on', 'day6' => 'on' ); |
|
122 | 122 | |
123 | 123 | update_option( 'ppp_options', $ppp_options ); |
124 | 124 | } |
@@ -140,29 +140,29 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function ppp_v22_postmeta_upgrade() { |
142 | 142 | |
143 | - if( ! current_user_can( PostPromoterPro::get_manage_capability() ) ) { |
|
143 | + if ( ! current_user_can( PostPromoterPro::get_manage_capability() )) { |
|
144 | 144 | wp_die( __( 'You do not have permission to do upgrades', 'ppp-txt' ), __( 'Error', 'ppp-txt' ), array( 'response' => 403 ) ); |
145 | 145 | } |
146 | 146 | |
147 | 147 | ignore_user_abort( true ); |
148 | 148 | |
149 | - if ( ! ini_get( 'safe_mode' ) ) { |
|
150 | - @set_time_limit(0); |
|
149 | + if ( ! ini_get( 'safe_mode' )) { |
|
150 | + @set_time_limit( 0 ); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | global $wpdb; |
154 | 154 | |
155 | 155 | |
156 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
156 | + $step = isset($_GET['step']) ? absint( $_GET['step'] ) : 1; |
|
157 | 157 | $number = 25; |
158 | - $offset = $step == 1 ? 0 : ( $step - 1 ) * $number; |
|
158 | + $offset = $step == 1 ? 0 : ($step - 1) * $number; |
|
159 | 159 | |
160 | - if ( $step < 2 ) { |
|
160 | + if ($step < 2) { |
|
161 | 161 | // Check if we have any payments before moving on |
162 | 162 | $sql = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_ppp_post_override_data' LIMIT 1"; |
163 | 163 | $has_overrides = $wpdb->get_col( $sql ); |
164 | 164 | |
165 | - if( empty( $has_overrides ) ) { |
|
165 | + if (empty($has_overrides)) { |
|
166 | 166 | // We had no payments, just complete |
167 | 167 | update_option( 'ppp_version', preg_replace( '/[^0-9.].*/', '', PPP_VERSION ) ); |
168 | 168 | ppp_set_upgrade_complete( 'upgrade_post_meta' ); |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
174 | + $total = isset($_GET['total']) ? absint( $_GET['total'] ) : false; |
|
175 | 175 | |
176 | - if ( empty( $total ) || $total <= 1 ) { |
|
176 | + if (empty($total) || $total <= 1) { |
|
177 | 177 | $total_sql = "SELECT COUNT(post_id) as total FROM $wpdb->postmeta WHERE meta_key = '_ppp_post_override_data'"; |
178 | 178 | $results = $wpdb->get_row( $total_sql, 0 ); |
179 | 179 | |
@@ -183,48 +183,48 @@ discard block |
||
183 | 183 | $results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_ppp_post_override_data' ORDER BY meta_id DESC LIMIT %d,%d;", $offset, $number ) ); |
184 | 184 | $new_post_meta = array(); |
185 | 185 | |
186 | - if ( $results ) { |
|
187 | - foreach ( $results as $result ) { |
|
186 | + if ($results) { |
|
187 | + foreach ($results as $result) { |
|
188 | 188 | |
189 | 189 | $share_key = 1; |
190 | 190 | |
191 | 191 | $override_data = unserialize( $result->meta_value ); |
192 | 192 | |
193 | - foreach ( $override_data as $day => $values ) { |
|
193 | + foreach ($override_data as $day => $values) { |
|
194 | 194 | |
195 | - if ( ! isset( $values['enabled'] ) ) { |
|
195 | + if ( ! isset($values['enabled'])) { |
|
196 | 196 | continue; |
197 | 197 | } |
198 | 198 | |
199 | - $text = ! empty( $values['text'] ) ? $values['text'] : ''; |
|
200 | - $time = ! empty( $values['time'] ) ? $values['time'] : '8:00am'; |
|
199 | + $text = ! empty($values['text']) ? $values['text'] : ''; |
|
200 | + $time = ! empty($values['time']) ? $values['time'] : '8:00am'; |
|
201 | 201 | |
202 | 202 | $post = get_post( $result->post_id ); |
203 | 203 | $days_ahead = substr( $day, -1 ); |
204 | - $date = date( 'm\/d\/Y', strtotime( $post->post_date . '+' . $days_ahead . ' days' ) ); |
|
204 | + $date = date( 'm\/d\/Y', strtotime( $post->post_date.'+'.$days_ahead.' days' ) ); |
|
205 | 205 | $image = ''; |
206 | 206 | $attachment_id = ''; |
207 | 207 | |
208 | - if ( ! empty( $values['use_image'] ) ) { |
|
208 | + if ( ! empty($values['use_image'])) { |
|
209 | 209 | $thumb_id = get_post_thumbnail_id( $result->post_id ); |
210 | 210 | $thumb_url = wp_get_attachment_image_src( $thumb_id, 'ppp-tw-share-image', true ); |
211 | 211 | |
212 | - if ( isset( $thumb_url[0] ) && ! empty( $thumb_url[0] ) && !strpos( $thumb_url[0], 'wp-includes/images/media/default.png' ) ) { |
|
212 | + if (isset($thumb_url[0]) && ! empty($thumb_url[0]) && ! strpos( $thumb_url[0], 'wp-includes/images/media/default.png' )) { |
|
213 | 213 | $thumb_url = $thumb_url[0]; |
214 | 214 | } |
215 | 215 | |
216 | - if ( ! empty( $thumb_id ) && ! empty( $thumb_url ) ) { |
|
216 | + if ( ! empty($thumb_id) && ! empty($thumb_url)) { |
|
217 | 217 | $attachment_id = $thumb_id; |
218 | 218 | $image = $thumb_url; |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - $new_post_meta[$share_key] = array ( |
|
222 | + $new_post_meta[$share_key] = array( |
|
223 | 223 | 'date' => $date, |
224 | 224 | 'time' => $time, |
225 | 225 | 'text' => $text, |
226 | - 'image' => ! empty( $image ) ? $image : '', |
|
227 | - 'attachment_id' => ! empty( $attachment_id ) ? $attachment_id : '' |
|
226 | + 'image' => ! empty($image) ? $image : '', |
|
227 | + 'attachment_id' => ! empty($attachment_id) ? $attachment_id : '' |
|
228 | 228 | ); |
229 | 229 | |
230 | 230 | $share_key++; |
@@ -259,29 +259,29 @@ discard block |
||
259 | 259 | |
260 | 260 | function ppp_fix_scheduled_shares_2319() { |
261 | 261 | |
262 | - if( ! current_user_can( PostPromoterPro::get_manage_capability() ) ) { |
|
262 | + if ( ! current_user_can( PostPromoterPro::get_manage_capability() )) { |
|
263 | 263 | wp_die( __( 'You do not have permission to do upgrades', 'ppp-txt' ), __( 'Error', 'ppp-txt' ), array( 'response' => 403 ) ); |
264 | 264 | } |
265 | 265 | |
266 | 266 | ignore_user_abort( true ); |
267 | 267 | |
268 | - if ( ! ini_get( 'safe_mode' ) ) { |
|
269 | - @set_time_limit(0); |
|
268 | + if ( ! ini_get( 'safe_mode' )) { |
|
269 | + @set_time_limit( 0 ); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | global $wpdb; |
273 | 273 | |
274 | 274 | |
275 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
275 | + $step = isset($_GET['step']) ? absint( $_GET['step'] ) : 1; |
|
276 | 276 | $number = 25; |
277 | - $offset = $step == 1 ? 0 : ( $step - 1 ) * $number; |
|
277 | + $offset = $step == 1 ? 0 : ($step - 1) * $number; |
|
278 | 278 | |
279 | - if ( $step < 2 ) { |
|
279 | + if ($step < 2) { |
|
280 | 280 | // Check if we have any payments before moving on |
281 | 281 | $sql = "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key IN ( '_ppp_tweets', '_ppp_fb_shares', '_ppp_li_shares' ) LIMIT 1"; |
282 | 282 | $has_shares = $wpdb->get_col( $sql ); |
283 | 283 | |
284 | - if( empty( $has_shares ) ) { |
|
284 | + if (empty($has_shares)) { |
|
285 | 285 | // We had no payments, just complete |
286 | 286 | update_option( 'ppp_version', preg_replace( '/[^0-9.].*/', '', PPP_VERSION ) ); |
287 | 287 | ppp_set_upgrade_complete( 'fix_scheduled_shares_2319' ); |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
293 | + $total = isset($_GET['total']) ? absint( $_GET['total'] ) : false; |
|
294 | 294 | |
295 | - if ( empty( $total ) || $total <= 1 ) { |
|
295 | + if (empty($total) || $total <= 1) { |
|
296 | 296 | $total_sql = "SELECT COUNT( DISTINCT post_id ) as total FROM $wpdb->postmeta WHERE meta_key IN ( '_ppp_tweets', '_ppp_fb_shares', '_ppp_li_shares' )"; |
297 | 297 | $results = $wpdb->get_row( $total_sql, 0 ); |
298 | 298 | |
@@ -301,18 +301,18 @@ discard block |
||
301 | 301 | |
302 | 302 | $results = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key IN ( '_ppp_tweets', '_ppp_fb_shares', '_ppp_li_shares' ) ORDER BY post_id DESC LIMIT %d,%d;", $offset, $number ) ); |
303 | 303 | |
304 | - if ( $results ) { |
|
304 | + if ($results) { |
|
305 | 305 | $allowed_post_types = ppp_allowed_post_types(); |
306 | 306 | |
307 | - foreach ( $results as $result ) { |
|
307 | + foreach ($results as $result) { |
|
308 | 308 | $post = get_post( $result->post_id ); |
309 | - if ( ! in_array( $post->post_type, $allowed_post_types ) ) { |
|
309 | + if ( ! in_array( $post->post_type, $allowed_post_types )) { |
|
310 | 310 | continue; |
311 | 311 | } |
312 | 312 | |
313 | 313 | $timestamps = ppp_get_timestamps( $result->post_id ); |
314 | 314 | |
315 | - foreach ( $timestamps as $timestamp => $name ) { |
|
315 | + foreach ($timestamps as $timestamp => $name) { |
|
316 | 316 | $timestamp = substr( $timestamp, 0, strlen( $timestamp ) - 3 ); |
317 | 317 | wp_schedule_single_event( $timestamp, 'ppp_share_post_event', array( $result->post_id, $name ) ); |
318 | 318 | } |