@@ -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 | |
@@ -14,6 +14,9 @@ |
||
| 14 | 14 | private $last_author = false; |
| 15 | 15 | private $timeshift_cached_meta; |
| 16 | 16 | |
| 17 | + /** |
|
| 18 | + * @param string $i18n |
|
| 19 | + */ |
|
| 17 | 20 | public function __construct($i18n) { |
| 18 | 21 | global $wpdb; |
| 19 | 22 | $this->i18n = $i18n; |
@@ -52,19 +52,19 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public function add_metabox() { |
| 54 | 54 | $cl = $this; |
| 55 | - if (! $this->timeshiftVisible()) { |
|
| 55 | + if ( ! $this->timeshiftVisible()) { |
|
| 56 | 56 | return; |
| 57 | 57 | } |
| 58 | - if (! isset($_GET['post']) || ! $this->hasTimeshifts($_GET['post'])) { |
|
| 58 | + if ( ! isset($_GET['post']) || ! $this->hasTimeshifts($_GET['post'])) { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | - add_action('add_meta_boxes', function () use ($cl) { |
|
| 61 | + add_action('add_meta_boxes', function() use ($cl) { |
|
| 62 | 62 | add_meta_box('krn-timeshift', __('Timeshift', 'kmm-timeshift'), [$cl, 'timeshift_metabox'], null, 'normal', 'core'); |
| 63 | 63 | }); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function timeshift_metabox() { |
| 67 | - if (! isset($_GET['post'])) { |
|
| 67 | + if ( ! isset($_GET['post'])) { |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | $prod_post = get_post($_GET['post']); |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | public function inject_metadata_timeshift($value, $post_id, $key, $single) { |
| 111 | - if (! isset($_GET['timeshift'])) { |
|
| 111 | + if ( ! isset($_GET['timeshift'])) { |
|
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | // Load timeshift |
| 115 | - if (! $this->timeshift_cached_meta) { |
|
| 115 | + if ( ! $this->timeshift_cached_meta) { |
|
| 116 | 116 | $post_type = get_post_type($post_id); |
| 117 | 117 | $table_name = $this->wpdb->prefix . 'timeshift_' . $post_type; |
| 118 | 118 | $sql = "select * from $table_name where id=" . intval($_GET['timeshift']); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | public function inject_timeshift($p) { |
| 135 | 135 | global $post; |
| 136 | - if (! isset($_GET['timeshift'])) { |
|
| 136 | + if ( ! isset($_GET['timeshift'])) { |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | // Load timeshift |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | unset($mdata['_edit_lock']); |
| 222 | 222 | |
| 223 | - $timeshift = (object) ['post' => $post, 'meta' => $mdata]; |
|
| 223 | + $timeshift = (object)['post' => $post, 'meta' => $mdata]; |
|
| 224 | 224 | $this->storeTimeshift($timeshift); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $table_name = $this->wpdb->prefix . 'timeshift_' . $prod_post->post_type; |
| 234 | 234 | $sql = "select count(1) as cnt from $table_name where post_id=" . $prod_post->ID; |
| 235 | 235 | $maxrows = $this->wpdb->get_results($sql); |
| 236 | - $allrows = (int) $maxrows[0]->{'cnt'}; |
|
| 236 | + $allrows = (int)$maxrows[0]->{'cnt'}; |
|
| 237 | 237 | |
| 238 | 238 | // max. number of pages |
| 239 | 239 | $max_page = ceil($allrows / $this->timeshift_posts_per_page); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | public function get_next_rows($prod_post, $start = 0) { |
| 254 | - if (! isset($prod_post)) { |
|
| 254 | + if ( ! isset($prod_post)) { |
|
| 255 | 255 | return; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | public function render_metabox_table($prod_post, $rows = []) { |
| 266 | - if (! isset($prod_post)) { |
|
| 266 | + if ( ! isset($prod_post)) { |
|
| 267 | 267 | return; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // some images dont have _edit_last field |
| 306 | - if (! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) { |
|
| 306 | + if ( ! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) { |
|
| 307 | 307 | $timeshift->meta['_edit_last'] = 0; |
| 308 | 308 | } |
| 309 | 309 | |