Completed
Push — beta ( f64331...c77f90 )
by
unknown
09:56 queued 12s
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   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
     }
51 51
 
52 52
     public function krn_timeshift_table($args, $assoc_args) {
53
-        if (! isset($assoc_args['postId'])) {
53
+        if ( ! isset($assoc_args['postId'])) {
54 54
             $this->cliLogError('missing param postId');
55 55
 
56 56
             return false;
57 57
         }
58
-        if (! is_numeric($assoc_args['postId'])) {
58
+        if ( ! is_numeric($assoc_args['postId'])) {
59 59
             $this->cliLogError('invalid postId (not numeric)');
60 60
 
61 61
             return false;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
         // check if valid post type
65 65
         $post_type = get_post_type($assoc_args['postId']);
66
-        if (! $post_type) {
66
+        if ( ! $post_type) {
67 67
             // use param post_type if set
68 68
             if (isset($assoc_args['post_type'])) {
69 69
                 if (ctype_alnum($assoc_args['post_type'])) {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         }
78 78
 
79 79
         // show all timeshifts of post if no version is specified
80
-        if (! isset($assoc_args['timeshiftId'])) {
80
+        if ( ! isset($assoc_args['timeshiftId'])) {
81 81
             $timeshiftSelection = $this->sql_get_timeshifts_by_postId($assoc_args['postId'], $post_type);
82 82
         } else {
83 83
             $timeshiftSelection = $this->sql_get_timeshift_by_timeshift_Id($assoc_args['timeshiftId'], $post_type);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         if (isset($assoc_args['restore'])) {
91 91
             // restore timeshift & obtain postID
92 92
             $restoredID = $this->krn_restore_timeshift($timeshiftSelection);
93
-            if (! $restoredID) {
93
+            if ( ! $restoredID) {
94 94
                 $this->cliLogError('Restoring Timeshift failed');
95 95
             } else {
96 96
                 $this->cliLogInfo('Timeshift/Post restored to ID: ' . $restoredID);
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $table_name = $this->wpdb->prefix . 'timeshift_' . $post_type;
116 116
         $sql = "select * from $table_name where post_id=" . $post_id;
117 117
         $timeshifts = $this->wpdb->get_results($sql);
118
-        if (! $timeshifts) {
118
+        if ( ! $timeshifts) {
119 119
             $this->cliLogError('no entries in table');
120 120
 
121 121
             return false;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         $postPayload = unserialize($timeshift[0]->post_payload);
138 138
 
139 139
         // if post status returns false => post is deleted completely
140
-        if (! get_post_status($postPayload->post->ID)) {
140
+        if ( ! get_post_status($postPayload->post->ID)) {
141 141
             $postPayload->post->ID = 0;
142 142
         }
143 143
 
@@ -186,20 +186,20 @@  discard block
 block discarded – undo
186 186
 
187 187
     public function add_metabox() {
188 188
         $cl = $this;
189
-        if (! $this->timeshiftVisible()) {
189
+        if ( ! $this->timeshiftVisible()) {
190 190
             return;
191 191
         }
192 192
         // Keep adding the metabox even if no timeshifts available, i.e. will render timeshift box with only live version
193
-        if (! isset($_GET['post'])) {
193
+        if ( ! isset($_GET['post'])) {
194 194
             return;
195 195
         }
196
-        add_action('add_meta_boxes', function () use ($cl) {
196
+        add_action('add_meta_boxes', function() use ($cl) {
197 197
             add_meta_box('krn-timeshift', __('Timeshift', 'kmm-timeshift'), [$cl, 'timeshift_metabox'], null, 'normal', 'core');
198 198
         });
199 199
     }
200 200
 
201 201
     public function timeshift_metabox() {
202
-        if (! isset($_GET['post'])) {
202
+        if ( ! isset($_GET['post'])) {
203 203
             return;
204 204
         }
205 205
         $prod_post = get_post($_GET['post']);
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
     }
244 244
 
245 245
     public function inject_metadata_timeshift($value, $post_id, $key, $single) {
246
-        if (! isset($_GET['timeshift'])) {
246
+        if ( ! isset($_GET['timeshift'])) {
247 247
             return;
248 248
         }
249 249
         // Load timeshift
250
-        if (! $this->timeshift_cached_meta) {
250
+        if ( ! $this->timeshift_cached_meta) {
251 251
             $post_type = get_post_type($post_id);
252 252
             $table_name = $this->wpdb->prefix . 'timeshift_' . $post_type;
253 253
             $sql = "select * from $table_name where id=" . intval($_GET['timeshift']);
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
     public function inject_timeshift($p) {
270 270
         global $post;
271
-        if (! isset($_GET['timeshift'])) {
271
+        if ( ! isset($_GET['timeshift'])) {
272 272
             return;
273 273
         }
274 274
         // Load timeshift
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         if (is_array($mdata) && isset($mdata['_timeshift_version'][0]) &&
341 341
         is_numeric($mdata['_timeshift_version'][0])) {
342 342
             // Increment version for post's meta
343
-            $verToSave = (int) $mdata['_timeshift_version'][0] + 1;
343
+            $verToSave = (int)$mdata['_timeshift_version'][0] + 1;
344 344
         }
345 345
         update_post_meta($postID, '_timeshift_version', $verToSave);
346 346
         if ($verToSave > 1) {
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         $timeshiftVer = $this->updateTimeshiftVersion($post_ID, $mdata);
377 377
         $mdata['_timeshift_version'][0] = $timeshiftVer;
378 378
         $mdata['KRN_MODE'] = 'DELETE';
379
-        $timeshift = (object) ['post' => $post, 'meta' => $mdata];
379
+        $timeshift = (object)['post' => $post, 'meta' => $mdata];
380 380
         $this->storeTimeshift($timeshift);
381 381
     }
382 382
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
         if ($recordTimeshift) {
431 431
             $mdata['_timeshift_version'][0] = $timeshiftVer;
432 432
             $mdata['save_initiator'] = $prevSaveInit;
433
-            $timeshift = (object) ['post' => $post, 'meta' => $mdata];
433
+            $timeshift = (object)['post' => $post, 'meta' => $mdata];
434 434
             $this->storeTimeshift($timeshift);
435 435
         }
436 436
     }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
         $table_name = $this->wpdb->prefix . 'timeshift_' . $prod_post->post_type;
445 445
         $sql = "select  count(1) as cnt from $table_name where post_id=" . $prod_post->ID;
446 446
         $maxrows = $this->wpdb->get_results($sql);
447
-        $allrows = (int) $maxrows[0]->{'cnt'};
447
+        $allrows = (int)$maxrows[0]->{'cnt'};
448 448
 
449 449
         // max. number of pages
450 450
         $max_page = ceil($allrows / $this->timeshift_posts_per_page);
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
     }
463 463
 
464 464
     public function get_next_rows($prod_post, $start = 0) {
465
-        if (! isset($prod_post)) {
465
+        if ( ! isset($prod_post)) {
466 466
             return;
467 467
         }
468 468
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
     }
475 475
 
476 476
     public function render_metabox_table($prod_post, $rows = []) {
477
-        if (! isset($prod_post)) {
477
+        if ( ! isset($prod_post)) {
478 478
             return;
479 479
         }
480 480
 
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
             }
524 524
 
525 525
             // some images don't have _edit_last field
526
-            if (! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) {
526
+            if ( ! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) {
527 527
                 $timeshift->meta['_edit_last'] = 0;
528 528
             }
529 529
 
Please login to merge, or discard this patch.