@@ -113,7 +113,7 @@ |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | - * Bind a singleton instance to the container |
|
116 | + * Bind a singleton instance to the container |
|
117 | 117 | * @param string $alias |
118 | 118 | * @param callable|string|null $binding |
119 | 119 | * @return void |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public static function load() |
39 | 39 | { |
40 | - if( empty( static::$instance )) { |
|
40 | + if( empty(static::$instance) ) { |
|
41 | 41 | static::$instance = new static; |
42 | 42 | } |
43 | 43 | return static::$instance; |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function __get( $property ) |
51 | 51 | { |
52 | - if( property_exists( $this, $property ) && !in_array( $property, static::PROTECTED_PROPERTIES )) { |
|
52 | + if( property_exists( $this, $property ) && !in_array( $property, static::PROTECTED_PROPERTIES ) ) { |
|
53 | 53 | return $this->$property; |
54 | 54 | } |
55 | - $constant = 'static::'.strtoupper( $this->make( Helper::class )->snakeCase( $property )); |
|
56 | - if( defined( $constant )) { |
|
55 | + $constant = 'static::'.strtoupper( $this->make( Helper::class )->snakeCase( $property ) ); |
|
56 | + if( defined( $constant ) ) { |
|
57 | 57 | return constant( $constant ); |
58 | 58 | } |
59 | 59 | return glsr_get( $this->storage, $property, null ); |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __set( $property, $value ) |
68 | 68 | { |
69 | - if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES )) { |
|
69 | + if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES ) ) { |
|
70 | 70 | $this->storage[$property] = $value; |
71 | 71 | } |
72 | - else if( !isset( $this->$property )) { |
|
72 | + else if( !isset($this->$property) ) { |
|
73 | 73 | $this->$property = $value; |
74 | 74 | } |
75 | 75 | else { |
76 | - throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property )); |
|
76 | + throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property ) ); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -95,16 +95,16 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function make( $abstract ) |
97 | 97 | { |
98 | - if( !isset( $this->services[$abstract] )) { |
|
98 | + if( !isset($this->services[$abstract]) ) { |
|
99 | 99 | $abstract = $this->addNamespace( $abstract ); |
100 | 100 | } |
101 | - if( isset( $this->services[$abstract] )) { |
|
101 | + if( isset($this->services[$abstract]) ) { |
|
102 | 102 | $abstract = $this->services[$abstract]; |
103 | 103 | } |
104 | - if( is_callable( $abstract )) { |
|
104 | + if( is_callable( $abstract ) ) { |
|
105 | 105 | return call_user_func_array( $abstract, [$this] ); |
106 | 106 | } |
107 | - if( is_object( $abstract )) { |
|
107 | + if( is_object( $abstract ) ) { |
|
108 | 108 | return $abstract; |
109 | 109 | } |
110 | 110 | return $this->resolve( $abstract ); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function singleton( $alias, $binding ) |
120 | 120 | { |
121 | - $this->bind( $alias, $this->make( $binding )); |
|
121 | + $this->bind( $alias, $this->make( $binding ) ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function addNamespace( $abstract ) |
130 | 130 | { |
131 | - if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract )) { |
|
131 | + if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract ) ) { |
|
132 | 132 | $abstract = __NAMESPACE__.'\\'.$abstract; |
133 | 133 | } |
134 | 134 | return $abstract; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | throw new Exception( 'Target ['.$concrete.'] is not instantiable.' ); |
151 | 151 | } |
152 | 152 | $constructor = $reflector->getConstructor(); |
153 | - if( empty( $constructor )) { |
|
153 | + if( empty($constructor) ) { |
|
154 | 154 | return new $concrete; |
155 | 155 | } |
156 | 156 | return $reflector->newInstanceArgs( |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | public function __construct( $idBase, $name, $values ) |
16 | 16 | { |
17 | 17 | $controlOptions = $widgetOptions = []; |
18 | - if( isset( $values['class'] )) { |
|
18 | + if( isset($values['class']) ) { |
|
19 | 19 | $widgetOptions['classname'] = $values['class']; |
20 | 20 | } |
21 | - if( isset( $values['description'] )) { |
|
21 | + if( isset($values['description']) ) { |
|
22 | 22 | $widgetOptions['description'] = $values['description']; |
23 | 23 | } |
24 | - if( isset( $values['width'] )) { |
|
24 | + if( isset($values['width']) ) { |
|
25 | 25 | $controlOptions['width'] = $values['width']; |
26 | 26 | } |
27 | 27 | parent::__construct( $idBase, $name, $widgetOptions, $controlOptions ); |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | protected function renderField( $tag, array $args = [] ) |
35 | 35 | { |
36 | 36 | $args = $this->normalizeFieldAttributes( $tag, $args ); |
37 | - $field = glsr( Builder::class )->{$tag}( $args['name'], $args ); |
|
37 | + $field = glsr( Builder::class )->{$tag}($args['name'], $args); |
|
38 | 38 | echo glsr( Builder::class )->div( $field, [ |
39 | 39 | 'class' => 'glsr-field', |
40 | - ]); |
|
40 | + ] ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | protected function normalizeFieldAttributes( $tag, array $args ) |
48 | 48 | { |
49 | - if( empty( $args['value'] )) { |
|
49 | + if( empty($args['value']) ) { |
|
50 | 50 | $args['value'] = $this->widgetArgs[$args['name']]; |
51 | 51 | } |
52 | - if( empty( $this->widgetArgs['options'] ) && in_array( $tag, ['checkbox', 'radio'] )) { |
|
52 | + if( empty($this->widgetArgs['options']) && in_array( $tag, ['checkbox', 'radio'] ) ) { |
|
53 | 53 | $args['checked'] = in_array( $args['value'], (array)$this->widgetArgs[$args['name']] ); |
54 | 54 | } |
55 | 55 | $args['id'] = $this->get_field_id( $args['name'] ); |
@@ -15,8 +15,8 @@ |
||
15 | 15 | */ |
16 | 16 | protected function sanitize( array $args ) |
17 | 17 | { |
18 | - if( empty( $args['id'] )) { |
|
19 | - $args['id'] = substr( md5( serialize( $args )), 0, 8 ); |
|
18 | + if( empty($args['id']) ) { |
|
19 | + $args['id'] = substr( md5( serialize( $args ) ), 0, 8 ); |
|
20 | 20 | } |
21 | 21 | return $args; |
22 | 22 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | foreach( $command->shortcodes as $shortcode ) { |
16 | 16 | $shortcodeClass = glsr( Helper::class )->buildClassName( $shortcode.'-shortcode', 'Shortcodes' ); |
17 | - if( !class_exists( $shortcodeClass )) { |
|
18 | - glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass )); |
|
17 | + if( !class_exists( $shortcodeClass ) ) { |
|
18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ) ); |
|
19 | 19 | continue; |
20 | 20 | } |
21 | 21 | add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] ); |
@@ -16,8 +16,8 @@ |
||
16 | 16 | global $wp_widget_factory; |
17 | 17 | foreach( $command->widgets as $key => $values ) { |
18 | 18 | $widgetClass = glsr( Helper::class )->buildClassName( $key.'-widget', 'Widgets' ); |
19 | - if( !class_exists( $widgetClass )) { |
|
20 | - glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass )); |
|
19 | + if( !class_exists( $widgetClass ) ) { |
|
20 | + glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ) ); |
|
21 | 21 | continue; |
22 | 22 | } |
23 | 23 | // Here we bypass register_widget() in order to pass our custom values to the widget |
@@ -11,10 +11,10 @@ |
||
11 | 11 | */ |
12 | 12 | public function handle( Command $command ) |
13 | 13 | { |
14 | - if( in_array( $command->postType, get_post_types( ['_builtin' => true] )))return; |
|
14 | + if( in_array( $command->postType, get_post_types( ['_builtin' => true] ) ) )return; |
|
15 | 15 | register_post_type( $command->postType, $command->args ); |
16 | 16 | glsr()->postTypeColumns = wp_parse_args( glsr()->postTypeColumns, [ |
17 | 17 | $command->postType => $command->columns, |
18 | - ]); |
|
18 | + ] ); |
|
19 | 19 | } |
20 | 20 | } |
@@ -12,10 +12,10 @@ |
||
12 | 12 | */ |
13 | 13 | public function handle( Command $command ) |
14 | 14 | { |
15 | - if( !get_post( $command->id )) { |
|
15 | + if( !get_post( $command->id ) ) { |
|
16 | 16 | return false; |
17 | 17 | } |
18 | - if( is_null( $command->pinned )) { |
|
18 | + if( is_null( $command->pinned ) ) { |
|
19 | 19 | $meta = get_post_meta( $command->id, 'pinned', true ); |
20 | 20 | $command->pinned = !wp_validate_boolean( $meta ); |
21 | 21 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function add( $type, $message, array $args = [] ) |
17 | 17 | { |
18 | - if( empty( array_filter( [$message, $type] )))return; |
|
18 | + if( empty(array_filter( [$message, $type] )) )return; |
|
19 | 19 | $args['message'] = $message; |
20 | 20 | $args['type'] = $type; |
21 | - add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ))); |
|
21 | + add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) ); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | public function get() |
55 | 55 | { |
56 | 56 | $notices = array_map( 'unserialize', |
57 | - array_unique( array_map( 'serialize', get_settings_errors( Application::ID ))) |
|
57 | + array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) ) |
|
58 | 58 | ); |
59 | - if( empty( $notices ))return; |
|
59 | + if( empty($notices) )return; |
|
60 | 60 | return array_reduce( $notices, function( $carry, $notice ) { |
61 | - return $carry.$this->buildNotice( json_decode( $notice['message'], true )); |
|
61 | + return $carry.$this->buildNotice( json_decode( $notice['message'], true ) ); |
|
62 | 62 | }); |
63 | 63 | } |
64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | return glsr( Builder::class )->div( $messages, [ |
81 | 81 | 'class' => $class, |
82 | - ]); |
|
82 | + ] ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | 'type' => '', |
95 | 95 | ]; |
96 | 96 | $args = shortcode_atts( $defaults, $args ); |
97 | - if( !in_array( $args['type'], ['error', 'warning', 'success'] )) { |
|
97 | + if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) { |
|
98 | 98 | $args['type'] = 'success'; |
99 | 99 | } |
100 | 100 | $args['messages'] = is_wp_error( $args['message'] ) |
101 | 101 | ? (array)$args['message']->get_error_message() |
102 | 102 | : (array)$args['message']; |
103 | - unset( $args['message'] ); |
|
103 | + unset($args['message']); |
|
104 | 104 | return $args; |
105 | 105 | } |
106 | 106 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | public function build( $partialPath, array $args = [] ) |
14 | 14 | { |
15 | 15 | $className = glsr( Helper::class )->buildClassName( $partialPath, 'Modules\Html\Partials' ); |
16 | - if( !class_exists( $className )) { |
|
16 | + if( !class_exists( $className ) ) { |
|
17 | 17 | glsr_log()->error( 'Partial missing: '.$className ); |
18 | 18 | return; |
19 | 19 | } |