@@ -7,39 +7,39 @@ |
||
7 | 7 | |
8 | 8 | abstract class Widget extends WP_Widget |
9 | 9 | { |
10 | - /** |
|
11 | - * @var array |
|
12 | - */ |
|
13 | - protected $widgetArgs; |
|
10 | + /** |
|
11 | + * @var array |
|
12 | + */ |
|
13 | + protected $widgetArgs; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @param string $tag |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - protected function renderField($tag, array $args = []) |
|
20 | - { |
|
21 | - $args = $this->normalizeFieldAttributes($tag, $args); |
|
22 | - $field = glsr(Builder::class)->$tag($args['name'], $args); |
|
23 | - echo glsr(Builder::class)->div($field, [ |
|
24 | - 'class' => 'glsr-field', |
|
25 | - ]); |
|
26 | - } |
|
15 | + /** |
|
16 | + * @param string $tag |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + protected function renderField($tag, array $args = []) |
|
20 | + { |
|
21 | + $args = $this->normalizeFieldAttributes($tag, $args); |
|
22 | + $field = glsr(Builder::class)->$tag($args['name'], $args); |
|
23 | + echo glsr(Builder::class)->div($field, [ |
|
24 | + 'class' => 'glsr-field', |
|
25 | + ]); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @param string $tag |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - protected function normalizeFieldAttributes($tag, array $args) |
|
33 | - { |
|
34 | - if (empty($args['value'])) { |
|
35 | - $args['value'] = $this->widgetArgs[$args['name']]; |
|
36 | - } |
|
37 | - if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) { |
|
38 | - $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]); |
|
39 | - } |
|
40 | - $args['id'] = $this->get_field_id($args['name']); |
|
41 | - $args['name'] = $this->get_field_name($args['name']); |
|
42 | - $args['is_widget'] = true; |
|
43 | - return $args; |
|
44 | - } |
|
28 | + /** |
|
29 | + * @param string $tag |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + protected function normalizeFieldAttributes($tag, array $args) |
|
33 | + { |
|
34 | + if (empty($args['value'])) { |
|
35 | + $args['value'] = $this->widgetArgs[$args['name']]; |
|
36 | + } |
|
37 | + if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) { |
|
38 | + $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]); |
|
39 | + } |
|
40 | + $args['id'] = $this->get_field_id($args['name']); |
|
41 | + $args['name'] = $this->get_field_name($args['name']); |
|
42 | + $args['is_widget'] = true; |
|
43 | + return $args; |
|
44 | + } |
|
45 | 45 | } |
@@ -8,103 +8,103 @@ |
||
8 | 8 | |
9 | 9 | class SiteReviewsWidget extends Widget |
10 | 10 | { |
11 | - public function __construct() |
|
12 | - { |
|
13 | - $idBase = Application::ID.'_site-reviews'; |
|
14 | - $name = __('Recent Reviews', 'site-reviews'); |
|
15 | - $widgetOptions = [ |
|
16 | - 'class' => 'glsr-widget glsr-widget-site-reviews', |
|
17 | - 'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'), |
|
18 | - ]; |
|
19 | - parent::__construct($idBase, $name, $widgetOptions); |
|
20 | - } |
|
11 | + public function __construct() |
|
12 | + { |
|
13 | + $idBase = Application::ID.'_site-reviews'; |
|
14 | + $name = __('Recent Reviews', 'site-reviews'); |
|
15 | + $widgetOptions = [ |
|
16 | + 'class' => 'glsr-widget glsr-widget-site-reviews', |
|
17 | + 'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'), |
|
18 | + ]; |
|
19 | + parent::__construct($idBase, $name, $widgetOptions); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param array $instance |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function form($instance) |
|
27 | - { |
|
28 | - $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance); |
|
29 | - $terms = glsr(Database::class)->getTerms(); |
|
30 | - $this->renderField('text', [ |
|
31 | - 'class' => 'widefat', |
|
32 | - 'label' => __('Title', 'site-reviews'), |
|
33 | - 'name' => 'title', |
|
34 | - ]); |
|
35 | - $this->renderField('number', [ |
|
36 | - 'class' => 'small-text', |
|
37 | - 'default' => 10, |
|
38 | - 'label' => __('How many reviews would you like to display?', 'site-reviews'), |
|
39 | - 'max' => 100, |
|
40 | - 'name' => 'display', |
|
41 | - ]); |
|
42 | - $this->renderField('select', [ |
|
43 | - 'label' => __('What is the minimum rating to display?', 'site-reviews'), |
|
44 | - 'name' => 'rating', |
|
45 | - 'options' => [ |
|
46 | - '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5), |
|
47 | - '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4), |
|
48 | - '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3), |
|
49 | - '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2), |
|
50 | - '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1), |
|
51 | - ], |
|
52 | - ]); |
|
53 | - if (count(glsr()->reviewTypes) > 1) { |
|
54 | - $this->renderField('select', [ |
|
55 | - 'class' => 'widefat', |
|
56 | - 'label' => __('Which type of review would you like to display?', 'site-reviews'), |
|
57 | - 'name' => 'type', |
|
58 | - 'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes, |
|
59 | - ]); |
|
60 | - } |
|
61 | - if (!empty($terms)) { |
|
62 | - $this->renderField('select', [ |
|
63 | - 'class' => 'widefat', |
|
64 | - 'label' => __('Limit reviews to this category', 'site-reviews'), |
|
65 | - 'name' => 'category', |
|
66 | - 'options' => ['' => __('All Categories', 'site-reviews')] + $terms, |
|
67 | - ]); |
|
68 | - } |
|
69 | - $this->renderField('text', [ |
|
70 | - 'class' => 'widefat', |
|
71 | - 'default' => '', |
|
72 | - '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>'), |
|
73 | - 'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'), |
|
74 | - 'name' => 'assigned_to', |
|
75 | - ]); |
|
76 | - $this->renderField('text', [ |
|
77 | - 'class' => 'widefat', |
|
78 | - 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
79 | - 'name' => 'class', |
|
80 | - ]); |
|
81 | - $this->renderField('checkbox', [ |
|
82 | - 'name' => 'hide', |
|
83 | - 'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(), |
|
84 | - ]); |
|
85 | - } |
|
22 | + /** |
|
23 | + * @param array $instance |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function form($instance) |
|
27 | + { |
|
28 | + $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance); |
|
29 | + $terms = glsr(Database::class)->getTerms(); |
|
30 | + $this->renderField('text', [ |
|
31 | + 'class' => 'widefat', |
|
32 | + 'label' => __('Title', 'site-reviews'), |
|
33 | + 'name' => 'title', |
|
34 | + ]); |
|
35 | + $this->renderField('number', [ |
|
36 | + 'class' => 'small-text', |
|
37 | + 'default' => 10, |
|
38 | + 'label' => __('How many reviews would you like to display?', 'site-reviews'), |
|
39 | + 'max' => 100, |
|
40 | + 'name' => 'display', |
|
41 | + ]); |
|
42 | + $this->renderField('select', [ |
|
43 | + 'label' => __('What is the minimum rating to display?', 'site-reviews'), |
|
44 | + 'name' => 'rating', |
|
45 | + 'options' => [ |
|
46 | + '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5), |
|
47 | + '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4), |
|
48 | + '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3), |
|
49 | + '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2), |
|
50 | + '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1), |
|
51 | + ], |
|
52 | + ]); |
|
53 | + if (count(glsr()->reviewTypes) > 1) { |
|
54 | + $this->renderField('select', [ |
|
55 | + 'class' => 'widefat', |
|
56 | + 'label' => __('Which type of review would you like to display?', 'site-reviews'), |
|
57 | + 'name' => 'type', |
|
58 | + 'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes, |
|
59 | + ]); |
|
60 | + } |
|
61 | + if (!empty($terms)) { |
|
62 | + $this->renderField('select', [ |
|
63 | + 'class' => 'widefat', |
|
64 | + 'label' => __('Limit reviews to this category', 'site-reviews'), |
|
65 | + 'name' => 'category', |
|
66 | + 'options' => ['' => __('All Categories', 'site-reviews')] + $terms, |
|
67 | + ]); |
|
68 | + } |
|
69 | + $this->renderField('text', [ |
|
70 | + 'class' => 'widefat', |
|
71 | + 'default' => '', |
|
72 | + '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>'), |
|
73 | + 'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'), |
|
74 | + 'name' => 'assigned_to', |
|
75 | + ]); |
|
76 | + $this->renderField('text', [ |
|
77 | + 'class' => 'widefat', |
|
78 | + 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
79 | + 'name' => 'class', |
|
80 | + ]); |
|
81 | + $this->renderField('checkbox', [ |
|
82 | + 'name' => 'hide', |
|
83 | + 'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(), |
|
84 | + ]); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param array $newInstance |
|
89 | - * @param array $oldInstance |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public function update($newInstance, $oldInstance) |
|
93 | - { |
|
94 | - if (!is_numeric($newInstance['display'])) { |
|
95 | - $newInstance['display'] = 10; |
|
96 | - } |
|
97 | - $newInstance['display'] = min(50, max(0, intval($newInstance['display']))); |
|
98 | - return parent::update($newInstance, $oldInstance); |
|
99 | - } |
|
87 | + /** |
|
88 | + * @param array $newInstance |
|
89 | + * @param array $oldInstance |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public function update($newInstance, $oldInstance) |
|
93 | + { |
|
94 | + if (!is_numeric($newInstance['display'])) { |
|
95 | + $newInstance['display'] = 10; |
|
96 | + } |
|
97 | + $newInstance['display'] = min(50, max(0, intval($newInstance['display']))); |
|
98 | + return parent::update($newInstance, $oldInstance); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @param array $args |
|
103 | - * @param array $instance |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public function widget($args, $instance) |
|
107 | - { |
|
108 | - echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget'); |
|
109 | - } |
|
101 | + /** |
|
102 | + * @param array $args |
|
103 | + * @param array $instance |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public function widget($args, $instance) |
|
107 | + { |
|
108 | + echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget'); |
|
109 | + } |
|
110 | 110 | } |
@@ -8,66 +8,66 @@ |
||
8 | 8 | |
9 | 9 | class SiteReviewsFormWidget extends Widget |
10 | 10 | { |
11 | - public function __construct() |
|
12 | - { |
|
13 | - $idBase = Application::ID.'_site-reviews-form'; |
|
14 | - $name = __('Submit a Review', 'site-reviews'); |
|
15 | - $widgetOptions = [ |
|
16 | - 'classname' => 'glsr-widget glsr-widget-site-reviews-form', |
|
17 | - 'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'), |
|
18 | - ]; |
|
19 | - parent::__construct($idBase, $name, $widgetOptions); |
|
20 | - } |
|
11 | + public function __construct() |
|
12 | + { |
|
13 | + $idBase = Application::ID.'_site-reviews-form'; |
|
14 | + $name = __('Submit a Review', 'site-reviews'); |
|
15 | + $widgetOptions = [ |
|
16 | + 'classname' => 'glsr-widget glsr-widget-site-reviews-form', |
|
17 | + 'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'), |
|
18 | + ]; |
|
19 | + parent::__construct($idBase, $name, $widgetOptions); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param array $instance |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function form($instance) |
|
27 | - { |
|
28 | - $this->widgetArgs = glsr(SiteReviewsFormShortcode::class)->normalizeAtts($instance); |
|
29 | - $terms = glsr(Database::class)->getTerms(); |
|
30 | - $this->renderField('text', [ |
|
31 | - 'class' => 'widefat', |
|
32 | - 'label' => __('Title', 'site-reviews'), |
|
33 | - 'name' => 'title', |
|
34 | - ]); |
|
35 | - $this->renderField('textarea', [ |
|
36 | - 'class' => 'widefat', |
|
37 | - 'label' => __('Description', 'site-reviews'), |
|
38 | - 'name' => 'description', |
|
39 | - ]); |
|
40 | - $this->renderField('select', [ |
|
41 | - 'class' => 'widefat', |
|
42 | - 'label' => __('Automatically assign a category', 'site-reviews'), |
|
43 | - 'name' => 'category', |
|
44 | - 'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms, |
|
45 | - ]); |
|
46 | - $this->renderField('text', [ |
|
47 | - 'class' => 'widefat', |
|
48 | - 'default' => '', |
|
49 | - 'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'), |
|
50 | - 'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'), |
|
51 | - 'name' => 'assign_to', |
|
52 | - ]); |
|
53 | - $this->renderField('text', [ |
|
54 | - 'class' => 'widefat', |
|
55 | - 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
56 | - 'name' => 'class', |
|
57 | - ]); |
|
58 | - $this->renderField('checkbox', [ |
|
59 | - 'name' => 'hide', |
|
60 | - 'options' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(), |
|
61 | - ]); |
|
62 | - } |
|
22 | + /** |
|
23 | + * @param array $instance |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function form($instance) |
|
27 | + { |
|
28 | + $this->widgetArgs = glsr(SiteReviewsFormShortcode::class)->normalizeAtts($instance); |
|
29 | + $terms = glsr(Database::class)->getTerms(); |
|
30 | + $this->renderField('text', [ |
|
31 | + 'class' => 'widefat', |
|
32 | + 'label' => __('Title', 'site-reviews'), |
|
33 | + 'name' => 'title', |
|
34 | + ]); |
|
35 | + $this->renderField('textarea', [ |
|
36 | + 'class' => 'widefat', |
|
37 | + 'label' => __('Description', 'site-reviews'), |
|
38 | + 'name' => 'description', |
|
39 | + ]); |
|
40 | + $this->renderField('select', [ |
|
41 | + 'class' => 'widefat', |
|
42 | + 'label' => __('Automatically assign a category', 'site-reviews'), |
|
43 | + 'name' => 'category', |
|
44 | + 'options' => ['' => __('Do not assign a category', 'site-reviews')] + $terms, |
|
45 | + ]); |
|
46 | + $this->renderField('text', [ |
|
47 | + 'class' => 'widefat', |
|
48 | + 'default' => '', |
|
49 | + 'description' => sprintf(__('You may also enter %s to assign to the current post.', 'site-reviews'), '<code>post_id</code>'), |
|
50 | + 'label' => __('Assign reviews to a custom page/post ID', 'site-reviews'), |
|
51 | + 'name' => 'assign_to', |
|
52 | + ]); |
|
53 | + $this->renderField('text', [ |
|
54 | + 'class' => 'widefat', |
|
55 | + 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
56 | + 'name' => 'class', |
|
57 | + ]); |
|
58 | + $this->renderField('checkbox', [ |
|
59 | + 'name' => 'hide', |
|
60 | + 'options' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(), |
|
61 | + ]); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param array $args |
|
66 | - * @param array $instance |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function widget($args, $instance) |
|
70 | - { |
|
71 | - echo glsr(SiteReviewsFormShortcode::class)->build($instance, $args, 'widget'); |
|
72 | - } |
|
64 | + /** |
|
65 | + * @param array $args |
|
66 | + * @param array $instance |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function widget($args, $instance) |
|
70 | + { |
|
71 | + echo glsr(SiteReviewsFormShortcode::class)->build($instance, $args, 'widget'); |
|
72 | + } |
|
73 | 73 | } |
@@ -8,71 +8,71 @@ |
||
8 | 8 | |
9 | 9 | class SiteReviewsSummaryWidget extends Widget |
10 | 10 | { |
11 | - public function __construct() |
|
12 | - { |
|
13 | - $idBase = Application::ID.'_site-reviews-summary'; |
|
14 | - $name = __('Summary of Reviews', 'site-reviews'); |
|
15 | - $widgetOptions = [ |
|
16 | - 'classname' => 'glsr-widget glsr-widget-site-reviews-summary', |
|
17 | - 'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'), |
|
18 | - ]; |
|
19 | - parent::__construct($idBase, $name, $widgetOptions); |
|
20 | - } |
|
11 | + public function __construct() |
|
12 | + { |
|
13 | + $idBase = Application::ID.'_site-reviews-summary'; |
|
14 | + $name = __('Summary of Reviews', 'site-reviews'); |
|
15 | + $widgetOptions = [ |
|
16 | + 'classname' => 'glsr-widget glsr-widget-site-reviews-summary', |
|
17 | + 'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'), |
|
18 | + ]; |
|
19 | + parent::__construct($idBase, $name, $widgetOptions); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param array $instance |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function form($instance) |
|
27 | - { |
|
28 | - $this->widgetArgs = glsr(SiteReviewsSummaryShortcode::class)->normalizeAtts($instance); |
|
29 | - $terms = glsr(Database::class)->getTerms(); |
|
30 | - $this->renderField('text', [ |
|
31 | - 'class' => 'widefat', |
|
32 | - 'label' => __('Title', 'site-reviews'), |
|
33 | - 'name' => 'title', |
|
34 | - ]); |
|
35 | - if (count(glsr()->reviewTypes) > 1) { |
|
36 | - $this->renderField('select', [ |
|
37 | - 'class' => 'widefat', |
|
38 | - 'label' => __('Which type of review would you like to use?', 'site-reviews'), |
|
39 | - 'name' => 'type', |
|
40 | - 'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes, |
|
41 | - ]); |
|
42 | - } |
|
43 | - if (!empty($terms)) { |
|
44 | - $this->renderField('select', [ |
|
45 | - 'class' => 'widefat', |
|
46 | - 'label' => __('Limit summary to this category', 'site-reviews'), |
|
47 | - 'name' => 'category', |
|
48 | - 'options' => ['' => __('All Categories', 'site-reviews')] + $terms, |
|
49 | - ]); |
|
50 | - } |
|
51 | - $this->renderField('text', [ |
|
52 | - 'class' => 'widefat', |
|
53 | - 'default' => '', |
|
54 | - '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>'), |
|
55 | - 'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'), |
|
56 | - 'name' => 'assigned_to', |
|
57 | - ]); |
|
58 | - $this->renderField('text', [ |
|
59 | - 'class' => 'widefat', |
|
60 | - 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
61 | - 'name' => 'class', |
|
62 | - ]); |
|
63 | - $this->renderField('checkbox', [ |
|
64 | - 'name' => 'hide', |
|
65 | - 'options' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(), |
|
66 | - ]); |
|
67 | - } |
|
22 | + /** |
|
23 | + * @param array $instance |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function form($instance) |
|
27 | + { |
|
28 | + $this->widgetArgs = glsr(SiteReviewsSummaryShortcode::class)->normalizeAtts($instance); |
|
29 | + $terms = glsr(Database::class)->getTerms(); |
|
30 | + $this->renderField('text', [ |
|
31 | + 'class' => 'widefat', |
|
32 | + 'label' => __('Title', 'site-reviews'), |
|
33 | + 'name' => 'title', |
|
34 | + ]); |
|
35 | + if (count(glsr()->reviewTypes) > 1) { |
|
36 | + $this->renderField('select', [ |
|
37 | + 'class' => 'widefat', |
|
38 | + 'label' => __('Which type of review would you like to use?', 'site-reviews'), |
|
39 | + 'name' => 'type', |
|
40 | + 'options' => ['' => __('All review types', 'site-reviews')] + glsr()->reviewTypes, |
|
41 | + ]); |
|
42 | + } |
|
43 | + if (!empty($terms)) { |
|
44 | + $this->renderField('select', [ |
|
45 | + 'class' => 'widefat', |
|
46 | + 'label' => __('Limit summary to this category', 'site-reviews'), |
|
47 | + 'name' => 'category', |
|
48 | + 'options' => ['' => __('All Categories', 'site-reviews')] + $terms, |
|
49 | + ]); |
|
50 | + } |
|
51 | + $this->renderField('text', [ |
|
52 | + 'class' => 'widefat', |
|
53 | + 'default' => '', |
|
54 | + '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>'), |
|
55 | + 'label' => __('Limit summary to reviews assigned to a page/post ID', 'site-reviews'), |
|
56 | + 'name' => 'assigned_to', |
|
57 | + ]); |
|
58 | + $this->renderField('text', [ |
|
59 | + 'class' => 'widefat', |
|
60 | + 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
61 | + 'name' => 'class', |
|
62 | + ]); |
|
63 | + $this->renderField('checkbox', [ |
|
64 | + 'name' => 'hide', |
|
65 | + 'options' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(), |
|
66 | + ]); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param array $args |
|
71 | - * @param array $instance |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - public function widget($args, $instance) |
|
75 | - { |
|
76 | - echo glsr(SiteReviewsSummaryShortcode::class)->build($instance, $args, 'widget'); |
|
77 | - } |
|
69 | + /** |
|
70 | + * @param array $args |
|
71 | + * @param array $instance |
|
72 | + * @return void |
|
73 | + */ |
|
74 | + public function widget($args, $instance) |
|
75 | + { |
|
76 | + echo glsr(SiteReviewsSummaryShortcode::class)->build($instance, $args, 'widget'); |
|
77 | + } |
|
78 | 78 | } |
@@ -8,19 +8,19 @@ |
||
8 | 8 | |
9 | 9 | class RegisterWidgets |
10 | 10 | { |
11 | - /** |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function handle(Command $command) |
|
15 | - { |
|
16 | - global $wp_widget_factory; |
|
17 | - foreach ($command->widgets as $widget) { |
|
18 | - $widgetClass = Helper::buildClassName($widget.'-widget', 'Widgets'); |
|
19 | - if (!class_exists($widgetClass)) { |
|
20 | - glsr_log()->error(sprintf('Class missing (%s)', $widgetClass)); |
|
21 | - continue; |
|
22 | - } |
|
23 | - $wp_widget_factory->widgets[$widgetClass] = new $widgetClass(); |
|
24 | - } |
|
25 | - } |
|
11 | + /** |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function handle(Command $command) |
|
15 | + { |
|
16 | + global $wp_widget_factory; |
|
17 | + foreach ($command->widgets as $widget) { |
|
18 | + $widgetClass = Helper::buildClassName($widget.'-widget', 'Widgets'); |
|
19 | + if (!class_exists($widgetClass)) { |
|
20 | + glsr_log()->error(sprintf('Class missing (%s)', $widgetClass)); |
|
21 | + continue; |
|
22 | + } |
|
23 | + $wp_widget_factory->widgets[$widgetClass] = new $widgetClass(); |
|
24 | + } |
|
25 | + } |
|
26 | 26 | } |
@@ -10,134 +10,134 @@ |
||
10 | 10 | |
11 | 11 | class Migrate |
12 | 12 | { |
13 | - /** |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - public $currentVersion; |
|
13 | + /** |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + public $currentVersion; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $transientKey; |
|
18 | + /** |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $transientKey; |
|
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->currentVersion = $this->getCurrentVersion(); |
|
26 | - $this->transientKey = Application::PREFIX.'migrations'; |
|
27 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->currentVersion = $this->getCurrentVersion(); |
|
26 | + $this->transientKey = Application::PREFIX.'migrations'; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @return bool |
|
31 | - */ |
|
32 | - public function isMigrationNeeded() |
|
33 | - { |
|
34 | - $transient = get_transient($this->transientKey); |
|
35 | - if (false === $transient || !isset($transient[glsr()->version])) { |
|
36 | - $transient = [ |
|
37 | - glsr()->version => !empty($this->getNewMigrationFiles()), |
|
38 | - ]; |
|
39 | - set_transient($this->transientKey, $transient); |
|
40 | - } |
|
41 | - return Helper::castToBool($transient[glsr()->version]); |
|
42 | - } |
|
29 | + /** |
|
30 | + * @return bool |
|
31 | + */ |
|
32 | + public function isMigrationNeeded() |
|
33 | + { |
|
34 | + $transient = get_transient($this->transientKey); |
|
35 | + if (false === $transient || !isset($transient[glsr()->version])) { |
|
36 | + $transient = [ |
|
37 | + glsr()->version => !empty($this->getNewMigrationFiles()), |
|
38 | + ]; |
|
39 | + set_transient($this->transientKey, $transient); |
|
40 | + } |
|
41 | + return Helper::castToBool($transient[glsr()->version]); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - public function run() |
|
48 | - { |
|
49 | - $this->runMigrations($this->getNewMigrationFiles()); |
|
50 | - } |
|
44 | + /** |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + public function run() |
|
48 | + { |
|
49 | + $this->runMigrations($this->getNewMigrationFiles()); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return bool |
|
54 | - */ |
|
55 | - public function runAll() |
|
56 | - { |
|
57 | - $this->runMigrations($this->getMigrationFiles()); |
|
58 | - } |
|
52 | + /** |
|
53 | + * @return bool |
|
54 | + */ |
|
55 | + public function runAll() |
|
56 | + { |
|
57 | + $this->runMigrations($this->getMigrationFiles()); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - protected function getCurrentVersion() |
|
64 | - { |
|
65 | - $fallback = '0.0.0'; |
|
66 | - $majorVersions = [4, 3, 2, 1]; |
|
67 | - foreach ($majorVersions as $majorVersion) { |
|
68 | - $settings = get_option(OptionManager::databaseKey($majorVersion)); |
|
69 | - $version = Arr::get($settings, 'version', $fallback); |
|
70 | - if (Helper::isGreaterThan($version, $fallback)) { |
|
71 | - return $version; |
|
72 | - } |
|
73 | - } |
|
74 | - return $fallback; |
|
75 | - } |
|
60 | + /** |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + protected function getCurrentVersion() |
|
64 | + { |
|
65 | + $fallback = '0.0.0'; |
|
66 | + $majorVersions = [4, 3, 2, 1]; |
|
67 | + foreach ($majorVersions as $majorVersion) { |
|
68 | + $settings = get_option(OptionManager::databaseKey($majorVersion)); |
|
69 | + $version = Arr::get($settings, 'version', $fallback); |
|
70 | + if (Helper::isGreaterThan($version, $fallback)) { |
|
71 | + return $version; |
|
72 | + } |
|
73 | + } |
|
74 | + return $fallback; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - protected function getMigrationFiles() |
|
81 | - { |
|
82 | - $files = []; |
|
83 | - $dir = glsr()->path('plugin/Modules/Migrations'); |
|
84 | - if (is_dir($dir)) { |
|
85 | - $iterator = new DirectoryIterator($dir); |
|
86 | - foreach ($iterator as $fileinfo) { |
|
87 | - if ($fileinfo->isFile()) { |
|
88 | - $files[] = $fileinfo->getFilename(); |
|
89 | - } |
|
90 | - } |
|
91 | - natsort($files); |
|
92 | - } |
|
93 | - return $files; |
|
94 | - } |
|
77 | + /** |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + protected function getMigrationFiles() |
|
81 | + { |
|
82 | + $files = []; |
|
83 | + $dir = glsr()->path('plugin/Modules/Migrations'); |
|
84 | + if (is_dir($dir)) { |
|
85 | + $iterator = new DirectoryIterator($dir); |
|
86 | + foreach ($iterator as $fileinfo) { |
|
87 | + if ($fileinfo->isFile()) { |
|
88 | + $files[] = $fileinfo->getFilename(); |
|
89 | + } |
|
90 | + } |
|
91 | + natsort($files); |
|
92 | + } |
|
93 | + return $files; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @return array |
|
98 | - */ |
|
99 | - protected function getNewMigrationFiles() |
|
100 | - { |
|
101 | - $files = $this->getMigrationFiles(); |
|
102 | - foreach ($files as $index => $file) { |
|
103 | - $className = str_replace('.php', '', $file); |
|
104 | - $migrationVersion = str_replace(['Migrate_', '_'], ['', '.'], $className); |
|
105 | - $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions |
|
106 | - if (Helper::isGreaterThanOrEqual($this->currentVersion, $migrationVersion.$suffix)) { |
|
107 | - unset($files[$index]); |
|
108 | - } |
|
109 | - } |
|
110 | - return $files; |
|
111 | - } |
|
96 | + /** |
|
97 | + * @return array |
|
98 | + */ |
|
99 | + protected function getNewMigrationFiles() |
|
100 | + { |
|
101 | + $files = $this->getMigrationFiles(); |
|
102 | + foreach ($files as $index => $file) { |
|
103 | + $className = str_replace('.php', '', $file); |
|
104 | + $migrationVersion = str_replace(['Migrate_', '_'], ['', '.'], $className); |
|
105 | + $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions |
|
106 | + if (Helper::isGreaterThanOrEqual($this->currentVersion, $migrationVersion.$suffix)) { |
|
107 | + unset($files[$index]); |
|
108 | + } |
|
109 | + } |
|
110 | + return $files; |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * @return void |
|
115 | - */ |
|
116 | - protected function runMigrations(array $files) |
|
117 | - { |
|
118 | - if (empty($files)) { |
|
119 | - return; |
|
120 | - } |
|
121 | - array_walk($files, function ($file) { |
|
122 | - $className = str_replace('.php', '', $file); |
|
123 | - glsr('Modules\\Migrations\\'.$className)->run(); |
|
124 | - $versionMigrated = str_replace(['Migrate_', '_'], ['v','.'], $className); |
|
125 | - glsr_log()->debug('migration completed for '.$versionMigrated); |
|
126 | - }); |
|
127 | - if ($this->currentVersion !== glsr()->version) { |
|
128 | - $this->updateVersionFrom($this->currentVersion); |
|
129 | - } |
|
130 | - glsr(OptionManager::class)->set('last_migration_run', current_time('timestamp')); |
|
131 | - delete_transient($this->transientKey); |
|
132 | - } |
|
113 | + /** |
|
114 | + * @return void |
|
115 | + */ |
|
116 | + protected function runMigrations(array $files) |
|
117 | + { |
|
118 | + if (empty($files)) { |
|
119 | + return; |
|
120 | + } |
|
121 | + array_walk($files, function ($file) { |
|
122 | + $className = str_replace('.php', '', $file); |
|
123 | + glsr('Modules\\Migrations\\'.$className)->run(); |
|
124 | + $versionMigrated = str_replace(['Migrate_', '_'], ['v','.'], $className); |
|
125 | + glsr_log()->debug('migration completed for '.$versionMigrated); |
|
126 | + }); |
|
127 | + if ($this->currentVersion !== glsr()->version) { |
|
128 | + $this->updateVersionFrom($this->currentVersion); |
|
129 | + } |
|
130 | + glsr(OptionManager::class)->set('last_migration_run', current_time('timestamp')); |
|
131 | + delete_transient($this->transientKey); |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * @param string $previousVersion |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - protected function updateVersionFrom($previousVersion) |
|
139 | - { |
|
140 | - glsr(OptionManager::class)->set('version', glsr()->version); |
|
141 | - glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion); |
|
142 | - } |
|
134 | + /** |
|
135 | + * @param string $previousVersion |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + protected function updateVersionFrom($previousVersion) |
|
139 | + { |
|
140 | + glsr(OptionManager::class)->set('version', glsr()->version); |
|
141 | + glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion); |
|
142 | + } |
|
143 | 143 | } |
@@ -17,356 +17,356 @@ |
||
17 | 17 | */ |
18 | 18 | final class Application extends Container |
19 | 19 | { |
20 | - const CAPABILITY = 'edit_others_posts'; |
|
21 | - const CRON_EVENT = 'site-reviews/schedule/session/purge'; |
|
22 | - const ID = 'site-reviews'; |
|
23 | - const PAGED_QUERY_VAR = 'reviews-page'; |
|
24 | - const POST_TYPE = 'site-review'; |
|
25 | - const PREFIX = 'glsr_'; |
|
26 | - const TAXONOMY = 'site-review-category'; |
|
20 | + const CAPABILITY = 'edit_others_posts'; |
|
21 | + const CRON_EVENT = 'site-reviews/schedule/session/purge'; |
|
22 | + const ID = 'site-reviews'; |
|
23 | + const PAGED_QUERY_VAR = 'reviews-page'; |
|
24 | + const POST_TYPE = 'site-review'; |
|
25 | + const PREFIX = 'glsr_'; |
|
26 | + const TAXONOMY = 'site-review-category'; |
|
27 | 27 | |
28 | - public $addons = []; |
|
29 | - public $defaults; |
|
30 | - public $deprecated = []; |
|
31 | - public $file; |
|
32 | - public $languages; |
|
33 | - public $mceShortcodes = []; //defined elsewhere |
|
34 | - public $name; |
|
35 | - public $postTypeColumns = []; // defined elsewhere |
|
36 | - public $reviewTypes; |
|
37 | - public $schemas = []; //defined elsewhere |
|
38 | - public $version; |
|
28 | + public $addons = []; |
|
29 | + public $defaults; |
|
30 | + public $deprecated = []; |
|
31 | + public $file; |
|
32 | + public $languages; |
|
33 | + public $mceShortcodes = []; //defined elsewhere |
|
34 | + public $name; |
|
35 | + public $postTypeColumns = []; // defined elsewhere |
|
36 | + public $reviewTypes; |
|
37 | + public $schemas = []; //defined elsewhere |
|
38 | + public $version; |
|
39 | 39 | |
40 | - public function __construct() |
|
41 | - { |
|
42 | - static::$instance = $this; |
|
43 | - $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
44 | - $plugin = get_file_data($this->file, [ |
|
45 | - 'languages' => 'Domain Path', |
|
46 | - 'name' => 'Plugin Name', |
|
47 | - 'version' => 'Version', |
|
48 | - ], 'plugin'); |
|
49 | - array_walk($plugin, function ($value, $key) { |
|
50 | - $this->$key = $value; |
|
51 | - }); |
|
52 | - } |
|
40 | + public function __construct() |
|
41 | + { |
|
42 | + static::$instance = $this; |
|
43 | + $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
44 | + $plugin = get_file_data($this->file, [ |
|
45 | + 'languages' => 'Domain Path', |
|
46 | + 'name' => 'Plugin Name', |
|
47 | + 'version' => 'Version', |
|
48 | + ], 'plugin'); |
|
49 | + array_walk($plugin, function ($value, $key) { |
|
50 | + $this->$key = $value; |
|
51 | + }); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function activate() |
|
58 | - { |
|
59 | - $this->scheduleCronJob(); |
|
60 | - add_option(static::PREFIX.'activated', true); |
|
61 | - } |
|
54 | + /** |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function activate() |
|
58 | + { |
|
59 | + $this->scheduleCronJob(); |
|
60 | + add_option(static::PREFIX.'activated', true); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param string $view |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function build($view, array $data = []) |
|
68 | - { |
|
69 | - ob_start(); |
|
70 | - $this->render($view, $data); |
|
71 | - return ob_get_clean(); |
|
72 | - } |
|
63 | + /** |
|
64 | + * @param string $view |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function build($view, array $data = []) |
|
68 | + { |
|
69 | + ob_start(); |
|
70 | + $this->render($view, $data); |
|
71 | + return ob_get_clean(); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param string $capability |
|
76 | - * @return bool |
|
77 | - */ |
|
78 | - public function can($capability) |
|
79 | - { |
|
80 | - return $this->make(Role::class)->can($capability); |
|
81 | - } |
|
74 | + /** |
|
75 | + * @param string $capability |
|
76 | + * @return bool |
|
77 | + */ |
|
78 | + public function can($capability) |
|
79 | + { |
|
80 | + return $this->make(Role::class)->can($capability); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @return void |
|
85 | - */ |
|
86 | - public function catchFatalError() |
|
87 | - { |
|
88 | - $error = error_get_last(); |
|
89 | - if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) { |
|
90 | - return; |
|
91 | - } |
|
92 | - glsr_log()->error($error['message']); |
|
93 | - } |
|
83 | + /** |
|
84 | + * @return void |
|
85 | + */ |
|
86 | + public function catchFatalError() |
|
87 | + { |
|
88 | + $error = error_get_last(); |
|
89 | + if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) { |
|
90 | + return; |
|
91 | + } |
|
92 | + glsr_log()->error($error['message']); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @param string $name |
|
97 | - * @return array |
|
98 | - */ |
|
99 | - public function config($name) |
|
100 | - { |
|
101 | - $configFile = $this->path('config/'.$name.'.php'); |
|
102 | - $config = file_exists($configFile) |
|
103 | - ? include $configFile |
|
104 | - : []; |
|
105 | - return apply_filters('site-reviews/config/'.$name, $config); |
|
106 | - } |
|
95 | + /** |
|
96 | + * @param string $name |
|
97 | + * @return array |
|
98 | + */ |
|
99 | + public function config($name) |
|
100 | + { |
|
101 | + $configFile = $this->path('config/'.$name.'.php'); |
|
102 | + $config = file_exists($configFile) |
|
103 | + ? include $configFile |
|
104 | + : []; |
|
105 | + return apply_filters('site-reviews/config/'.$name, $config); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * @param string $property |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function constant($property, $className = 'static') |
|
113 | - { |
|
114 | - $constant = $className.'::'.$property; |
|
115 | - return defined($constant) |
|
116 | - ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
117 | - : ''; |
|
118 | - } |
|
108 | + /** |
|
109 | + * @param string $property |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function constant($property, $className = 'static') |
|
113 | + { |
|
114 | + $constant = $className.'::'.$property; |
|
115 | + return defined($constant) |
|
116 | + ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
117 | + : ''; |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * @return void |
|
122 | - */ |
|
123 | - public function deactivate() |
|
124 | - { |
|
125 | - $this->unscheduleCronJob(); |
|
126 | - } |
|
120 | + /** |
|
121 | + * @return void |
|
122 | + */ |
|
123 | + public function deactivate() |
|
124 | + { |
|
125 | + $this->unscheduleCronJob(); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * @param string $view |
|
130 | - * @return void|string |
|
131 | - */ |
|
132 | - public function file($view) |
|
133 | - { |
|
134 | - $view.= '.php'; |
|
135 | - $filePaths = []; |
|
136 | - if (Str::startsWith('templates/', $view)) { |
|
137 | - $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view)); |
|
138 | - } |
|
139 | - $filePaths[] = $this->path($view); |
|
140 | - $filePaths[] = $this->path('views/'.$view); |
|
141 | - foreach ($filePaths as $file) { |
|
142 | - if (!file_exists($file)) { |
|
143 | - continue; |
|
144 | - } |
|
145 | - return $file; |
|
146 | - } |
|
147 | - } |
|
128 | + /** |
|
129 | + * @param string $view |
|
130 | + * @return void|string |
|
131 | + */ |
|
132 | + public function file($view) |
|
133 | + { |
|
134 | + $view.= '.php'; |
|
135 | + $filePaths = []; |
|
136 | + if (Str::startsWith('templates/', $view)) { |
|
137 | + $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view)); |
|
138 | + } |
|
139 | + $filePaths[] = $this->path($view); |
|
140 | + $filePaths[] = $this->path('views/'.$view); |
|
141 | + foreach ($filePaths as $file) { |
|
142 | + if (!file_exists($file)) { |
|
143 | + continue; |
|
144 | + } |
|
145 | + return $file; |
|
146 | + } |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @return array |
|
151 | - */ |
|
152 | - public function getDefaults() |
|
153 | - { |
|
154 | - if (empty($this->defaults)) { |
|
155 | - $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
156 | - } |
|
157 | - return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
158 | - } |
|
149 | + /** |
|
150 | + * @return array |
|
151 | + */ |
|
152 | + public function getDefaults() |
|
153 | + { |
|
154 | + if (empty($this->defaults)) { |
|
155 | + $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
156 | + } |
|
157 | + return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * @param string $page |
|
162 | - * @param string $tab |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function getPermission($page = '', $tab = 'index') |
|
166 | - { |
|
167 | - $fallback = 'edit_posts'; |
|
168 | - $permissions = [ |
|
169 | - 'addons' => 'install_plugins', |
|
170 | - 'documentation' => [ |
|
171 | - 'faq' => 'edit_others_posts', |
|
172 | - 'functions' => 'manage_options', |
|
173 | - 'hooks' => 'edit_others_posts', |
|
174 | - 'index' => 'edit_posts', |
|
175 | - 'support' => 'edit_others_posts', |
|
176 | - ], |
|
177 | - 'settings' => 'manage_options', |
|
178 | - 'tools' => [ |
|
179 | - 'console' => 'edit_others_posts', |
|
180 | - 'general' => 'edit_others_posts', |
|
181 | - 'index' => 'edit_others_posts', |
|
182 | - 'sync' => 'manage_options', |
|
183 | - 'system-info' => 'edit_others_posts', |
|
184 | - ] |
|
185 | - ]; |
|
186 | - $permission = Arr::get($permissions, $page, $fallback); |
|
187 | - if (is_array($permission)) { |
|
188 | - $permission = Arr::get($permission, $tab, $fallback); |
|
189 | - } |
|
190 | - return empty($permission) || !is_string($permission) |
|
191 | - ? $fallback |
|
192 | - : $permission; |
|
193 | - } |
|
160 | + /** |
|
161 | + * @param string $page |
|
162 | + * @param string $tab |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function getPermission($page = '', $tab = 'index') |
|
166 | + { |
|
167 | + $fallback = 'edit_posts'; |
|
168 | + $permissions = [ |
|
169 | + 'addons' => 'install_plugins', |
|
170 | + 'documentation' => [ |
|
171 | + 'faq' => 'edit_others_posts', |
|
172 | + 'functions' => 'manage_options', |
|
173 | + 'hooks' => 'edit_others_posts', |
|
174 | + 'index' => 'edit_posts', |
|
175 | + 'support' => 'edit_others_posts', |
|
176 | + ], |
|
177 | + 'settings' => 'manage_options', |
|
178 | + 'tools' => [ |
|
179 | + 'console' => 'edit_others_posts', |
|
180 | + 'general' => 'edit_others_posts', |
|
181 | + 'index' => 'edit_others_posts', |
|
182 | + 'sync' => 'manage_options', |
|
183 | + 'system-info' => 'edit_others_posts', |
|
184 | + ] |
|
185 | + ]; |
|
186 | + $permission = Arr::get($permissions, $page, $fallback); |
|
187 | + if (is_array($permission)) { |
|
188 | + $permission = Arr::get($permission, $tab, $fallback); |
|
189 | + } |
|
190 | + return empty($permission) || !is_string($permission) |
|
191 | + ? $fallback |
|
192 | + : $permission; |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * @param string $page |
|
197 | - * @param string $tab |
|
198 | - * @return bool |
|
199 | - */ |
|
200 | - public function hasPermission($page = '', $tab = 'index') |
|
201 | - { |
|
202 | - $isAdmin = $this->isAdmin(); |
|
203 | - return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab))); |
|
204 | - } |
|
195 | + /** |
|
196 | + * @param string $page |
|
197 | + * @param string $tab |
|
198 | + * @return bool |
|
199 | + */ |
|
200 | + public function hasPermission($page = '', $tab = 'index') |
|
201 | + { |
|
202 | + $isAdmin = $this->isAdmin(); |
|
203 | + return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab))); |
|
204 | + } |
|
205 | 205 | |
206 | - /** |
|
207 | - * @return void |
|
208 | - */ |
|
209 | - public function init() |
|
210 | - { |
|
211 | - $this->make(Actions::class)->run(); |
|
212 | - $this->make(Filters::class)->run(); |
|
213 | - } |
|
206 | + /** |
|
207 | + * @return void |
|
208 | + */ |
|
209 | + public function init() |
|
210 | + { |
|
211 | + $this->make(Actions::class)->run(); |
|
212 | + $this->make(Filters::class)->run(); |
|
213 | + } |
|
214 | 214 | |
215 | - /** |
|
216 | - * @return bool |
|
217 | - */ |
|
218 | - public function isAdmin() |
|
219 | - { |
|
220 | - return is_admin() && !wp_doing_ajax(); |
|
221 | - } |
|
215 | + /** |
|
216 | + * @return bool |
|
217 | + */ |
|
218 | + public function isAdmin() |
|
219 | + { |
|
220 | + return is_admin() && !wp_doing_ajax(); |
|
221 | + } |
|
222 | 222 | |
223 | - /** |
|
224 | - * @param string $file |
|
225 | - * @return string |
|
226 | - */ |
|
227 | - public function path($file = '', $realpath = true) |
|
228 | - { |
|
229 | - $path = plugin_dir_path($this->file); |
|
230 | - if (!$realpath) { |
|
231 | - $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
232 | - } |
|
233 | - $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
234 | - return apply_filters('site-reviews/path', $path, $file); |
|
235 | - } |
|
223 | + /** |
|
224 | + * @param string $file |
|
225 | + * @return string |
|
226 | + */ |
|
227 | + public function path($file = '', $realpath = true) |
|
228 | + { |
|
229 | + $path = plugin_dir_path($this->file); |
|
230 | + if (!$realpath) { |
|
231 | + $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
232 | + } |
|
233 | + $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
234 | + return apply_filters('site-reviews/path', $path, $file); |
|
235 | + } |
|
236 | 236 | |
237 | - /** |
|
238 | - * @param object $addon |
|
239 | - * @return void |
|
240 | - */ |
|
241 | - public function register($addon) |
|
242 | - { |
|
243 | - try { |
|
244 | - $reflection = new \ReflectionClass($addon); |
|
245 | - if ($id = $reflection->getConstant('ID')) { |
|
246 | - $this->addons[] = $id; |
|
247 | - $this->bind($id, $addon); |
|
248 | - $addon->init(); |
|
249 | - } |
|
250 | - } catch(\ReflectionException $e) { |
|
251 | - glsr_log()->error('Attempted to register an invalid addon.'); |
|
252 | - } |
|
253 | - } |
|
237 | + /** |
|
238 | + * @param object $addon |
|
239 | + * @return void |
|
240 | + */ |
|
241 | + public function register($addon) |
|
242 | + { |
|
243 | + try { |
|
244 | + $reflection = new \ReflectionClass($addon); |
|
245 | + if ($id = $reflection->getConstant('ID')) { |
|
246 | + $this->addons[] = $id; |
|
247 | + $this->bind($id, $addon); |
|
248 | + $addon->init(); |
|
249 | + } |
|
250 | + } catch(\ReflectionException $e) { |
|
251 | + glsr_log()->error('Attempted to register an invalid addon.'); |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - /** |
|
256 | - * @return void |
|
257 | - */ |
|
258 | - public function registerAddons() |
|
259 | - { |
|
260 | - do_action('site-reviews/addon/register', $this); |
|
261 | - } |
|
255 | + /** |
|
256 | + * @return void |
|
257 | + */ |
|
258 | + public function registerAddons() |
|
259 | + { |
|
260 | + do_action('site-reviews/addon/register', $this); |
|
261 | + } |
|
262 | 262 | |
263 | - /** |
|
264 | - * @return void |
|
265 | - */ |
|
266 | - public function registerLanguages() |
|
267 | - { |
|
268 | - load_plugin_textdomain(static::ID, false, |
|
269 | - trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
270 | - ); |
|
271 | - } |
|
263 | + /** |
|
264 | + * @return void |
|
265 | + */ |
|
266 | + public function registerLanguages() |
|
267 | + { |
|
268 | + load_plugin_textdomain(static::ID, false, |
|
269 | + trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
270 | + ); |
|
271 | + } |
|
272 | 272 | |
273 | - /** |
|
274 | - * @return void |
|
275 | - */ |
|
276 | - public function registerReviewTypes() |
|
277 | - { |
|
278 | - $types = apply_filters('site-reviews/addon/types', []); |
|
279 | - $this->reviewTypes = wp_parse_args($types, [ |
|
280 | - 'local' => __('Local', 'site-reviews'), |
|
281 | - ]); |
|
282 | - } |
|
273 | + /** |
|
274 | + * @return void |
|
275 | + */ |
|
276 | + public function registerReviewTypes() |
|
277 | + { |
|
278 | + $types = apply_filters('site-reviews/addon/types', []); |
|
279 | + $this->reviewTypes = wp_parse_args($types, [ |
|
280 | + 'local' => __('Local', 'site-reviews'), |
|
281 | + ]); |
|
282 | + } |
|
283 | 283 | |
284 | - /** |
|
285 | - * @param string $view |
|
286 | - * @return void |
|
287 | - */ |
|
288 | - public function render($view, array $data = []) |
|
289 | - { |
|
290 | - $view = apply_filters('site-reviews/render/view', $view, $data); |
|
291 | - $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
292 | - if (!file_exists($file)) { |
|
293 | - glsr_log()->error('File not found: '.$file); |
|
294 | - return; |
|
295 | - } |
|
296 | - $data = apply_filters('site-reviews/views/data', $data, $view); |
|
297 | - extract($data); |
|
298 | - include $file; |
|
299 | - } |
|
284 | + /** |
|
285 | + * @param string $view |
|
286 | + * @return void |
|
287 | + */ |
|
288 | + public function render($view, array $data = []) |
|
289 | + { |
|
290 | + $view = apply_filters('site-reviews/render/view', $view, $data); |
|
291 | + $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
292 | + if (!file_exists($file)) { |
|
293 | + glsr_log()->error('File not found: '.$file); |
|
294 | + return; |
|
295 | + } |
|
296 | + $data = apply_filters('site-reviews/views/data', $data, $view); |
|
297 | + extract($data); |
|
298 | + include $file; |
|
299 | + } |
|
300 | 300 | |
301 | - /** |
|
302 | - * @return void |
|
303 | - */ |
|
304 | - public function scheduleCronJob() |
|
305 | - { |
|
306 | - if (false === wp_next_scheduled(static::CRON_EVENT)) { |
|
307 | - wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
308 | - } |
|
309 | - } |
|
301 | + /** |
|
302 | + * @return void |
|
303 | + */ |
|
304 | + public function scheduleCronJob() |
|
305 | + { |
|
306 | + if (false === wp_next_scheduled(static::CRON_EVENT)) { |
|
307 | + wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
308 | + } |
|
309 | + } |
|
310 | 310 | |
311 | - /** |
|
312 | - * @return void |
|
313 | - */ |
|
314 | - public function setDefaults() |
|
315 | - { |
|
316 | - if (get_option(static::PREFIX.'activated')) { |
|
317 | - $this->make(DefaultsManager::class)->set(); |
|
318 | - delete_option(static::PREFIX.'activated'); |
|
319 | - } |
|
320 | - } |
|
311 | + /** |
|
312 | + * @return void |
|
313 | + */ |
|
314 | + public function setDefaults() |
|
315 | + { |
|
316 | + if (get_option(static::PREFIX.'activated')) { |
|
317 | + $this->make(DefaultsManager::class)->set(); |
|
318 | + delete_option(static::PREFIX.'activated'); |
|
319 | + } |
|
320 | + } |
|
321 | 321 | |
322 | - /** |
|
323 | - * @param string $file |
|
324 | - * @return string |
|
325 | - */ |
|
326 | - public function themePath($file = '') |
|
327 | - { |
|
328 | - return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
329 | - } |
|
322 | + /** |
|
323 | + * @param string $file |
|
324 | + * @return string |
|
325 | + */ |
|
326 | + public function themePath($file = '') |
|
327 | + { |
|
328 | + return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
329 | + } |
|
330 | 330 | |
331 | - /** |
|
332 | - * @return void |
|
333 | - */ |
|
334 | - public function unscheduleCronJob() |
|
335 | - { |
|
336 | - wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
337 | - } |
|
331 | + /** |
|
332 | + * @return void |
|
333 | + */ |
|
334 | + public function unscheduleCronJob() |
|
335 | + { |
|
336 | + wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
337 | + } |
|
338 | 338 | |
339 | - /** |
|
340 | - * @param string $path |
|
341 | - * @return string |
|
342 | - */ |
|
343 | - public function url($path = '') |
|
344 | - { |
|
345 | - $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
346 | - return apply_filters('site-reviews/url', $url, $path); |
|
347 | - } |
|
339 | + /** |
|
340 | + * @param string $path |
|
341 | + * @return string |
|
342 | + */ |
|
343 | + public function url($path = '') |
|
344 | + { |
|
345 | + $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
346 | + return apply_filters('site-reviews/url', $url, $path); |
|
347 | + } |
|
348 | 348 | |
349 | - /** |
|
350 | - * @param string $versionLevel |
|
351 | - * @return string |
|
352 | - */ |
|
353 | - public function version($versionLevel = '') |
|
354 | - { |
|
355 | - $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i'; |
|
356 | - preg_match($pattern, $this->version, $matches); |
|
357 | - switch ($versionLevel) { |
|
358 | - case 'major': |
|
359 | - $version = Arr::get($matches, 1); |
|
360 | - break; |
|
361 | - case 'minor': |
|
362 | - $version = Arr::get($matches, 1).Arr::get($matches, 2); |
|
363 | - break; |
|
364 | - case 'patch': |
|
365 | - $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3); |
|
366 | - break; |
|
367 | - } |
|
368 | - return empty($version) |
|
369 | - ? $this->version |
|
370 | - : $version; |
|
371 | - } |
|
349 | + /** |
|
350 | + * @param string $versionLevel |
|
351 | + * @return string |
|
352 | + */ |
|
353 | + public function version($versionLevel = '') |
|
354 | + { |
|
355 | + $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i'; |
|
356 | + preg_match($pattern, $this->version, $matches); |
|
357 | + switch ($versionLevel) { |
|
358 | + case 'major': |
|
359 | + $version = Arr::get($matches, 1); |
|
360 | + break; |
|
361 | + case 'minor': |
|
362 | + $version = Arr::get($matches, 1).Arr::get($matches, 2); |
|
363 | + break; |
|
364 | + case 'patch': |
|
365 | + $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3); |
|
366 | + break; |
|
367 | + } |
|
368 | + return empty($version) |
|
369 | + ? $this->version |
|
370 | + : $version; |
|
371 | + } |
|
372 | 372 | } |
@@ -8,28 +8,28 @@ |
||
8 | 8 | |
9 | 9 | class TogglePinned |
10 | 10 | { |
11 | - /** |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function handle(Command $command) |
|
15 | - { |
|
16 | - if (!get_post($command->id)) { |
|
17 | - return false; |
|
18 | - } |
|
19 | - if (!glsr()->can('edit_others_posts')) { |
|
20 | - $meta = (Database::class)->get($command->id, 'pinned'); |
|
21 | - return wp_validate_boolean($meta); |
|
22 | - } |
|
23 | - if (is_null($command->pinned)) { |
|
24 | - $meta = glsr(Database::class)->get($command->id, 'pinned'); |
|
25 | - $command->pinned = !wp_validate_boolean($meta); |
|
26 | - } else { |
|
27 | - $notice = $command->pinned |
|
28 | - ? __('Review pinned.', 'site-reviews') |
|
29 | - : __('Review unpinned.', 'site-reviews'); |
|
30 | - glsr(Notice::class)->addSuccess($notice); |
|
31 | - } |
|
32 | - glsr(Database::class)->update($command->id, 'pinned', $command->pinned); |
|
33 | - return $command->pinned; |
|
34 | - } |
|
11 | + /** |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function handle(Command $command) |
|
15 | + { |
|
16 | + if (!get_post($command->id)) { |
|
17 | + return false; |
|
18 | + } |
|
19 | + if (!glsr()->can('edit_others_posts')) { |
|
20 | + $meta = (Database::class)->get($command->id, 'pinned'); |
|
21 | + return wp_validate_boolean($meta); |
|
22 | + } |
|
23 | + if (is_null($command->pinned)) { |
|
24 | + $meta = glsr(Database::class)->get($command->id, 'pinned'); |
|
25 | + $command->pinned = !wp_validate_boolean($meta); |
|
26 | + } else { |
|
27 | + $notice = $command->pinned |
|
28 | + ? __('Review pinned.', 'site-reviews') |
|
29 | + : __('Review unpinned.', 'site-reviews'); |
|
30 | + glsr(Notice::class)->addSuccess($notice); |
|
31 | + } |
|
32 | + glsr(Database::class)->update($command->id, 'pinned', $command->pinned); |
|
33 | + return $command->pinned; |
|
34 | + } |
|
35 | 35 | } |
@@ -6,133 +6,133 @@ |
||
6 | 6 | |
7 | 7 | class Role |
8 | 8 | { |
9 | - /** |
|
10 | - * @param string $role |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function addCapabilities($role) |
|
14 | - { |
|
15 | - $roleCapabilities = $this->roleCapabilities(); |
|
16 | - $wpRole = get_role($role); |
|
17 | - if (empty($wpRole) || !array_key_exists($role, $roleCapabilities)) { |
|
18 | - return; |
|
19 | - } |
|
20 | - foreach ($roleCapabilities[$role] as $capability) { |
|
21 | - $wpRole->add_cap($this->normalizeCapability($capability)); |
|
22 | - } |
|
23 | - } |
|
9 | + /** |
|
10 | + * @param string $role |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function addCapabilities($role) |
|
14 | + { |
|
15 | + $roleCapabilities = $this->roleCapabilities(); |
|
16 | + $wpRole = get_role($role); |
|
17 | + if (empty($wpRole) || !array_key_exists($role, $roleCapabilities)) { |
|
18 | + return; |
|
19 | + } |
|
20 | + foreach ($roleCapabilities[$role] as $capability) { |
|
21 | + $wpRole->add_cap($this->normalizeCapability($capability)); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param string $capability |
|
27 | - * @return bool |
|
28 | - */ |
|
29 | - public function can($capability) |
|
30 | - { |
|
31 | - return in_array($capability, $this->capabilities()) |
|
32 | - ? current_user_can($this->normalizeCapability($capability)) |
|
33 | - : current_user_can($capability); |
|
34 | - } |
|
25 | + /** |
|
26 | + * @param string $capability |
|
27 | + * @return bool |
|
28 | + */ |
|
29 | + public function can($capability) |
|
30 | + { |
|
31 | + return in_array($capability, $this->capabilities()) |
|
32 | + ? current_user_can($this->normalizeCapability($capability)) |
|
33 | + : current_user_can($capability); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param string $role |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public function removeCapabilities($role) |
|
41 | - { |
|
42 | - $wpRole = get_role($role); |
|
43 | - if (empty($wpRole) || 'administrator' === $role) { // do not remove from administrator role |
|
44 | - return; |
|
45 | - } |
|
46 | - foreach ($this->capabilities() as $capability) { |
|
47 | - $wpRole->remove_cap($this->normalizeCapability($capability)); |
|
48 | - } |
|
49 | - } |
|
36 | + /** |
|
37 | + * @param string $role |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public function removeCapabilities($role) |
|
41 | + { |
|
42 | + $wpRole = get_role($role); |
|
43 | + if (empty($wpRole) || 'administrator' === $role) { // do not remove from administrator role |
|
44 | + return; |
|
45 | + } |
|
46 | + foreach ($this->capabilities() as $capability) { |
|
47 | + $wpRole->remove_cap($this->normalizeCapability($capability)); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public function resetAll() |
|
55 | - { |
|
56 | - $roles = array_keys(wp_roles()->roles); |
|
57 | - array_walk($roles, [$this, 'removeCapabilities']); |
|
58 | - $roles = array_keys($this->roleCapabilities()); |
|
59 | - array_walk($roles, [$this, 'addCapabilities']); |
|
60 | - } |
|
51 | + /** |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public function resetAll() |
|
55 | + { |
|
56 | + $roles = array_keys(wp_roles()->roles); |
|
57 | + array_walk($roles, [$this, 'removeCapabilities']); |
|
58 | + $roles = array_keys($this->roleCapabilities()); |
|
59 | + array_walk($roles, [$this, 'addCapabilities']); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return array |
|
64 | - */ |
|
65 | - protected function capabilities() |
|
66 | - { |
|
67 | - $capabilities = [ |
|
68 | - 'delete_others_posts', |
|
69 | - 'delete_post', |
|
70 | - 'delete_posts', |
|
71 | - 'delete_private_posts', |
|
72 | - 'delete_published_posts', |
|
73 | - 'edit_others_posts', |
|
74 | - 'edit_post', |
|
75 | - 'edit_posts', |
|
76 | - 'edit_private_posts', |
|
77 | - 'edit_published_posts', |
|
78 | - 'publish_posts', |
|
79 | - 'read_post', |
|
80 | - 'read_private_posts', |
|
81 | - ]; |
|
82 | - return apply_filters('site-reviews/capabilities', $capabilities); |
|
83 | - } |
|
62 | + /** |
|
63 | + * @return array |
|
64 | + */ |
|
65 | + protected function capabilities() |
|
66 | + { |
|
67 | + $capabilities = [ |
|
68 | + 'delete_others_posts', |
|
69 | + 'delete_post', |
|
70 | + 'delete_posts', |
|
71 | + 'delete_private_posts', |
|
72 | + 'delete_published_posts', |
|
73 | + 'edit_others_posts', |
|
74 | + 'edit_post', |
|
75 | + 'edit_posts', |
|
76 | + 'edit_private_posts', |
|
77 | + 'edit_published_posts', |
|
78 | + 'publish_posts', |
|
79 | + 'read_post', |
|
80 | + 'read_private_posts', |
|
81 | + ]; |
|
82 | + return apply_filters('site-reviews/capabilities', $capabilities); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $capability |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - protected function normalizeCapability($capability) |
|
90 | - { |
|
91 | - return str_replace('post', Application::POST_TYPE, $capability); |
|
92 | - } |
|
85 | + /** |
|
86 | + * @param string $capability |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + protected function normalizeCapability($capability) |
|
90 | + { |
|
91 | + return str_replace('post', Application::POST_TYPE, $capability); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - protected function roleCapabilities() |
|
98 | - { |
|
99 | - $capabilities = [ |
|
100 | - 'administrator' => [ |
|
101 | - 'delete_others_posts', |
|
102 | - 'delete_posts', |
|
103 | - 'delete_private_posts', |
|
104 | - 'delete_published_posts', |
|
105 | - 'edit_others_posts', |
|
106 | - 'edit_posts', |
|
107 | - 'edit_private_posts', |
|
108 | - 'edit_published_posts', |
|
109 | - 'publish_posts', |
|
110 | - 'read_private_posts', |
|
111 | - ], |
|
112 | - 'editor' => [ |
|
113 | - 'delete_others_posts', |
|
114 | - 'delete_posts', |
|
115 | - 'delete_private_posts', |
|
116 | - 'delete_published_posts', |
|
117 | - 'edit_others_posts', |
|
118 | - 'edit_posts', |
|
119 | - 'edit_private_posts', |
|
120 | - 'edit_published_posts', |
|
121 | - 'publish_posts', |
|
122 | - 'read_private_posts', |
|
123 | - ], |
|
124 | - 'author' => [ |
|
125 | - 'delete_posts', |
|
126 | - 'delete_published_posts', |
|
127 | - 'edit_posts', |
|
128 | - 'edit_published_posts', |
|
129 | - 'publish_posts', |
|
130 | - ], |
|
131 | - 'contributor' => [ |
|
132 | - 'delete_posts', |
|
133 | - 'edit_posts', |
|
134 | - ], |
|
135 | - ]; |
|
136 | - return apply_filters('site-reviews/capabilities/for-roles', $capabilities); |
|
137 | - } |
|
94 | + /** |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + protected function roleCapabilities() |
|
98 | + { |
|
99 | + $capabilities = [ |
|
100 | + 'administrator' => [ |
|
101 | + 'delete_others_posts', |
|
102 | + 'delete_posts', |
|
103 | + 'delete_private_posts', |
|
104 | + 'delete_published_posts', |
|
105 | + 'edit_others_posts', |
|
106 | + 'edit_posts', |
|
107 | + 'edit_private_posts', |
|
108 | + 'edit_published_posts', |
|
109 | + 'publish_posts', |
|
110 | + 'read_private_posts', |
|
111 | + ], |
|
112 | + 'editor' => [ |
|
113 | + 'delete_others_posts', |
|
114 | + 'delete_posts', |
|
115 | + 'delete_private_posts', |
|
116 | + 'delete_published_posts', |
|
117 | + 'edit_others_posts', |
|
118 | + 'edit_posts', |
|
119 | + 'edit_private_posts', |
|
120 | + 'edit_published_posts', |
|
121 | + 'publish_posts', |
|
122 | + 'read_private_posts', |
|
123 | + ], |
|
124 | + 'author' => [ |
|
125 | + 'delete_posts', |
|
126 | + 'delete_published_posts', |
|
127 | + 'edit_posts', |
|
128 | + 'edit_published_posts', |
|
129 | + 'publish_posts', |
|
130 | + ], |
|
131 | + 'contributor' => [ |
|
132 | + 'delete_posts', |
|
133 | + 'edit_posts', |
|
134 | + ], |
|
135 | + ]; |
|
136 | + return apply_filters('site-reviews/capabilities/for-roles', $capabilities); |
|
137 | + } |
|
138 | 138 | } |