@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p>This page shows all of the available shortcode options with examples of how to use them. You can use multiple options in the same shortcode.</p> |
4 | 4 | |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | <div class="glsr-card-header"> |
7 | 7 | <h3>[site_reviews]</h3> |
8 | 8 | <button type="button" class="handlediv" aria-expanded="true"> |
9 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
9 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
10 | 10 | <span class="toggle-indicator" aria-hidden="true"></span> |
11 | 11 | </button> |
12 | 12 | </div> |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | <div class="glsr-card-header"> |
81 | 81 | <h3>[site_reviews_form]</h3> |
82 | 82 | <button type="button" class="handlediv" aria-expanded="true"> |
83 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
83 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
84 | 84 | <span class="toggle-indicator" aria-hidden="true"></span> |
85 | 85 | </button> |
86 | 86 | </div> |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | <div class="glsr-card-header"> |
129 | 129 | <h3>[site_reviews_summary]</h3> |
130 | 130 | <button type="button" class="handlediv" aria-expanded="true"> |
131 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
131 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
132 | 132 | <span class="toggle-indicator" aria-hidden="true"></span> |
133 | 133 | </button> |
134 | 134 | </div> |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | <pre><code>[site_reviews_summary hide="bars,if_empty,rating,stars,summary"]</code></pre> |
159 | 159 | |
160 | 160 | <p class="glsr-heading">labels</p> |
161 | - <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!translations'); ?>">Settings → Translations</a></code> page.</p> |
|
161 | + <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!translations' ); ?>">Settings → Translations</a></code> page.</p> |
|
162 | 162 | <p>The default labels value is: <code>"Excellent,Very good,Average,Poor,Terrible"</code></p> |
163 | 163 | <pre><code>[site_reviews_summary labels="5 star,4 star,3 star,2 star,1 star"]</code></pre> |
164 | 164 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | <pre><code>[site_reviews_summary schema="true"]</code></pre> |
176 | 176 | |
177 | 177 | <p class="glsr-heading">text</p> |
178 | - <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!translations'); ?>">Settings → Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p> |
|
178 | + <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!translations' ); ?>">Settings → Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p> |
|
179 | 179 | <p>The default text value is: <code>"{rating} out of {max} stars (based on {num} reviews)"</code></p> |
180 | 180 | <pre><code>[site_reviews_summary text="{num} customer reviews"]</code></pre> |
181 | 181 |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <div class="notice notice-info is-dismissible glsr-notice" data-dismiss="welcome"> |
2 | - <p><?= $text; ?> — <a class="button button-small" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=welcome#!whatsnew'); ?>">See what's new</a></p> |
|
2 | + <p><?= $text; ?> — <a class="button button-small" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=welcome#!whatsnew' ); ?>">See what's new</a></p> |
|
3 | 3 | </div> |
@@ -7,92 +7,92 @@ |
||
7 | 7 | |
8 | 8 | class SiteReviewsWidget extends Widget |
9 | 9 | { |
10 | - /** |
|
11 | - * @param array $instance |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function form($instance) |
|
15 | - { |
|
16 | - $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance); |
|
17 | - $terms = glsr(Database::class)->getTerms(); |
|
18 | - $this->renderField('text', [ |
|
19 | - 'class' => 'widefat', |
|
20 | - 'label' => __('Title', 'site-reviews'), |
|
21 | - 'name' => 'title', |
|
22 | - ]); |
|
23 | - $this->renderField('number', [ |
|
24 | - 'class' => 'small-text', |
|
25 | - 'default' => 10, |
|
26 | - 'label' => __('How many reviews would you like to display?', 'site-reviews'), |
|
27 | - 'max' => 100, |
|
28 | - 'name' => 'display', |
|
29 | - ]); |
|
30 | - $this->renderField('select', [ |
|
31 | - 'label' => __('What is the minimum rating to display?', 'site-reviews'), |
|
32 | - 'name' => 'rating', |
|
33 | - 'options' => [ |
|
34 | - '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5), |
|
35 | - '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4), |
|
36 | - '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3), |
|
37 | - '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2), |
|
38 | - '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1), |
|
39 | - ], |
|
40 | - ]); |
|
41 | - if (count(glsr()->reviewTypes) > 1) { |
|
42 | - $this->renderField('select', [ |
|
43 | - 'class' => 'widefat', |
|
44 | - 'label' => __('Which type of review would you like to display?', 'site-reviews'), |
|
45 | - 'name' => 'type', |
|
46 | - 'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes, |
|
47 | - ]); |
|
48 | - } |
|
49 | - if (!empty($terms)) { |
|
50 | - $this->renderField('select', [ |
|
51 | - 'class' => 'widefat', |
|
52 | - 'label' => __('Limit reviews to this category', 'site-reviews'), |
|
53 | - 'name' => 'category', |
|
54 | - 'options' => ['' => __('All Categories', 'site-reviews')] + $terms, |
|
55 | - ]); |
|
56 | - } |
|
57 | - $this->renderField('text', [ |
|
58 | - 'class' => 'widefat', |
|
59 | - 'default' => '', |
|
60 | - 'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'), |
|
61 | - 'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'), |
|
62 | - 'name' => 'assigned_to', |
|
63 | - ]); |
|
64 | - $this->renderField('text', [ |
|
65 | - 'class' => 'widefat', |
|
66 | - 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
67 | - 'name' => 'class', |
|
68 | - ]); |
|
69 | - $this->renderField('checkbox', [ |
|
70 | - 'name' => 'hide', |
|
71 | - 'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(), |
|
72 | - ]); |
|
73 | - } |
|
10 | + /** |
|
11 | + * @param array $instance |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function form($instance) |
|
15 | + { |
|
16 | + $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance); |
|
17 | + $terms = glsr(Database::class)->getTerms(); |
|
18 | + $this->renderField('text', [ |
|
19 | + 'class' => 'widefat', |
|
20 | + 'label' => __('Title', 'site-reviews'), |
|
21 | + 'name' => 'title', |
|
22 | + ]); |
|
23 | + $this->renderField('number', [ |
|
24 | + 'class' => 'small-text', |
|
25 | + 'default' => 10, |
|
26 | + 'label' => __('How many reviews would you like to display?', 'site-reviews'), |
|
27 | + 'max' => 100, |
|
28 | + 'name' => 'display', |
|
29 | + ]); |
|
30 | + $this->renderField('select', [ |
|
31 | + 'label' => __('What is the minimum rating to display?', 'site-reviews'), |
|
32 | + 'name' => 'rating', |
|
33 | + 'options' => [ |
|
34 | + '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5), |
|
35 | + '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4), |
|
36 | + '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3), |
|
37 | + '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2), |
|
38 | + '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1), |
|
39 | + ], |
|
40 | + ]); |
|
41 | + if (count(glsr()->reviewTypes) > 1) { |
|
42 | + $this->renderField('select', [ |
|
43 | + 'class' => 'widefat', |
|
44 | + 'label' => __('Which type of review would you like to display?', 'site-reviews'), |
|
45 | + 'name' => 'type', |
|
46 | + 'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes, |
|
47 | + ]); |
|
48 | + } |
|
49 | + if (!empty($terms)) { |
|
50 | + $this->renderField('select', [ |
|
51 | + 'class' => 'widefat', |
|
52 | + 'label' => __('Limit reviews to this category', 'site-reviews'), |
|
53 | + 'name' => 'category', |
|
54 | + 'options' => ['' => __('All Categories', 'site-reviews')] + $terms, |
|
55 | + ]); |
|
56 | + } |
|
57 | + $this->renderField('text', [ |
|
58 | + 'class' => 'widefat', |
|
59 | + 'default' => '', |
|
60 | + 'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'), |
|
61 | + 'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'), |
|
62 | + 'name' => 'assigned_to', |
|
63 | + ]); |
|
64 | + $this->renderField('text', [ |
|
65 | + 'class' => 'widefat', |
|
66 | + 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
67 | + 'name' => 'class', |
|
68 | + ]); |
|
69 | + $this->renderField('checkbox', [ |
|
70 | + 'name' => 'hide', |
|
71 | + 'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(), |
|
72 | + ]); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @param array $newInstance |
|
77 | - * @param array $oldInstance |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - public function update($newInstance, $oldInstance) |
|
81 | - { |
|
82 | - if (!is_numeric($newInstance['display'])) { |
|
83 | - $newInstance['display'] = 10; |
|
84 | - } |
|
85 | - $newInstance['display'] = min(50, max(0, intval($newInstance['display']))); |
|
86 | - return parent::update($newInstance, $oldInstance); |
|
87 | - } |
|
75 | + /** |
|
76 | + * @param array $newInstance |
|
77 | + * @param array $oldInstance |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + public function update($newInstance, $oldInstance) |
|
81 | + { |
|
82 | + if (!is_numeric($newInstance['display'])) { |
|
83 | + $newInstance['display'] = 10; |
|
84 | + } |
|
85 | + $newInstance['display'] = min(50, max(0, intval($newInstance['display']))); |
|
86 | + return parent::update($newInstance, $oldInstance); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param array $args |
|
91 | - * @param array $instance |
|
92 | - * @return void |
|
93 | - */ |
|
94 | - public function widget($args, $instance) |
|
95 | - { |
|
96 | - echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget'); |
|
97 | - } |
|
89 | + /** |
|
90 | + * @param array $args |
|
91 | + * @param array $instance |
|
92 | + * @return void |
|
93 | + */ |
|
94 | + public function widget($args, $instance) |
|
95 | + { |
|
96 | + echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget'); |
|
97 | + } |
|
98 | 98 | } |
@@ -11,65 +11,65 @@ discard block |
||
11 | 11 | * @param array $instance |
12 | 12 | * @return void |
13 | 13 | */ |
14 | - public function form($instance) |
|
14 | + public function form( $instance ) |
|
15 | 15 | { |
16 | - $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance); |
|
17 | - $terms = glsr(Database::class)->getTerms(); |
|
18 | - $this->renderField('text', [ |
|
16 | + $this->widgetArgs = glsr( SiteReviewsShortcode::class )->normalizeAtts( $instance ); |
|
17 | + $terms = glsr( Database::class )->getTerms(); |
|
18 | + $this->renderField( 'text', [ |
|
19 | 19 | 'class' => 'widefat', |
20 | - 'label' => __('Title', 'site-reviews'), |
|
20 | + 'label' => __( 'Title', 'site-reviews' ), |
|
21 | 21 | 'name' => 'title', |
22 | - ]); |
|
23 | - $this->renderField('number', [ |
|
22 | + ] ); |
|
23 | + $this->renderField( 'number', [ |
|
24 | 24 | 'class' => 'small-text', |
25 | 25 | 'default' => 10, |
26 | - 'label' => __('How many reviews would you like to display?', 'site-reviews'), |
|
26 | + 'label' => __( 'How many reviews would you like to display?', 'site-reviews' ), |
|
27 | 27 | 'max' => 100, |
28 | 28 | 'name' => 'display', |
29 | - ]); |
|
30 | - $this->renderField('select', [ |
|
31 | - 'label' => __('What is the minimum rating to display?', 'site-reviews'), |
|
29 | + ] ); |
|
30 | + $this->renderField( 'select', [ |
|
31 | + 'label' => __( 'What is the minimum rating to display?', 'site-reviews' ), |
|
32 | 32 | 'name' => 'rating', |
33 | 33 | 'options' => [ |
34 | - '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5), |
|
35 | - '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4), |
|
36 | - '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3), |
|
37 | - '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2), |
|
38 | - '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1), |
|
34 | + '5' => sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ), |
|
35 | + '4' => sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ), |
|
36 | + '3' => sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ), |
|
37 | + '2' => sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ), |
|
38 | + '1' => sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ), |
|
39 | 39 | ], |
40 | - ]); |
|
41 | - if (count(glsr()->reviewTypes) > 1) { |
|
42 | - $this->renderField('select', [ |
|
40 | + ] ); |
|
41 | + if( count( glsr()->reviewTypes ) > 1 ) { |
|
42 | + $this->renderField( 'select', [ |
|
43 | 43 | 'class' => 'widefat', |
44 | - 'label' => __('Which type of review would you like to display?', 'site-reviews'), |
|
44 | + 'label' => __( 'Which type of review would you like to display?', 'site-reviews' ), |
|
45 | 45 | 'name' => 'type', |
46 | - 'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes, |
|
47 | - ]); |
|
46 | + 'options' => ['' => __( 'All Reviews', 'site-reviews' )] + glsr()->reviewTypes, |
|
47 | + ] ); |
|
48 | 48 | } |
49 | - if (!empty($terms)) { |
|
50 | - $this->renderField('select', [ |
|
49 | + if( !empty($terms) ) { |
|
50 | + $this->renderField( 'select', [ |
|
51 | 51 | 'class' => 'widefat', |
52 | - 'label' => __('Limit reviews to this category', 'site-reviews'), |
|
52 | + 'label' => __( 'Limit reviews to this category', 'site-reviews' ), |
|
53 | 53 | 'name' => 'category', |
54 | - 'options' => ['' => __('All Categories', 'site-reviews')] + $terms, |
|
55 | - ]); |
|
54 | + 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
|
55 | + ] ); |
|
56 | 56 | } |
57 | - $this->renderField('text', [ |
|
57 | + $this->renderField( 'text', [ |
|
58 | 58 | 'class' => 'widefat', |
59 | 59 | 'default' => '', |
60 | - 'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'), |
|
61 | - 'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'), |
|
60 | + 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
|
61 | + 'label' => __( 'Limit reviews to those assigned to this page/post ID', 'site-reviews' ), |
|
62 | 62 | 'name' => 'assigned_to', |
63 | - ]); |
|
64 | - $this->renderField('text', [ |
|
63 | + ] ); |
|
64 | + $this->renderField( 'text', [ |
|
65 | 65 | 'class' => 'widefat', |
66 | - 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
66 | + 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
|
67 | 67 | 'name' => 'class', |
68 | - ]); |
|
69 | - $this->renderField('checkbox', [ |
|
68 | + ] ); |
|
69 | + $this->renderField( 'checkbox', [ |
|
70 | 70 | 'name' => 'hide', |
71 | - 'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(), |
|
72 | - ]); |
|
71 | + 'options' => glsr( SiteReviewsShortcode::class )->getHideOptions(), |
|
72 | + ] ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | * @param array $oldInstance |
78 | 78 | * @return array |
79 | 79 | */ |
80 | - public function update($newInstance, $oldInstance) |
|
80 | + public function update( $newInstance, $oldInstance ) |
|
81 | 81 | { |
82 | - if (!is_numeric($newInstance['display'])) { |
|
82 | + if( !is_numeric( $newInstance['display'] ) ) { |
|
83 | 83 | $newInstance['display'] = 10; |
84 | 84 | } |
85 | - $newInstance['display'] = min(50, max(0, intval($newInstance['display']))); |
|
86 | - return parent::update($newInstance, $oldInstance); |
|
85 | + $newInstance['display'] = min( 50, max( 0, intval( $newInstance['display'] ) ) ); |
|
86 | + return parent::update( $newInstance, $oldInstance ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * @param array $instance |
92 | 92 | * @return void |
93 | 93 | */ |
94 | - public function widget($args, $instance) |
|
94 | + public function widget( $args, $instance ) |
|
95 | 95 | { |
96 | - echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget'); |
|
96 | + echo glsr( SiteReviewsShortcode::class )->build( $instance, $args, 'widget' ); |
|
97 | 97 | } |
98 | 98 | } |
@@ -6,124 +6,124 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsBlock extends BlockGenerator |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function attributes() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'assigned_to' => [ |
|
16 | - 'default' => '', |
|
17 | - 'type' => 'string', |
|
18 | - ], |
|
19 | - 'category' => [ |
|
20 | - 'default' => '', |
|
21 | - 'type' => 'string', |
|
22 | - ], |
|
23 | - 'className' => [ |
|
24 | - 'default' => '', |
|
25 | - 'type' => 'string', |
|
26 | - ], |
|
27 | - 'display' => [ |
|
28 | - 'default' => 5, |
|
29 | - 'type' => 'number', |
|
30 | - ], |
|
31 | - 'hide' => [ |
|
32 | - 'default' => '', |
|
33 | - 'type' => 'string', |
|
34 | - ], |
|
35 | - 'id' => [ |
|
36 | - 'default' => '', |
|
37 | - 'type' => 'string', |
|
38 | - ], |
|
39 | - 'pagination' => [ |
|
40 | - 'default' => '', |
|
41 | - 'type' => 'string', |
|
42 | - ], |
|
43 | - 'post_id' => [ |
|
44 | - 'default' => '', |
|
45 | - 'type' => 'string', |
|
46 | - ], |
|
47 | - 'rating' => [ |
|
48 | - 'default' => 0, |
|
49 | - 'type' => 'number', |
|
50 | - ], |
|
51 | - 'schema' => [ |
|
52 | - 'default' => false, |
|
53 | - 'type' => 'boolean', |
|
54 | - ], |
|
55 | - 'type' => [ |
|
56 | - 'default' => 'local', |
|
57 | - 'type' => 'string', |
|
58 | - ], |
|
59 | - ]; |
|
60 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function attributes() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'assigned_to' => [ |
|
16 | + 'default' => '', |
|
17 | + 'type' => 'string', |
|
18 | + ], |
|
19 | + 'category' => [ |
|
20 | + 'default' => '', |
|
21 | + 'type' => 'string', |
|
22 | + ], |
|
23 | + 'className' => [ |
|
24 | + 'default' => '', |
|
25 | + 'type' => 'string', |
|
26 | + ], |
|
27 | + 'display' => [ |
|
28 | + 'default' => 5, |
|
29 | + 'type' => 'number', |
|
30 | + ], |
|
31 | + 'hide' => [ |
|
32 | + 'default' => '', |
|
33 | + 'type' => 'string', |
|
34 | + ], |
|
35 | + 'id' => [ |
|
36 | + 'default' => '', |
|
37 | + 'type' => 'string', |
|
38 | + ], |
|
39 | + 'pagination' => [ |
|
40 | + 'default' => '', |
|
41 | + 'type' => 'string', |
|
42 | + ], |
|
43 | + 'post_id' => [ |
|
44 | + 'default' => '', |
|
45 | + 'type' => 'string', |
|
46 | + ], |
|
47 | + 'rating' => [ |
|
48 | + 'default' => 0, |
|
49 | + 'type' => 'number', |
|
50 | + ], |
|
51 | + 'schema' => [ |
|
52 | + 'default' => false, |
|
53 | + 'type' => 'boolean', |
|
54 | + ], |
|
55 | + 'type' => [ |
|
56 | + 'default' => 'local', |
|
57 | + 'type' => 'string', |
|
58 | + ], |
|
59 | + ]; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function render(array $attributes) |
|
66 | - { |
|
67 | - $attributes['class'] = $attributes['className']; |
|
68 | - $shortcode = glsr(Shortcode::class); |
|
69 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | - $attributes = $this->normalize($attributes); |
|
71 | - $this->filterReviewLinks(); |
|
72 | - $this->filterShortcodeClass(); |
|
73 | - $this->filterShowMoreLinks('content'); |
|
74 | - $this->filterShowMoreLinks('response'); |
|
75 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
76 | - $this->filterInterpolation(); |
|
77 | - } |
|
78 | - } |
|
79 | - return $shortcode->buildShortcode($attributes); |
|
80 | - } |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function render(array $attributes) |
|
66 | + { |
|
67 | + $attributes['class'] = $attributes['className']; |
|
68 | + $shortcode = glsr(Shortcode::class); |
|
69 | + if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | + $attributes = $this->normalize($attributes); |
|
71 | + $this->filterReviewLinks(); |
|
72 | + $this->filterShortcodeClass(); |
|
73 | + $this->filterShowMoreLinks('content'); |
|
74 | + $this->filterShowMoreLinks('response'); |
|
75 | + if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
76 | + $this->filterInterpolation(); |
|
77 | + } |
|
78 | + } |
|
79 | + return $shortcode->buildShortcode($attributes); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return void |
|
84 | - */ |
|
85 | - protected function filterInterpolation() |
|
86 | - { |
|
87 | - add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
88 | - $context['class'] = 'glsr-default glsr-block-disabled'; |
|
89 | - $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
90 | - return $context; |
|
91 | - }); |
|
92 | - } |
|
82 | + /** |
|
83 | + * @return void |
|
84 | + */ |
|
85 | + protected function filterInterpolation() |
|
86 | + { |
|
87 | + add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
88 | + $context['class'] = 'glsr-default glsr-block-disabled'; |
|
89 | + $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
90 | + return $context; |
|
91 | + }); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - protected function filterReviewLinks() |
|
98 | - { |
|
99 | - add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | - return str_replace('<a', '<a tabindex="-1"', $template); |
|
101 | - }); |
|
102 | - } |
|
94 | + /** |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + protected function filterReviewLinks() |
|
98 | + { |
|
99 | + add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | + return str_replace('<a', '<a tabindex="-1"', $template); |
|
101 | + }); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - protected function filterShortcodeClass() |
|
108 | - { |
|
109 | - add_filter('site-reviews/style', function () { |
|
110 | - return 'default'; |
|
111 | - }); |
|
112 | - } |
|
104 | + /** |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + protected function filterShortcodeClass() |
|
108 | + { |
|
109 | + add_filter('site-reviews/style', function () { |
|
110 | + return 'default'; |
|
111 | + }); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @param string $field |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - protected function filterShowMoreLinks($field) |
|
119 | - { |
|
120 | - add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
121 | - $value = preg_replace( |
|
122 | - '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s', |
|
123 | - '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
124 | - $value |
|
125 | - ); |
|
126 | - return $value; |
|
127 | - }); |
|
128 | - } |
|
114 | + /** |
|
115 | + * @param string $field |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + protected function filterShowMoreLinks($field) |
|
119 | + { |
|
120 | + add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
121 | + $value = preg_replace( |
|
122 | + '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s', |
|
123 | + '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
124 | + $value |
|
125 | + ); |
|
126 | + return $value; |
|
127 | + }); |
|
128 | + } |
|
129 | 129 | } |
@@ -4,84 +4,84 @@ |
||
4 | 4 | |
5 | 5 | class SiteReviewsPopup extends TinymcePopupGenerator |
6 | 6 | { |
7 | - /** |
|
8 | - * @return array |
|
9 | - */ |
|
10 | - public function fields() |
|
11 | - { |
|
12 | - return [[ |
|
13 | - 'html' => sprintf('<p class="strong">%s</p>', esc_html__('All settings are optional.', 'site-reviews')), |
|
14 | - 'minWidth' => 320, |
|
15 | - 'type' => 'container', |
|
16 | - ], [ |
|
17 | - 'label' => esc_html__('Title', 'site-reviews'), |
|
18 | - 'name' => 'title', |
|
19 | - 'tooltip' => __('Enter a custom shortcode heading.', 'site-reviews'), |
|
20 | - 'type' => 'textbox', |
|
21 | - ], [ |
|
22 | - 'label' => esc_html__('Display', 'site-reviews'), |
|
23 | - 'maxLength' => 5, |
|
24 | - 'name' => 'display', |
|
25 | - 'size' => 3, |
|
26 | - 'text' => '10', |
|
27 | - 'tooltip' => __('How many reviews would you like to display (default: 10)?', 'site-reviews'), |
|
28 | - 'type' => 'textbox', |
|
29 | - ], [ |
|
30 | - 'label' => esc_html__('Rating', 'site-reviews'), |
|
31 | - 'name' => 'rating', |
|
32 | - 'options' => [ |
|
33 | - '5' => esc_html(sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5)), |
|
34 | - '4' => esc_html(sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4)), |
|
35 | - '3' => esc_html(sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3)), |
|
36 | - '2' => esc_html(sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2)), |
|
37 | - '1' => esc_html(sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1)), |
|
38 | - '0' => esc_html(__('Unrated', 'site-reviews')), |
|
39 | - ], |
|
40 | - 'tooltip' => __('What is the minimum rating to display (default: 1 star)?', 'site-reviews'), |
|
41 | - 'type' => 'listbox', |
|
42 | - ], [ |
|
43 | - 'label' => esc_html__('Pagination', 'site-reviews'), |
|
44 | - 'name' => 'pagination', |
|
45 | - 'options' => [ |
|
46 | - 'true' => esc_html__('Enable', 'site-reviews'), |
|
47 | - 'ajax' => esc_html__('Enable (using ajax)', 'site-reviews'), |
|
48 | - 'false' => esc_html__('Disable', 'site-reviews'), |
|
49 | - ], |
|
50 | - 'tooltip' => __('When using pagination this shortcode can only be used once on a page. (default: disable)', 'site-reviews'), |
|
51 | - 'type' => 'listbox', |
|
52 | - ], |
|
53 | - $this->getTypes(__('Which type of review would you like to display?', 'site-reviews')), |
|
54 | - $this->getCategories(__('Limit reviews to this category.', 'site-reviews')), |
|
55 | - [ |
|
56 | - 'label' => esc_html__('Assigned To', 'site-reviews'), |
|
57 | - 'name' => 'assigned_to', |
|
58 | - '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'), |
|
59 | - 'type' => 'textbox', |
|
60 | - ], [ |
|
61 | - 'label' => esc_html__('Schema', 'site-reviews'), |
|
62 | - 'name' => 'schema', |
|
63 | - 'options' => [ |
|
64 | - 'true' => esc_html__('Enable rich snippets', 'site-reviews'), |
|
65 | - 'false' => esc_html__('Disable rich snippets', 'site-reviews'), |
|
66 | - ], |
|
67 | - 'tooltip' => __('Rich snippets are disabled by default.', 'site-reviews'), |
|
68 | - 'type' => 'listbox', |
|
69 | - ], [ |
|
70 | - 'label' => esc_html__('Classes', 'site-reviews'), |
|
71 | - 'name' => 'class', |
|
72 | - 'tooltip' => __('Add custom CSS classes to the shortcode.', 'site-reviews'), |
|
73 | - 'type' => 'textbox', |
|
74 | - ], [ |
|
75 | - 'columns' => 2, |
|
76 | - 'items' => $this->getHideOptions(), |
|
77 | - 'label' => esc_html__('Hide', 'site-reviews'), |
|
78 | - 'layout' => 'grid', |
|
79 | - 'spacing' => 5, |
|
80 | - 'type' => 'container', |
|
81 | - ], [ |
|
82 | - 'hidden' => true, |
|
83 | - 'name' => 'id', |
|
84 | - 'type' => 'textbox', |
|
85 | - ], ]; |
|
86 | - } |
|
7 | + /** |
|
8 | + * @return array |
|
9 | + */ |
|
10 | + public function fields() |
|
11 | + { |
|
12 | + return [[ |
|
13 | + 'html' => sprintf('<p class="strong">%s</p>', esc_html__('All settings are optional.', 'site-reviews')), |
|
14 | + 'minWidth' => 320, |
|
15 | + 'type' => 'container', |
|
16 | + ], [ |
|
17 | + 'label' => esc_html__('Title', 'site-reviews'), |
|
18 | + 'name' => 'title', |
|
19 | + 'tooltip' => __('Enter a custom shortcode heading.', 'site-reviews'), |
|
20 | + 'type' => 'textbox', |
|
21 | + ], [ |
|
22 | + 'label' => esc_html__('Display', 'site-reviews'), |
|
23 | + 'maxLength' => 5, |
|
24 | + 'name' => 'display', |
|
25 | + 'size' => 3, |
|
26 | + 'text' => '10', |
|
27 | + 'tooltip' => __('How many reviews would you like to display (default: 10)?', 'site-reviews'), |
|
28 | + 'type' => 'textbox', |
|
29 | + ], [ |
|
30 | + 'label' => esc_html__('Rating', 'site-reviews'), |
|
31 | + 'name' => 'rating', |
|
32 | + 'options' => [ |
|
33 | + '5' => esc_html(sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5)), |
|
34 | + '4' => esc_html(sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4)), |
|
35 | + '3' => esc_html(sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3)), |
|
36 | + '2' => esc_html(sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2)), |
|
37 | + '1' => esc_html(sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1)), |
|
38 | + '0' => esc_html(__('Unrated', 'site-reviews')), |
|
39 | + ], |
|
40 | + 'tooltip' => __('What is the minimum rating to display (default: 1 star)?', 'site-reviews'), |
|
41 | + 'type' => 'listbox', |
|
42 | + ], [ |
|
43 | + 'label' => esc_html__('Pagination', 'site-reviews'), |
|
44 | + 'name' => 'pagination', |
|
45 | + 'options' => [ |
|
46 | + 'true' => esc_html__('Enable', 'site-reviews'), |
|
47 | + 'ajax' => esc_html__('Enable (using ajax)', 'site-reviews'), |
|
48 | + 'false' => esc_html__('Disable', 'site-reviews'), |
|
49 | + ], |
|
50 | + 'tooltip' => __('When using pagination this shortcode can only be used once on a page. (default: disable)', 'site-reviews'), |
|
51 | + 'type' => 'listbox', |
|
52 | + ], |
|
53 | + $this->getTypes(__('Which type of review would you like to display?', 'site-reviews')), |
|
54 | + $this->getCategories(__('Limit reviews to this category.', 'site-reviews')), |
|
55 | + [ |
|
56 | + 'label' => esc_html__('Assigned To', 'site-reviews'), |
|
57 | + 'name' => 'assigned_to', |
|
58 | + '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'), |
|
59 | + 'type' => 'textbox', |
|
60 | + ], [ |
|
61 | + 'label' => esc_html__('Schema', 'site-reviews'), |
|
62 | + 'name' => 'schema', |
|
63 | + 'options' => [ |
|
64 | + 'true' => esc_html__('Enable rich snippets', 'site-reviews'), |
|
65 | + 'false' => esc_html__('Disable rich snippets', 'site-reviews'), |
|
66 | + ], |
|
67 | + 'tooltip' => __('Rich snippets are disabled by default.', 'site-reviews'), |
|
68 | + 'type' => 'listbox', |
|
69 | + ], [ |
|
70 | + 'label' => esc_html__('Classes', 'site-reviews'), |
|
71 | + 'name' => 'class', |
|
72 | + 'tooltip' => __('Add custom CSS classes to the shortcode.', 'site-reviews'), |
|
73 | + 'type' => 'textbox', |
|
74 | + ], [ |
|
75 | + 'columns' => 2, |
|
76 | + 'items' => $this->getHideOptions(), |
|
77 | + 'label' => esc_html__('Hide', 'site-reviews'), |
|
78 | + 'layout' => 'grid', |
|
79 | + 'spacing' => 5, |
|
80 | + 'type' => 'container', |
|
81 | + ], [ |
|
82 | + 'hidden' => true, |
|
83 | + 'name' => 'id', |
|
84 | + 'type' => 'textbox', |
|
85 | + ], ]; |
|
86 | + } |
|
87 | 87 | } |
@@ -10,71 +10,71 @@ |
||
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 | - 'label' => esc_html__('Display', 'site-reviews'), |
|
22 | + 'label' => esc_html__( 'Display', 'site-reviews' ), |
|
23 | 23 | 'maxLength' => 5, |
24 | 24 | 'name' => 'display', |
25 | 25 | 'size' => 3, |
26 | 26 | 'text' => '10', |
27 | - 'tooltip' => __('How many reviews would you like to display (default: 10)?', 'site-reviews'), |
|
27 | + 'tooltip' => __( 'How many reviews would you like to display (default: 10)?', 'site-reviews' ), |
|
28 | 28 | 'type' => 'textbox', |
29 | 29 | ], [ |
30 | - 'label' => esc_html__('Rating', 'site-reviews'), |
|
30 | + 'label' => esc_html__( 'Rating', 'site-reviews' ), |
|
31 | 31 | 'name' => 'rating', |
32 | 32 | 'options' => [ |
33 | - '5' => esc_html(sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5)), |
|
34 | - '4' => esc_html(sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4)), |
|
35 | - '3' => esc_html(sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3)), |
|
36 | - '2' => esc_html(sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2)), |
|
37 | - '1' => esc_html(sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1)), |
|
38 | - '0' => esc_html(__('Unrated', 'site-reviews')), |
|
33 | + '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ) ), |
|
34 | + '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ) ), |
|
35 | + '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ) ), |
|
36 | + '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ) ), |
|
37 | + '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ) ), |
|
38 | + '0' => esc_html( __( 'Unrated', 'site-reviews' ) ), |
|
39 | 39 | ], |
40 | - 'tooltip' => __('What is the minimum rating to display (default: 1 star)?', 'site-reviews'), |
|
40 | + 'tooltip' => __( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ), |
|
41 | 41 | 'type' => 'listbox', |
42 | 42 | ], [ |
43 | - 'label' => esc_html__('Pagination', 'site-reviews'), |
|
43 | + 'label' => esc_html__( 'Pagination', 'site-reviews' ), |
|
44 | 44 | 'name' => 'pagination', |
45 | 45 | 'options' => [ |
46 | - 'true' => esc_html__('Enable', 'site-reviews'), |
|
47 | - 'ajax' => esc_html__('Enable (using ajax)', 'site-reviews'), |
|
48 | - 'false' => esc_html__('Disable', 'site-reviews'), |
|
46 | + 'true' => esc_html__( 'Enable', 'site-reviews' ), |
|
47 | + 'ajax' => esc_html__( 'Enable (using ajax)', 'site-reviews' ), |
|
48 | + 'false' => esc_html__( 'Disable', 'site-reviews' ), |
|
49 | 49 | ], |
50 | - 'tooltip' => __('When using pagination this shortcode can only be used once on a page. (default: disable)', 'site-reviews'), |
|
50 | + 'tooltip' => __( 'When using pagination this shortcode can only be used once on a page. (default: disable)', 'site-reviews' ), |
|
51 | 51 | 'type' => 'listbox', |
52 | 52 | ], |
53 | - $this->getTypes(__('Which type of review would you like to display?', 'site-reviews')), |
|
54 | - $this->getCategories(__('Limit reviews to this category.', 'site-reviews')), |
|
53 | + $this->getTypes( __( 'Which type of review would you like to display?', 'site-reviews' ) ), |
|
54 | + $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' ) ), |
|
55 | 55 | [ |
56 | - 'label' => esc_html__('Assigned To', 'site-reviews'), |
|
56 | + 'label' => esc_html__( 'Assigned To', 'site-reviews' ), |
|
57 | 57 | 'name' => 'assigned_to', |
58 | - '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'), |
|
58 | + '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' ), |
|
59 | 59 | 'type' => 'textbox', |
60 | 60 | ], [ |
61 | - 'label' => esc_html__('Schema', 'site-reviews'), |
|
61 | + 'label' => esc_html__( 'Schema', 'site-reviews' ), |
|
62 | 62 | 'name' => 'schema', |
63 | 63 | 'options' => [ |
64 | - 'true' => esc_html__('Enable rich snippets', 'site-reviews'), |
|
65 | - 'false' => esc_html__('Disable rich snippets', 'site-reviews'), |
|
64 | + 'true' => esc_html__( 'Enable rich snippets', 'site-reviews' ), |
|
65 | + 'false' => esc_html__( 'Disable rich snippets', 'site-reviews' ), |
|
66 | 66 | ], |
67 | - 'tooltip' => __('Rich snippets are disabled by default.', 'site-reviews'), |
|
67 | + 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
|
68 | 68 | 'type' => 'listbox', |
69 | 69 | ], [ |
70 | - 'label' => esc_html__('Classes', 'site-reviews'), |
|
70 | + 'label' => esc_html__( 'Classes', 'site-reviews' ), |
|
71 | 71 | 'name' => 'class', |
72 | - 'tooltip' => __('Add custom CSS classes to the shortcode.', 'site-reviews'), |
|
72 | + 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
|
73 | 73 | 'type' => 'textbox', |
74 | 74 | ], [ |
75 | 75 | 'columns' => 2, |
76 | 76 | 'items' => $this->getHideOptions(), |
77 | - 'label' => esc_html__('Hide', 'site-reviews'), |
|
77 | + 'label' => esc_html__( 'Hide', 'site-reviews' ), |
|
78 | 78 | 'layout' => 'grid', |
79 | 79 | 'spacing' => 5, |
80 | 80 | 'type' => 'container', |
@@ -8,97 +8,97 @@ |
||
8 | 8 | |
9 | 9 | class WelcomeController extends Controller |
10 | 10 | { |
11 | - /** |
|
12 | - * @return array |
|
13 | - * @filter plugin_action_links_site-reviews/site-reviews.php |
|
14 | - */ |
|
15 | - public function filterActionLinks(array $links) |
|
16 | - { |
|
17 | - $links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [ |
|
18 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'), |
|
19 | - ]); |
|
20 | - return $links; |
|
21 | - } |
|
11 | + /** |
|
12 | + * @return array |
|
13 | + * @filter plugin_action_links_site-reviews/site-reviews.php |
|
14 | + */ |
|
15 | + public function filterActionLinks(array $links) |
|
16 | + { |
|
17 | + $links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [ |
|
18 | + 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'), |
|
19 | + ]); |
|
20 | + return $links; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return string |
|
25 | - * @filter admin_title |
|
26 | - */ |
|
27 | - public function filterAdminTitle($title) |
|
28 | - { |
|
29 | - return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id |
|
30 | - ? sprintf(__('Welcome to %s — WordPress', 'site-reviews'), glsr()->name) |
|
31 | - : $title; |
|
32 | - } |
|
23 | + /** |
|
24 | + * @return string |
|
25 | + * @filter admin_title |
|
26 | + */ |
|
27 | + public function filterAdminTitle($title) |
|
28 | + { |
|
29 | + return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id |
|
30 | + ? sprintf(__('Welcome to %s — WordPress', 'site-reviews'), glsr()->name) |
|
31 | + : $title; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param string $text |
|
36 | - * @return string |
|
37 | - * @filter admin_footer_text |
|
38 | - */ |
|
39 | - public function filterFooterText($text) |
|
40 | - { |
|
41 | - if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) { |
|
42 | - return $text; |
|
43 | - } |
|
44 | - $url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post'; |
|
45 | - return wp_kses_post(sprintf( |
|
46 | - __('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'), |
|
47 | - '<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">★★★★★</a>', |
|
48 | - '<a href="'.$url.'" target="_blank">wordpress.org</a>' |
|
49 | - )); |
|
50 | - } |
|
34 | + /** |
|
35 | + * @param string $text |
|
36 | + * @return string |
|
37 | + * @filter admin_footer_text |
|
38 | + */ |
|
39 | + public function filterFooterText($text) |
|
40 | + { |
|
41 | + if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) { |
|
42 | + return $text; |
|
43 | + } |
|
44 | + $url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post'; |
|
45 | + return wp_kses_post(sprintf( |
|
46 | + __('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'), |
|
47 | + '<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">★★★★★</a>', |
|
48 | + '<a href="'.$url.'" target="_blank">wordpress.org</a>' |
|
49 | + )); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param string $plugin |
|
54 | - * @param bool $isNetworkActivation |
|
55 | - * @return void |
|
56 | - * @action activated_plugin |
|
57 | - */ |
|
58 | - public function redirectOnActivation($plugin, $isNetworkActivation) |
|
59 | - { |
|
60 | - if (!$isNetworkActivation |
|
61 | - && 'cli' !== php_sapi_name() |
|
62 | - && $plugin === plugin_basename(glsr()->file)) { |
|
63 | - wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome')); |
|
64 | - exit; |
|
65 | - } |
|
66 | - } |
|
52 | + /** |
|
53 | + * @param string $plugin |
|
54 | + * @param bool $isNetworkActivation |
|
55 | + * @return void |
|
56 | + * @action activated_plugin |
|
57 | + */ |
|
58 | + public function redirectOnActivation($plugin, $isNetworkActivation) |
|
59 | + { |
|
60 | + if (!$isNetworkActivation |
|
61 | + && 'cli' !== php_sapi_name() |
|
62 | + && $plugin === plugin_basename(glsr()->file)) { |
|
63 | + wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome')); |
|
64 | + exit; |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return void |
|
70 | - * @action admin_menu |
|
71 | - */ |
|
72 | - public function registerPage() |
|
73 | - { |
|
74 | - add_submenu_page('edit.php?post_type='.Application::POST_TYPE, |
|
75 | - sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name), |
|
76 | - glsr()->name, |
|
77 | - glsr()->getPermission('welcome'), |
|
78 | - 'welcome', |
|
79 | - [$this, 'renderPage'] |
|
80 | - ); |
|
81 | - remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome'); |
|
82 | - } |
|
68 | + /** |
|
69 | + * @return void |
|
70 | + * @action admin_menu |
|
71 | + */ |
|
72 | + public function registerPage() |
|
73 | + { |
|
74 | + add_submenu_page('edit.php?post_type='.Application::POST_TYPE, |
|
75 | + sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name), |
|
76 | + glsr()->name, |
|
77 | + glsr()->getPermission('welcome'), |
|
78 | + 'welcome', |
|
79 | + [$this, 'renderPage'] |
|
80 | + ); |
|
81 | + remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome'); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return void |
|
86 | - * @see $this->registerPage() |
|
87 | - * @callback add_submenu_page |
|
88 | - */ |
|
89 | - public function renderPage() |
|
90 | - { |
|
91 | - $tabs = apply_filters('site-reviews/addon/welcome/tabs', [ |
|
92 | - 'getting-started' => __('Getting Started', 'site-reviews'), |
|
93 | - 'whatsnew' => __('What\'s New', 'site-reviews'), |
|
94 | - 'upgrade-guide' => __('Upgrade Guide', 'site-reviews'), |
|
95 | - 'support' => __('Support', 'site-reviews'), |
|
96 | - ]); |
|
97 | - glsr()->render('pages/welcome/index', [ |
|
98 | - 'data' => ['context' => []], |
|
99 | - 'http_referer' => (string) wp_get_referer(), |
|
100 | - 'tabs' => $tabs, |
|
101 | - 'template' => glsr(Template::class), |
|
102 | - ]); |
|
103 | - } |
|
84 | + /** |
|
85 | + * @return void |
|
86 | + * @see $this->registerPage() |
|
87 | + * @callback add_submenu_page |
|
88 | + */ |
|
89 | + public function renderPage() |
|
90 | + { |
|
91 | + $tabs = apply_filters('site-reviews/addon/welcome/tabs', [ |
|
92 | + 'getting-started' => __('Getting Started', 'site-reviews'), |
|
93 | + 'whatsnew' => __('What\'s New', 'site-reviews'), |
|
94 | + 'upgrade-guide' => __('Upgrade Guide', 'site-reviews'), |
|
95 | + 'support' => __('Support', 'site-reviews'), |
|
96 | + ]); |
|
97 | + glsr()->render('pages/welcome/index', [ |
|
98 | + 'data' => ['context' => []], |
|
99 | + 'http_referer' => (string) wp_get_referer(), |
|
100 | + 'tabs' => $tabs, |
|
101 | + 'template' => glsr(Template::class), |
|
102 | + ]); |
|
103 | + } |
|
104 | 104 | } |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | * @filter plugin_action_links_site-reviews/site-reviews.php |
14 | 14 | */ |
15 | - public function filterActionLinks(array $links) |
|
15 | + public function filterActionLinks( array $links ) |
|
16 | 16 | { |
17 | - $links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [ |
|
18 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'), |
|
19 | - ]); |
|
17 | + $links['welcome'] = glsr( Builder::class )->a( __( 'About', 'site-reviews' ), [ |
|
18 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=welcome' ), |
|
19 | + ] ); |
|
20 | 20 | return $links; |
21 | 21 | } |
22 | 22 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @return string |
25 | 25 | * @filter admin_title |
26 | 26 | */ |
27 | - public function filterAdminTitle($title) |
|
27 | + public function filterAdminTitle( $title ) |
|
28 | 28 | { |
29 | 29 | return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id |
30 | - ? sprintf(__('Welcome to %s — WordPress', 'site-reviews'), glsr()->name) |
|
30 | + ? sprintf( __( 'Welcome to %s — WordPress', 'site-reviews' ), glsr()->name ) |
|
31 | 31 | : $title; |
32 | 32 | } |
33 | 33 | |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | * @return string |
37 | 37 | * @filter admin_footer_text |
38 | 38 | */ |
39 | - public function filterFooterText($text) |
|
39 | + public function filterFooterText( $text ) |
|
40 | 40 | { |
41 | - if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) { |
|
41 | + if( Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id ) { |
|
42 | 42 | return $text; |
43 | 43 | } |
44 | 44 | $url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post'; |
45 | - return wp_kses_post(sprintf( |
|
46 | - __('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'), |
|
45 | + return wp_kses_post( sprintf( |
|
46 | + __( 'Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews' ), |
|
47 | 47 | '<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">★★★★★</a>', |
48 | 48 | '<a href="'.$url.'" target="_blank">wordpress.org</a>' |
49 | - )); |
|
49 | + ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * @return void |
56 | 56 | * @action activated_plugin |
57 | 57 | */ |
58 | - public function redirectOnActivation($plugin, $isNetworkActivation) |
|
58 | + public function redirectOnActivation( $plugin, $isNetworkActivation ) |
|
59 | 59 | { |
60 | - if (!$isNetworkActivation |
|
60 | + if( !$isNetworkActivation |
|
61 | 61 | && 'cli' !== php_sapi_name() |
62 | - && $plugin === plugin_basename(glsr()->file)) { |
|
63 | - wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome')); |
|
62 | + && $plugin === plugin_basename( glsr()->file ) ) { |
|
63 | + wp_safe_redirect( admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=welcome' ) ); |
|
64 | 64 | exit; |
65 | 65 | } |
66 | 66 | } |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function registerPage() |
73 | 73 | { |
74 | - add_submenu_page('edit.php?post_type='.Application::POST_TYPE, |
|
75 | - sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name), |
|
74 | + add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, |
|
75 | + sprintf( __( 'Welcome to %s', 'site-reviews' ), glsr()->name ), |
|
76 | 76 | glsr()->name, |
77 | - glsr()->getPermission('welcome'), |
|
77 | + glsr()->getPermission( 'welcome' ), |
|
78 | 78 | 'welcome', |
79 | 79 | [$this, 'renderPage'] |
80 | 80 | ); |
81 | - remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome'); |
|
81 | + remove_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, 'welcome' ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -88,17 +88,17 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function renderPage() |
90 | 90 | { |
91 | - $tabs = apply_filters('site-reviews/addon/welcome/tabs', [ |
|
92 | - 'getting-started' => __('Getting Started', 'site-reviews'), |
|
93 | - 'whatsnew' => __('What\'s New', 'site-reviews'), |
|
94 | - 'upgrade-guide' => __('Upgrade Guide', 'site-reviews'), |
|
95 | - 'support' => __('Support', 'site-reviews'), |
|
96 | - ]); |
|
97 | - glsr()->render('pages/welcome/index', [ |
|
91 | + $tabs = apply_filters( 'site-reviews/addon/welcome/tabs', [ |
|
92 | + 'getting-started' => __( 'Getting Started', 'site-reviews' ), |
|
93 | + 'whatsnew' => __( 'What\'s New', 'site-reviews' ), |
|
94 | + 'upgrade-guide' => __( 'Upgrade Guide', 'site-reviews' ), |
|
95 | + 'support' => __( 'Support', 'site-reviews' ), |
|
96 | + ] ); |
|
97 | + glsr()->render( 'pages/welcome/index', [ |
|
98 | 98 | 'data' => ['context' => []], |
99 | - 'http_referer' => (string) wp_get_referer(), |
|
99 | + 'http_referer' => (string)wp_get_referer(), |
|
100 | 100 | 'tabs' => $tabs, |
101 | - 'template' => glsr(Template::class), |
|
102 | - ]); |
|
101 | + 'template' => glsr( Template::class ), |
|
102 | + ] ); |
|
103 | 103 | } |
104 | 104 | } |
@@ -8,124 +8,124 @@ |
||
8 | 8 | |
9 | 9 | class NoticeController extends Controller |
10 | 10 | { |
11 | - const USER_META_KEY = '_glsr_notices'; |
|
11 | + const USER_META_KEY = '_glsr_notices'; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $dismissValuesMap; |
|
13 | + /** |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $dismissValuesMap; |
|
17 | 17 | |
18 | - public function __construct() |
|
19 | - { |
|
20 | - $this->dismissValuesMap = [ |
|
21 | - 'rebusify' => glsr()->version('major'), |
|
22 | - 'welcome' => glsr()->version('minor'), |
|
23 | - ]; |
|
24 | - } |
|
18 | + public function __construct() |
|
19 | + { |
|
20 | + $this->dismissValuesMap = [ |
|
21 | + 'rebusify' => glsr()->version('major'), |
|
22 | + 'welcome' => glsr()->version('minor'), |
|
23 | + ]; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @return void |
|
28 | - * @action admin_notices |
|
29 | - */ |
|
30 | - public function filterAdminNotices() |
|
31 | - { |
|
32 | - $screen = glsr_current_screen(); |
|
33 | - $this->renderWelcomeNotice($screen->post_type); |
|
34 | - $this->renderRebusifyNotice($screen->post_type); |
|
35 | - $this->renderAddonsNotice($screen->id); |
|
36 | - } |
|
26 | + /** |
|
27 | + * @return void |
|
28 | + * @action admin_notices |
|
29 | + */ |
|
30 | + public function filterAdminNotices() |
|
31 | + { |
|
32 | + $screen = glsr_current_screen(); |
|
33 | + $this->renderWelcomeNotice($screen->post_type); |
|
34 | + $this->renderRebusifyNotice($screen->post_type); |
|
35 | + $this->renderAddonsNotice($screen->id); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - public function routerDismissNotice(array $request) |
|
42 | - { |
|
43 | - if ($key = Arr::get($request, 'notice')) { |
|
44 | - $this->dismissNotice($key); |
|
45 | - } |
|
46 | - } |
|
38 | + /** |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + public function routerDismissNotice(array $request) |
|
42 | + { |
|
43 | + if ($key = Arr::get($request, 'notice')) { |
|
44 | + $this->dismissNotice($key); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param string $key |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - protected function dismissNotice($key) |
|
53 | - { |
|
54 | - $this->setUserMeta($key, $this->getVersionFor($key)); |
|
55 | - } |
|
48 | + /** |
|
49 | + * @param string $key |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + protected function dismissNotice($key) |
|
53 | + { |
|
54 | + $this->setUserMeta($key, $this->getVersionFor($key)); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param string $key |
|
59 | - * @param mixed $fallback |
|
60 | - * @return mixed |
|
61 | - */ |
|
62 | - protected function getUserMeta($key, $fallback) |
|
63 | - { |
|
64 | - $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
65 | - return Arr::get($meta, $key, $fallback); |
|
66 | - } |
|
57 | + /** |
|
58 | + * @param string $key |
|
59 | + * @param mixed $fallback |
|
60 | + * @return mixed |
|
61 | + */ |
|
62 | + protected function getUserMeta($key, $fallback) |
|
63 | + { |
|
64 | + $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
65 | + return Arr::get($meta, $key, $fallback); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param string $noticeKey |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - protected function getVersionFor($noticeKey) |
|
73 | - { |
|
74 | - return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major')); |
|
75 | - } |
|
68 | + /** |
|
69 | + * @param string $noticeKey |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + protected function getVersionFor($noticeKey) |
|
73 | + { |
|
74 | + return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major')); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @param string $screenId |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - protected function renderAddonsNotice($screenId) |
|
82 | - { |
|
83 | - if (Application::POST_TYPE.'_page_addons' == $screenId) { |
|
84 | - echo glsr()->render('partials/notices/addons'); |
|
85 | - } |
|
86 | - } |
|
77 | + /** |
|
78 | + * @param string $screenId |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + protected function renderAddonsNotice($screenId) |
|
82 | + { |
|
83 | + if (Application::POST_TYPE.'_page_addons' == $screenId) { |
|
84 | + echo glsr()->render('partials/notices/addons'); |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @param string $screenPostType |
|
90 | - * @return void |
|
91 | - */ |
|
92 | - protected function renderRebusifyNotice($screenPostType) |
|
93 | - { |
|
94 | - if (Application::POST_TYPE == $screenPostType |
|
95 | - && version_compare($this->getVersionFor('rebusify'), $this->getUserMeta('rebusify', 0), '>') |
|
96 | - && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) { |
|
97 | - echo glsr()->render('partials/notices/rebusify'); |
|
98 | - } |
|
99 | - } |
|
88 | + /** |
|
89 | + * @param string $screenPostType |
|
90 | + * @return void |
|
91 | + */ |
|
92 | + protected function renderRebusifyNotice($screenPostType) |
|
93 | + { |
|
94 | + if (Application::POST_TYPE == $screenPostType |
|
95 | + && version_compare($this->getVersionFor('rebusify'), $this->getUserMeta('rebusify', 0), '>') |
|
96 | + && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) { |
|
97 | + echo glsr()->render('partials/notices/rebusify'); |
|
98 | + } |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @param string $screenPostType |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - protected function renderWelcomeNotice($screenPostType) |
|
106 | - { |
|
107 | - if (Application::POST_TYPE == $screenPostType |
|
108 | - && version_compare($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0), '>')) { |
|
109 | - $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from') |
|
110 | - ? __('Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews') |
|
111 | - : __('Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews'); |
|
112 | - echo glsr()->render('partials/notices/welcome', [ |
|
113 | - 'text' => sprintf($welcomeText, glsr()->version), |
|
114 | - ]); |
|
115 | - } |
|
116 | - } |
|
101 | + /** |
|
102 | + * @param string $screenPostType |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + protected function renderWelcomeNotice($screenPostType) |
|
106 | + { |
|
107 | + if (Application::POST_TYPE == $screenPostType |
|
108 | + && version_compare($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0), '>')) { |
|
109 | + $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from') |
|
110 | + ? __('Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews') |
|
111 | + : __('Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews'); |
|
112 | + echo glsr()->render('partials/notices/welcome', [ |
|
113 | + 'text' => sprintf($welcomeText, glsr()->version), |
|
114 | + ]); |
|
115 | + } |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * @param string $key |
|
120 | - * @param mixed $fallback |
|
121 | - * @return mixed |
|
122 | - */ |
|
123 | - protected function setUserMeta($key, $value) |
|
124 | - { |
|
125 | - $userId = get_current_user_id(); |
|
126 | - $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
127 | - $meta = array_filter(wp_parse_args($meta, [])); |
|
128 | - $meta[$key] = $value; |
|
129 | - update_user_meta($userId, static::USER_META_KEY, $meta); |
|
130 | - } |
|
118 | + /** |
|
119 | + * @param string $key |
|
120 | + * @param mixed $fallback |
|
121 | + * @return mixed |
|
122 | + */ |
|
123 | + protected function setUserMeta($key, $value) |
|
124 | + { |
|
125 | + $userId = get_current_user_id(); |
|
126 | + $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
127 | + $meta = array_filter(wp_parse_args($meta, [])); |
|
128 | + $meta[$key] = $value; |
|
129 | + update_user_meta($userId, static::USER_META_KEY, $meta); |
|
130 | + } |
|
131 | 131 | } |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | public function __construct() |
19 | 19 | { |
20 | 20 | $this->dismissValuesMap = [ |
21 | - 'rebusify' => glsr()->version('major'), |
|
22 | - 'welcome' => glsr()->version('minor'), |
|
21 | + 'rebusify' => glsr()->version( 'major' ), |
|
22 | + 'welcome' => glsr()->version( 'minor' ), |
|
23 | 23 | ]; |
24 | 24 | } |
25 | 25 | |
@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | public function filterAdminNotices() |
31 | 31 | { |
32 | 32 | $screen = glsr_current_screen(); |
33 | - $this->renderWelcomeNotice($screen->post_type); |
|
34 | - $this->renderRebusifyNotice($screen->post_type); |
|
35 | - $this->renderAddonsNotice($screen->id); |
|
33 | + $this->renderWelcomeNotice( $screen->post_type ); |
|
34 | + $this->renderRebusifyNotice( $screen->post_type ); |
|
35 | + $this->renderAddonsNotice( $screen->id ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @return void |
40 | 40 | */ |
41 | - public function routerDismissNotice(array $request) |
|
41 | + public function routerDismissNotice( array $request ) |
|
42 | 42 | { |
43 | - if ($key = Arr::get($request, 'notice')) { |
|
44 | - $this->dismissNotice($key); |
|
43 | + if( $key = Arr::get( $request, 'notice' ) ) { |
|
44 | + $this->dismissNotice( $key ); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @param string $key |
50 | 50 | * @return void |
51 | 51 | */ |
52 | - protected function dismissNotice($key) |
|
52 | + protected function dismissNotice( $key ) |
|
53 | 53 | { |
54 | - $this->setUserMeta($key, $this->getVersionFor($key)); |
|
54 | + $this->setUserMeta( $key, $this->getVersionFor( $key ) ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -59,29 +59,29 @@ discard block |
||
59 | 59 | * @param mixed $fallback |
60 | 60 | * @return mixed |
61 | 61 | */ |
62 | - protected function getUserMeta($key, $fallback) |
|
62 | + protected function getUserMeta( $key, $fallback ) |
|
63 | 63 | { |
64 | - $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
65 | - return Arr::get($meta, $key, $fallback); |
|
64 | + $meta = get_user_meta( get_current_user_id(), static::USER_META_KEY, true ); |
|
65 | + return Arr::get( $meta, $key, $fallback ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @param string $noticeKey |
70 | 70 | * @return string |
71 | 71 | */ |
72 | - protected function getVersionFor($noticeKey) |
|
72 | + protected function getVersionFor( $noticeKey ) |
|
73 | 73 | { |
74 | - return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major')); |
|
74 | + return Arr::get( $this->dismissValuesMap, $noticeKey, glsr()->version( 'major' ) ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @param string $screenId |
79 | 79 | * @return void |
80 | 80 | */ |
81 | - protected function renderAddonsNotice($screenId) |
|
81 | + protected function renderAddonsNotice( $screenId ) |
|
82 | 82 | { |
83 | - if (Application::POST_TYPE.'_page_addons' == $screenId) { |
|
84 | - echo glsr()->render('partials/notices/addons'); |
|
83 | + if( Application::POST_TYPE.'_page_addons' == $screenId ) { |
|
84 | + echo glsr()->render( 'partials/notices/addons' ); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | * @param string $screenPostType |
90 | 90 | * @return void |
91 | 91 | */ |
92 | - protected function renderRebusifyNotice($screenPostType) |
|
92 | + protected function renderRebusifyNotice( $screenPostType ) |
|
93 | 93 | { |
94 | - if (Application::POST_TYPE == $screenPostType |
|
95 | - && version_compare($this->getVersionFor('rebusify'), $this->getUserMeta('rebusify', 0), '>') |
|
96 | - && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) { |
|
97 | - echo glsr()->render('partials/notices/rebusify'); |
|
94 | + if( Application::POST_TYPE == $screenPostType |
|
95 | + && version_compare( $this->getVersionFor( 'rebusify' ), $this->getUserMeta( 'rebusify', 0 ), '>' ) |
|
96 | + && !glsr( OptionManager::class )->getBool( 'settings.general.rebusify' ) ) { |
|
97 | + echo glsr()->render( 'partials/notices/rebusify' ); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | * @param string $screenPostType |
103 | 103 | * @return void |
104 | 104 | */ |
105 | - protected function renderWelcomeNotice($screenPostType) |
|
105 | + protected function renderWelcomeNotice( $screenPostType ) |
|
106 | 106 | { |
107 | - if (Application::POST_TYPE == $screenPostType |
|
108 | - && version_compare($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0), '>')) { |
|
109 | - $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from') |
|
110 | - ? __('Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews') |
|
111 | - : __('Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews'); |
|
112 | - echo glsr()->render('partials/notices/welcome', [ |
|
113 | - 'text' => sprintf($welcomeText, glsr()->version), |
|
114 | - ]); |
|
107 | + if( Application::POST_TYPE == $screenPostType |
|
108 | + && version_compare( $this->getVersionFor( 'welcome' ), $this->getUserMeta( 'welcome', 0 ), '>' ) ) { |
|
109 | + $welcomeText = '0.0.0' == glsr( OptionManager::class )->get( 'version_upgraded_from' ) |
|
110 | + ? __( 'Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews' ) |
|
111 | + : __( 'Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews' ); |
|
112 | + echo glsr()->render( 'partials/notices/welcome', [ |
|
113 | + 'text' => sprintf( $welcomeText, glsr()->version ), |
|
114 | + ] ); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | * @param mixed $fallback |
121 | 121 | * @return mixed |
122 | 122 | */ |
123 | - protected function setUserMeta($key, $value) |
|
123 | + protected function setUserMeta( $key, $value ) |
|
124 | 124 | { |
125 | 125 | $userId = get_current_user_id(); |
126 | - $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
127 | - $meta = array_filter(wp_parse_args($meta, [])); |
|
126 | + $meta = (array)get_user_meta( $userId, static::USER_META_KEY, true ); |
|
127 | + $meta = array_filter( wp_parse_args( $meta, [] ) ); |
|
128 | 128 | $meta[$key] = $value; |
129 | - update_user_meta($userId, static::USER_META_KEY, $meta); |
|
129 | + update_user_meta( $userId, static::USER_META_KEY, $meta ); |
|
130 | 130 | } |
131 | 131 | } |
@@ -14,189 +14,189 @@ |
||
14 | 14 | |
15 | 15 | class MenuController extends Controller |
16 | 16 | { |
17 | - /** |
|
18 | - * @return void |
|
19 | - * @action admin_menu |
|
20 | - */ |
|
21 | - public function registerMenuCount() |
|
22 | - { |
|
23 | - global $menu, $typenow; |
|
24 | - foreach ($menu as $key => $value) { |
|
25 | - if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) { |
|
26 | - continue; |
|
27 | - } |
|
28 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
29 | - $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [ |
|
30 | - 'class' => 'unapproved-count', |
|
31 | - ]); |
|
32 | - $awaitingModeration = glsr(Builder::class)->span($pendingCount, [ |
|
33 | - 'class' => 'awaiting-mod count-'.$postCount->pending, |
|
34 | - ]); |
|
35 | - $menu[$key][0].= ' '.$awaitingModeration; |
|
36 | - if (Application::POST_TYPE === $typenow) { |
|
37 | - $menu[$key][4].= ' current'; |
|
38 | - } |
|
39 | - break; |
|
40 | - } |
|
41 | - } |
|
17 | + /** |
|
18 | + * @return void |
|
19 | + * @action admin_menu |
|
20 | + */ |
|
21 | + public function registerMenuCount() |
|
22 | + { |
|
23 | + global $menu, $typenow; |
|
24 | + foreach ($menu as $key => $value) { |
|
25 | + if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) { |
|
26 | + continue; |
|
27 | + } |
|
28 | + $postCount = wp_count_posts(Application::POST_TYPE); |
|
29 | + $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [ |
|
30 | + 'class' => 'unapproved-count', |
|
31 | + ]); |
|
32 | + $awaitingModeration = glsr(Builder::class)->span($pendingCount, [ |
|
33 | + 'class' => 'awaiting-mod count-'.$postCount->pending, |
|
34 | + ]); |
|
35 | + $menu[$key][0].= ' '.$awaitingModeration; |
|
36 | + if (Application::POST_TYPE === $typenow) { |
|
37 | + $menu[$key][4].= ' current'; |
|
38 | + } |
|
39 | + break; |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return void |
|
45 | - * @action admin_menu |
|
46 | - */ |
|
47 | - public function registerSubMenus() |
|
48 | - { |
|
49 | - $pages = $this->parseWithFilter('submenu/pages', [ |
|
50 | - 'settings' => __('Settings', 'site-reviews'), |
|
51 | - 'tools' => __('Tools', 'site-reviews'), |
|
52 | - 'addons' => __('Add-ons', 'site-reviews'), |
|
53 | - 'documentation' => __('Help', 'site-reviews'), |
|
54 | - ]); |
|
55 | - foreach ($pages as $slug => $title) { |
|
56 | - $method = Helper::buildMethodName('render-'.$slug.'-menu'); |
|
57 | - $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug); |
|
58 | - if (!is_callable($callback)) { |
|
59 | - continue; |
|
60 | - } |
|
61 | - add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback); |
|
62 | - } |
|
63 | - } |
|
43 | + /** |
|
44 | + * @return void |
|
45 | + * @action admin_menu |
|
46 | + */ |
|
47 | + public function registerSubMenus() |
|
48 | + { |
|
49 | + $pages = $this->parseWithFilter('submenu/pages', [ |
|
50 | + 'settings' => __('Settings', 'site-reviews'), |
|
51 | + 'tools' => __('Tools', 'site-reviews'), |
|
52 | + 'addons' => __('Add-ons', 'site-reviews'), |
|
53 | + 'documentation' => __('Help', 'site-reviews'), |
|
54 | + ]); |
|
55 | + foreach ($pages as $slug => $title) { |
|
56 | + $method = Helper::buildMethodName('render-'.$slug.'-menu'); |
|
57 | + $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug); |
|
58 | + if (!is_callable($callback)) { |
|
59 | + continue; |
|
60 | + } |
|
61 | + add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback); |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return void |
|
67 | - * @see $this->registerSubMenus() |
|
68 | - * @callback add_submenu_page |
|
69 | - */ |
|
70 | - public function renderAddonsMenu() |
|
71 | - { |
|
72 | - $this->renderPage('addons', [ |
|
73 | - 'template' => glsr(Template::class), |
|
74 | - ]); |
|
75 | - } |
|
65 | + /** |
|
66 | + * @return void |
|
67 | + * @see $this->registerSubMenus() |
|
68 | + * @callback add_submenu_page |
|
69 | + */ |
|
70 | + public function renderAddonsMenu() |
|
71 | + { |
|
72 | + $this->renderPage('addons', [ |
|
73 | + 'template' => glsr(Template::class), |
|
74 | + ]); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return void |
|
79 | - * @see $this->registerSubMenus() |
|
80 | - * @callback add_submenu_page |
|
81 | - */ |
|
82 | - public function renderDocumentationMenu() |
|
83 | - { |
|
84 | - $tabs = $this->parseWithFilter('documentation/tabs', [ |
|
85 | - 'support' => __('Support', 'site-reviews'), |
|
86 | - 'faq' => __('FAQ', 'site-reviews'), |
|
87 | - 'shortcodes' => __('Shortcodes', 'site-reviews'), |
|
88 | - 'hooks' => __('Hooks', 'site-reviews'), |
|
89 | - 'functions' => __('Functions', 'site-reviews'), |
|
90 | - 'addons' => __('Addons', 'site-reviews'), |
|
91 | - ]); |
|
92 | - $addons = apply_filters('site-reviews/addon/documentation', []); |
|
93 | - ksort($addons); |
|
94 | - if (empty($addons)) { |
|
95 | - unset($tabs['addons']); |
|
96 | - } |
|
97 | - $this->renderPage('documentation', [ |
|
98 | - 'addons' => $addons, |
|
99 | - 'tabs' => $tabs, |
|
100 | - ]); |
|
101 | - } |
|
77 | + /** |
|
78 | + * @return void |
|
79 | + * @see $this->registerSubMenus() |
|
80 | + * @callback add_submenu_page |
|
81 | + */ |
|
82 | + public function renderDocumentationMenu() |
|
83 | + { |
|
84 | + $tabs = $this->parseWithFilter('documentation/tabs', [ |
|
85 | + 'support' => __('Support', 'site-reviews'), |
|
86 | + 'faq' => __('FAQ', 'site-reviews'), |
|
87 | + 'shortcodes' => __('Shortcodes', 'site-reviews'), |
|
88 | + 'hooks' => __('Hooks', 'site-reviews'), |
|
89 | + 'functions' => __('Functions', 'site-reviews'), |
|
90 | + 'addons' => __('Addons', 'site-reviews'), |
|
91 | + ]); |
|
92 | + $addons = apply_filters('site-reviews/addon/documentation', []); |
|
93 | + ksort($addons); |
|
94 | + if (empty($addons)) { |
|
95 | + unset($tabs['addons']); |
|
96 | + } |
|
97 | + $this->renderPage('documentation', [ |
|
98 | + 'addons' => $addons, |
|
99 | + 'tabs' => $tabs, |
|
100 | + ]); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @return void |
|
105 | - * @see $this->registerSubMenus() |
|
106 | - * @callback add_submenu_page |
|
107 | - */ |
|
108 | - public function renderSettingsMenu() |
|
109 | - { |
|
110 | - $tabs = $this->parseWithFilter('settings/tabs', [ |
|
111 | - 'general' => __('General', 'site-reviews'), |
|
112 | - 'reviews' => __('Reviews', 'site-reviews'), |
|
113 | - 'submissions' => __('Submissions', 'site-reviews'), |
|
114 | - 'schema' => __('Schema', 'site-reviews'), |
|
115 | - 'translations' => __('Translations', 'site-reviews'), |
|
116 | - 'addons' => __('Addons', 'site-reviews'), |
|
117 | - 'licenses' => __('Licenses', 'site-reviews'), |
|
118 | - ]); |
|
119 | - if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) { |
|
120 | - unset($tabs['addons']); |
|
121 | - } |
|
122 | - if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) { |
|
123 | - unset($tabs['licenses']); |
|
124 | - } |
|
125 | - $this->renderPage('settings', [ |
|
126 | - 'settings' => glsr(Settings::class), |
|
127 | - 'tabs' => $tabs, |
|
128 | - ]); |
|
129 | - } |
|
103 | + /** |
|
104 | + * @return void |
|
105 | + * @see $this->registerSubMenus() |
|
106 | + * @callback add_submenu_page |
|
107 | + */ |
|
108 | + public function renderSettingsMenu() |
|
109 | + { |
|
110 | + $tabs = $this->parseWithFilter('settings/tabs', [ |
|
111 | + 'general' => __('General', 'site-reviews'), |
|
112 | + 'reviews' => __('Reviews', 'site-reviews'), |
|
113 | + 'submissions' => __('Submissions', 'site-reviews'), |
|
114 | + 'schema' => __('Schema', 'site-reviews'), |
|
115 | + 'translations' => __('Translations', 'site-reviews'), |
|
116 | + 'addons' => __('Addons', 'site-reviews'), |
|
117 | + 'licenses' => __('Licenses', 'site-reviews'), |
|
118 | + ]); |
|
119 | + if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) { |
|
120 | + unset($tabs['addons']); |
|
121 | + } |
|
122 | + if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) { |
|
123 | + unset($tabs['licenses']); |
|
124 | + } |
|
125 | + $this->renderPage('settings', [ |
|
126 | + 'settings' => glsr(Settings::class), |
|
127 | + 'tabs' => $tabs, |
|
128 | + ]); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * @return void |
|
133 | - * @see $this->registerSubMenus() |
|
134 | - * @callback add_submenu_page |
|
135 | - */ |
|
136 | - public function renderToolsMenu() |
|
137 | - { |
|
138 | - $tabs = $this->parseWithFilter('tools/tabs', [ |
|
139 | - 'general' => __('General', 'site-reviews'), |
|
140 | - 'sync' => __('Sync Reviews', 'site-reviews'), |
|
141 | - 'console' => __('Console', 'site-reviews'), |
|
142 | - 'system-info' => __('System Info', 'site-reviews'), |
|
143 | - ]); |
|
144 | - if (!apply_filters('site-reviews/addon/sync/enable', false)) { |
|
145 | - unset($tabs['sync']); |
|
146 | - } |
|
147 | - $this->renderPage('tools', [ |
|
148 | - 'data' => [ |
|
149 | - 'context' => [ |
|
150 | - 'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE), |
|
151 | - 'console' => strval(glsr(Console::class)), |
|
152 | - 'id' => Application::ID, |
|
153 | - 'system' => strval(glsr(System::class)), |
|
154 | - ], |
|
155 | - 'services' => apply_filters('site-reviews/addon/sync/services', []), |
|
156 | - ], |
|
157 | - 'tabs' => $tabs, |
|
158 | - 'template' => glsr(Template::class), |
|
159 | - ]); |
|
160 | - } |
|
131 | + /** |
|
132 | + * @return void |
|
133 | + * @see $this->registerSubMenus() |
|
134 | + * @callback add_submenu_page |
|
135 | + */ |
|
136 | + public function renderToolsMenu() |
|
137 | + { |
|
138 | + $tabs = $this->parseWithFilter('tools/tabs', [ |
|
139 | + 'general' => __('General', 'site-reviews'), |
|
140 | + 'sync' => __('Sync Reviews', 'site-reviews'), |
|
141 | + 'console' => __('Console', 'site-reviews'), |
|
142 | + 'system-info' => __('System Info', 'site-reviews'), |
|
143 | + ]); |
|
144 | + if (!apply_filters('site-reviews/addon/sync/enable', false)) { |
|
145 | + unset($tabs['sync']); |
|
146 | + } |
|
147 | + $this->renderPage('tools', [ |
|
148 | + 'data' => [ |
|
149 | + 'context' => [ |
|
150 | + 'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE), |
|
151 | + 'console' => strval(glsr(Console::class)), |
|
152 | + 'id' => Application::ID, |
|
153 | + 'system' => strval(glsr(System::class)), |
|
154 | + ], |
|
155 | + 'services' => apply_filters('site-reviews/addon/sync/services', []), |
|
156 | + ], |
|
157 | + 'tabs' => $tabs, |
|
158 | + 'template' => glsr(Template::class), |
|
159 | + ]); |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * @return void |
|
164 | - * @action admin_init |
|
165 | - */ |
|
166 | - public function setCustomPermissions() |
|
167 | - { |
|
168 | - foreach (wp_roles()->roles as $role => $value) { |
|
169 | - wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE); |
|
170 | - } |
|
171 | - } |
|
162 | + /** |
|
163 | + * @return void |
|
164 | + * @action admin_init |
|
165 | + */ |
|
166 | + public function setCustomPermissions() |
|
167 | + { |
|
168 | + foreach (wp_roles()->roles as $role => $value) { |
|
169 | + wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE); |
|
170 | + } |
|
171 | + } |
|
172 | 172 | |
173 | - /** |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - protected function getNotices() |
|
177 | - { |
|
178 | - return glsr(Builder::class)->div(glsr(Notice::class)->get(), [ |
|
179 | - 'id' => 'glsr-notices', |
|
180 | - ]); |
|
181 | - } |
|
173 | + /** |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + protected function getNotices() |
|
177 | + { |
|
178 | + return glsr(Builder::class)->div(glsr(Notice::class)->get(), [ |
|
179 | + 'id' => 'glsr-notices', |
|
180 | + ]); |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * @param string $hookSuffix |
|
185 | - * @return array |
|
186 | - */ |
|
187 | - protected function parseWithFilter($hookSuffix, array $args = []) |
|
188 | - { |
|
189 | - return apply_filters('site-reviews/addon/'.$hookSuffix, $args); |
|
190 | - } |
|
183 | + /** |
|
184 | + * @param string $hookSuffix |
|
185 | + * @return array |
|
186 | + */ |
|
187 | + protected function parseWithFilter($hookSuffix, array $args = []) |
|
188 | + { |
|
189 | + return apply_filters('site-reviews/addon/'.$hookSuffix, $args); |
|
190 | + } |
|
191 | 191 | |
192 | - /** |
|
193 | - * @param string $page |
|
194 | - * @return void |
|
195 | - */ |
|
196 | - protected function renderPage($page, array $data = []) |
|
197 | - { |
|
198 | - $data['http_referer'] = (string) wp_get_referer(); |
|
199 | - $data['notices'] = $this->getNotices(); |
|
200 | - glsr()->render('pages/'.$page.'/index', $data); |
|
201 | - } |
|
192 | + /** |
|
193 | + * @param string $page |
|
194 | + * @return void |
|
195 | + */ |
|
196 | + protected function renderPage($page, array $data = []) |
|
197 | + { |
|
198 | + $data['http_referer'] = (string) wp_get_referer(); |
|
199 | + $data['notices'] = $this->getNotices(); |
|
200 | + glsr()->render('pages/'.$page.'/index', $data); |
|
201 | + } |
|
202 | 202 | } |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | public function registerMenuCount() |
22 | 22 | { |
23 | 23 | global $menu, $typenow; |
24 | - foreach ($menu as $key => $value) { |
|
25 | - if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) { |
|
24 | + foreach( $menu as $key => $value ) { |
|
25 | + if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE ) { |
|
26 | 26 | continue; |
27 | 27 | } |
28 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
29 | - $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [ |
|
28 | + $postCount = wp_count_posts( Application::POST_TYPE ); |
|
29 | + $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
|
30 | 30 | 'class' => 'unapproved-count', |
31 | - ]); |
|
32 | - $awaitingModeration = glsr(Builder::class)->span($pendingCount, [ |
|
31 | + ] ); |
|
32 | + $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [ |
|
33 | 33 | 'class' => 'awaiting-mod count-'.$postCount->pending, |
34 | - ]); |
|
35 | - $menu[$key][0].= ' '.$awaitingModeration; |
|
36 | - if (Application::POST_TYPE === $typenow) { |
|
37 | - $menu[$key][4].= ' current'; |
|
34 | + ] ); |
|
35 | + $menu[$key][0] .= ' '.$awaitingModeration; |
|
36 | + if( Application::POST_TYPE === $typenow ) { |
|
37 | + $menu[$key][4] .= ' current'; |
|
38 | 38 | } |
39 | 39 | break; |
40 | 40 | } |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function registerSubMenus() |
48 | 48 | { |
49 | - $pages = $this->parseWithFilter('submenu/pages', [ |
|
50 | - 'settings' => __('Settings', 'site-reviews'), |
|
51 | - 'tools' => __('Tools', 'site-reviews'), |
|
52 | - 'addons' => __('Add-ons', 'site-reviews'), |
|
53 | - 'documentation' => __('Help', 'site-reviews'), |
|
54 | - ]); |
|
55 | - foreach ($pages as $slug => $title) { |
|
56 | - $method = Helper::buildMethodName('render-'.$slug.'-menu'); |
|
57 | - $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug); |
|
58 | - if (!is_callable($callback)) { |
|
49 | + $pages = $this->parseWithFilter( 'submenu/pages', [ |
|
50 | + 'settings' => __( 'Settings', 'site-reviews' ), |
|
51 | + 'tools' => __( 'Tools', 'site-reviews' ), |
|
52 | + 'addons' => __( 'Add-ons', 'site-reviews' ), |
|
53 | + 'documentation' => __( 'Help', 'site-reviews' ), |
|
54 | + ] ); |
|
55 | + foreach( $pages as $slug => $title ) { |
|
56 | + $method = Helper::buildMethodName( 'render-'.$slug.'-menu' ); |
|
57 | + $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
|
58 | + if( !is_callable( $callback ) ) { |
|
59 | 59 | continue; |
60 | 60 | } |
61 | - add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback); |
|
61 | + add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback ); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function renderAddonsMenu() |
71 | 71 | { |
72 | - $this->renderPage('addons', [ |
|
73 | - 'template' => glsr(Template::class), |
|
74 | - ]); |
|
72 | + $this->renderPage( 'addons', [ |
|
73 | + 'template' => glsr( Template::class ), |
|
74 | + ] ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -81,23 +81,23 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function renderDocumentationMenu() |
83 | 83 | { |
84 | - $tabs = $this->parseWithFilter('documentation/tabs', [ |
|
85 | - 'support' => __('Support', 'site-reviews'), |
|
86 | - 'faq' => __('FAQ', 'site-reviews'), |
|
87 | - 'shortcodes' => __('Shortcodes', 'site-reviews'), |
|
88 | - 'hooks' => __('Hooks', 'site-reviews'), |
|
89 | - 'functions' => __('Functions', 'site-reviews'), |
|
90 | - 'addons' => __('Addons', 'site-reviews'), |
|
91 | - ]); |
|
92 | - $addons = apply_filters('site-reviews/addon/documentation', []); |
|
93 | - ksort($addons); |
|
94 | - if (empty($addons)) { |
|
84 | + $tabs = $this->parseWithFilter( 'documentation/tabs', [ |
|
85 | + 'support' => __( 'Support', 'site-reviews' ), |
|
86 | + 'faq' => __( 'FAQ', 'site-reviews' ), |
|
87 | + 'shortcodes' => __( 'Shortcodes', 'site-reviews' ), |
|
88 | + 'hooks' => __( 'Hooks', 'site-reviews' ), |
|
89 | + 'functions' => __( 'Functions', 'site-reviews' ), |
|
90 | + 'addons' => __( 'Addons', 'site-reviews' ), |
|
91 | + ] ); |
|
92 | + $addons = apply_filters( 'site-reviews/addon/documentation', [] ); |
|
93 | + ksort( $addons ); |
|
94 | + if( empty($addons) ) { |
|
95 | 95 | unset($tabs['addons']); |
96 | 96 | } |
97 | - $this->renderPage('documentation', [ |
|
97 | + $this->renderPage( 'documentation', [ |
|
98 | 98 | 'addons' => $addons, |
99 | 99 | 'tabs' => $tabs, |
100 | - ]); |
|
100 | + ] ); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,25 +107,25 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function renderSettingsMenu() |
109 | 109 | { |
110 | - $tabs = $this->parseWithFilter('settings/tabs', [ |
|
111 | - 'general' => __('General', 'site-reviews'), |
|
112 | - 'reviews' => __('Reviews', 'site-reviews'), |
|
113 | - 'submissions' => __('Submissions', 'site-reviews'), |
|
114 | - 'schema' => __('Schema', 'site-reviews'), |
|
115 | - 'translations' => __('Translations', 'site-reviews'), |
|
116 | - 'addons' => __('Addons', 'site-reviews'), |
|
117 | - 'licenses' => __('Licenses', 'site-reviews'), |
|
118 | - ]); |
|
119 | - if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) { |
|
110 | + $tabs = $this->parseWithFilter( 'settings/tabs', [ |
|
111 | + 'general' => __( 'General', 'site-reviews' ), |
|
112 | + 'reviews' => __( 'Reviews', 'site-reviews' ), |
|
113 | + 'submissions' => __( 'Submissions', 'site-reviews' ), |
|
114 | + 'schema' => __( 'Schema', 'site-reviews' ), |
|
115 | + 'translations' => __( 'Translations', 'site-reviews' ), |
|
116 | + 'addons' => __( 'Addons', 'site-reviews' ), |
|
117 | + 'licenses' => __( 'Licenses', 'site-reviews' ), |
|
118 | + ] ); |
|
119 | + if( empty(Arr::get( glsr()->defaults, 'settings.addons' )) ) { |
|
120 | 120 | unset($tabs['addons']); |
121 | 121 | } |
122 | - if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) { |
|
122 | + if( empty(Arr::get( glsr()->defaults, 'settings.licenses' )) ) { |
|
123 | 123 | unset($tabs['licenses']); |
124 | 124 | } |
125 | - $this->renderPage('settings', [ |
|
126 | - 'settings' => glsr(Settings::class), |
|
125 | + $this->renderPage( 'settings', [ |
|
126 | + 'settings' => glsr( Settings::class ), |
|
127 | 127 | 'tabs' => $tabs, |
128 | - ]); |
|
128 | + ] ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -135,28 +135,28 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function renderToolsMenu() |
137 | 137 | { |
138 | - $tabs = $this->parseWithFilter('tools/tabs', [ |
|
139 | - 'general' => __('General', 'site-reviews'), |
|
140 | - 'sync' => __('Sync Reviews', 'site-reviews'), |
|
141 | - 'console' => __('Console', 'site-reviews'), |
|
142 | - 'system-info' => __('System Info', 'site-reviews'), |
|
143 | - ]); |
|
144 | - if (!apply_filters('site-reviews/addon/sync/enable', false)) { |
|
138 | + $tabs = $this->parseWithFilter( 'tools/tabs', [ |
|
139 | + 'general' => __( 'General', 'site-reviews' ), |
|
140 | + 'sync' => __( 'Sync Reviews', 'site-reviews' ), |
|
141 | + 'console' => __( 'Console', 'site-reviews' ), |
|
142 | + 'system-info' => __( 'System Info', 'site-reviews' ), |
|
143 | + ] ); |
|
144 | + if( !apply_filters( 'site-reviews/addon/sync/enable', false ) ) { |
|
145 | 145 | unset($tabs['sync']); |
146 | 146 | } |
147 | - $this->renderPage('tools', [ |
|
147 | + $this->renderPage( 'tools', [ |
|
148 | 148 | 'data' => [ |
149 | 149 | 'context' => [ |
150 | - 'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE), |
|
151 | - 'console' => strval(glsr(Console::class)), |
|
150 | + 'base_url' => admin_url( 'edit.php?post_type='.Application::POST_TYPE ), |
|
151 | + 'console' => strval( glsr( Console::class ) ), |
|
152 | 152 | 'id' => Application::ID, |
153 | - 'system' => strval(glsr(System::class)), |
|
153 | + 'system' => strval( glsr( System::class ) ), |
|
154 | 154 | ], |
155 | - 'services' => apply_filters('site-reviews/addon/sync/services', []), |
|
155 | + 'services' => apply_filters( 'site-reviews/addon/sync/services', [] ), |
|
156 | 156 | ], |
157 | 157 | 'tabs' => $tabs, |
158 | - 'template' => glsr(Template::class), |
|
159 | - ]); |
|
158 | + 'template' => glsr( Template::class ), |
|
159 | + ] ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function setCustomPermissions() |
167 | 167 | { |
168 | - foreach (wp_roles()->roles as $role => $value) { |
|
169 | - wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE); |
|
168 | + foreach( wp_roles()->roles as $role => $value ) { |
|
169 | + wp_roles()->remove_cap( $role, 'create_'.Application::POST_TYPE ); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -175,28 +175,28 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function getNotices() |
177 | 177 | { |
178 | - return glsr(Builder::class)->div(glsr(Notice::class)->get(), [ |
|
178 | + return glsr( Builder::class )->div( glsr( Notice::class )->get(), [ |
|
179 | 179 | 'id' => 'glsr-notices', |
180 | - ]); |
|
180 | + ] ); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | 184 | * @param string $hookSuffix |
185 | 185 | * @return array |
186 | 186 | */ |
187 | - protected function parseWithFilter($hookSuffix, array $args = []) |
|
187 | + protected function parseWithFilter( $hookSuffix, array $args = [] ) |
|
188 | 188 | { |
189 | - return apply_filters('site-reviews/addon/'.$hookSuffix, $args); |
|
189 | + return apply_filters( 'site-reviews/addon/'.$hookSuffix, $args ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
193 | 193 | * @param string $page |
194 | 194 | * @return void |
195 | 195 | */ |
196 | - protected function renderPage($page, array $data = []) |
|
196 | + protected function renderPage( $page, array $data = [] ) |
|
197 | 197 | { |
198 | - $data['http_referer'] = (string) wp_get_referer(); |
|
198 | + $data['http_referer'] = (string)wp_get_referer(); |
|
199 | 199 | $data['notices'] = $this->getNotices(); |
200 | - glsr()->render('pages/'.$page.'/index', $data); |
|
200 | + glsr()->render( 'pages/'.$page.'/index', $data ); |
|
201 | 201 | } |
202 | 202 | } |
@@ -6,41 +6,41 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected $guarded = [ |
|
13 | - 'fallback', |
|
14 | - 'title', |
|
15 | - ]; |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected $guarded = [ |
|
13 | + 'fallback', |
|
14 | + 'title', |
|
15 | + ]; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - protected $mapped = [ |
|
21 | - 'count' => 'display', // @deprecated since v4.1.0 |
|
22 | - 'per_page' => 'display', |
|
23 | - ]; |
|
17 | + /** |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + protected $mapped = [ |
|
21 | + 'count' => 'display', // @deprecated since v4.1.0 |
|
22 | + 'per_page' => 'display', |
|
23 | + ]; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @return array |
|
27 | - */ |
|
28 | - protected function defaults() |
|
29 | - { |
|
30 | - return [ |
|
31 | - 'assigned_to' => '', |
|
32 | - 'category' => '', |
|
33 | - 'class' => '', |
|
34 | - 'display' => 5, |
|
35 | - 'fallback' => '', |
|
36 | - 'hide' => [], |
|
37 | - 'id' => '', |
|
38 | - 'offset' => '', |
|
39 | - 'pagination' => false, |
|
40 | - 'rating' => 0, |
|
41 | - 'schema' => false, |
|
42 | - 'title' => '', |
|
43 | - 'type' => 'local', |
|
44 | - ]; |
|
45 | - } |
|
25 | + /** |
|
26 | + * @return array |
|
27 | + */ |
|
28 | + protected function defaults() |
|
29 | + { |
|
30 | + return [ |
|
31 | + 'assigned_to' => '', |
|
32 | + 'category' => '', |
|
33 | + 'class' => '', |
|
34 | + 'display' => 5, |
|
35 | + 'fallback' => '', |
|
36 | + 'hide' => [], |
|
37 | + 'id' => '', |
|
38 | + 'offset' => '', |
|
39 | + 'pagination' => false, |
|
40 | + 'rating' => 0, |
|
41 | + 'schema' => false, |
|
42 | + 'title' => '', |
|
43 | + 'type' => 'local', |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | } |