@@ -6,7 +6,7 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | // Prevent direct file access |
| 9 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
| 9 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
| 10 | 10 | |
| 11 | 11 | // Load module functions |
| 12 | 12 | require_once 'functions.php'; |
@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | // Prevent direct file access |
| 16 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
| 16 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Prevent loading the library more than once |
| 20 | 20 | */ |
| 21 | -if( defined( 'AMARKAL_METABOX' ) ) return false; |
|
| 22 | -define( 'AMARKAL_METABOX', true ); |
|
| 21 | +if (defined('AMARKAL_METABOX')) return false; |
|
| 22 | +define('AMARKAL_METABOX', true); |
|
| 23 | 23 | |
| 24 | -if(!function_exists('amarkal_add_meta_box')) |
|
| 24 | +if (!function_exists('amarkal_add_meta_box')) |
|
| 25 | 25 | { |
| 26 | 26 | /** |
| 27 | 27 | * Add a meta box to a given post type |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | * @param string $id |
| 30 | 30 | * @param array $args |
| 31 | 31 | */ |
| 32 | - function amarkal_add_meta_box( $id, array $args ) |
|
| 32 | + function amarkal_add_meta_box($id, array $args) |
|
| 33 | 33 | { |
| 34 | 34 | $mb = Amarkal\Metabox\Manager::get_instance(); |
| 35 | - $mb->add( $id, $args ); |
|
| 35 | + $mb->add($id, $args); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -16,8 +16,8 @@ |
||
| 16 | 16 | |
| 17 | 17 | protected function on_created() |
| 18 | 18 | { |
| 19 | - \get_post_meta( $this->post_id, $this->name, true ); |
|
| 20 | - $this->model['value'] = \get_post_meta( $this->post_id, $this->name, true ); |
|
| 19 | + \get_post_meta($this->post_id, $this->name, true); |
|
| 20 | + $this->model['value'] = \get_post_meta($this->post_id, $this->name, true); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function get_template_path() |
@@ -6,13 +6,13 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | // Prevent direct file access |
| 9 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
| 9 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Load module functions. If this amarkal module has not been loaded, |
| 13 | 13 | * functions.php will not return false. |
| 14 | 14 | */ |
| 15 | -if(false !== (require_once 'functions.php')) |
|
| 15 | +if (false !== (require_once 'functions.php')) |
|
| 16 | 16 | { |
| 17 | 17 | // Load required classes if not using composer |
| 18 | 18 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public static function get_instance() |
| 31 | 31 | { |
| 32 | - if( null === static::$instance ) |
|
| 32 | + if (null === static::$instance) |
|
| 33 | 33 | { |
| 34 | 34 | static::$instance = new static(); |
| 35 | 35 | } |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * @param array $args |
| 52 | 52 | * @throws \RuntimeException if the given metabox id has already been registered |
| 53 | 53 | */ |
| 54 | - public function add( $id, array $args ) |
|
| 54 | + public function add($id, array $args) |
|
| 55 | 55 | { |
| 56 | - if( !in_array($id, $this->metaboxes) ) |
|
| 56 | + if (!in_array($id, $this->metaboxes)) |
|
| 57 | 57 | { |
| 58 | 58 | $this->metaboxes[$id] = array_merge($this->default_args(), $args); |
| 59 | 59 | } |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | * @param WP_Post $post |
| 67 | 67 | * @param array $args |
| 68 | 68 | */ |
| 69 | - public function render( $post, $args ) |
|
| 69 | + public function render($post, $args) |
|
| 70 | 70 | { |
| 71 | 71 | $metabox = $this->metaboxes[$args['id']]; |
| 72 | 72 | wp_nonce_field(self::NONCE_ACTION, $args['id'].'_nonce'); |
| 73 | - foreach( $metabox['fields'] as $field ) |
|
| 73 | + foreach ($metabox['fields'] as $field) |
|
| 74 | 74 | { |
| 75 | 75 | $field['post_id'] = $post->ID; |
| 76 | 76 | $field_template = new Field($field); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function add_meta_boxes() |
| 85 | 85 | { |
| 86 | - foreach( $this->metaboxes as $id => $args ) |
|
| 86 | + foreach ($this->metaboxes as $id => $args) |
|
| 87 | 87 | { |
| 88 | 88 | \add_meta_box( |
| 89 | 89 | $id, |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @param number $post_id |
| 103 | 103 | */ |
| 104 | - public function save_meta_boxes( $post_id ) |
|
| 104 | + public function save_meta_boxes($post_id) |
|
| 105 | 105 | { |
| 106 | 106 | /** |
| 107 | 107 | * A note on security: |
@@ -119,22 +119,22 @@ discard block |
||
| 119 | 119 | * If this is an autosave, our form has not been submitted, |
| 120 | 120 | * so we don't want to do anything. |
| 121 | 121 | */ |
| 122 | - if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
| 122 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
| 123 | 123 | { |
| 124 | 124 | return $post_id; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // Check the user's permissions. |
| 128 | 128 | $post_type = filter_input(INPUT_POST, 'post_type'); |
| 129 | - if( null !== $post_type && !current_user_can('edit_'.$post_type, $post_id) ) |
|
| 129 | + if (null !== $post_type && !current_user_can('edit_'.$post_type, $post_id)) |
|
| 130 | 130 | { |
| 131 | 131 | return $post_id; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Update the meta fields. |
| 135 | - foreach( $this->metaboxes as $id => $metabox ) |
|
| 135 | + foreach ($this->metaboxes as $id => $metabox) |
|
| 136 | 136 | { |
| 137 | - $this->save_meta_box( $post_id, $id, $metabox ); |
|
| 137 | + $this->save_meta_box($post_id, $id, $metabox); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -145,21 +145,21 @@ discard block |
||
| 145 | 145 | * @param string $id |
| 146 | 146 | * @param array $metabox |
| 147 | 147 | */ |
| 148 | - public function save_meta_box( $post_id, $id, $metabox ) |
|
| 148 | + public function save_meta_box($post_id, $id, $metabox) |
|
| 149 | 149 | { |
| 150 | 150 | $nonce_name = $id.'_nonce'; |
| 151 | 151 | $nonce_value = filter_input(INPUT_POST, $nonce_name); |
| 152 | 152 | |
| 153 | 153 | // Check if our nonce is set and verify it |
| 154 | - if( null === $nonce_value || !wp_verify_nonce($nonce_value, self::NONCE_ACTION) ) |
|
| 154 | + if (null === $nonce_value || !wp_verify_nonce($nonce_value, self::NONCE_ACTION)) |
|
| 155 | 155 | { |
| 156 | 156 | return $post_id; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - foreach( $metabox['fields'] as $field ) |
|
| 159 | + foreach ($metabox['fields'] as $field) |
|
| 160 | 160 | { |
| 161 | - $data = filter_input( INPUT_POST, $field['name'] ); |
|
| 162 | - \update_post_meta( $post_id, $field['name'], $data ); |
|
| 161 | + $data = filter_input(INPUT_POST, $field['name']); |
|
| 162 | + \update_post_meta($post_id, $field['name'], $data); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | $cs = get_current_screen(); |
| 172 | 172 | |
| 173 | - foreach( $this->metaboxes as $metabox ) |
|
| 173 | + foreach ($this->metaboxes as $metabox) |
|
| 174 | 174 | { |
| 175 | - if( $metabox['screen'] === $cs->id ) |
|
| 175 | + if ($metabox['screen'] === $cs->id) |
|
| 176 | 176 | { |
| 177 | 177 | echo '<style>'; |
| 178 | 178 | include 'metabox.css'; |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | private function init() |
| 189 | 189 | { |
| 190 | - \add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); |
|
| 191 | - \add_action( 'save_post', array( $this, 'save_meta_boxes' ) ); |
|
| 192 | - \add_action( 'admin_footer', array( $this, 'print_style' ) ); |
|
| 190 | + \add_action('add_meta_boxes', array($this, 'add_meta_boxes')); |
|
| 191 | + \add_action('save_post', array($this, 'save_meta_boxes')); |
|
| 192 | + \add_action('admin_footer', array($this, 'print_style')); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |