@@ -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,14 +49,14 @@ 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 | - return isset( $this->storage[$property] ) |
|
| 59 | + return isset($this->storage[$property]) |
|
| 60 | 60 | ? $this->storage[$property] |
| 61 | 61 | : null; |
| 62 | 62 | } |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function __set( $property, $value ) |
| 70 | 70 | { |
| 71 | - if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES )) { |
|
| 71 | + if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES ) ) { |
|
| 72 | 72 | $this->storage[$property] = $value; |
| 73 | 73 | } |
| 74 | - else if( !isset( $this->$property )) { |
|
| 74 | + else if( !isset($this->$property) ) { |
|
| 75 | 75 | $this->$property = $value; |
| 76 | 76 | } |
| 77 | 77 | else { |
| 78 | - throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property )); |
|
| 78 | + throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property ) ); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
@@ -97,16 +97,16 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function make( $abstract ) |
| 99 | 99 | { |
| 100 | - if( !isset( $this->services[$abstract] )) { |
|
| 100 | + if( !isset($this->services[$abstract]) ) { |
|
| 101 | 101 | $abstract = $this->addNamespace( $abstract ); |
| 102 | 102 | } |
| 103 | - if( isset( $this->services[$abstract] )) { |
|
| 103 | + if( isset($this->services[$abstract]) ) { |
|
| 104 | 104 | $abstract = $this->services[$abstract]; |
| 105 | 105 | } |
| 106 | - if( is_callable( $abstract )) { |
|
| 106 | + if( is_callable( $abstract ) ) { |
|
| 107 | 107 | return call_user_func_array( $abstract, [$this] ); |
| 108 | 108 | } |
| 109 | - if( is_object( $abstract )) { |
|
| 109 | + if( is_object( $abstract ) ) { |
|
| 110 | 110 | return $abstract; |
| 111 | 111 | } |
| 112 | 112 | return $this->resolve( $abstract ); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function singleton( $alias, $binding ) |
| 122 | 122 | { |
| 123 | - $this->bind( $alias, $this->make( $binding )); |
|
| 123 | + $this->bind( $alias, $this->make( $binding ) ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | protected function addNamespace( $abstract ) |
| 132 | 132 | { |
| 133 | - if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract )) { |
|
| 133 | + if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract ) ) { |
|
| 134 | 134 | $abstract = __NAMESPACE__.'\\'.$abstract; |
| 135 | 135 | } |
| 136 | 136 | return $abstract; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | throw new Exception( 'Target ['.$concrete.'] is not instantiable.' ); |
| 153 | 153 | } |
| 154 | 154 | $constructor = $reflector->getConstructor(); |
| 155 | - if( empty( $constructor )) { |
|
| 155 | + if( empty($constructor) ) { |
|
| 156 | 156 | return new $concrete; |
| 157 | 157 | } |
| 158 | 158 | return $reflector->newInstanceArgs( |
@@ -153,7 +153,9 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function scheduleCronJob() |
| 155 | 155 | { |
| 156 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 156 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
| 157 | + return; |
|
| 158 | + } |
|
| 157 | 159 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 158 | 160 | } |
| 159 | 161 | |
@@ -184,7 +186,9 @@ discard block |
||
| 184 | 186 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
| 185 | 187 | || $data['action'] != 'update' |
| 186 | 188 | || $data['type'] != 'plugin' |
| 187 | - )return; |
|
| 189 | + ) { |
|
| 190 | + return; |
|
| 191 | + } |
|
| 188 | 192 | $this->upgrade(); |
| 189 | 193 | } |
| 190 | 194 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function getDefaults() |
| 68 | 68 | { |
| 69 | - if( empty( $this->defaults )) { |
|
| 69 | + if( empty($this->defaults) ) { |
|
| 70 | 70 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
| 71 | 71 | $this->upgrade(); |
| 72 | 72 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function hasPermission() |
| 80 | 80 | { |
| 81 | - return !$this->isAdmin() || ( $this->isAdmin() && current_user_can( static::CAPABILITY )); |
|
| 81 | + return !$this->isAdmin() || ($this->isAdmin() && current_user_can( static::CAPABILITY )); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
| 134 | 134 | $this->reviewTypes = wp_parse_args( $types, [ |
| 135 | 135 | 'local' => __( 'Local', 'site-reviews' ), |
| 136 | - ]); |
|
| 136 | + ] ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function scheduleCronJob() |
| 154 | 154 | { |
| 155 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 155 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
| 156 | 156 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function unscheduleCronJob() |
| 163 | 163 | { |
| 164 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
| 164 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -193,6 +193,6 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function url( $path = '' ) |
| 195 | 195 | { |
| 196 | - return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 196 | + return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
| 197 | 197 | } |
| 198 | 198 | } |
@@ -76,7 +76,9 @@ discard block |
||
| 76 | 76 | $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args )); |
| 77 | 77 | array_walk( $args, function( &$value, $key ) { |
| 78 | 78 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
| 79 | - if( !method_exists( $this, $methodName ))return; |
|
| 79 | + if( !method_exists( $this, $methodName )) { |
|
| 80 | + return; |
|
| 81 | + } |
|
| 80 | 82 | $value = $this->$methodName( $value ); |
| 81 | 83 | }); |
| 82 | 84 | return $this->sanitize( $args ); |
@@ -141,7 +143,9 @@ discard block |
||
| 141 | 143 | $defaults = array_pad( $defaults, Rating::MAX_RATING, '' ); |
| 142 | 144 | $labels = array_map( 'trim', explode( ',', $labels )); |
| 143 | 145 | foreach( $defaults as $i => $label ) { |
| 144 | - if( empty( $labels[$i] ))continue; |
|
| 146 | + if( empty( $labels[$i] )) { |
|
| 147 | + continue; |
|
| 148 | + } |
|
| 145 | 149 | $defaults[$i] = $labels[$i]; |
| 146 | 150 | } |
| 147 | 151 | return array_combine( range( Rating::MAX_RATING, 1 ), $defaults ); |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | 'after_widget' => '</div>', |
| 28 | 28 | 'before_title' => '<h3 class="glsr-shortcode-title">', |
| 29 | 29 | 'after_title' => '</h3>', |
| 30 | - ]); |
|
| 30 | + ] ); |
|
| 31 | 31 | $instance = $this->normalize( $instance ); |
| 32 | 32 | $partial = glsr( Html::class )->buildPartial( $shortcodePartial, $instance ); |
| 33 | - if( !empty( $instance['title'] )) { |
|
| 33 | + if( !empty($instance['title']) ) { |
|
| 34 | 34 | $instance['title'] = $args['before_title'].$instance['title'].$args['after_title']; |
| 35 | 35 | } |
| 36 | 36 | return $args['before_widget'].$instance['title'].$partial.$args['after_widget']; |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function normalize( $args ) |
| 75 | 75 | { |
| 76 | - $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args )); |
|
| 76 | + $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args ) ); |
|
| 77 | 77 | array_walk( $args, function( &$value, $key ) { |
| 78 | 78 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
| 79 | - if( !method_exists( $this, $methodName ))return; |
|
| 79 | + if( !method_exists( $this, $methodName ) )return; |
|
| 80 | 80 | $value = $this->$methodName( $value ); |
| 81 | 81 | }); |
| 82 | 82 | return $this->sanitize( $args ); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function normalizeHide( $hide ) |
| 110 | 110 | { |
| 111 | - if( is_string( $hide )) { |
|
| 111 | + if( is_string( $hide ) ) { |
|
| 112 | 112 | $hide = explode( ',', $hide ); |
| 113 | 113 | } |
| 114 | 114 | return array_filter( array_map( 'trim', $hide ), function( $value ) { |
@@ -139,9 +139,9 @@ discard block |
||
| 139 | 139 | __( 'Terrible', 'site-reviews' ), |
| 140 | 140 | ]; |
| 141 | 141 | $defaults = array_pad( $defaults, Rating::MAX_RATING, '' ); |
| 142 | - $labels = array_map( 'trim', explode( ',', $labels )); |
|
| 142 | + $labels = array_map( 'trim', explode( ',', $labels ) ); |
|
| 143 | 143 | foreach( $defaults as $i => $label ) { |
| 144 | - if( empty( $labels[$i] ))continue; |
|
| 144 | + if( empty($labels[$i]) )continue; |
|
| 145 | 145 | $defaults[$i] = $labels[$i]; |
| 146 | 146 | } |
| 147 | 147 | return array_combine( range( Rating::MAX_RATING, 1 ), $defaults ); |
@@ -29,7 +29,9 @@ |
||
| 29 | 29 | { |
| 30 | 30 | foreach( $args as $key => $value ) { |
| 31 | 31 | $property = glsr( Helper::class )->buildPropertyName( $key ); |
| 32 | - if( !property_exists( $this, $property ))continue; |
|
| 32 | + if( !property_exists( $this, $property )) { |
|
| 33 | + continue; |
|
| 34 | + } |
|
| 33 | 35 | $this->$property = $value; |
| 34 | 36 | unset( $args[$key] ); |
| 35 | 37 | } |
@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | foreach( $args as $key => $value ) { |
| 31 | 31 | $property = glsr( Helper::class )->buildPropertyName( $key ); |
| 32 | - if( !property_exists( $this, $property ))continue; |
|
| 32 | + if( !property_exists( $this, $property ) )continue; |
|
| 33 | 33 | $this->$property = $value; |
| 34 | - unset( $args[$key] ); |
|
| 34 | + unset($args[$key]); |
|
| 35 | 35 | } |
| 36 | 36 | $this->args = wp_parse_args( $args, [ |
| 37 | 37 | 'menu_name' => $this->plural, |
| 38 | - ]); |
|
| 38 | + ] ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | 'singular_name' => $this->single, |
| 59 | 59 | 'uploaded_to_this_item' => sprintf( _x( 'Uploaded to this %s', 'Uploaded to this Post', 'site-reviews' ), $this->single ), |
| 60 | 60 | 'view_item' => sprintf( _x( 'View %s', 'View Post', 'site-reviews' ), $this->single ), |
| 61 | - ]); |
|
| 62 | - unset( $this->args['menu_name'] ); |
|
| 61 | + ] ); |
|
| 62 | + unset($this->args['menu_name']); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | protected function normalizeColumns() |
| 69 | 69 | { |
| 70 | 70 | $this->columns = ['cb' => ''] + $this->columns; |
| 71 | - if( array_key_exists( 'category', $this->columns )) { |
|
| 71 | + if( array_key_exists( 'category', $this->columns ) ) { |
|
| 72 | 72 | $keys = array_keys( $this->columns ); |
| 73 | 73 | $keys[array_search( 'category', $keys )] = 'taxonomy-'.Application::TAXONOMY; |
| 74 | 74 | $this->columns = array_combine( $keys, $this->columns ); |
| 75 | 75 | } |
| 76 | - if( array_key_exists( 'pinned', $this->columns )) { |
|
| 76 | + if( array_key_exists( 'pinned', $this->columns ) ) { |
|
| 77 | 77 | $stickyValue = '<span class="pinned-icon"><span>'.$this->columns['pinned'].'</span></span>'; |
| 78 | 78 | $this->columns['pinned'] = $stickyValue; |
| 79 | 79 | } |
@@ -58,7 +58,9 @@ |
||
| 58 | 58 | { |
| 59 | 59 | $args = shortcode_atts( array_fill_keys( ['context', 'globals'], [] ), $args ); |
| 60 | 60 | foreach( $args as $key => $value ) { |
| 61 | - if( is_array( $value ))continue; |
|
| 61 | + if( is_array( $value )) { |
|
| 62 | + continue; |
|
| 63 | + } |
|
| 62 | 64 | $args[$key] = []; |
| 63 | 65 | } |
| 64 | 66 | return $args; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | { |
| 15 | 15 | $args = $this->normalize( $args ); |
| 16 | 16 | $file = glsr()->path( 'views/'.$templatePath.'.php' ); |
| 17 | - if( !file_exists( $file )) { |
|
| 17 | + if( !file_exists( $file ) ) { |
|
| 18 | 18 | glsr_log()->error( 'Template missing: '.$file ); |
| 19 | 19 | return; |
| 20 | 20 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $args = shortcode_atts( array_fill_keys( ['context', 'globals'], [] ), $args ); |
| 60 | 60 | foreach( $args as $key => $value ) { |
| 61 | - if( is_array( $value ))continue; |
|
| 61 | + if( is_array( $value ) )continue; |
|
| 62 | 62 | $args[$key] = []; |
| 63 | 63 | } |
| 64 | 64 | return $args; |
@@ -181,7 +181,9 @@ discard block |
||
| 181 | 181 | $key = $value; |
| 182 | 182 | $value = true; |
| 183 | 183 | } |
| 184 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
| 184 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES )) { |
|
| 185 | + continue; |
|
| 186 | + } |
|
| 185 | 187 | $this->attributes[$key] = wp_validate_boolean( $value ); |
| 186 | 188 | } |
| 187 | 189 | } |
@@ -196,7 +198,9 @@ discard block |
||
| 196 | 198 | $key = $value; |
| 197 | 199 | $value = ''; |
| 198 | 200 | } |
| 199 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
| 201 | + if( !glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
| 202 | + continue; |
|
| 203 | + } |
|
| 200 | 204 | if( is_array( $value )) { |
| 201 | 205 | $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); |
| 202 | 206 | } |
@@ -210,7 +214,9 @@ discard block |
||
| 210 | 214 | protected function normalizeStringAttributes() |
| 211 | 215 | { |
| 212 | 216 | foreach( $this->attributes as $key => $value ) { |
| 213 | - if( !is_string( $value ))continue; |
|
| 217 | + if( !is_string( $value )) { |
|
| 218 | + continue; |
|
| 219 | + } |
|
| 214 | 220 | $this->attributes[$key] = trim( $value ); |
| 215 | 221 | } |
| 216 | 222 | } |
@@ -221,7 +227,9 @@ discard block |
||
| 221 | 227 | */ |
| 222 | 228 | protected function normalizeInputType( $method ) |
| 223 | 229 | { |
| 224 | - if( $method != 'input' )return; |
|
| 230 | + if( $method != 'input' ) { |
|
| 231 | + return; |
|
| 232 | + } |
|
| 225 | 233 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
| 226 | 234 | if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
| 227 | 235 | $this->attributes['type'] = 'text'; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | protected function filterAttributes( array $allowedAttributeKeys ) |
| 114 | 114 | { |
| 115 | - return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys )); |
|
| 115 | + return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys ) ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $globalAttributes = $this->filterAttributes( static::GLOBAL_ATTRIBUTES ); |
| 124 | 124 | $wildcards = []; |
| 125 | 125 | foreach( static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard ) { |
| 126 | - $newWildcards = array_filter( $this->attributes, function( $key ) use( $wildcard ) { |
|
| 126 | + $newWildcards = array_filter( $this->attributes, function( $key ) use($wildcard) { |
|
| 127 | 127 | return glsr( Helper::class )->startsWith( $wildcard, $key ); |
| 128 | 128 | }, ARRAY_FILTER_USE_KEY ); |
| 129 | 129 | $wildcards = array_merge( $wildcards, $newWildcards ); |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | protected function normalizeBooleanAttributes() |
| 178 | 178 | { |
| 179 | 179 | foreach( $this->attributes as $key => $value ) { |
| 180 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
| 180 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 181 | 181 | $key = $value; |
| 182 | 182 | $value = true; |
| 183 | 183 | } |
| 184 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
| 184 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ) )continue; |
|
| 185 | 185 | $this->attributes[$key] = wp_validate_boolean( $value ); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | protected function normalizeDataAttributes() |
| 193 | 193 | { |
| 194 | 194 | foreach( $this->attributes as $key => $value ) { |
| 195 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
| 195 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 196 | 196 | $key = $value; |
| 197 | 197 | $value = ''; |
| 198 | 198 | } |
| 199 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
| 200 | - if( is_array( $value )) { |
|
| 199 | + if( !glsr( Helper::class )->startsWith( 'data-', $key ) )continue; |
|
| 200 | + if( is_array( $value ) ) { |
|
| 201 | 201 | $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); |
| 202 | 202 | } |
| 203 | 203 | $this->attributes[$key] = $value; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | protected function normalizeStringAttributes() |
| 211 | 211 | { |
| 212 | 212 | foreach( $this->attributes as $key => $value ) { |
| 213 | - if( !is_string( $value ))continue; |
|
| 213 | + if( !is_string( $value ) )continue; |
|
| 214 | 214 | $this->attributes[$key] = trim( $value ); |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | if( $method != 'input' )return; |
| 225 | 225 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
| 226 | - if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
|
| 226 | + if( !in_array( $attributes['type'], static::INPUT_TYPES ) ) { |
|
| 227 | 227 | $this->attributes['type'] = 'text'; |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | $dataAttributes = []; |
| 238 | 238 | foreach( $this->attributes as $key => $value ) { |
| 239 | 239 | if( in_array( $key, static::BOOLEAN_ATTRIBUTES ) && !$value ) { |
| 240 | - unset( $attributes[$key] ); |
|
| 240 | + unset($attributes[$key]); |
|
| 241 | 241 | } |
| 242 | - if( glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
| 242 | + if( glsr( Helper::class )->startsWith( 'data-', $key ) ) { |
|
| 243 | 243 | $dataAttributes[$key] = $value; |
| 244 | - unset( $attributes[$key] ); |
|
| 244 | + unset($attributes[$key]); |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | $this->attributes = array_merge( array_filter( $attributes ), $dataAttributes ); |
@@ -24,7 +24,9 @@ |
||
| 24 | 24 | public function build( $name, array $args = [] ) |
| 25 | 25 | { |
| 26 | 26 | $this->normalize( $args ); |
| 27 | - if( count( $this->sections ) < 2 )return; |
|
| 27 | + if( count( $this->sections ) < 2 ) { |
|
| 28 | + return; |
|
| 29 | + } |
|
| 28 | 30 | $links = array_reduce( array_keys( $this->sections ), function( $result, $section ) { |
| 29 | 31 | return $result.glsr( Builder::class )->li( $this->buildLink( $section )); |
| 30 | 32 | }); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $this->normalize( $args ); |
| 27 | 27 | if( count( $this->sections ) < 2 )return; |
| 28 | 28 | $links = array_reduce( array_keys( $this->sections ), function( $result, $section ) { |
| 29 | - return $result.glsr( Builder::class )->li( $this->buildLink( $section )); |
|
| 29 | + return $result.glsr( Builder::class )->li( $this->buildLink( $section ) ); |
|
| 30 | 30 | }); |
| 31 | 31 | return glsr( Builder::class )->ul( $links, ['class' => 'subsubsub glsr-subsubsub'] ); |
| 32 | 32 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | 'section' => '', |
| 42 | 42 | 'tab' => '', |
| 43 | 43 | 'tabs' => [], |
| 44 | - ]); |
|
| 44 | + ] ); |
|
| 45 | 45 | $this->sections = $this->args['tabs'][$this->args['tab']]['sections']; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -61,6 +61,6 @@ discard block |
||
| 61 | 61 | return glsr( Builder::class )->a( $this->sections[$section], [ |
| 62 | 62 | 'class' => $class, |
| 63 | 63 | 'href' => '?post_type='.Application::POST_TYPE.'&page='.$this->args['page'].'&tab='.$this->args['tab'].'§ion='.$section, |
| 64 | - ]).$separator; |
|
| 64 | + ] ).$separator; |
|
| 65 | 65 | } |
| 66 | 66 | } |
@@ -32,7 +32,9 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $this->args = $args; |
| 34 | 34 | $this->reviews = glsr( Database::class )->getReviews( $args ); |
| 35 | - if( $this->isHidden() )return; |
|
| 35 | + if( $this->isHidden() ) { |
|
| 36 | + return; |
|
| 37 | + } |
|
| 36 | 38 | $this->rating = glsr( Rating::class )->getAverage( $this->reviews->results ); |
| 37 | 39 | $this->buildSchema(); |
| 38 | 40 | return glsr( Builder::class )->div( $this->buildSummary().$this->buildPercentageBars(), [ |
@@ -72,7 +74,9 @@ discard block |
||
| 72 | 74 | */ |
| 73 | 75 | protected function buildPercentageBars() |
| 74 | 76 | { |
| 75 | - if( in_array( 'bars', $this->args['hide'] ))return; |
|
| 77 | + if( in_array( 'bars', $this->args['hide'] )) { |
|
| 78 | + return; |
|
| 79 | + } |
|
| 76 | 80 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews->results )); |
| 77 | 81 | $range = range( Rating::MAX_RATING, 1 ); |
| 78 | 82 | $bars = array_reduce( $range, function( $carry, $index ) use( $percentages ) { |
@@ -88,7 +92,9 @@ discard block |
||
| 88 | 92 | */ |
| 89 | 93 | protected function buildSchema() |
| 90 | 94 | { |
| 91 | - if( !$this->args['schema'] )return; |
|
| 95 | + if( !$this->args['schema'] ) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 92 | 98 | $schema = glsr( Schema::class ); |
| 93 | 99 | $schema->store( $schema->buildSummary( $this->args )); |
| 94 | 100 | } |
@@ -99,7 +105,9 @@ discard block |
||
| 99 | 105 | protected function buildSummary() |
| 100 | 106 | { |
| 101 | 107 | $summary = $this->buildSummaryRating().$this->buildSummaryStars().$this->buildSummaryText(); |
| 102 | - if( empty( $summary ))return; |
|
| 108 | + if( empty( $summary )) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 103 | 111 | return glsr( Builder::class )->div( $summary, [ |
| 104 | 112 | 'class' => 'glsr-summary', |
| 105 | 113 | ]); |
@@ -110,7 +118,9 @@ discard block |
||
| 110 | 118 | */ |
| 111 | 119 | protected function buildSummaryRating() |
| 112 | 120 | { |
| 113 | - if( in_array( 'rating', $this->args['hide'] ))return; |
|
| 121 | + if( in_array( 'rating', $this->args['hide'] )) { |
|
| 122 | + return; |
|
| 123 | + } |
|
| 114 | 124 | return glsr( Builder::class )->span( $this->rating, [ |
| 115 | 125 | 'class' => 'glsr-summary-rating', |
| 116 | 126 | ]); |
@@ -121,7 +131,9 @@ discard block |
||
| 121 | 131 | */ |
| 122 | 132 | protected function buildSummaryStars() |
| 123 | 133 | { |
| 124 | - if( in_array( 'stars', $this->args['hide'] ))return; |
|
| 134 | + if( in_array( 'stars', $this->args['hide'] )) { |
|
| 135 | + return; |
|
| 136 | + } |
|
| 125 | 137 | $stars = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 126 | 138 | 'rating' => $this->rating, |
| 127 | 139 | ]); |
@@ -135,7 +147,9 @@ discard block |
||
| 135 | 147 | */ |
| 136 | 148 | protected function buildSummaryText() |
| 137 | 149 | { |
| 138 | - if( in_array( 'summary', $this->args['hide'] ))return; |
|
| 150 | + if( in_array( 'summary', $this->args['hide'] )) { |
|
| 151 | + return; |
|
| 152 | + } |
|
| 139 | 153 | $count = count( $this->reviews->results ); |
| 140 | 154 | if( empty( $this->args['text'] )) { |
| 141 | 155 | $this->args['text'] = _nx( |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | return glsr( Builder::class )->div( $this->buildSummary().$this->buildPercentageBars(), [ |
| 39 | 39 | 'class' => 'glsr-summary-wrap '.$args['class'], |
| 40 | 40 | 'id' => $args['id'], |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -51,20 +51,20 @@ discard block |
||
| 51 | 51 | $build = glsr( Builder::class ); |
| 52 | 52 | $label = $build->span( $this->args['labels'][$index], [ |
| 53 | 53 | 'class' => 'glsr-bar-label', |
| 54 | - ]); |
|
| 55 | - $barBackground = $build->span([ |
|
| 54 | + ] ); |
|
| 55 | + $barBackground = $build->span( [ |
|
| 56 | 56 | 'class' => 'glsr-bar-percent', |
| 57 | 57 | 'style' => 'width:'.$percent, |
| 58 | - ]); |
|
| 58 | + ] ); |
|
| 59 | 59 | $barPercent = $build->span( $barBackground, [ |
| 60 | 60 | 'class' => 'glsr-bar-background', |
| 61 | - ]); |
|
| 61 | + ] ); |
|
| 62 | 62 | $percent = $build->span( $percent, [ |
| 63 | 63 | 'class' => 'glsr-bar-count', |
| 64 | - ]); |
|
| 64 | + ] ); |
|
| 65 | 65 | return $build->div( $label.$barPercent.$percent, [ |
| 66 | 66 | 'class' => 'glsr-percentage-bar', |
| 67 | - ]); |
|
| 67 | + ] ); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | protected function buildPercentageBars() |
| 74 | 74 | { |
| 75 | - if( in_array( 'bars', $this->args['hide'] ))return; |
|
| 76 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews->results )); |
|
| 75 | + if( in_array( 'bars', $this->args['hide'] ) )return; |
|
| 76 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews->results ) ); |
|
| 77 | 77 | $range = range( Rating::MAX_RATING, 1 ); |
| 78 | - $bars = array_reduce( $range, function( $carry, $index ) use( $percentages ) { |
|
| 78 | + $bars = array_reduce( $range, function( $carry, $index ) use($percentages) { |
|
| 79 | 79 | return $carry.$this->buildPercentageBar( intval( $index ), $percentages[$index] ); |
| 80 | 80 | }); |
| 81 | 81 | return glsr( Builder::class )->div( $bars, [ |
| 82 | 82 | 'class' => 'glsr-percentage-bars', |
| 83 | - ]); |
|
| 83 | + ] ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | if( !$this->args['schema'] )return; |
| 92 | 92 | $schema = glsr( Schema::class ); |
| 93 | - $schema->store( $schema->buildSummary( $this->args )); |
|
| 93 | + $schema->store( $schema->buildSummary( $this->args ) ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | protected function buildSummary() |
| 100 | 100 | { |
| 101 | 101 | $summary = $this->buildSummaryRating().$this->buildSummaryStars().$this->buildSummaryText(); |
| 102 | - if( empty( $summary ))return; |
|
| 102 | + if( empty($summary) )return; |
|
| 103 | 103 | return glsr( Builder::class )->div( $summary, [ |
| 104 | 104 | 'class' => 'glsr-summary', |
| 105 | - ]); |
|
| 105 | + ] ); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | protected function buildSummaryRating() |
| 112 | 112 | { |
| 113 | - if( in_array( 'rating', $this->args['hide'] ))return; |
|
| 113 | + if( in_array( 'rating', $this->args['hide'] ) )return; |
|
| 114 | 114 | return glsr( Builder::class )->span( $this->rating, [ |
| 115 | 115 | 'class' => 'glsr-summary-rating', |
| 116 | - ]); |
|
| 116 | + ] ); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function buildSummaryStars() |
| 123 | 123 | { |
| 124 | - if( in_array( 'stars', $this->args['hide'] ))return; |
|
| 124 | + if( in_array( 'stars', $this->args['hide'] ) )return; |
|
| 125 | 125 | $stars = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 126 | 126 | 'rating' => $this->rating, |
| 127 | - ]); |
|
| 127 | + ] ); |
|
| 128 | 128 | return glsr( Builder::class )->span( $stars, [ |
| 129 | 129 | 'class' => 'glsr-summary-stars', |
| 130 | - ]); |
|
| 130 | + ] ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | protected function buildSummaryText() |
| 137 | 137 | { |
| 138 | - if( in_array( 'summary', $this->args['hide'] ))return; |
|
| 138 | + if( in_array( 'summary', $this->args['hide'] ) )return; |
|
| 139 | 139 | $count = count( $this->reviews->results ); |
| 140 | - if( empty( $this->args['text'] )) { |
|
| 140 | + if( empty($this->args['text']) ) { |
|
| 141 | 141 | $this->args['text'] = _nx( |
| 142 | 142 | '{rating} out of {max} stars (based on %d review)', |
| 143 | 143 | '{rating} out of {max} stars (based on %d reviews)', |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | ); |
| 148 | 148 | } |
| 149 | 149 | $summary = str_replace( |
| 150 | - ['{rating}','{max}'], [$this->rating, Rating::MAX_RATING], $this->args['text'] |
|
| 150 | + ['{rating}', '{max}'], [$this->rating, Rating::MAX_RATING], $this->args['text'] |
|
| 151 | 151 | ); |
| 152 | - return str_replace( ['%s','%d'], $count, $summary ); |
|
| 152 | + return str_replace( ['%s', '%d'], $count, $summary ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -157,6 +157,6 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function isHidden() |
| 159 | 159 | { |
| 160 | - return empty( $this->reviews->results ) && in_array( 'if_empty', $this->args['hide'] ); |
|
| 160 | + return empty($this->reviews->results) && in_array( 'if_empty', $this->args['hide'] ); |
|
| 161 | 161 | } |
| 162 | 162 | } |
@@ -19,7 +19,9 @@ |
||
| 19 | 19 | public function build( $name, array $args = [] ) |
| 20 | 20 | { |
| 21 | 21 | $this->normalize( $args ); |
| 22 | - if( count( $this->args['tabs'] ) < 2 )return; |
|
| 22 | + if( count( $this->args['tabs'] ) < 2 ) { |
|
| 23 | + return; |
|
| 24 | + } |
|
| 23 | 25 | $links = array_reduce( array_keys( $this->args['tabs'] ), function( $result, $tab ) { |
| 24 | 26 | return $result.$this->buildLink( $tab ); |
| 25 | 27 | }); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | 'page' => '', |
| 36 | 36 | 'tab' => '', |
| 37 | 37 | 'tabs' => [], |
| 38 | - ]); |
|
| 38 | + ] ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -50,6 +50,6 @@ discard block |
||
| 50 | 50 | return glsr( Builder::class )->a( $this->args['tabs'][$tab]['title'], [ |
| 51 | 51 | 'class' => 'nav-tab'.$class, |
| 52 | 52 | 'href' => '?post_type='.Application::POST_TYPE.'&page='.$this->args['page'].'&tab='.$tab, |
| 53 | - ]); |
|
| 53 | + ] ); |
|
| 54 | 54 | } |
| 55 | 55 | } |