@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function krn_timeshift_table($args, $assoc_args) |
| 59 | 59 | { |
| 60 | - if (! isset($assoc_args['postId'])) { |
|
| 60 | + if ( ! isset($assoc_args['postId'])) { |
|
| 61 | 61 | $this->cliLogError('missing param postId'); |
| 62 | 62 | |
| 63 | 63 | return false; |
| 64 | 64 | } |
| 65 | - if (! is_numeric($assoc_args['postId'])) { |
|
| 65 | + if ( ! is_numeric($assoc_args['postId'])) { |
|
| 66 | 66 | $this->cliLogError('invalid postId (not numeric)'); |
| 67 | 67 | |
| 68 | 68 | return false; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | // check if valid post type |
| 72 | 72 | $post_type = get_post_type($assoc_args['postId']); |
| 73 | - if (! $post_type) { |
|
| 73 | + if ( ! $post_type) { |
|
| 74 | 74 | // use param post_type if set |
| 75 | 75 | if (isset($assoc_args['post_type'])) { |
| 76 | 76 | if (ctype_alnum($assoc_args['post_type'])) { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // show all timeshifts of post if no version is specified |
| 87 | - if (! isset($assoc_args['timeshiftId'])) { |
|
| 87 | + if ( ! isset($assoc_args['timeshiftId'])) { |
|
| 88 | 88 | $timeshiftSelection = $this->sql_get_timeshifts_by_postId($assoc_args['postId'], $post_type); |
| 89 | 89 | } else { |
| 90 | 90 | $timeshiftSelection = $this->sql_get_timeshift_by_timeshift_Id($assoc_args['timeshiftId'], $post_type); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | if (isset($assoc_args['restore'])) { |
| 98 | 98 | // restore timeshift & obtain postID |
| 99 | 99 | $restoredID = $this->krn_restore_timeshift($timeshiftSelection); |
| 100 | - if (! $restoredID) { |
|
| 100 | + if ( ! $restoredID) { |
|
| 101 | 101 | $this->cliLogError('Restoring Timeshift failed'); |
| 102 | 102 | } else { |
| 103 | 103 | $this->cliLogInfo('Timeshift/Post restored to ID: ' . $restoredID); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $table_name = $this->wpdb->prefix . 'timeshift_' . $post_type; |
| 125 | 125 | $sql = "select * from `$table_name` where post_id=" . $post_id; |
| 126 | 126 | $timeshifts = $this->wpdb->get_results($sql); |
| 127 | - if (! $timeshifts) { |
|
| 127 | + if ( ! $timeshifts) { |
|
| 128 | 128 | $this->cliLogError('no entries in table'); |
| 129 | 129 | |
| 130 | 130 | return false; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $postPayload = unserialize($timeshift[0]->post_payload); |
| 149 | 149 | |
| 150 | 150 | // if post status returns false => post is deleted completely |
| 151 | - if (! get_post_status($postPayload->post->ID)) { |
|
| 151 | + if ( ! get_post_status($postPayload->post->ID)) { |
|
| 152 | 152 | $postPayload->post->ID = 0; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -200,25 +200,25 @@ discard block |
||
| 200 | 200 | public function add_metabox() |
| 201 | 201 | { |
| 202 | 202 | $cl = $this; |
| 203 | - if (! $this->timeshiftVisible()) { |
|
| 203 | + if ( ! $this->timeshiftVisible()) { |
|
| 204 | 204 | return; |
| 205 | 205 | } |
| 206 | 206 | // Keep adding the metabox even if no timeshifts available, i.e. will render timeshift box with only live version |
| 207 | - if (! isset($_GET['post'])) { |
|
| 207 | + if ( ! isset($_GET['post'])) { |
|
| 208 | 208 | return; |
| 209 | 209 | } |
| 210 | 210 | $prod_post = get_post($_GET['post']); |
| 211 | 211 | if (true == apply_filters('krn_timeshift_disabled', false, $prod_post->post_type)) { |
| 212 | 212 | return; |
| 213 | 213 | } |
| 214 | - add_action('add_meta_boxes', function () use ($cl) { |
|
| 214 | + add_action('add_meta_boxes', function() use ($cl) { |
|
| 215 | 215 | add_meta_box('krn-timeshift', __('Timeshift', 'kmm-timeshift'), [$cl, 'timeshift_metabox'], null, 'normal', 'core'); |
| 216 | 216 | }); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | public function timeshift_metabox() |
| 220 | 220 | { |
| 221 | - if (! isset($_GET['post'])) { |
|
| 221 | + if ( ! isset($_GET['post'])) { |
|
| 222 | 222 | return; |
| 223 | 223 | } |
| 224 | 224 | $prod_post = get_post($_GET['post']); |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | public function inject_metadata_timeshift($value, $post_id, $key, $single) |
| 267 | 267 | { |
| 268 | - if (! isset($_GET['timeshift'])) { |
|
| 268 | + if ( ! isset($_GET['timeshift'])) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | // Load timeshift |
| 272 | - if (! $this->timeshift_cached_meta) { |
|
| 272 | + if ( ! $this->timeshift_cached_meta) { |
|
| 273 | 273 | $post_type = get_post_type($post_id); |
| 274 | 274 | $table_name = $this->wpdb->prefix . 'timeshift_' . $post_type; |
| 275 | 275 | $sql = "select * from `$table_name` where id=" . intval($_GET['timeshift']); |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | public function inject_timeshift($p) |
| 292 | 292 | { |
| 293 | 293 | global $post; |
| 294 | - if (! isset($_GET['timeshift'])) { |
|
| 294 | + if ( ! isset($_GET['timeshift'])) { |
|
| 295 | 295 | return; |
| 296 | 296 | } |
| 297 | 297 | // Load timeshift |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | if (is_array($mdata) && isset($mdata['_timeshift_version'][0]) && |
| 370 | 370 | is_numeric($mdata['_timeshift_version'][0])) { |
| 371 | 371 | // Increment version for post's meta |
| 372 | - $verToSave = (int) $mdata['_timeshift_version'][0] + 1; |
|
| 372 | + $verToSave = (int)$mdata['_timeshift_version'][0] + 1; |
|
| 373 | 373 | } |
| 374 | 374 | update_post_meta($postID, '_timeshift_version', $verToSave); |
| 375 | 375 | if ($verToSave > 1) { |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | $timeshiftVer = $this->updateTimeshiftVersion($post_ID, $mdata); |
| 410 | 410 | $mdata['_timeshift_version'][0] = $timeshiftVer; |
| 411 | 411 | $mdata['KRN_MODE'] = 'DELETE'; |
| 412 | - $timeshift = (object) ['post' => $post, 'meta' => $mdata]; |
|
| 412 | + $timeshift = (object)['post' => $post, 'meta' => $mdata]; |
|
| 413 | 413 | $this->storeTimeshift($timeshift); |
| 414 | 414 | } |
| 415 | 415 | |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | if ($recordTimeshift) { |
| 468 | 468 | $mdata['_timeshift_version'][0] = $timeshiftVer; |
| 469 | 469 | $mdata['save_initiator'] = $prevSaveInit; |
| 470 | - $timeshift = (object) ['post' => $post, 'meta' => $mdata]; |
|
| 470 | + $timeshift = (object)['post' => $post, 'meta' => $mdata]; |
|
| 471 | 471 | $this->storeTimeshift($timeshift); |
| 472 | 472 | } |
| 473 | 473 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | $table_name = $this->wpdb->prefix . 'timeshift_' . $prod_post->post_type; |
| 483 | 483 | $sql = "select count(1) as cnt from `$table_name` where post_id=" . $prod_post->ID; |
| 484 | 484 | $maxrows = $this->wpdb->get_results($sql); |
| 485 | - $allrows = (int) $maxrows[0]->{'cnt'}; |
|
| 485 | + $allrows = (int)$maxrows[0]->{'cnt'}; |
|
| 486 | 486 | |
| 487 | 487 | // max. number of pages |
| 488 | 488 | $max_page = ceil($allrows / $this->timeshift_posts_per_page); |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | public function get_next_rows($prod_post, $start = 0) |
| 503 | 503 | { |
| 504 | - if (! isset($prod_post)) { |
|
| 504 | + if ( ! isset($prod_post)) { |
|
| 505 | 505 | return; |
| 506 | 506 | } |
| 507 | 507 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | public function render_metabox_table($prod_post, $rows = []) |
| 516 | 516 | { |
| 517 | - if (! isset($prod_post)) { |
|
| 517 | + if ( ! isset($prod_post)) { |
|
| 518 | 518 | return; |
| 519 | 519 | } |
| 520 | 520 | |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | // some images don't have _edit_last field |
| 566 | - if (! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) { |
|
| 566 | + if ( ! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) { |
|
| 567 | 567 | $timeshift->meta['_edit_last'] = 0; |
| 568 | 568 | } |
| 569 | 569 | |