@@ -64,21 +64,21 @@ discard block |
||
64 | 64 | * @param Meta_Box $meta_box |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - public function register( Meta_Box $meta_box ): void { |
|
67 | + public function register(Meta_Box $meta_box): void { |
|
68 | 68 | |
69 | - if ( ! $this->validator->verify_meta_box( $meta_box ) ) { |
|
70 | - throw new Exception( 'Invalid meta box model' ); |
|
69 | + if ( ! $this->validator->verify_meta_box($meta_box)) { |
|
70 | + throw new Exception('Invalid meta box model'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // Set the view using View, if not traditional callback supplied and a defined template. |
74 | - if ( ! \is_callable( $meta_box->view ) && is_string( $meta_box->view_template ) ) { |
|
75 | - $meta_box = $this->set_view_callback_from_view( $meta_box ); |
|
74 | + if ( ! \is_callable($meta_box->view) && is_string($meta_box->view_template)) { |
|
75 | + $meta_box = $this->set_view_callback_from_view($meta_box); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Add meta_box to loader. |
79 | 79 | $this->loader->action( |
80 | 80 | 'add_meta_boxes', |
81 | - function() use ( $meta_box ) : void { |
|
81 | + function() use ($meta_box) : void { |
|
82 | 82 | \add_meta_box( |
83 | 83 | $meta_box->key, |
84 | 84 | $meta_box->label, |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | } |
92 | 92 | ); |
93 | 93 | // If we have any hook calls, add them to the loader. |
94 | - if ( $this->is_active( $meta_box ) && ! empty( $meta_box->actions ) ) { |
|
95 | - foreach ( $meta_box->actions as $handle => $hook ) { |
|
96 | - $this->loader->action( (string) $handle, $hook['callback'], $hook['priority'], $hook['params'] ); |
|
94 | + if ($this->is_active($meta_box) && ! empty($meta_box->actions)) { |
|
95 | + foreach ($meta_box->actions as $handle => $hook) { |
|
96 | + $this->loader->action((string) $handle, $hook['callback'], $hook['priority'], $hook['params']); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | * @param \PinkCrab\Registerables\Meta_Box $meta_box |
106 | 106 | * @return \PinkCrab\Registerables\Meta_Box |
107 | 107 | */ |
108 | - protected function set_view_callback_from_view( Meta_Box $meta_box ): Meta_Box { |
|
108 | + protected function set_view_callback_from_view(Meta_Box $meta_box): Meta_Box { |
|
109 | 109 | |
110 | 110 | // Create View(View) |
111 | - $view = $this->container->create( View::class ); |
|
112 | - if ( is_null( $view ) || ! is_a( $view, View::class ) ) { |
|
113 | - throw new Exception( 'View not defined' ); |
|
111 | + $view = $this->container->create(View::class); |
|
112 | + if (is_null($view) || ! is_a($view, View::class)) { |
|
113 | + throw new Exception('View not defined'); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $meta_box->view( |
117 | - function ( \WP_Post $post, array $args ) use ( $meta_box, $view ) { |
|
117 | + function(\WP_Post $post, array $args) use ($meta_box, $view) { |
|
118 | 118 | $args['args']['post'] = $post; |
119 | 119 | |
120 | 120 | // @phpstan-ignore-next-line, template should already be checked for valid template path in register() method (which calls this) |
121 | - $view->render( $meta_box->view_template, $args['args'] ); |
|
121 | + $view->render($meta_box->view_template, $args['args']); |
|
122 | 122 | } |
123 | 123 | ); |
124 | 124 | |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return boolean |
132 | 132 | */ |
133 | - protected function is_active( Meta_Box $meta_box ): bool { |
|
133 | + protected function is_active(Meta_Box $meta_box): bool { |
|
134 | 134 | global $current_screen; |
135 | 135 | |
136 | - return ! is_null( $current_screen ) |
|
137 | - && ! empty( $current_screen->post_type ) |
|
138 | - && in_array( $current_screen->post_type, $meta_box->screen, true ); |
|
136 | + return ! is_null($current_screen) |
|
137 | + && ! empty($current_screen->post_type) |
|
138 | + && in_array($current_screen->post_type, $meta_box->screen, true); |
|
139 | 139 | } |
140 | 140 | } |