@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | use KMM\Timeshift\Core; |
| 17 | 17 | |
| 18 | 18 | if ( ! function_exists( 'add_filter' ) ) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -29,21 +29,21 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function ensure_class_loaded( $class_name ) { |
| 31 | 31 | |
| 32 | - $class_exists = class_exists( $class_name ); |
|
| 33 | - $autoload_found = file_exists( __DIR__ . '/vendor/autoload.php' ); |
|
| 32 | + $class_exists = class_exists( $class_name ); |
|
| 33 | + $autoload_found = file_exists( __DIR__ . '/vendor/autoload.php' ); |
|
| 34 | 34 | |
| 35 | - // If the class does not exist, and the vendor file is there |
|
| 36 | - // maybe the plugin was installed separately via Composer, let's try to load autoload |
|
| 37 | - if ( ! $class_exists && $autoload_found ) { |
|
| 38 | - @require_once __DIR__ . '/vendor/autoload.php'; |
|
| 39 | - } |
|
| 35 | + // If the class does not exist, and the vendor file is there |
|
| 36 | + // maybe the plugin was installed separately via Composer, let's try to load autoload |
|
| 37 | + if ( ! $class_exists && $autoload_found ) { |
|
| 38 | + @require_once __DIR__ . '/vendor/autoload.php'; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - return $class_exists || ( $autoload_found && class_exists( $class_name ) ); |
|
| 41 | + return $class_exists || ( $autoload_found && class_exists( $class_name ) ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Exit if classes are not available |
| 45 | 45 | if ( ! ensure_class_loaded( __NAMESPACE__ . '\Core' ) ) { |
| 46 | - return; |
|
| 46 | + return; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | add_action( 'plugins_loaded', __NAMESPACE__ . '\main' ); |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | * @wp-hook plugins_loaded |
| 54 | 54 | */ |
| 55 | 55 | function main() { |
| 56 | - new Core(); |
|
| 56 | + new Core(); |
|
| 57 | 57 | |
| 58 | - if ( is_admin() ) { |
|
| 59 | - // Backend |
|
| 58 | + if ( is_admin() ) { |
|
| 59 | + // Backend |
|
| 60 | 60 | |
| 61 | - // TODO: register your backend-code here... |
|
| 61 | + // TODO: register your backend-code here... |
|
| 62 | 62 | |
| 63 | - } else { |
|
| 64 | - // Frontend |
|
| 63 | + } else { |
|
| 64 | + // Frontend |
|
| 65 | 65 | |
| 66 | - // TODO: register frontend-code here... |
|
| 67 | - } |
|
| 66 | + // TODO: register frontend-code here... |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | } |
@@ -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 | |
@@ -27,26 +27,26 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return bool |
| 29 | 29 | */ |
| 30 | -function ensure_class_loaded( $class_name ) { |
|
| 30 | +function ensure_class_loaded($class_name) { |
|
| 31 | 31 | |
| 32 | - $class_exists = class_exists( $class_name ); |
|
| 33 | - $autoload_found = file_exists( __DIR__ . '/vendor/autoload.php' ); |
|
| 32 | + $class_exists = class_exists($class_name); |
|
| 33 | + $autoload_found = file_exists(__DIR__ . '/vendor/autoload.php'); |
|
| 34 | 34 | |
| 35 | 35 | // If the class does not exist, and the vendor file is there |
| 36 | 36 | // maybe the plugin was installed separately via Composer, let's try to load autoload |
| 37 | - if ( ! $class_exists && $autoload_found ) { |
|
| 37 | + if ( ! $class_exists && $autoload_found) { |
|
| 38 | 38 | @require_once __DIR__ . '/vendor/autoload.php'; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return $class_exists || ( $autoload_found && class_exists( $class_name ) ); |
|
| 41 | + return $class_exists || ($autoload_found && class_exists($class_name)); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Exit if classes are not available |
| 45 | -if ( ! ensure_class_loaded( __NAMESPACE__ . '\Core' ) ) { |
|
| 45 | +if ( ! ensure_class_loaded(__NAMESPACE__ . '\Core')) { |
|
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | -add_action( 'plugins_loaded', __NAMESPACE__ . '\main' ); |
|
| 49 | +add_action('plugins_loaded', __NAMESPACE__ . '\main'); |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | function main() { |
| 56 | 56 | new Core(); |
| 57 | 57 | |
| 58 | - if ( is_admin() ) { |
|
| 58 | + if (is_admin()) { |
|
| 59 | 59 | // Backend |
| 60 | 60 | |
| 61 | 61 | // TODO: register your backend-code here... |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | public function add_metabox() |
| 44 | 44 | { |
| 45 | 45 | $cl = $this; |
| 46 | - if (! isset($_GET['post']) || ! $this->hasTimeshifts($_GET['post'])) { |
|
| 46 | + if ( ! isset($_GET['post']) || ! $this->hasTimeshifts($_GET['post'])) { |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | - add_action('add_meta_boxes', function () use ($cl) { |
|
| 49 | + add_action('add_meta_boxes', function() use ($cl) { |
|
| 50 | 50 | add_meta_box('krn-timeshift', __('Timeshift', 'kmm-timeshift'), [$cl, 'timeshift_metabox'], null, 'normal', 'core'); |
| 51 | 51 | }); |
| 52 | 52 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function timeshift_metabox() |
| 55 | 55 | { |
| 56 | 56 | global $post; |
| 57 | - if (! isset($_GET['post'])) { |
|
| 57 | + if ( ! isset($_GET['post'])) { |
|
| 58 | 58 | return; |
| 59 | 59 | } |
| 60 | 60 | $table_name = $this->wpdb->prefix . 'timeshift_' . $post->post_type; |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | public function inject_metadata_timeshift($value, $post_id, $key, $single) |
| 107 | 107 | { |
| 108 | - if (! isset($_GET['timeshift'])) { |
|
| 108 | + if ( ! isset($_GET['timeshift'])) { |
|
| 109 | 109 | return; |
| 110 | 110 | } |
| 111 | 111 | //Load timeshift |
| 112 | - if (! $this->timeshift_cached_meta) { |
|
| 112 | + if ( ! $this->timeshift_cached_meta) { |
|
| 113 | 113 | $post_type = get_post_type($post_id); |
| 114 | 114 | $table_name = $this->wpdb->prefix . 'timeshift_' . $post_type; |
| 115 | 115 | $sql = "select * from $table_name where id=" . intval($_GET['timeshift']); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | public function inject_timeshift($p) |
| 128 | 128 | { |
| 129 | 129 | global $post; |
| 130 | - if (! isset($_GET['timeshift'])) { |
|
| 130 | + if ( ! isset($_GET['timeshift'])) { |
|
| 131 | 131 | return; |
| 132 | 132 | } |
| 133 | 133 | //Load timeshift |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | add_action('edit_form_top', [$this, 'inject_timeshift'], 1, 1); |
| 146 | 146 | add_action('pre_post_update', [$this, 'pre_post_update'], 2, 1); |
| 147 | - add_action('admin_notices', function () { |
|
| 147 | + add_action('admin_notices', function() { |
|
| 148 | 148 | if (isset($_GET['timeshift']) && $_GET['timeshift']) { |
| 149 | 149 | echo '<div class="notice notice-warning is-dismissible"> |
| 150 | 150 | <p>You are editing a historical version! if you save or publish, this will replace the current live one</p> |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $mdata = get_metadata('post', $post_ID); |
| 194 | 194 | $post = get_post($post_ID); |
| 195 | 195 | |
| 196 | - $timeshift = (object) ['post' => $post, 'meta' => $mdata]; |
|
| 196 | + $timeshift = (object)['post' => $post, 'meta' => $mdata]; |
|
| 197 | 197 | $this->storeTimeshift($timeshift); |
| 198 | 198 | } |
| 199 | 199 | } |