@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public static function get_instance() |
26 | 26 | { |
27 | - if( null === static::$instance ) |
|
27 | + if (null === static::$instance) |
|
28 | 28 | { |
29 | 29 | static::$instance = new static(); |
30 | 30 | static::$instance->init(); |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | return static::$instance; |
33 | 33 | } |
34 | 34 | |
35 | - public function add( $id, $args ) |
|
35 | + public function add($id, $args) |
|
36 | 36 | { |
37 | - if( !in_array($id, $this->metaboxes) ) |
|
37 | + if (!in_array($id, $this->metaboxes)) |
|
38 | 38 | { |
39 | 39 | $this->metaboxes[$id] = array_merge($this->default_args(), $args); |
40 | 40 | } |
41 | 41 | else throw new \RuntimeException("A metabox with id '$id' has already been registered."); |
42 | 42 | } |
43 | 43 | |
44 | - public function render( $post, $args ) |
|
44 | + public function render($post, $args) |
|
45 | 45 | { |
46 | - foreach( $this->metaboxes[$args['id']]['fields'] as $field ) |
|
46 | + foreach ($this->metaboxes[$args['id']]['fields'] as $field) |
|
47 | 47 | { |
48 | 48 | $field_template = new Field($field); |
49 | 49 | echo $field_template->render(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | public function add_meta_boxes() |
54 | 54 | { |
55 | - foreach( $this->metaboxes as $id => $args ) |
|
55 | + foreach ($this->metaboxes as $id => $args) |
|
56 | 56 | { |
57 | 57 | \add_meta_box( |
58 | 58 | $id, |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | { |
75 | 75 | $cs = get_current_screen(); |
76 | 76 | |
77 | - foreach( $this->metaboxes as $metabox ) |
|
77 | + foreach ($this->metaboxes as $metabox) |
|
78 | 78 | { |
79 | - if( $metabox['screen'] === $cs->id ) |
|
79 | + if ($metabox['screen'] === $cs->id) |
|
80 | 80 | { |
81 | 81 | echo '<style>'; |
82 | 82 | include 'metabox.css'; |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | |
89 | 89 | private function init() |
90 | 90 | { |
91 | - \add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); |
|
92 | - \add_action( 'save_post', array( $this, 'save_meta_boxes' ) ); |
|
93 | - \add_action( 'admin_footer', array( $this, 'print_style' ) ); |
|
91 | + \add_action('add_meta_boxes', array($this, 'add_meta_boxes')); |
|
92 | + \add_action('save_post', array($this, 'save_meta_boxes')); |
|
93 | + \add_action('admin_footer', array($this, 'print_style')); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | private function default_args() |
@@ -37,8 +37,9 @@ |
||
37 | 37 | if( !in_array($id, $this->metaboxes) ) |
38 | 38 | { |
39 | 39 | $this->metaboxes[$id] = array_merge($this->default_args(), $args); |
40 | + } else { |
|
41 | + throw new \RuntimeException("A metabox with id '$id' has already been registered."); |
|
40 | 42 | } |
41 | - else throw new \RuntimeException("A metabox with id '$id' has already been registered."); |
|
42 | 43 | } |
43 | 44 | |
44 | 45 | public function render( $post, $args ) |
@@ -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'; |
@@ -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 |
@@ -13,19 +13,19 @@ |
||
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 | - function amarkal_add_meta_box( $id, $args ) |
|
26 | + function amarkal_add_meta_box($id, $args) |
|
27 | 27 | { |
28 | 28 | $mb = Amarkal\Metabox\Manager::get_instance(); |
29 | - $mb->add( $id, $args ); |
|
29 | + $mb->add($id, $args); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -18,7 +18,9 @@ |
||
18 | 18 | /** |
19 | 19 | * Prevent loading the library more than once |
20 | 20 | */ |
21 | -if( defined( 'AMARKAL_METABOX' ) ) return false; |
|
21 | +if( defined( 'AMARKAL_METABOX' ) ) { |
|
22 | + return false; |
|
23 | +} |
|
22 | 24 | define( 'AMARKAL_METABOX', true ); |
23 | 25 | |
24 | 26 | if(!function_exists('amarkal_add_meta_box')) |