@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | public function fields() |
| 14 | 14 | { |
| 15 | 15 | return [[ |
| 16 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
| 16 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
| 17 | 17 | 'minWidth' => 320, |
| 18 | 18 | 'type' => 'container', |
| 19 | - ],[ |
|
| 19 | + ], [ |
|
| 20 | 20 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 21 | 21 | 'name' => 'title', |
| 22 | 22 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
| 23 | 23 | 'type' => 'textbox', |
| 24 | - ],[ |
|
| 24 | + ], [ |
|
| 25 | 25 | 'label' => esc_html__( 'Count', 'site-reviews' ), |
| 26 | 26 | 'maxLength' => 5, |
| 27 | 27 | 'name' => 'count', |
@@ -29,19 +29,19 @@ discard block |
||
| 29 | 29 | 'text' => '10', |
| 30 | 30 | 'tooltip' => __( 'How many reviews would you like to display (default: 10)?', 'site-reviews' ), |
| 31 | 31 | 'type' => 'textbox', |
| 32 | - ],[ |
|
| 32 | + ], [ |
|
| 33 | 33 | 'label' => esc_html__( 'Rating', 'site-reviews' ), |
| 34 | 34 | 'name' => 'rating', |
| 35 | 35 | 'options' => [ |
| 36 | - '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 )), |
|
| 37 | - '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 )), |
|
| 38 | - '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 )), |
|
| 39 | - '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 )), |
|
| 40 | - '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 )), |
|
| 36 | + '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ) ), |
|
| 37 | + '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ) ), |
|
| 38 | + '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ) ), |
|
| 39 | + '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ) ), |
|
| 40 | + '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ) ), |
|
| 41 | 41 | ], |
| 42 | 42 | 'tooltip' => __( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ), |
| 43 | 43 | 'type' => 'listbox', |
| 44 | - ],[ |
|
| 44 | + ], [ |
|
| 45 | 45 | 'label' => esc_html__( 'Pagination', 'site-reviews' ), |
| 46 | 46 | 'name' => 'pagination', |
| 47 | 47 | 'options' => [ |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | 'name' => 'assigned_to', |
| 60 | 60 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ), |
| 61 | 61 | 'type' => 'textbox', |
| 62 | - ],[ |
|
| 62 | + ], [ |
|
| 63 | 63 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
| 64 | 64 | 'name' => 'schema', |
| 65 | 65 | 'options' => [ |
@@ -68,39 +68,39 @@ discard block |
||
| 68 | 68 | ], |
| 69 | 69 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
| 70 | 70 | 'type' => 'listbox', |
| 71 | - ],[ |
|
| 71 | + ], [ |
|
| 72 | 72 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 73 | 73 | 'name' => 'class', |
| 74 | 74 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 75 | 75 | 'type' => 'textbox', |
| 76 | - ],[ |
|
| 76 | + ], [ |
|
| 77 | 77 | 'columns' => 2, |
| 78 | 78 | 'items' => [[ |
| 79 | 79 | 'name' => 'hide_author', |
| 80 | 80 | 'text' => esc_html__( 'Author', 'site-reviews' ), |
| 81 | 81 | 'tooltip' => __( 'Hide the review author?', 'site-reviews' ), |
| 82 | 82 | 'type' => 'checkbox', |
| 83 | - ],[ |
|
| 83 | + ], [ |
|
| 84 | 84 | 'name' => 'hide_date', |
| 85 | 85 | 'text' => esc_html__( 'Date', 'site-reviews' ), |
| 86 | 86 | 'tooltip' => __( 'Hide the review date?', 'site-reviews' ), |
| 87 | 87 | 'type' => 'checkbox', |
| 88 | - ],[ |
|
| 88 | + ], [ |
|
| 89 | 89 | 'name' => 'hide_excerpt', |
| 90 | 90 | 'text' => esc_html__( 'Excerpt', 'site-reviews' ), |
| 91 | 91 | 'tooltip' => __( 'Hide the review excerpt?', 'site-reviews' ), |
| 92 | 92 | 'type' => 'checkbox', |
| 93 | - ],[ |
|
| 93 | + ], [ |
|
| 94 | 94 | 'name' => 'hide_rating', |
| 95 | 95 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
| 96 | 96 | 'tooltip' => __( 'Hide the review rating?', 'site-reviews' ), |
| 97 | 97 | 'type' => 'checkbox', |
| 98 | - ],[ |
|
| 98 | + ], [ |
|
| 99 | 99 | 'name' => 'hide_response', |
| 100 | 100 | 'text' => esc_html__( 'Response', 'site-reviews' ), |
| 101 | 101 | 'tooltip' => __( 'Hide the review response?', 'site-reviews' ), |
| 102 | 102 | 'type' => 'checkbox', |
| 103 | - ],[ |
|
| 103 | + ], [ |
|
| 104 | 104 | 'name' => 'hide_title', |
| 105 | 105 | 'text' => esc_html__( 'Title', 'site-reviews' ), |
| 106 | 106 | 'tooltip' => __( 'Hide the review title?', 'site-reviews' ), |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
| 111 | 111 | 'spacing' => 5, |
| 112 | 112 | 'type' => 'container', |
| 113 | - ],[ |
|
| 113 | + ], [ |
|
| 114 | 114 | 'hidden' => true, |
| 115 | 115 | 'name' => 'id', |
| 116 | 116 | 'type' => 'textbox', |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | public function getTerms() |
| 124 | 124 | { |
| 125 | 125 | $terms = glsr( Database::class )->getTerms(); |
| 126 | - if( empty( $terms )) { |
|
| 126 | + if( empty($terms) ) { |
|
| 127 | 127 | return []; |
| 128 | 128 | } |
| 129 | 129 | return [ |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | return [[ |
| 16 | 16 | 'type' => 'container', |
| 17 | 17 | 'html' => '<p class="strong">'.esc_html__( 'All settings are optional.', 'site-reviews' ).'</p>', |
| 18 | - ],[ |
|
| 18 | + ], [ |
|
| 19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 20 | 20 | 'name' => 'title', |
| 21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
| 22 | 22 | 'type' => 'textbox', |
| 23 | - ],[ |
|
| 23 | + ], [ |
|
| 24 | 24 | 'label' => esc_html__( 'Description', 'site-reviews' ), |
| 25 | 25 | 'minHeight' => 60, |
| 26 | 26 | 'minWidth' => 240, |
@@ -35,29 +35,29 @@ discard block |
||
| 35 | 35 | 'name' => 'assign_to', |
| 36 | 36 | 'tooltip' => __( 'Assign submitted reviews to a custom page/post ID. You can also enter "post_id" to assign reviews to the ID of the current page.', 'site-reviews' ), |
| 37 | 37 | 'type' => 'textbox', |
| 38 | - ],[ |
|
| 38 | + ], [ |
|
| 39 | 39 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 40 | 40 | 'name' => 'class', |
| 41 | 41 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 42 | 42 | 'type' => 'textbox', |
| 43 | - ],[ |
|
| 43 | + ], [ |
|
| 44 | 44 | 'columns' => 2, |
| 45 | 45 | 'items' => [[ |
| 46 | 46 | 'name' => 'hide_email', |
| 47 | 47 | 'text' => esc_html__( 'Email', 'site-reviews' ), |
| 48 | 48 | 'tooltip' => __( 'Hide the email field?', 'site-reviews' ), |
| 49 | 49 | 'type' => 'checkbox', |
| 50 | - ],[ |
|
| 50 | + ], [ |
|
| 51 | 51 | 'name' => 'hide_name', |
| 52 | 52 | 'text' => esc_html__( 'Name', 'site-reviews' ), |
| 53 | 53 | 'tooltip' => __( 'Hide the name field?', 'site-reviews' ), |
| 54 | 54 | 'type' => 'checkbox', |
| 55 | - ],[ |
|
| 55 | + ], [ |
|
| 56 | 56 | 'name' => 'hide_terms', |
| 57 | 57 | 'text' => esc_html__( 'Terms', 'site-reviews' ), |
| 58 | 58 | 'tooltip' => __( 'Hide the terms field?', 'site-reviews' ), |
| 59 | 59 | 'type' => 'checkbox', |
| 60 | - ],[ |
|
| 60 | + ], [ |
|
| 61 | 61 | 'name' => 'hide_title', |
| 62 | 62 | 'text' => esc_html__( 'Title', 'site-reviews' ), |
| 63 | 63 | 'tooltip' => __( 'Hide the title field?', 'site-reviews' ), |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | 'layout' => 'grid', |
| 68 | 68 | 'spacing' => 5, |
| 69 | 69 | 'type' => 'container', |
| 70 | - ],[ |
|
| 70 | + ], [ |
|
| 71 | 71 | 'hidden' => true, |
| 72 | 72 | 'name' => 'id', |
| 73 | 73 | 'type' => 'textbox', |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | public function getTerms() |
| 81 | 81 | { |
| 82 | 82 | $terms = glsr( Database::class )->getTerms(); |
| 83 | - if( empty( $terms )) { |
|
| 83 | + if( empty($terms) ) { |
|
| 84 | 84 | return []; |
| 85 | 85 | } |
| 86 | 86 | return [ |
@@ -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 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'label' => '['.$tag.']', |
| 48 | 48 | 'required' => $this->required, |
| 49 | 49 | 'title' => esc_html__( 'Shortcode', 'site-reviews' ), |
| 50 | - ]); |
|
| 50 | + ] ); |
|
| 51 | 51 | return $this; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | protected function generateFields( array $fields ) |
| 58 | 58 | { |
| 59 | 59 | $generatedFields = array_map( function( $field ) { |
| 60 | - if( empty( $field ))return; |
|
| 60 | + if( empty($field) )return; |
|
| 61 | 61 | $field = $this->normalize( $field ); |
| 62 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
| 62 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ) ) )return; |
|
| 63 | 63 | return $this->$method( $field ); |
| 64 | 64 | }, $fields ); |
| 65 | - return array_values( array_filter( $generatedFields )); |
|
| 65 | + return array_values( array_filter( $generatedFields ) ); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | protected function getFields() |
| 72 | 72 | { |
| 73 | 73 | $fields = $this->generateFields( $this->fields() ); |
| 74 | - if( !empty( $this->errors )) { |
|
| 74 | + if( !empty($this->errors) ) { |
|
| 75 | 75 | $errors = []; |
| 76 | 76 | foreach( $this->required as $name => $alert ) { |
| 77 | - if( false !== array_search( $name, array_column( $fields, 'name' )))continue; |
|
| 77 | + if( false !== array_search( $name, array_column( $fields, 'name' ) ) )continue; |
|
| 78 | 78 | $errors[] = $this->errors[$name]; |
| 79 | 79 | } |
| 80 | 80 | $this->errors = $errors; |
| 81 | 81 | } |
| 82 | - return empty( $this->errors ) |
|
| 82 | + return empty($this->errors) |
|
| 83 | 83 | ? $fields |
| 84 | 84 | : $this->errors; |
| 85 | 85 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | return wp_parse_args( $field, [ |
| 93 | 93 | 'items' => [], |
| 94 | 94 | 'type' => '', |
| 95 | - ]); |
|
| 95 | + ] ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | 'tooltip' => '', |
| 111 | 111 | 'type' => '', |
| 112 | 112 | 'value' => '', |
| 113 | - ]); |
|
| 113 | + ] ); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | protected function normalizeContainer( array $field ) |
| 120 | 120 | { |
| 121 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
| 121 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ) )return; |
|
| 122 | 122 | $field['items'] = $this->generateFields( $field['items'] ); |
| 123 | 123 | return $field; |
| 124 | 124 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function normalizeField( array $field, array $defaults ) |
| 130 | 130 | { |
| 131 | - if( !$this->validate( $field ))return; |
|
| 131 | + if( !$this->validate( $field ) )return; |
|
| 132 | 132 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
| 133 | 133 | return $value !== ''; |
| 134 | 134 | }); |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | 'tooltip' => '', |
| 149 | 149 | 'type' => '', |
| 150 | 150 | 'value' => '', |
| 151 | - ]); |
|
| 151 | + ] ); |
|
| 152 | 152 | if( !$listbox )return; |
| 153 | - if( !array_key_exists( '', $listbox['options'] )) { |
|
| 153 | + if( !array_key_exists( '', $listbox['options'] ) ) { |
|
| 154 | 154 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
| 155 | 155 | } |
| 156 | 156 | foreach( $listbox['options'] as $value => $text ) { |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | protected function normalizePost( array $field ) |
| 169 | 169 | { |
| 170 | - if( !is_array( $field['query_args'] )) { |
|
| 170 | + if( !is_array( $field['query_args'] ) ) { |
|
| 171 | 171 | $field['query_args'] = []; |
| 172 | 172 | } |
| 173 | 173 | $posts = get_posts( wp_parse_args( $field['query_args'], [ |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | 'orderby' => 'title', |
| 176 | 176 | 'post_type' => 'post', |
| 177 | 177 | 'posts_per_page' => 30, |
| 178 | - ])); |
|
| 179 | - if( !empty( $posts )) { |
|
| 178 | + ] ) ); |
|
| 179 | + if( !empty($posts) ) { |
|
| 180 | 180 | $options = []; |
| 181 | 181 | foreach( $posts as $post ) { |
| 182 | 182 | $options[$post->ID] = esc_html( $post->post_title ); |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | 'tooltip' => '', |
| 207 | 207 | 'type' => '', |
| 208 | 208 | 'value' => '', |
| 209 | - ]); |
|
| 209 | + ] ); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function validate( array $field ) |
| 216 | 216 | { |
| 217 | - $args = shortcode_atts([ |
|
| 217 | + $args = shortcode_atts( [ |
|
| 218 | 218 | 'label' => '', |
| 219 | 219 | 'name' => false, |
| 220 | 220 | 'required' => false, |
@@ -230,13 +230,13 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | protected function validateErrors( array $args ) |
| 232 | 232 | { |
| 233 | - if( !isset( $args['required']['error'] )) { |
|
| 233 | + if( !isset($args['required']['error']) ) { |
|
| 234 | 234 | return true; |
| 235 | 235 | } |
| 236 | - $this->errors[$name] = $this->normalizeContainer([ |
|
| 236 | + $this->errors[$name] = $this->normalizeContainer( [ |
|
| 237 | 237 | 'html' => $args['required']['error'], |
| 238 | 238 | 'type' => 'container', |
| 239 | - ]); |
|
| 239 | + ] ); |
|
| 240 | 240 | return false; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | return true; |
| 250 | 250 | } |
| 251 | 251 | $alert = esc_html__( 'Some of the shortcode options are required.', 'site-reviews' ); |
| 252 | - if( isset( $args['required']['alert'] )) { |
|
| 252 | + if( isset($args['required']['alert']) ) { |
|
| 253 | 253 | $alert = $args['required']['alert']; |
| 254 | 254 | } |
| 255 | - else if( !empty( $args['label'] )) { |
|
| 255 | + else if( !empty($args['label']) ) { |
|
| 256 | 256 | $alert = sprintf( |
| 257 | 257 | esc_html_x( 'The "%s" option is required.', 'the option label', 'site-reviews' ), |
| 258 | 258 | str_replace( ':', '', $args['label'] ) |
@@ -57,9 +57,13 @@ discard block |
||
| 57 | 57 | protected function generateFields( array $fields ) |
| 58 | 58 | { |
| 59 | 59 | $generatedFields = array_map( function( $field ) { |
| 60 | - if( empty( $field ))return; |
|
| 60 | + if( empty( $field )) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 61 | 63 | $field = $this->normalize( $field ); |
| 62 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
| 64 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ))) { |
|
| 65 | + return; |
|
| 66 | + } |
|
| 63 | 67 | return $this->$method( $field ); |
| 64 | 68 | }, $fields ); |
| 65 | 69 | return array_values( array_filter( $generatedFields )); |
@@ -74,7 +78,9 @@ discard block |
||
| 74 | 78 | if( !empty( $this->errors )) { |
| 75 | 79 | $errors = []; |
| 76 | 80 | foreach( $this->required as $name => $alert ) { |
| 77 | - if( false !== array_search( $name, array_column( $fields, 'name' )))continue; |
|
| 81 | + if( false !== array_search( $name, array_column( $fields, 'name' ))) { |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 78 | 84 | $errors[] = $this->errors[$name]; |
| 79 | 85 | } |
| 80 | 86 | $this->errors = $errors; |
@@ -118,7 +124,9 @@ discard block |
||
| 118 | 124 | */ |
| 119 | 125 | protected function normalizeContainer( array $field ) |
| 120 | 126 | { |
| 121 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
| 127 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field )) { |
|
| 128 | + return; |
|
| 129 | + } |
|
| 122 | 130 | $field['items'] = $this->generateFields( $field['items'] ); |
| 123 | 131 | return $field; |
| 124 | 132 | } |
@@ -128,7 +136,9 @@ discard block |
||
| 128 | 136 | */ |
| 129 | 137 | protected function normalizeField( array $field, array $defaults ) |
| 130 | 138 | { |
| 131 | - if( !$this->validate( $field ))return; |
|
| 139 | + if( !$this->validate( $field )) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 132 | 142 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
| 133 | 143 | return $value !== ''; |
| 134 | 144 | }); |
@@ -149,7 +159,9 @@ discard block |
||
| 149 | 159 | 'type' => '', |
| 150 | 160 | 'value' => '', |
| 151 | 161 | ]); |
| 152 | - if( !$listbox )return; |
|
| 162 | + if( !$listbox ) { |
|
| 163 | + return; |
|
| 164 | + } |
|
| 153 | 165 | if( !array_key_exists( '', $listbox['options'] )) { |
| 154 | 166 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
| 155 | 167 | } |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | public function fields() |
| 13 | 13 | { |
| 14 | 14 | return [[ |
| 15 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
| 15 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
| 16 | 16 | 'minWidth' => 320, |
| 17 | 17 | 'type' => 'container', |
| 18 | - ],[ |
|
| 18 | + ], [ |
|
| 19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 20 | 20 | 'name' => 'title', |
| 21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | 'name' => 'assigned_to', |
| 29 | 29 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ), |
| 30 | 30 | 'type' => 'textbox', |
| 31 | - ],[ |
|
| 31 | + ], [ |
|
| 32 | 32 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
| 33 | 33 | 'name' => 'schema', |
| 34 | 34 | 'options' => [ |
@@ -37,34 +37,34 @@ discard block |
||
| 37 | 37 | ], |
| 38 | 38 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
| 39 | 39 | 'type' => 'listbox', |
| 40 | - ],[ |
|
| 40 | + ], [ |
|
| 41 | 41 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 42 | 42 | 'name' => 'class', |
| 43 | 43 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 44 | 44 | 'type' => 'textbox', |
| 45 | - ],[ |
|
| 45 | + ], [ |
|
| 46 | 46 | 'columns' => 2, |
| 47 | 47 | 'items' => [[ |
| 48 | 48 | 'type' => 'checkbox', |
| 49 | 49 | 'name' => 'hide_bars', |
| 50 | 50 | 'text' => esc_html__( 'Bars', 'site-reviews' ), |
| 51 | 51 | 'tooltip' => esc_attr__( 'Hide the percentage bars?', 'site-reviews' ), |
| 52 | - ],[ |
|
| 52 | + ], [ |
|
| 53 | 53 | 'type' => 'checkbox', |
| 54 | 54 | 'name' => 'hide_if_empty', |
| 55 | 55 | 'text' => esc_html__( 'If Empty', 'site-reviews' ), |
| 56 | 56 | 'tooltip' => esc_attr__( 'Hide the summary if no reviews are found?', 'site-reviews' ), |
| 57 | - ],[ |
|
| 57 | + ], [ |
|
| 58 | 58 | 'type' => 'checkbox', |
| 59 | 59 | 'name' => 'hide_rating', |
| 60 | 60 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
| 61 | 61 | 'tooltip' => esc_attr__( 'Hide the rating?', 'site-reviews' ), |
| 62 | - ],[ |
|
| 62 | + ], [ |
|
| 63 | 63 | 'type' => 'checkbox', |
| 64 | 64 | 'name' => 'hide_stars', |
| 65 | 65 | 'text' => esc_html__( 'Stars', 'site-reviews' ), |
| 66 | 66 | 'tooltip' => esc_attr__( 'Hide the stars?', 'site-reviews' ), |
| 67 | - ],[ |
|
| 67 | + ], [ |
|
| 68 | 68 | 'type' => 'checkbox', |
| 69 | 69 | 'name' => 'hide_summary', |
| 70 | 70 | 'text' => esc_html__( 'Summary', 'site-reviews' ), |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | { |
| 15 | 15 | foreach( $command->shortcodes as $slug => $label ) { |
| 16 | 16 | $buttonClass = glsr( Helper::class )->buildClassName( $slug.'-button', 'Shortcodes' ); |
| 17 | - if( !class_exists( $buttonClass )) { |
|
| 18 | - glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass )); |
|
| 17 | + if( !class_exists( $buttonClass ) ) { |
|
| 18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) ); |
|
| 19 | 19 | continue; |
| 20 | 20 | } |
| 21 | 21 | $shortcode = glsr( $buttonClass )->register( $slug, [ |
| 22 | 22 | 'label' => $label, |
| 23 | 23 | 'title' => $label, |
| 24 | - ]); |
|
| 24 | + ] ); |
|
| 25 | 25 | glsr()->mceShortcodes[$slug] = $shortcode->properties; |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function handle( Command $command ) |
| 14 | 14 | { |
| 15 | - $postId = wp_update_post([ |
|
| 15 | + $postId = wp_update_post( [ |
|
| 16 | 16 | 'ID' => $command->id, |
| 17 | 17 | 'post_status' => $command->status, |
| 18 | - ]); |
|
| 18 | + ] ); |
|
| 19 | 19 | return [ |
| 20 | 20 | 'class' => 'status-'.$command->status, |
| 21 | 21 | 'link' => $this->getPostLink( $postId ).$this->getPostState( $postId ), |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'href' => get_edit_post_link( $postId ), |
| 34 | 34 | 'class' => 'row-title', |
| 35 | 35 | 'title' => __( 'Edit', 'site-reviews' ).' “'.esc_attr( $title ).'”', |
| 36 | - ]); |
|
| 36 | + ] ); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | protected function getPostState( $postId ) |
| 44 | 44 | { |
| 45 | 45 | ob_start(); |
| 46 | - _post_states( get_post( $postId )); |
|
| 46 | + _post_states( get_post( $postId ) ); |
|
| 47 | 47 | return ob_get_clean(); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -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 |