@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | use KMM\Timeshift\Core; |
| 17 | 17 | |
| 18 | -if (! function_exists('add_filter')) { |
|
| 18 | +if ( ! function_exists('add_filter')) { |
|
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | // If the class does not exist, and the vendor file is there |
| 37 | 37 | // maybe the plugin was installed separately via Composer, let's try to load autoload |
| 38 | - if (! $class_exists && $autoload_found) { |
|
| 38 | + if ( ! $class_exists && $autoload_found) { |
|
| 39 | 39 | @require_once __DIR__ . '/vendor/autoload.php'; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - return $class_exists || ( $autoload_found && class_exists($class_name) ); |
|
| 42 | + return $class_exists || ($autoload_found && class_exists($class_name)); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Exit if classes are not available |
| 46 | -if (! ensure_class_loaded(__NAMESPACE__ . '\Core')) { |
|
| 46 | +if ( ! ensure_class_loaded(__NAMESPACE__ . '\Core')) { |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public function krn_timeshift_table($args, $assoc_args) { |
| 54 | - if (! isset($assoc_args['postId'])) { |
|
| 54 | + if ( ! isset($assoc_args['postId'])) { |
|
| 55 | 55 | $this->cliLogError('missing param postId'); |
| 56 | 56 | |
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | - if (! is_numeric($assoc_args['postId'])) { |
|
| 59 | + if ( ! is_numeric($assoc_args['postId'])) { |
|
| 60 | 60 | $this->cliLogError('invalid postId (not numeric)'); |
| 61 | 61 | |
| 62 | 62 | return false; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | // check if valid post type |
| 66 | 66 | $post_type = get_post_type($assoc_args['postId']); |
| 67 | - if (! $post_type) { |
|
| 67 | + if ( ! $post_type) { |
|
| 68 | 68 | // use param post_type if set |
| 69 | 69 | if (isset($assoc_args['post_type'])) { |
| 70 | 70 | if (ctype_alnum($assoc_args['post_type'])) { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // show all timeshifts of post if no version is specified |
| 81 | - if (! isset($assoc_args['timeshiftId'])) { |
|
| 81 | + if ( ! isset($assoc_args['timeshiftId'])) { |
|
| 82 | 82 | $timeshiftSelection = $this->sql_get_timeshifts_by_postId($assoc_args['postId'], $post_type); |
| 83 | 83 | } else { |
| 84 | 84 | $timeshiftSelection = $this->sql_get_timeshift_by_timeshift_Id($assoc_args['timeshiftId'], $post_type); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | if (isset($assoc_args['restore'])) { |
| 92 | 92 | // restore timeshift & obtain postID |
| 93 | 93 | $restoredID = $this->krn_restore_timeshift($timeshiftSelection); |
| 94 | - if (! $restoredID) { |
|
| 94 | + if ( ! $restoredID) { |
|
| 95 | 95 | $this->cliLogError('Restoring Timeshift failed'); |
| 96 | 96 | } else { |
| 97 | 97 | $this->cliLogInfo('Timeshift/Post restored to ID: ' . $restoredID); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $table_name = $this->wpdb->prefix . 'timeshift_' . $post_type; |
| 117 | 117 | $sql = "select * from `$table_name` where post_id=" . $post_id; |
| 118 | 118 | $timeshifts = $this->wpdb->get_results($sql); |
| 119 | - if (! $timeshifts) { |
|
| 119 | + if ( ! $timeshifts) { |
|
| 120 | 120 | $this->cliLogError('no entries in table'); |
| 121 | 121 | |
| 122 | 122 | return false; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $postPayload = unserialize($timeshift[0]->post_payload); |
| 139 | 139 | |
| 140 | 140 | // if post status returns false => post is deleted completely |
| 141 | - if (! get_post_status($postPayload->post->ID)) { |
|
| 141 | + if ( ! get_post_status($postPayload->post->ID)) { |
|
| 142 | 142 | $postPayload->post->ID = 0; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -187,24 +187,24 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | public function add_metabox() { |
| 189 | 189 | $cl = $this; |
| 190 | - if (! $this->timeshiftVisible()) { |
|
| 190 | + if ( ! $this->timeshiftVisible()) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | // Keep adding the metabox even if no timeshifts available, i.e. will render timeshift box with only live version |
| 194 | - if (! isset($_GET['post'])) { |
|
| 194 | + if ( ! isset($_GET['post'])) { |
|
| 195 | 195 | return; |
| 196 | 196 | } |
| 197 | 197 | $prod_post = get_post($_GET['post']); |
| 198 | 198 | if (true == apply_filters('krn_timeshift_disabled', false, $prod_post->post_type)) { |
| 199 | 199 | return; |
| 200 | 200 | } |
| 201 | - add_action('add_meta_boxes', function () use ($cl) { |
|
| 201 | + add_action('add_meta_boxes', function() use ($cl) { |
|
| 202 | 202 | add_meta_box('krn-timeshift', __('Timeshift', 'kmm-timeshift'), [$cl, 'timeshift_metabox'], null, 'normal', 'core'); |
| 203 | 203 | }); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | public function timeshift_metabox() { |
| 207 | - if (! isset($_GET['post'])) { |
|
| 207 | + if ( ! isset($_GET['post'])) { |
|
| 208 | 208 | return; |
| 209 | 209 | } |
| 210 | 210 | $prod_post = get_post($_GET['post']); |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | public function inject_metadata_timeshift($value, $post_id, $key, $single) { |
| 251 | - if (! isset($_GET['timeshift'])) { |
|
| 251 | + if ( ! isset($_GET['timeshift'])) { |
|
| 252 | 252 | return; |
| 253 | 253 | } |
| 254 | 254 | // Load timeshift |
| 255 | - if (! $this->timeshift_cached_meta) { |
|
| 255 | + if ( ! $this->timeshift_cached_meta) { |
|
| 256 | 256 | $post_type = get_post_type($post_id); |
| 257 | 257 | $table_name = $this->wpdb->prefix . 'timeshift_' . $post_type; |
| 258 | 258 | $sql = "select * from `$table_name` where id=" . intval($_GET['timeshift']); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | public function inject_timeshift($p) { |
| 275 | 275 | global $post; |
| 276 | - if (! isset($_GET['timeshift'])) { |
|
| 276 | + if ( ! isset($_GET['timeshift'])) { |
|
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | // Load timeshift |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | if (is_array($mdata) && isset($mdata['_timeshift_version'][0]) |
| 346 | 346 | && is_numeric($mdata['_timeshift_version'][0])) { |
| 347 | 347 | // Increment version for post's meta |
| 348 | - $verToSave = (int) $mdata['_timeshift_version'][0] + 1; |
|
| 348 | + $verToSave = (int)$mdata['_timeshift_version'][0] + 1; |
|
| 349 | 349 | } |
| 350 | 350 | update_post_meta($postID, '_timeshift_version', $verToSave); |
| 351 | 351 | if ($verToSave > 1) { |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | $timeshiftVer = $this->updateTimeshiftVersion($post_ID, $mdata); |
| 382 | 382 | $mdata['_timeshift_version'][0] = $timeshiftVer; |
| 383 | 383 | $mdata['KRN_MODE'] = 'DELETE'; |
| 384 | - $timeshift = (object) ['post' => $post, 'meta' => $mdata]; |
|
| 384 | + $timeshift = (object)['post' => $post, 'meta' => $mdata]; |
|
| 385 | 385 | $this->storeTimeshift($timeshift); |
| 386 | 386 | } |
| 387 | 387 | |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | if ($recordTimeshift) { |
| 439 | 439 | $mdata['_timeshift_version'][0] = $timeshiftVer; |
| 440 | 440 | $mdata['save_initiator'] = $prevSaveInit; |
| 441 | - $timeshift = (object) ['post' => $post, 'meta' => $mdata]; |
|
| 441 | + $timeshift = (object)['post' => $post, 'meta' => $mdata]; |
|
| 442 | 442 | $this->storeTimeshift($timeshift); |
| 443 | 443 | } |
| 444 | 444 | } |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $table_name = $this->wpdb->prefix . 'timeshift_' . $prod_post->post_type; |
| 453 | 453 | $sql = "select count(1) as cnt from `$table_name` where post_id=" . $prod_post->ID; |
| 454 | 454 | $maxrows = $this->wpdb->get_results($sql); |
| 455 | - $allrows = (int) $maxrows[0]->{'cnt'}; |
|
| 455 | + $allrows = (int)$maxrows[0]->{'cnt'}; |
|
| 456 | 456 | |
| 457 | 457 | // max. number of pages |
| 458 | 458 | $max_page = ceil($allrows / $this->timeshift_posts_per_page); |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | public function get_next_rows($prod_post, $start = 0) { |
| 473 | - if (! isset($prod_post)) { |
|
| 473 | + if ( ! isset($prod_post)) { |
|
| 474 | 474 | return; |
| 475 | 475 | } |
| 476 | 476 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | public function render_metabox_table($prod_post, $rows = []) { |
| 485 | - if (! isset($prod_post)) { |
|
| 485 | + if ( ! isset($prod_post)) { |
|
| 486 | 486 | return; |
| 487 | 487 | } |
| 488 | 488 | |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | |
| 524 | 524 | foreach ($rows as $rev) { |
| 525 | 525 | $timeshift = unserialize($rev->post_payload); |
| 526 | - if (! $timeshift) { // broken record |
|
| 526 | + if ( ! $timeshift) { // broken record |
|
| 527 | 527 | continue; |
| 528 | 528 | } |
| 529 | 529 | |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | // some images don't have _edit_last field |
| 538 | - if (! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) { |
|
| 538 | + if ( ! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) { |
|
| 539 | 539 | $timeshift->meta['_edit_last'] = 0; |
| 540 | 540 | } |
| 541 | 541 | |