@@ -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 | |
@@ -15,6 +15,9 @@ |
||
| 15 | 15 | private $last_author = false; |
| 16 | 16 | private $timeshift_cached_meta; |
| 17 | 17 | |
| 18 | + /** |
|
| 19 | + * @param string $i18n |
|
| 20 | + */ |
|
| 18 | 21 | public function __construct($i18n) |
| 19 | 22 | { |
| 20 | 23 | global $wpdb; |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | public function add_metabox() |
| 56 | 56 | { |
| 57 | 57 | $cl = $this; |
| 58 | - if (! $this->timeshiftVisible()) { |
|
| 58 | + if ( ! $this->timeshiftVisible()) { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | - if (! isset($_GET['post']) || ! $this->hasTimeshifts($_GET['post'])) { |
|
| 61 | + if ( ! isset($_GET['post']) || ! $this->hasTimeshifts($_GET['post'])) { |
|
| 62 | 62 | return; |
| 63 | 63 | } |
| 64 | - add_action('add_meta_boxes', function () use ($cl) { |
|
| 64 | + add_action('add_meta_boxes', function() use ($cl) { |
|
| 65 | 65 | add_meta_box('krn-timeshift', __('Timeshift', 'kmm-timeshift'), [$cl, 'timeshift_metabox'], null, 'normal', 'core'); |
| 66 | 66 | }); |
| 67 | 67 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function timeshift_metabox() |
| 70 | 70 | { |
| 71 | 71 | global $post; |
| 72 | - if (! isset($_GET['post'])) { |
|
| 72 | + if ( ! isset($_GET['post'])) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | $prod_post = get_post($_GET['post']); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if (isset($_GET['timeshift']) && $_GET['timeshift'] == $rev->id) { |
| 107 | 107 | $style = 'style="font-style:italic;background-color: lightblue;"'; |
| 108 | 108 | } |
| 109 | - if(!isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) { |
|
| 109 | + if ( ! isset($timeshift->meta['_edit_last']) || is_null($timeshift->meta['_edit_last'])) { |
|
| 110 | 110 | $timeshift->meta['_edit_last'] = 0; // some images dont have _edit_last field |
| 111 | 111 | } |
| 112 | 112 | echo '<tr ' . $style . '>'; |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | public function inject_metadata_timeshift($value, $post_id, $key, $single) |
| 144 | 144 | { |
| 145 | - if (! isset($_GET['timeshift'])) { |
|
| 145 | + if ( ! isset($_GET['timeshift'])) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | //Load timeshift |
| 149 | - if (! $this->timeshift_cached_meta) { |
|
| 149 | + if ( ! $this->timeshift_cached_meta) { |
|
| 150 | 150 | $post_type = get_post_type($post_id); |
| 151 | 151 | $table_name = $this->wpdb->prefix . 'timeshift_' . $post_type; |
| 152 | 152 | $sql = "select * from $table_name where id=" . intval($_GET['timeshift']); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | public function inject_timeshift($p) |
| 169 | 169 | { |
| 170 | 170 | global $post; |
| 171 | - if (! isset($_GET['timeshift'])) { |
|
| 171 | + if ( ! isset($_GET['timeshift'])) { |
|
| 172 | 172 | return; |
| 173 | 173 | } |
| 174 | 174 | //Load timeshift |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | add_action('edit_form_top', [$this, 'inject_timeshift'], 1, 1); |
| 187 | 187 | add_action('pre_post_update', [$this, 'pre_post_update'], 2, 1); |
| 188 | - add_action('admin_notices', function () { |
|
| 188 | + add_action('admin_notices', function() { |
|
| 189 | 189 | if (isset($_GET['timeshift']) && $_GET['timeshift']) { |
| 190 | 190 | echo '<div class="notice notice-warning is-dismissible"> |
| 191 | 191 | <p style="font-weight: 800; color: red">' . __('You are editing a historical version! if you save or publish, this will replace the current live one', 'kmm-timeshift') . '</p> |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | unset($mdata['_edit_lock']); |
| 249 | 249 | |
| 250 | - $timeshift = (object) ['post' => $post, 'meta' => $mdata]; |
|
| 250 | + $timeshift = (object)['post' => $post, 'meta' => $mdata]; |
|
| 251 | 251 | $this->storeTimeshift($timeshift); |
| 252 | 252 | } |
| 253 | 253 | } |