Completed
Push — beta ( e1c499...d8a9c0 )
by
unknown
05:41 queued 13s
created
kmm-timeshift.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Core.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         if (is_array($mdata) && isset($mdata['_timeshift_version'][0])
350 350
         && is_numeric($mdata['_timeshift_version'][0])) {
351 351
             // Increment version for post's meta
352
-            $verToSave = (int) $mdata['_timeshift_version'][0] + 1;
352
+            $verToSave = (int)$mdata['_timeshift_version'][0] + 1;
353 353
         }
354 354
         update_post_meta($postID, '_timeshift_version', $verToSave);
355 355
         if ($verToSave > 1) {
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
         $timeshiftVer = $this->updateTimeshiftVersion($post_ID, $mdata);
386 386
         $mdata['_timeshift_version'][0] = $timeshiftVer;
387 387
         $mdata['KRN_MODE'] = 'DELETE';
388
-        $timeshift = (object) ['post' => $post, 'meta' => $mdata];
388
+        $timeshift = (object)['post' => $post, 'meta' => $mdata];
389 389
         $this->storeTimeshift($timeshift);
390 390
     }
391 391
 
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
         $timeshiftVer = $this->updateTimeshiftVersion($post_ID, $mdata);
399 399
         $mdata['_timeshift_version'][0] = $timeshiftVer;
400 400
         $mdata['KRN_MODE'] = 'MANUAL';
401
-        if (! is_array($initiator)) {
401
+        if ( ! is_array($initiator)) {
402 402
             $initiator = [$initiator];
403 403
         }
404 404
 
405 405
         $mdata['save_initiator'] = $initiator;
406
-        $timeshift = (object) ['post' => $post, 'meta' => $mdata];
406
+        $timeshift = (object)['post' => $post, 'meta' => $mdata];
407 407
         $this->storeTimeshift($timeshift);
408 408
     }
409 409
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
         if ($recordTimeshift) {
461 461
             $mdata['_timeshift_version'][0] = $timeshiftVer;
462 462
             $mdata['save_initiator'] = $prevSaveInit;
463
-            $timeshift = (object) ['post' => $post, 'meta' => $mdata];
463
+            $timeshift = (object)['post' => $post, 'meta' => $mdata];
464 464
             $this->storeTimeshift($timeshift);
465 465
         }
466 466
     }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         $table_name = $this->wpdb->prefix . 'timeshift_' . $prod_post->post_type;
475 475
         $sql = "select  count(1) as cnt from `$table_name` where post_id=" . $prod_post->ID;
476 476
         $maxrows = $this->wpdb->get_results($sql);
477
-        $allrows = (int) $maxrows[0]->{'cnt'};
477
+        $allrows = (int)$maxrows[0]->{'cnt'};
478 478
 
479 479
         // max. number of pages
480 480
         $max_page = ceil($allrows / $this->timeshift_posts_per_page);
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
     }
493 493
 
494 494
     public function get_next_rows($prod_post, $start = 0) {
495
-        if (! isset($prod_post)) {
495
+        if ( ! isset($prod_post)) {
496 496
             return;
497 497
         }
498 498
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
     }
505 505
 
506 506
     public function render_metabox_table($prod_post, $rows = []) {
507
-        if (! isset($prod_post)) {
507
+        if ( ! isset($prod_post)) {
508 508
             return;
509 509
         }
510 510
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 
546 546
         foreach ($rows as $rev) {
547 547
             $timeshift = unserialize($rev->post_payload);
548
-            if (! $timeshift) { // broken record
548
+            if ( ! $timeshift) { // broken record
549 549
                 continue;
550 550
             }
551 551
 
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
             }
558 558
 
559 559
             // some images don't have _edit_last field
560
-            if (! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) {
560
+            if ( ! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) {
561 561
                 $timeshift->meta['_edit_last'] = 0;
562 562
             }
563 563
 
Please login to merge, or discard this patch.