@@ -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,20 +29,20 @@ 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 )), |
|
| 41 | - '0' => esc_html( __( 'Unrated', 'site-reviews' )), |
|
| 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 | + '0' => esc_html( __( 'Unrated', 'site-reviews' ) ), |
|
| 42 | 42 | ], |
| 43 | 43 | 'tooltip' => __( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ), |
| 44 | 44 | 'type' => 'listbox', |
| 45 | - ],[ |
|
| 45 | + ], [ |
|
| 46 | 46 | 'label' => esc_html__( 'Pagination', 'site-reviews' ), |
| 47 | 47 | 'name' => 'pagination', |
| 48 | 48 | 'options' => [ |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | 'tooltip' => __( 'When using pagination this shortcode can only be used once on a page. (default: disable)', 'site-reviews' ), |
| 54 | 54 | 'type' => 'listbox', |
| 55 | 55 | ], |
| 56 | - $this->getTypes( __( 'Which type of review would you like to display?', 'site-reviews' )), |
|
| 57 | - $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' )), |
|
| 56 | + $this->getTypes( __( 'Which type of review would you like to display?', 'site-reviews' ) ), |
|
| 57 | + $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' ) ), |
|
| 58 | 58 | [ |
| 59 | 59 | 'label' => esc_html__( 'Assigned To', 'site-reviews' ), |
| 60 | 60 | 'name' => 'assigned_to', |
| 61 | 61 | '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, or "parent_id" to use the ID of the parent page.', 'site-reviews' ), |
| 62 | 62 | 'type' => 'textbox', |
| 63 | - ],[ |
|
| 63 | + ], [ |
|
| 64 | 64 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
| 65 | 65 | 'name' => 'schema', |
| 66 | 66 | 'options' => [ |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | ], |
| 70 | 70 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
| 71 | 71 | 'type' => 'listbox', |
| 72 | - ],[ |
|
| 72 | + ], [ |
|
| 73 | 73 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 74 | 74 | 'name' => 'class', |
| 75 | 75 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 76 | 76 | 'type' => 'textbox', |
| 77 | - ],[ |
|
| 77 | + ], [ |
|
| 78 | 78 | 'columns' => 2, |
| 79 | 79 | 'items' => $this->getHideOptions(), |
| 80 | 80 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
| 81 | 81 | 'layout' => 'grid', |
| 82 | 82 | 'spacing' => 5, |
| 83 | 83 | 'type' => 'container', |
| 84 | - ],[ |
|
| 84 | + ], [ |
|
| 85 | 85 | 'hidden' => true, |
| 86 | 86 | 'name' => 'id', |
| 87 | 87 | 'type' => 'textbox', |
@@ -12,23 +12,23 @@ 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' ), |
| 22 | 22 | 'type' => 'textbox', |
| 23 | 23 | ], |
| 24 | - $this->getTypes( __( 'Which type of review would you like to use?', 'site-reviews' )), |
|
| 25 | - $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' )), |
|
| 24 | + $this->getTypes( __( 'Which type of review would you like to use?', 'site-reviews' ) ), |
|
| 25 | + $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' ) ), |
|
| 26 | 26 | [ |
| 27 | 27 | 'label' => esc_html__( 'Assigned To', 'site-reviews' ), |
| 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, or "parent_id" to use the ID of the parent 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,12 +37,12 @@ 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' => $this->getHideOptions(), |
| 48 | 48 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | public function normalize( array $attributes ) |
| 21 | 21 | { |
| 22 | - if( !isset( $attributes['assigned_to'] )) { |
|
| 22 | + if( !isset($attributes['assigned_to']) ) { |
|
| 23 | 23 | return $attributes; |
| 24 | 24 | } |
| 25 | 25 | if( $attributes['assigned_to'] == 'post_id' ) { |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function register( $block ) |
| 38 | 38 | { |
| 39 | - if( !function_exists( 'register_block_type' ))return; |
|
| 39 | + if( !function_exists( 'register_block_type' ) )return; |
|
| 40 | 40 | register_block_type( Application::ID.'/'.$block, [ |
| 41 | 41 | 'attributes' => $this->attributes(), |
| 42 | 42 | 'editor_script' => Application::ID.'/blocks', |
| 43 | 43 | 'editor_style' => Application::ID.'/blocks', |
| 44 | 44 | 'render_callback' => [$this, 'render'], |
| 45 | 45 | 'style' => Application::ID, |
| 46 | - ]); |
|
| 46 | + ] ); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | 'after_widget' => '</div>', |
| 24 | 24 | 'before_title' => '<h3 class="glsr-'.$type.'-title">', |
| 25 | 25 | 'after_title' => '</h3>', |
| 26 | - ]); |
|
| 26 | + ] ); |
|
| 27 | 27 | $args = apply_filters( 'site-reviews/shortcode/args', $args, $type, $shortcodePartial ); |
| 28 | 28 | $instance = $this->normalize( $instance ); |
| 29 | 29 | $partial = glsr( Partial::class )->build( $shortcodePartial, $instance ); |
| 30 | - if( !empty( $instance['title'] )) { |
|
| 30 | + if( !empty($instance['title']) ) { |
|
| 31 | 31 | $instance['title'] = $args['before_title'].$instance['title'].$args['after_title']; |
| 32 | 32 | } |
| 33 | 33 | return $args['before_widget'].$instance['title'].$partial.$args['after_widget']; |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function normalize( $args ) |
| 92 | 92 | { |
| 93 | - $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args )); |
|
| 93 | + $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args ) ); |
|
| 94 | 94 | array_walk( $args, function( &$value, $key ) { |
| 95 | 95 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
| 96 | - if( !method_exists( $this, $methodName ))return; |
|
| 96 | + if( !method_exists( $this, $methodName ) )return; |
|
| 97 | 97 | $value = $this->$methodName( $value ); |
| 98 | 98 | }); |
| 99 | 99 | return $this->sanitize( $args ); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | protected function normalizeAssignedTo( $postId ) |
| 112 | 112 | { |
| 113 | 113 | if( $postId == 'parent_id' ) { |
| 114 | - $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ))); |
|
| 114 | + $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ) ) ); |
|
| 115 | 115 | } |
| 116 | 116 | else if( $postId == 'post_id' ) { |
| 117 | 117 | $postId = intval( get_the_ID() ); |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | protected function normalizeHide( $hide ) |
| 136 | 136 | { |
| 137 | - if( is_string( $hide )) { |
|
| 137 | + if( is_string( $hide ) ) { |
|
| 138 | 138 | $hide = explode( ',', $hide ); |
| 139 | 139 | } |
| 140 | 140 | $hideKeys = array_keys( $this->getHideOptions() ); |
| 141 | - return array_filter( array_map( 'trim', $hide ), function( $value ) use( $hideKeys ) { |
|
| 141 | + return array_filter( array_map( 'trim', $hide ), function( $value ) use($hideKeys) { |
|
| 142 | 142 | return in_array( $value, $hideKeys ); |
| 143 | 143 | }); |
| 144 | 144 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | __( 'Terrible', 'site-reviews' ), |
| 167 | 167 | ]; |
| 168 | 168 | $defaults = array_pad( $defaults, Rating::MAX_RATING, '' ); |
| 169 | - $labels = array_map( 'trim', explode( ',', $labels )); |
|
| 169 | + $labels = array_map( 'trim', explode( ',', $labels ) ); |
|
| 170 | 170 | foreach( $defaults as $i => $label ) { |
| 171 | - if( empty( $labels[$i] ))continue; |
|
| 171 | + if( empty($labels[$i]) )continue; |
|
| 172 | 172 | $defaults[$i] = $labels[$i]; |
| 173 | 173 | } |
| 174 | 174 | return array_combine( range( Rating::MAX_RATING, 1 ), $defaults ); |