@@ -1,17 +1,17 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="is-fullwidth"> |
4 | 4 | <div class="glsr-flex-row glsr-has-2-columns"> |
5 | 5 | <div class="glsr-column"> |
6 | 6 | <h3>Editor Blocks</h3> |
7 | 7 | <p>The fastest way to getting started with Site Reviews is to use the three provided blocks in the WordPress Block Editor. Each block comes with multiple settings which let you configure the block exactly as needed. To add a block to your page, click the "Add Block" button and search for "Site Reviews".</p> |
8 | - <img class="screenshot" src="<?= glsr()->url('assets/images/blocks.png'); ?>" alt="Editor Blocks" /> |
|
8 | + <img class="screenshot" src="<?= glsr()->url( 'assets/images/blocks.png' ); ?>" alt="Editor Blocks" /> |
|
9 | 9 | </div> |
10 | 10 | <div class="glsr-column"> |
11 | 11 | <h3>Shortcodes and Widgets</h3> |
12 | 12 | <p>You can also use the shortcodes or widgets on your page. Keep in mind, however, that widgets are limited in options compared to the shortcodes (for example, the "Latest Reviews" widget does not allow pagination). If you are using the Classic Editor in WordPress, you can click on the Site Reviews shortcode button above the editor (next to the media button) to add a shortcode via a friendly popup.</p> |
13 | 13 | <p>To learn more about the shortcodes and the available shortcode options, please see the Shortcode Documentation page of the plugin.</p> |
14 | - <a class="button" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">View Shortcode Documentation</a> |
|
14 | + <a class="button" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">View Shortcode Documentation</a> |
|
15 | 15 | </div> |
16 | 16 | </div> |
17 | 17 | </div> |
@@ -20,27 +20,27 @@ discard block |
||
20 | 20 | <h2>Features</h2> |
21 | 21 | <ul class="glsr-flex-row glsr-has-3-columns"> |
22 | 22 | <li class="glsr-column"> |
23 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-reviews'); ?>">Avatars</a></h3> |
|
23 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-reviews' ); ?>">Avatars</a></h3> |
|
24 | 24 | <p>Enable avatars to generate images using the WordPress Gravatar service.</p> |
25 | 25 | </li> |
26 | 26 | <li class="glsr-column"> |
27 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=tools#tab-general'); ?>">Backup/Restore</a></h3> |
|
27 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=tools#tab-general' ); ?>">Backup/Restore</a></h3> |
|
28 | 28 | <p>Backup and restore your plugin settings as needed.</p> |
29 | 29 | </li> |
30 | 30 | <li class="glsr-column"> |
31 | - <h3><a data-expand="#faq-14" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Bayesian Ranking</a></h3> |
|
31 | + <h3><a data-expand="#faq-14" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Bayesian Ranking</a></h3> |
|
32 | 32 | <p>Easily rank pages with assigned reviews using the bayesian algorithm.</p> |
33 | 33 | </li> |
34 | 34 | <li class="glsr-column"> |
35 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions'); ?>">Blacklist</a></h3> |
|
35 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions' ); ?>">Blacklist</a></h3> |
|
36 | 36 | <p>Blacklist words, phrases, IP addresses, names, and emails.</p> |
37 | 37 | </li> |
38 | 38 | <li class="glsr-column"> |
39 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Blockchain Validation</a></h3> |
|
39 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Blockchain Validation</a></h3> |
|
40 | 40 | <p>Verify your reviews on the Blockchain with <a href="https://trustalyze.com?ref=105">Trustalyze</a>.</p> |
41 | 41 | </li> |
42 | 42 | <li class="glsr-column"> |
43 | - <h3><a href="<?= admin_url('edit-tags.php?taxonomy=site-review-category&post_type=site-review'); ?>">Categories</a></h3> |
|
43 | + <h3><a href="<?= admin_url( 'edit-tags.php?taxonomy=site-review-category&post_type=site-review' ); ?>">Categories</a></h3> |
|
44 | 44 | <p>Add your own categories and assign reviews to them.</p> |
45 | 45 | </li> |
46 | 46 | <li class="glsr-column"> |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | <p>Designed for WordPress developers with over 100 filter hooks and convenient functions.</p> |
49 | 49 | </li> |
50 | 50 | <li class="glsr-column"> |
51 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Documentation</a></h3> |
|
51 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Documentation</a></h3> |
|
52 | 52 | <p>Provides FAQ and documenation for hooks and all shortcodes and functions.</p> |
53 | 53 | </li> |
54 | 54 | <li class="glsr-column"> |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | <p>Use configurable editor blocks in the new WordPress 5.0 editor.</p> |
57 | 57 | </li> |
58 | 58 | <li class="glsr-column"> |
59 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-schema'); ?>">JSON-LD Schema</a></h3> |
|
59 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-schema' ); ?>">JSON-LD Schema</a></h3> |
|
60 | 60 | <p>Enable JSON-LD schema to display your reviews and ratings in search results.</p> |
61 | 61 | </li> |
62 | 62 | <li class="glsr-column"> |
63 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Multilingual</a></h3> |
|
63 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Multilingual</a></h3> |
|
64 | 64 | <p>Integrates with Polylang and WPML and provides easy search/replace translation.</p> |
65 | 65 | </li> |
66 | 66 | <li class="glsr-column"> |
@@ -68,47 +68,47 @@ discard block |
||
68 | 68 | <p>Provides full support for the WordPress multisite feature.</p> |
69 | 69 | </li> |
70 | 70 | <li class="glsr-column"> |
71 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Notifications</a></h3> |
|
71 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Notifications</a></h3> |
|
72 | 72 | <p>Send notifications to one or more emails when a review is submitted.</p> |
73 | 73 | </li> |
74 | 74 | <li class="glsr-column"> |
75 | - <h3><a data-expand="#faq-03" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Page Assignment</a></h3> |
|
75 | + <h3><a data-expand="#faq-03" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Page Assignment</a></h3> |
|
76 | 76 | <p>Assign reviews to Posts, Pages, and Custom Post Types.</p> |
77 | 77 | </li> |
78 | 78 | <li class="glsr-column"> |
79 | - <h3><a data-expand="#faq-02" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Pagination</a></h3> |
|
79 | + <h3><a data-expand="#faq-02" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Pagination</a></h3> |
|
80 | 80 | <p>Enable AJAX pagination to display a custom number of reviews per-page.</p> |
81 | 81 | </li> |
82 | 82 | <li class="glsr-column"> |
83 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.''); ?>">Responses</a></h3> |
|
83 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'' ); ?>">Responses</a></h3> |
|
84 | 84 | <p>Write a response to reviews that require a response.</p> |
85 | 85 | </li> |
86 | 86 | <li class="glsr-column"> |
87 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Restrictions</a></h3> |
|
87 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Restrictions</a></h3> |
|
88 | 88 | <p>Require approval before publishing reviews and limit to registered users.</p> |
89 | 89 | </li> |
90 | 90 | <li class="glsr-column"> |
91 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions'); ?>">Review Limits</a></h3> |
|
91 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions' ); ?>">Review Limits</a></h3> |
|
92 | 92 | <p>Limit review submissions by email address, IP address, or username.</p> |
93 | 93 | </li> |
94 | 94 | <li class="glsr-column"> |
95 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Review Summaries</a></h3> |
|
95 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Review Summaries</a></h3> |
|
96 | 96 | <p>Display a summary of your review ratings from high to low.</p> |
97 | 97 | </li> |
98 | 98 | <li class="glsr-column"> |
99 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Shortcodes</a></h3> |
|
99 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Shortcodes</a></h3> |
|
100 | 100 | <p>Use the configurable shortcodes complete with documentation.</p> |
101 | 101 | </li> |
102 | 102 | <li class="glsr-column"> |
103 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Slack</a></h3> |
|
103 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Slack</a></h3> |
|
104 | 104 | <p>Receive notifications in Slack when a review is submitted.</p> |
105 | 105 | </li> |
106 | 106 | <li class="glsr-column"> |
107 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions'); ?>">SPAM Protection</a></h3> |
|
107 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions' ); ?>">SPAM Protection</a></h3> |
|
108 | 108 | <p>Uses a Honeypot and integrates with Invisible reCAPTCHA and Akismet.</p> |
109 | 109 | </li> |
110 | 110 | <li class="glsr-column"> |
111 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Styles</a></h3> |
|
111 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Styles</a></h3> |
|
112 | 112 | <p>Change the submission form style to match popular themes and form plugins.</p> |
113 | 113 | </li> |
114 | 114 | <li class="glsr-column"> |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | <p>Free premium-level support included on the WordPress support forum.</p> |
117 | 117 | </li> |
118 | 118 | <li class="glsr-column"> |
119 | - <h3><a data-expand="#faq-18" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Templates</a></h3> |
|
119 | + <h3><a data-expand="#faq-18" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Templates</a></h3> |
|
120 | 120 | <p>Use the Site Reviews templates in your theme for full control over the HTML.</p> |
121 | 121 | </li> |
122 | 122 | <li class="glsr-column"> |
123 | - <h3><a href="<?= admin_url('widgets.php'); ?>">Widgets</a></h3> |
|
123 | + <h3><a href="<?= admin_url( 'widgets.php' ); ?>">Widgets</a></h3> |
|
124 | 124 | <p>Use the configurable widgets in your sidebars.</p> |
125 | 125 | </li> |
126 | 126 | </ul> |
@@ -15,197 +15,197 @@ |
||
15 | 15 | |
16 | 16 | class MenuController extends Controller |
17 | 17 | { |
18 | - /** |
|
19 | - * @return void |
|
20 | - * @action admin_menu |
|
21 | - */ |
|
22 | - public function registerMenuCount() |
|
23 | - { |
|
24 | - global $menu, $typenow; |
|
25 | - foreach ($menu as $key => $value) { |
|
26 | - if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) { |
|
27 | - continue; |
|
28 | - } |
|
29 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
30 | - $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [ |
|
31 | - 'class' => 'unapproved-count', |
|
32 | - ]); |
|
33 | - $awaitingModeration = glsr(Builder::class)->span($pendingCount, [ |
|
34 | - 'class' => 'awaiting-mod count-'.$postCount->pending, |
|
35 | - ]); |
|
36 | - $menu[$key][0].= ' '.$awaitingModeration; |
|
37 | - if (Application::POST_TYPE === $typenow) { |
|
38 | - $menu[$key][4].= ' current'; |
|
39 | - } |
|
40 | - break; |
|
41 | - } |
|
42 | - } |
|
18 | + /** |
|
19 | + * @return void |
|
20 | + * @action admin_menu |
|
21 | + */ |
|
22 | + public function registerMenuCount() |
|
23 | + { |
|
24 | + global $menu, $typenow; |
|
25 | + foreach ($menu as $key => $value) { |
|
26 | + if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) { |
|
27 | + continue; |
|
28 | + } |
|
29 | + $postCount = wp_count_posts(Application::POST_TYPE); |
|
30 | + $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [ |
|
31 | + 'class' => 'unapproved-count', |
|
32 | + ]); |
|
33 | + $awaitingModeration = glsr(Builder::class)->span($pendingCount, [ |
|
34 | + 'class' => 'awaiting-mod count-'.$postCount->pending, |
|
35 | + ]); |
|
36 | + $menu[$key][0].= ' '.$awaitingModeration; |
|
37 | + if (Application::POST_TYPE === $typenow) { |
|
38 | + $menu[$key][4].= ' current'; |
|
39 | + } |
|
40 | + break; |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @return void |
|
46 | - * @action admin_menu |
|
47 | - */ |
|
48 | - public function registerSubMenus() |
|
49 | - { |
|
50 | - $pages = $this->parseWithFilter('submenu/pages', [ |
|
51 | - 'settings' => __('Settings', 'site-reviews'), |
|
52 | - 'tools' => __('Tools', 'site-reviews'), |
|
53 | - // 'addons' => __('Add-ons', 'site-reviews'), |
|
54 | - 'documentation' => __('Help', 'site-reviews'), |
|
55 | - ]); |
|
56 | - foreach ($pages as $slug => $title) { |
|
57 | - $method = Helper::buildMethodName('render-'.$slug.'-menu'); |
|
58 | - $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug); |
|
59 | - if (!is_callable($callback)) { |
|
60 | - continue; |
|
61 | - } |
|
62 | - add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback); |
|
63 | - } |
|
64 | - } |
|
44 | + /** |
|
45 | + * @return void |
|
46 | + * @action admin_menu |
|
47 | + */ |
|
48 | + public function registerSubMenus() |
|
49 | + { |
|
50 | + $pages = $this->parseWithFilter('submenu/pages', [ |
|
51 | + 'settings' => __('Settings', 'site-reviews'), |
|
52 | + 'tools' => __('Tools', 'site-reviews'), |
|
53 | + // 'addons' => __('Add-ons', 'site-reviews'), |
|
54 | + 'documentation' => __('Help', 'site-reviews'), |
|
55 | + ]); |
|
56 | + foreach ($pages as $slug => $title) { |
|
57 | + $method = Helper::buildMethodName('render-'.$slug.'-menu'); |
|
58 | + $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug); |
|
59 | + if (!is_callable($callback)) { |
|
60 | + continue; |
|
61 | + } |
|
62 | + add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return void |
|
68 | - * @see $this->registerSubMenus() |
|
69 | - * @callback add_submenu_page |
|
70 | - */ |
|
71 | - public function renderAddonsMenu() |
|
72 | - { |
|
73 | - $this->renderPage('addons', [ |
|
74 | - 'template' => glsr(Template::class), |
|
75 | - ]); |
|
76 | - } |
|
66 | + /** |
|
67 | + * @return void |
|
68 | + * @see $this->registerSubMenus() |
|
69 | + * @callback add_submenu_page |
|
70 | + */ |
|
71 | + public function renderAddonsMenu() |
|
72 | + { |
|
73 | + $this->renderPage('addons', [ |
|
74 | + 'template' => glsr(Template::class), |
|
75 | + ]); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return void |
|
80 | - * @see $this->registerSubMenus() |
|
81 | - * @callback add_submenu_page |
|
82 | - */ |
|
83 | - public function renderDocumentationMenu() |
|
84 | - { |
|
85 | - $tabs = $this->parseWithFilter('documentation/tabs', [ |
|
86 | - 'support' => __('Support', 'site-reviews'), |
|
87 | - 'faq' => __('FAQ', 'site-reviews'), |
|
88 | - 'shortcodes' => __('Shortcodes', 'site-reviews'), |
|
89 | - 'hooks' => __('Hooks', 'site-reviews'), |
|
90 | - 'functions' => __('Functions', 'site-reviews'), |
|
91 | - 'addons' => __('Addons', 'site-reviews'), |
|
92 | - ]); |
|
93 | - $addons = apply_filters('site-reviews/addon/documentation', []); |
|
94 | - ksort($addons); |
|
95 | - if (empty($addons)) { |
|
96 | - unset($tabs['addons']); |
|
97 | - } |
|
98 | - $this->renderPage('documentation', [ |
|
99 | - 'addons' => $addons, |
|
100 | - 'tabs' => $tabs, |
|
101 | - ]); |
|
102 | - } |
|
78 | + /** |
|
79 | + * @return void |
|
80 | + * @see $this->registerSubMenus() |
|
81 | + * @callback add_submenu_page |
|
82 | + */ |
|
83 | + public function renderDocumentationMenu() |
|
84 | + { |
|
85 | + $tabs = $this->parseWithFilter('documentation/tabs', [ |
|
86 | + 'support' => __('Support', 'site-reviews'), |
|
87 | + 'faq' => __('FAQ', 'site-reviews'), |
|
88 | + 'shortcodes' => __('Shortcodes', 'site-reviews'), |
|
89 | + 'hooks' => __('Hooks', 'site-reviews'), |
|
90 | + 'functions' => __('Functions', 'site-reviews'), |
|
91 | + 'addons' => __('Addons', 'site-reviews'), |
|
92 | + ]); |
|
93 | + $addons = apply_filters('site-reviews/addon/documentation', []); |
|
94 | + ksort($addons); |
|
95 | + if (empty($addons)) { |
|
96 | + unset($tabs['addons']); |
|
97 | + } |
|
98 | + $this->renderPage('documentation', [ |
|
99 | + 'addons' => $addons, |
|
100 | + 'tabs' => $tabs, |
|
101 | + ]); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @return void |
|
106 | - * @see $this->registerSubMenus() |
|
107 | - * @callback add_submenu_page |
|
108 | - */ |
|
109 | - public function renderSettingsMenu() |
|
110 | - { |
|
111 | - $tabs = $this->parseWithFilter('settings/tabs', [ |
|
112 | - 'general' => __('General', 'site-reviews'), |
|
113 | - 'reviews' => __('Reviews', 'site-reviews'), |
|
114 | - 'submissions' => __('Submissions', 'site-reviews'), |
|
115 | - 'schema' => __('Schema', 'site-reviews'), |
|
116 | - 'translations' => __('Translations', 'site-reviews'), |
|
117 | - 'addons' => __('Addons', 'site-reviews'), |
|
118 | - 'licenses' => __('Licenses', 'site-reviews'), |
|
119 | - ]); |
|
120 | - if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) { |
|
121 | - unset($tabs['addons']); |
|
122 | - } |
|
123 | - if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) { |
|
124 | - unset($tabs['licenses']); |
|
125 | - } |
|
126 | - $this->renderPage('settings', [ |
|
127 | - 'settings' => glsr(Settings::class), |
|
128 | - 'tabs' => $tabs, |
|
129 | - ]); |
|
130 | - } |
|
104 | + /** |
|
105 | + * @return void |
|
106 | + * @see $this->registerSubMenus() |
|
107 | + * @callback add_submenu_page |
|
108 | + */ |
|
109 | + public function renderSettingsMenu() |
|
110 | + { |
|
111 | + $tabs = $this->parseWithFilter('settings/tabs', [ |
|
112 | + 'general' => __('General', 'site-reviews'), |
|
113 | + 'reviews' => __('Reviews', 'site-reviews'), |
|
114 | + 'submissions' => __('Submissions', 'site-reviews'), |
|
115 | + 'schema' => __('Schema', 'site-reviews'), |
|
116 | + 'translations' => __('Translations', 'site-reviews'), |
|
117 | + 'addons' => __('Addons', 'site-reviews'), |
|
118 | + 'licenses' => __('Licenses', 'site-reviews'), |
|
119 | + ]); |
|
120 | + if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) { |
|
121 | + unset($tabs['addons']); |
|
122 | + } |
|
123 | + if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) { |
|
124 | + unset($tabs['licenses']); |
|
125 | + } |
|
126 | + $this->renderPage('settings', [ |
|
127 | + 'settings' => glsr(Settings::class), |
|
128 | + 'tabs' => $tabs, |
|
129 | + ]); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @return void |
|
134 | - * @see $this->registerSubMenus() |
|
135 | - * @callback add_submenu_page |
|
136 | - */ |
|
137 | - public function renderToolsMenu() |
|
138 | - { |
|
139 | - $tabs = $this->parseWithFilter('tools/tabs', [ |
|
140 | - 'general' => __('General', 'site-reviews'), |
|
141 | - 'sync' => __('Sync Reviews', 'site-reviews'), |
|
142 | - 'console' => __('Console', 'site-reviews'), |
|
143 | - 'system-info' => __('System Info', 'site-reviews'), |
|
144 | - ]); |
|
145 | - if (!apply_filters('site-reviews/addon/sync/enable', false)) { |
|
146 | - unset($tabs['sync']); |
|
147 | - } |
|
148 | - $this->renderPage('tools', [ |
|
149 | - 'data' => [ |
|
150 | - 'context' => [ |
|
151 | - 'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE), |
|
152 | - 'console' => strval(glsr(Console::class)), |
|
153 | - 'id' => Application::ID, |
|
154 | - 'system' => strval(glsr(System::class)), |
|
155 | - ], |
|
156 | - 'services' => apply_filters('site-reviews/addon/sync/services', []), |
|
157 | - ], |
|
158 | - 'tabs' => $tabs, |
|
159 | - 'template' => glsr(Template::class), |
|
160 | - ]); |
|
161 | - } |
|
132 | + /** |
|
133 | + * @return void |
|
134 | + * @see $this->registerSubMenus() |
|
135 | + * @callback add_submenu_page |
|
136 | + */ |
|
137 | + public function renderToolsMenu() |
|
138 | + { |
|
139 | + $tabs = $this->parseWithFilter('tools/tabs', [ |
|
140 | + 'general' => __('General', 'site-reviews'), |
|
141 | + 'sync' => __('Sync Reviews', 'site-reviews'), |
|
142 | + 'console' => __('Console', 'site-reviews'), |
|
143 | + 'system-info' => __('System Info', 'site-reviews'), |
|
144 | + ]); |
|
145 | + if (!apply_filters('site-reviews/addon/sync/enable', false)) { |
|
146 | + unset($tabs['sync']); |
|
147 | + } |
|
148 | + $this->renderPage('tools', [ |
|
149 | + 'data' => [ |
|
150 | + 'context' => [ |
|
151 | + 'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE), |
|
152 | + 'console' => strval(glsr(Console::class)), |
|
153 | + 'id' => Application::ID, |
|
154 | + 'system' => strval(glsr(System::class)), |
|
155 | + ], |
|
156 | + 'services' => apply_filters('site-reviews/addon/sync/services', []), |
|
157 | + ], |
|
158 | + 'tabs' => $tabs, |
|
159 | + 'template' => glsr(Template::class), |
|
160 | + ]); |
|
161 | + } |
|
162 | 162 | |
163 | - /** |
|
164 | - * @return void |
|
165 | - * @action admin_init |
|
166 | - */ |
|
167 | - public function setCustomPermissions() |
|
168 | - { |
|
169 | - foreach (wp_roles()->roles as $role => $value) { |
|
170 | - wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE); |
|
171 | - } |
|
172 | - } |
|
163 | + /** |
|
164 | + * @return void |
|
165 | + * @action admin_init |
|
166 | + */ |
|
167 | + public function setCustomPermissions() |
|
168 | + { |
|
169 | + foreach (wp_roles()->roles as $role => $value) { |
|
170 | + wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE); |
|
171 | + } |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * @return string |
|
176 | - */ |
|
177 | - protected function getNotices() |
|
178 | - { |
|
179 | - return glsr(Builder::class)->div(glsr(Notice::class)->get(), [ |
|
180 | - 'id' => 'glsr-notices', |
|
181 | - ]); |
|
182 | - } |
|
174 | + /** |
|
175 | + * @return string |
|
176 | + */ |
|
177 | + protected function getNotices() |
|
178 | + { |
|
179 | + return glsr(Builder::class)->div(glsr(Notice::class)->get(), [ |
|
180 | + 'id' => 'glsr-notices', |
|
181 | + ]); |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * @param string $hookSuffix |
|
186 | - * @return array |
|
187 | - */ |
|
188 | - protected function parseWithFilter($hookSuffix, array $args = []) |
|
189 | - { |
|
190 | - if (Str::endsWith('/tabs', $hookSuffix)) { |
|
191 | - $page = str_replace('/tabs', '', $hookSuffix); |
|
192 | - foreach ($args as $tab => $title) { |
|
193 | - if (!glsr()->hasPermission($page, $tab)) { |
|
194 | - unset($args[$tab]); |
|
195 | - } |
|
196 | - } |
|
197 | - } |
|
198 | - return apply_filters('site-reviews/addon/'.$hookSuffix, $args); |
|
199 | - } |
|
184 | + /** |
|
185 | + * @param string $hookSuffix |
|
186 | + * @return array |
|
187 | + */ |
|
188 | + protected function parseWithFilter($hookSuffix, array $args = []) |
|
189 | + { |
|
190 | + if (Str::endsWith('/tabs', $hookSuffix)) { |
|
191 | + $page = str_replace('/tabs', '', $hookSuffix); |
|
192 | + foreach ($args as $tab => $title) { |
|
193 | + if (!glsr()->hasPermission($page, $tab)) { |
|
194 | + unset($args[$tab]); |
|
195 | + } |
|
196 | + } |
|
197 | + } |
|
198 | + return apply_filters('site-reviews/addon/'.$hookSuffix, $args); |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * @param string $page |
|
203 | - * @return void |
|
204 | - */ |
|
205 | - protected function renderPage($page, array $data = []) |
|
206 | - { |
|
207 | - $data['http_referer'] = (string) wp_get_referer(); |
|
208 | - $data['notices'] = $this->getNotices(); |
|
209 | - glsr()->render('pages/'.$page.'/index', $data); |
|
210 | - } |
|
201 | + /** |
|
202 | + * @param string $page |
|
203 | + * @return void |
|
204 | + */ |
|
205 | + protected function renderPage($page, array $data = []) |
|
206 | + { |
|
207 | + $data['http_referer'] = (string) wp_get_referer(); |
|
208 | + $data['notices'] = $this->getNotices(); |
|
209 | + glsr()->render('pages/'.$page.'/index', $data); |
|
210 | + } |
|
211 | 211 | } |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | public function registerMenuCount() |
23 | 23 | { |
24 | 24 | global $menu, $typenow; |
25 | - foreach ($menu as $key => $value) { |
|
26 | - if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) { |
|
25 | + foreach( $menu as $key => $value ) { |
|
26 | + if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE ) { |
|
27 | 27 | continue; |
28 | 28 | } |
29 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
30 | - $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [ |
|
29 | + $postCount = wp_count_posts( Application::POST_TYPE ); |
|
30 | + $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
|
31 | 31 | 'class' => 'unapproved-count', |
32 | - ]); |
|
33 | - $awaitingModeration = glsr(Builder::class)->span($pendingCount, [ |
|
32 | + ] ); |
|
33 | + $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [ |
|
34 | 34 | 'class' => 'awaiting-mod count-'.$postCount->pending, |
35 | - ]); |
|
36 | - $menu[$key][0].= ' '.$awaitingModeration; |
|
37 | - if (Application::POST_TYPE === $typenow) { |
|
38 | - $menu[$key][4].= ' current'; |
|
35 | + ] ); |
|
36 | + $menu[$key][0] .= ' '.$awaitingModeration; |
|
37 | + if( Application::POST_TYPE === $typenow ) { |
|
38 | + $menu[$key][4] .= ' current'; |
|
39 | 39 | } |
40 | 40 | break; |
41 | 41 | } |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function registerSubMenus() |
49 | 49 | { |
50 | - $pages = $this->parseWithFilter('submenu/pages', [ |
|
51 | - 'settings' => __('Settings', 'site-reviews'), |
|
52 | - 'tools' => __('Tools', 'site-reviews'), |
|
50 | + $pages = $this->parseWithFilter( 'submenu/pages', [ |
|
51 | + 'settings' => __( 'Settings', 'site-reviews' ), |
|
52 | + 'tools' => __( 'Tools', 'site-reviews' ), |
|
53 | 53 | // 'addons' => __('Add-ons', 'site-reviews'), |
54 | - 'documentation' => __('Help', 'site-reviews'), |
|
55 | - ]); |
|
56 | - foreach ($pages as $slug => $title) { |
|
57 | - $method = Helper::buildMethodName('render-'.$slug.'-menu'); |
|
58 | - $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug); |
|
59 | - if (!is_callable($callback)) { |
|
54 | + 'documentation' => __( 'Help', 'site-reviews' ), |
|
55 | + ] ); |
|
56 | + foreach( $pages as $slug => $title ) { |
|
57 | + $method = Helper::buildMethodName( 'render-'.$slug.'-menu' ); |
|
58 | + $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
|
59 | + if( !is_callable( $callback ) ) { |
|
60 | 60 | continue; |
61 | 61 | } |
62 | - add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback); |
|
62 | + add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback ); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function renderAddonsMenu() |
72 | 72 | { |
73 | - $this->renderPage('addons', [ |
|
74 | - 'template' => glsr(Template::class), |
|
75 | - ]); |
|
73 | + $this->renderPage( 'addons', [ |
|
74 | + 'template' => glsr( Template::class ), |
|
75 | + ] ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function renderDocumentationMenu() |
84 | 84 | { |
85 | - $tabs = $this->parseWithFilter('documentation/tabs', [ |
|
86 | - 'support' => __('Support', 'site-reviews'), |
|
87 | - 'faq' => __('FAQ', 'site-reviews'), |
|
88 | - 'shortcodes' => __('Shortcodes', 'site-reviews'), |
|
89 | - 'hooks' => __('Hooks', 'site-reviews'), |
|
90 | - 'functions' => __('Functions', 'site-reviews'), |
|
91 | - 'addons' => __('Addons', 'site-reviews'), |
|
92 | - ]); |
|
93 | - $addons = apply_filters('site-reviews/addon/documentation', []); |
|
94 | - ksort($addons); |
|
95 | - if (empty($addons)) { |
|
85 | + $tabs = $this->parseWithFilter( 'documentation/tabs', [ |
|
86 | + 'support' => __( 'Support', 'site-reviews' ), |
|
87 | + 'faq' => __( 'FAQ', 'site-reviews' ), |
|
88 | + 'shortcodes' => __( 'Shortcodes', 'site-reviews' ), |
|
89 | + 'hooks' => __( 'Hooks', 'site-reviews' ), |
|
90 | + 'functions' => __( 'Functions', 'site-reviews' ), |
|
91 | + 'addons' => __( 'Addons', 'site-reviews' ), |
|
92 | + ] ); |
|
93 | + $addons = apply_filters( 'site-reviews/addon/documentation', [] ); |
|
94 | + ksort( $addons ); |
|
95 | + if( empty($addons) ) { |
|
96 | 96 | unset($tabs['addons']); |
97 | 97 | } |
98 | - $this->renderPage('documentation', [ |
|
98 | + $this->renderPage( 'documentation', [ |
|
99 | 99 | 'addons' => $addons, |
100 | 100 | 'tabs' => $tabs, |
101 | - ]); |
|
101 | + ] ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,25 +108,25 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function renderSettingsMenu() |
110 | 110 | { |
111 | - $tabs = $this->parseWithFilter('settings/tabs', [ |
|
112 | - 'general' => __('General', 'site-reviews'), |
|
113 | - 'reviews' => __('Reviews', 'site-reviews'), |
|
114 | - 'submissions' => __('Submissions', 'site-reviews'), |
|
115 | - 'schema' => __('Schema', 'site-reviews'), |
|
116 | - 'translations' => __('Translations', 'site-reviews'), |
|
117 | - 'addons' => __('Addons', 'site-reviews'), |
|
118 | - 'licenses' => __('Licenses', 'site-reviews'), |
|
119 | - ]); |
|
120 | - if (empty(Arr::get(glsr()->defaults, 'settings.addons'))) { |
|
111 | + $tabs = $this->parseWithFilter( 'settings/tabs', [ |
|
112 | + 'general' => __( 'General', 'site-reviews' ), |
|
113 | + 'reviews' => __( 'Reviews', 'site-reviews' ), |
|
114 | + 'submissions' => __( 'Submissions', 'site-reviews' ), |
|
115 | + 'schema' => __( 'Schema', 'site-reviews' ), |
|
116 | + 'translations' => __( 'Translations', 'site-reviews' ), |
|
117 | + 'addons' => __( 'Addons', 'site-reviews' ), |
|
118 | + 'licenses' => __( 'Licenses', 'site-reviews' ), |
|
119 | + ] ); |
|
120 | + if( empty(Arr::get( glsr()->defaults, 'settings.addons' )) ) { |
|
121 | 121 | unset($tabs['addons']); |
122 | 122 | } |
123 | - if (empty(Arr::get(glsr()->defaults, 'settings.licenses'))) { |
|
123 | + if( empty(Arr::get( glsr()->defaults, 'settings.licenses' )) ) { |
|
124 | 124 | unset($tabs['licenses']); |
125 | 125 | } |
126 | - $this->renderPage('settings', [ |
|
127 | - 'settings' => glsr(Settings::class), |
|
126 | + $this->renderPage( 'settings', [ |
|
127 | + 'settings' => glsr( Settings::class ), |
|
128 | 128 | 'tabs' => $tabs, |
129 | - ]); |
|
129 | + ] ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -136,28 +136,28 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function renderToolsMenu() |
138 | 138 | { |
139 | - $tabs = $this->parseWithFilter('tools/tabs', [ |
|
140 | - 'general' => __('General', 'site-reviews'), |
|
141 | - 'sync' => __('Sync Reviews', 'site-reviews'), |
|
142 | - 'console' => __('Console', 'site-reviews'), |
|
143 | - 'system-info' => __('System Info', 'site-reviews'), |
|
144 | - ]); |
|
145 | - if (!apply_filters('site-reviews/addon/sync/enable', false)) { |
|
139 | + $tabs = $this->parseWithFilter( 'tools/tabs', [ |
|
140 | + 'general' => __( 'General', 'site-reviews' ), |
|
141 | + 'sync' => __( 'Sync Reviews', 'site-reviews' ), |
|
142 | + 'console' => __( 'Console', 'site-reviews' ), |
|
143 | + 'system-info' => __( 'System Info', 'site-reviews' ), |
|
144 | + ] ); |
|
145 | + if( !apply_filters( 'site-reviews/addon/sync/enable', false ) ) { |
|
146 | 146 | unset($tabs['sync']); |
147 | 147 | } |
148 | - $this->renderPage('tools', [ |
|
148 | + $this->renderPage( 'tools', [ |
|
149 | 149 | 'data' => [ |
150 | 150 | 'context' => [ |
151 | - 'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE), |
|
152 | - 'console' => strval(glsr(Console::class)), |
|
151 | + 'base_url' => admin_url( 'edit.php?post_type='.Application::POST_TYPE ), |
|
152 | + 'console' => strval( glsr( Console::class ) ), |
|
153 | 153 | 'id' => Application::ID, |
154 | - 'system' => strval(glsr(System::class)), |
|
154 | + 'system' => strval( glsr( System::class ) ), |
|
155 | 155 | ], |
156 | - 'services' => apply_filters('site-reviews/addon/sync/services', []), |
|
156 | + 'services' => apply_filters( 'site-reviews/addon/sync/services', [] ), |
|
157 | 157 | ], |
158 | 158 | 'tabs' => $tabs, |
159 | - 'template' => glsr(Template::class), |
|
160 | - ]); |
|
159 | + 'template' => glsr( Template::class ), |
|
160 | + ] ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function setCustomPermissions() |
168 | 168 | { |
169 | - foreach (wp_roles()->roles as $role => $value) { |
|
170 | - wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE); |
|
169 | + foreach( wp_roles()->roles as $role => $value ) { |
|
170 | + wp_roles()->remove_cap( $role, 'create_'.Application::POST_TYPE ); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -176,36 +176,36 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function getNotices() |
178 | 178 | { |
179 | - return glsr(Builder::class)->div(glsr(Notice::class)->get(), [ |
|
179 | + return glsr( Builder::class )->div( glsr( Notice::class )->get(), [ |
|
180 | 180 | 'id' => 'glsr-notices', |
181 | - ]); |
|
181 | + ] ); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | 185 | * @param string $hookSuffix |
186 | 186 | * @return array |
187 | 187 | */ |
188 | - protected function parseWithFilter($hookSuffix, array $args = []) |
|
188 | + protected function parseWithFilter( $hookSuffix, array $args = [] ) |
|
189 | 189 | { |
190 | - if (Str::endsWith('/tabs', $hookSuffix)) { |
|
191 | - $page = str_replace('/tabs', '', $hookSuffix); |
|
192 | - foreach ($args as $tab => $title) { |
|
193 | - if (!glsr()->hasPermission($page, $tab)) { |
|
190 | + if( Str::endsWith( '/tabs', $hookSuffix ) ) { |
|
191 | + $page = str_replace( '/tabs', '', $hookSuffix ); |
|
192 | + foreach( $args as $tab => $title ) { |
|
193 | + if( !glsr()->hasPermission( $page, $tab ) ) { |
|
194 | 194 | unset($args[$tab]); |
195 | 195 | } |
196 | 196 | } |
197 | 197 | } |
198 | - return apply_filters('site-reviews/addon/'.$hookSuffix, $args); |
|
198 | + return apply_filters( 'site-reviews/addon/'.$hookSuffix, $args ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
202 | 202 | * @param string $page |
203 | 203 | * @return void |
204 | 204 | */ |
205 | - protected function renderPage($page, array $data = []) |
|
205 | + protected function renderPage( $page, array $data = [] ) |
|
206 | 206 | { |
207 | - $data['http_referer'] = (string) wp_get_referer(); |
|
207 | + $data['http_referer'] = (string)wp_get_referer(); |
|
208 | 208 | $data['notices'] = $this->getNotices(); |
209 | - glsr()->render('pages/'.$page.'/index', $data); |
|
209 | + glsr()->render( 'pages/'.$page.'/index', $data ); |
|
210 | 210 | } |
211 | 211 | } |