@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @return string |
52 | 52 | */ |
53 | - public function render(array $attributes) |
|
53 | + public function render( array $attributes ) |
|
54 | 54 | { |
55 | 55 | $attributes['class'] = $attributes['className']; |
56 | - $shortcode = glsr(Shortcode::class); |
|
57 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
58 | - $attributes = $this->normalize($attributes); |
|
56 | + $shortcode = glsr( Shortcode::class ); |
|
57 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
58 | + $attributes = $this->normalize( $attributes ); |
|
59 | 59 | $this->filterShortcodeClass(); |
60 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
60 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
61 | 61 | $this->filterInterpolation(); |
62 | 62 | } |
63 | 63 | } |
64 | - return $shortcode->buildShortcode($attributes); |
|
64 | + return $shortcode->buildShortcode( $attributes ); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | */ |
70 | 70 | protected function filterInterpolation() |
71 | 71 | { |
72 | - add_filter('site-reviews/interpolate/reviews-summary', function ($context) { |
|
72 | + add_filter( 'site-reviews/interpolate/reviews-summary', function( $context ) { |
|
73 | 73 | $context['class'] = 'glsr-default glsr-block-disabled'; |
74 | - $context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
74 | + $context['text'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
75 | 75 | return $context; |
76 | 76 | }); |
77 | 77 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function filterShortcodeClass() |
83 | 83 | { |
84 | - add_filter('site-reviews/style', function () { |
|
84 | + add_filter( 'site-reviews/style', function() { |
|
85 | 85 | return 'default'; |
86 | 86 | }); |
87 | 87 | } |
@@ -17,18 +17,18 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @return array |
19 | 19 | */ |
20 | - public function normalize(array $attributes) |
|
20 | + public function normalize( array $attributes ) |
|
21 | 21 | { |
22 | - $hide = array_flip(explode(',', $attributes['hide'])); |
|
22 | + $hide = array_flip( explode( ',', $attributes['hide'] ) ); |
|
23 | 23 | unset($hide['if_empty']); |
24 | - $attributes['hide'] = implode(',', array_keys($hide)); |
|
25 | - if (!isset($attributes['assigned_to'])) { |
|
24 | + $attributes['hide'] = implode( ',', array_keys( $hide ) ); |
|
25 | + if( !isset($attributes['assigned_to']) ) { |
|
26 | 26 | return $attributes; |
27 | 27 | } |
28 | - if ('post_id' == $attributes['assigned_to']) { |
|
28 | + if( 'post_id' == $attributes['assigned_to'] ) { |
|
29 | 29 | $attributes['assigned_to'] = $attributes['post_id']; |
30 | - } elseif ('parent_id' == $attributes['assigned_to']) { |
|
31 | - $attributes['assigned_to'] = wp_get_post_parent_id($attributes['post_id']); |
|
30 | + } elseif( 'parent_id' == $attributes['assigned_to'] ) { |
|
31 | + $attributes['assigned_to'] = wp_get_post_parent_id( $attributes['post_id'] ); |
|
32 | 32 | } |
33 | 33 | return $attributes; |
34 | 34 | } |
@@ -36,35 +36,35 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @return void |
38 | 38 | */ |
39 | - public function register($block) |
|
39 | + public function register( $block ) |
|
40 | 40 | { |
41 | - if (!function_exists('register_block_type')) { |
|
41 | + if( !function_exists( 'register_block_type' ) ) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | - register_block_type(Application::ID.'/'.$block, [ |
|
44 | + register_block_type( Application::ID.'/'.$block, [ |
|
45 | 45 | 'attributes' => $this->attributes(), |
46 | 46 | 'editor_script' => Application::ID.'/blocks', |
47 | 47 | 'editor_style' => Application::ID.'/blocks', |
48 | 48 | 'render_callback' => [$this, 'render'], |
49 | 49 | 'style' => Application::ID, |
50 | - ]); |
|
50 | + ] ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @return void |
55 | 55 | */ |
56 | - abstract public function render(array $attributes); |
|
56 | + abstract public function render( array $attributes ); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @param mixed $shortcode |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | - protected function hasVisibleFields($shortcode, array $attributes) |
|
62 | + protected function hasVisibleFields( $shortcode, array $attributes ) |
|
63 | 63 | { |
64 | - $args = $shortcode->normalizeAtts($attributes); |
|
64 | + $args = $shortcode->normalizeAtts( $attributes ); |
|
65 | 65 | $defaults = $shortcode->getHideOptions(); |
66 | - $hide = array_flip($args['hide']); |
|
66 | + $hide = array_flip( $args['hide'] ); |
|
67 | 67 | unset($defaults['if_empty'], $hide['if_empty']); |
68 | - return !empty(array_diff_key($defaults, $hide)); |
|
68 | + return !empty(array_diff_key( $defaults, $hide )); |
|
69 | 69 | } |
70 | 70 | } |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function render(array $attributes) |
|
65 | + public function render( array $attributes ) |
|
66 | 66 | { |
67 | 67 | $attributes['class'] = $attributes['className']; |
68 | - $shortcode = glsr(Shortcode::class); |
|
69 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | - $attributes = $this->normalize($attributes); |
|
68 | + $shortcode = glsr( Shortcode::class ); |
|
69 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
70 | + $attributes = $this->normalize( $attributes ); |
|
71 | 71 | $this->filterReviewLinks(); |
72 | 72 | $this->filterShortcodeClass(); |
73 | - $this->filterShowMoreLinks('content'); |
|
74 | - $this->filterShowMoreLinks('response'); |
|
75 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
73 | + $this->filterShowMoreLinks( 'content' ); |
|
74 | + $this->filterShowMoreLinks( 'response' ); |
|
75 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
76 | 76 | $this->filterInterpolation(); |
77 | 77 | } |
78 | 78 | } |
79 | - return $shortcode->buildShortcode($attributes); |
|
79 | + return $shortcode->buildShortcode( $attributes ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function filterInterpolation() |
86 | 86 | { |
87 | - add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
87 | + add_filter( 'site-reviews/interpolate/reviews', function( $context ) { |
|
88 | 88 | $context['class'] = 'glsr-default glsr-block-disabled'; |
89 | - $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
89 | + $context['reviews'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
90 | 90 | return $context; |
91 | 91 | }); |
92 | 92 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function filterReviewLinks() |
98 | 98 | { |
99 | - add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | - return str_replace('<a', '<a tabindex="-1"', $template); |
|
99 | + add_filter( 'site-reviews/rendered/template/reviews', function( $template ) { |
|
100 | + return str_replace( '<a', '<a tabindex="-1"', $template ); |
|
101 | 101 | }); |
102 | 102 | } |
103 | 103 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function filterShortcodeClass() |
108 | 108 | { |
109 | - add_filter('site-reviews/style', function () { |
|
109 | + add_filter( 'site-reviews/style', function() { |
|
110 | 110 | return 'default'; |
111 | 111 | }); |
112 | 112 | } |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | * @param string $field |
116 | 116 | * @return void |
117 | 117 | */ |
118 | - protected function filterShowMoreLinks($field) |
|
118 | + protected function filterShowMoreLinks( $field ) |
|
119 | 119 | { |
120 | - add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
120 | + add_filter( 'site-reviews/review/wrap/'.$field, function( $value ) { |
|
121 | 121 | $value = preg_replace( |
122 | 122 | '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s', |
123 | - '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
123 | + '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__( 'Show more', 'site-reviews' ).'</a>$5', |
|
124 | 124 | $value |
125 | 125 | ); |
126 | 126 | return $value; |
@@ -10,9 +10,9 @@ |
||
10 | 10 | /** |
11 | 11 | * @return void |
12 | 12 | */ |
13 | - public function handle(Command $command) |
|
13 | + public function handle( Command $command ) |
|
14 | 14 | { |
15 | - register_taxonomy(Application::TAXONOMY, Application::POST_TYPE, $command->args); |
|
16 | - register_taxonomy_for_object_type(Application::TAXONOMY, Application::POST_TYPE); |
|
15 | + register_taxonomy( Application::TAXONOMY, Application::POST_TYPE, $command->args ); |
|
16 | + register_taxonomy_for_object_type( Application::TAXONOMY, Application::POST_TYPE ); |
|
17 | 17 | } |
18 | 18 | } |
@@ -9,13 +9,13 @@ |
||
9 | 9 | /** |
10 | 10 | * @return void |
11 | 11 | */ |
12 | - public function handle(Command $command) |
|
12 | + public function handle( Command $command ) |
|
13 | 13 | { |
14 | - if (!in_array($command->postType, get_post_types(['_builtin' => true]))) { |
|
15 | - register_post_type($command->postType, $command->args); |
|
16 | - glsr()->postTypeColumns = wp_parse_args(glsr()->postTypeColumns, [ |
|
14 | + if( !in_array( $command->postType, get_post_types( ['_builtin' => true] ) ) ) { |
|
15 | + register_post_type( $command->postType, $command->args ); |
|
16 | + glsr()->postTypeColumns = wp_parse_args( glsr()->postTypeColumns, [ |
|
17 | 17 | $command->postType => $command->columns, |
18 | - ]); |
|
18 | + ] ); |
|
19 | 19 | } |
20 | 20 | } |
21 | 21 | } |
@@ -11,36 +11,36 @@ |
||
11 | 11 | { |
12 | 12 | return [[ |
13 | 13 | 'type' => 'container', |
14 | - 'html' => '<p class="strong">'.esc_html__('All settings are optional.', 'site-reviews').'</p>', |
|
14 | + 'html' => '<p class="strong">'.esc_html__( 'All settings are optional.', 'site-reviews' ).'</p>', |
|
15 | 15 | ], [ |
16 | - 'label' => esc_html__('Title', 'site-reviews'), |
|
16 | + 'label' => esc_html__( 'Title', 'site-reviews' ), |
|
17 | 17 | 'name' => 'title', |
18 | - 'tooltip' => __('Enter a custom shortcode heading.', 'site-reviews'), |
|
18 | + 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
|
19 | 19 | 'type' => 'textbox', |
20 | 20 | ], [ |
21 | - 'label' => esc_html__('Description', 'site-reviews'), |
|
21 | + 'label' => esc_html__( 'Description', 'site-reviews' ), |
|
22 | 22 | 'minHeight' => 60, |
23 | 23 | 'minWidth' => 240, |
24 | 24 | 'multiline' => true, |
25 | 25 | 'name' => 'description', |
26 | - 'tooltip' => __('Enter a custom shortcode description.', 'site-reviews'), |
|
26 | + 'tooltip' => __( 'Enter a custom shortcode description.', 'site-reviews' ), |
|
27 | 27 | 'type' => 'textbox', |
28 | 28 | ], |
29 | - $this->getCategories(__('Automatically assign a category to reviews submitted with this shortcode.', 'site-reviews')), |
|
29 | + $this->getCategories( __( 'Automatically assign a category to reviews submitted with this shortcode.', 'site-reviews' ) ), |
|
30 | 30 | [ |
31 | - 'label' => esc_html__('Assign To', 'site-reviews'), |
|
31 | + 'label' => esc_html__( 'Assign To', 'site-reviews' ), |
|
32 | 32 | 'name' => 'assign_to', |
33 | - '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'), |
|
33 | + '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' ), |
|
34 | 34 | 'type' => 'textbox', |
35 | 35 | ], [ |
36 | - 'label' => esc_html__('Classes', 'site-reviews'), |
|
36 | + 'label' => esc_html__( 'Classes', 'site-reviews' ), |
|
37 | 37 | 'name' => 'class', |
38 | - 'tooltip' => __('Add custom CSS classes to the shortcode.', 'site-reviews'), |
|
38 | + 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
|
39 | 39 | 'type' => 'textbox', |
40 | 40 | ], [ |
41 | 41 | 'columns' => 2, |
42 | 42 | 'items' => $this->getHideOptions(), |
43 | - 'label' => esc_html__('Hide', 'site-reviews'), |
|
43 | + 'label' => esc_html__( 'Hide', 'site-reviews' ), |
|
44 | 44 | 'layout' => 'grid', |
45 | 45 | 'spacing' => 5, |
46 | 46 | 'type' => 'container', |
@@ -10,40 +10,40 @@ |
||
10 | 10 | public function fields() |
11 | 11 | { |
12 | 12 | return [[ |
13 | - 'html' => sprintf('<p class="strong">%s</p>', esc_html__('All settings are optional.', 'site-reviews')), |
|
13 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
14 | 14 | 'minWidth' => 320, |
15 | 15 | 'type' => 'container', |
16 | 16 | ], [ |
17 | - 'label' => esc_html__('Title', 'site-reviews'), |
|
17 | + 'label' => esc_html__( 'Title', 'site-reviews' ), |
|
18 | 18 | 'name' => 'title', |
19 | - 'tooltip' => __('Enter a custom shortcode heading.', 'site-reviews'), |
|
19 | + 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
|
20 | 20 | 'type' => 'textbox', |
21 | 21 | ], |
22 | - $this->getTypes(__('Which type of review would you like to use?', 'site-reviews')), |
|
23 | - $this->getCategories(__('Limit reviews to this category.', 'site-reviews')), |
|
22 | + $this->getTypes( __( 'Which type of review would you like to use?', 'site-reviews' ) ), |
|
23 | + $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' ) ), |
|
24 | 24 | [ |
25 | - 'label' => esc_html__('Assigned To', 'site-reviews'), |
|
25 | + 'label' => esc_html__( 'Assigned To', 'site-reviews' ), |
|
26 | 26 | 'name' => 'assigned_to', |
27 | - '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'), |
|
27 | + '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' ), |
|
28 | 28 | 'type' => 'textbox', |
29 | 29 | ], [ |
30 | - 'label' => esc_html__('Schema', 'site-reviews'), |
|
30 | + 'label' => esc_html__( 'Schema', 'site-reviews' ), |
|
31 | 31 | 'name' => 'schema', |
32 | 32 | 'options' => [ |
33 | - 'true' => esc_html__('Enable rich snippets', 'site-reviews'), |
|
34 | - 'false' => esc_html__('Disable rich snippets', 'site-reviews'), |
|
33 | + 'true' => esc_html__( 'Enable rich snippets', 'site-reviews' ), |
|
34 | + 'false' => esc_html__( 'Disable rich snippets', 'site-reviews' ), |
|
35 | 35 | ], |
36 | - 'tooltip' => __('Rich snippets are disabled by default.', 'site-reviews'), |
|
36 | + 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
|
37 | 37 | 'type' => 'listbox', |
38 | 38 | ], [ |
39 | - 'label' => esc_html__('Classes', 'site-reviews'), |
|
39 | + 'label' => esc_html__( 'Classes', 'site-reviews' ), |
|
40 | 40 | 'name' => 'class', |
41 | - 'tooltip' => __('Add custom CSS classes to the shortcode.', 'site-reviews'), |
|
41 | + 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
|
42 | 42 | 'type' => 'textbox', |
43 | 43 | ], [ |
44 | 44 | 'columns' => 2, |
45 | 45 | 'items' => $this->getHideOptions(), |
46 | - 'label' => esc_html__('Hide', 'site-reviews'), |
|
46 | + 'label' => esc_html__( 'Hide', 'site-reviews' ), |
|
47 | 47 | 'layout' => 'grid', |
48 | 48 | 'spacing' => 5, |
49 | 49 | 'type' => 'container', |
@@ -7,14 +7,14 @@ |
||
7 | 7 | protected function hideOptions() |
8 | 8 | { |
9 | 9 | return [ |
10 | - 'title' => __('Hide the title', 'site-reviews'), |
|
11 | - 'rating' => __('Hide the rating', 'site-reviews'), |
|
12 | - 'date' => __('Hide the date', 'site-reviews'), |
|
13 | - 'assigned_to' => __('Hide the assigned to link (if shown)', 'site-reviews'), |
|
14 | - 'content' => __('Hide the content', 'site-reviews'), |
|
15 | - 'avatar' => __('Hide the avatar (if shown)', 'site-reviews'), |
|
16 | - 'author' => __('Hide the author', 'site-reviews'), |
|
17 | - 'response' => __('Hide the response', 'site-reviews'), |
|
10 | + 'title' => __( 'Hide the title', 'site-reviews' ), |
|
11 | + 'rating' => __( 'Hide the rating', 'site-reviews' ), |
|
12 | + 'date' => __( 'Hide the date', 'site-reviews' ), |
|
13 | + 'assigned_to' => __( 'Hide the assigned to link (if shown)', 'site-reviews' ), |
|
14 | + 'content' => __( 'Hide the content', 'site-reviews' ), |
|
15 | + 'avatar' => __( 'Hide the avatar (if shown)', 'site-reviews' ), |
|
16 | + 'author' => __( 'Hide the author', 'site-reviews' ), |
|
17 | + 'response' => __( 'Hide the response', 'site-reviews' ), |
|
18 | 18 | ]; |
19 | 19 | } |
20 | 20 | } |
@@ -7,11 +7,11 @@ |
||
7 | 7 | protected function hideOptions() |
8 | 8 | { |
9 | 9 | return [ |
10 | - 'rating' => __('Hide the rating', 'site-reviews'), |
|
11 | - 'stars' => __('Hide the stars', 'site-reviews'), |
|
12 | - 'summary' => __('Hide the summary', 'site-reviews'), |
|
13 | - 'bars' => __('Hide the percentage bars', 'site-reviews'), |
|
14 | - 'if_empty' => __('Hide if no reviews are found', 'site-reviews'), |
|
10 | + 'rating' => __( 'Hide the rating', 'site-reviews' ), |
|
11 | + 'stars' => __( 'Hide the stars', 'site-reviews' ), |
|
12 | + 'summary' => __( 'Hide the summary', 'site-reviews' ), |
|
13 | + 'bars' => __( 'Hide the percentage bars', 'site-reviews' ), |
|
14 | + 'if_empty' => __( 'Hide if no reviews are found', 'site-reviews' ), |
|
15 | 15 | ]; |
16 | 16 | } |
17 | 17 | } |