@@ -8,137 +8,137 @@ |
||
8 | 8 | */ |
9 | 9 | class GL_Plugin_Check_v3 |
10 | 10 | { |
11 | - const MIN_PHP_VERSION = '5.6.0'; |
|
12 | - const MIN_WORDPRESS_VERSION = '4.7.0'; |
|
11 | + const MIN_PHP_VERSION = '5.6.0'; |
|
12 | + const MIN_WORDPRESS_VERSION = '4.7.0'; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $file; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $file; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $versions; |
|
19 | + /** |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $versions; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @param string $file |
|
26 | - */ |
|
27 | - public function __construct($file, array $versions = array()) |
|
28 | - { |
|
29 | - $this->file = realpath($file); |
|
30 | - $this->versions = wp_parse_args($versions, array( |
|
31 | - 'php' => static::MIN_PHP_VERSION, |
|
32 | - 'wordpress' => static::MIN_WORDPRESS_VERSION, |
|
33 | - )); |
|
34 | - } |
|
24 | + /** |
|
25 | + * @param string $file |
|
26 | + */ |
|
27 | + public function __construct($file, array $versions = array()) |
|
28 | + { |
|
29 | + $this->file = realpath($file); |
|
30 | + $this->versions = wp_parse_args($versions, array( |
|
31 | + 'php' => static::MIN_PHP_VERSION, |
|
32 | + 'wordpress' => static::MIN_WORDPRESS_VERSION, |
|
33 | + )); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return bool |
|
38 | - */ |
|
39 | - public function canProceed() |
|
40 | - { |
|
41 | - if ($this->isValid()) { |
|
42 | - return true; |
|
43 | - } |
|
44 | - add_action('activated_plugin', array($this, 'deactivate')); |
|
45 | - add_action('admin_notices', array($this, 'deactivate')); |
|
46 | - return false; |
|
47 | - } |
|
36 | + /** |
|
37 | + * @return bool |
|
38 | + */ |
|
39 | + public function canProceed() |
|
40 | + { |
|
41 | + if ($this->isValid()) { |
|
42 | + return true; |
|
43 | + } |
|
44 | + add_action('activated_plugin', array($this, 'deactivate')); |
|
45 | + add_action('admin_notices', array($this, 'deactivate')); |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return bool |
|
51 | - */ |
|
52 | - public function isPhpValid() |
|
53 | - { |
|
54 | - return !version_compare(PHP_VERSION, $this->versions['php'], '<'); |
|
55 | - } |
|
49 | + /** |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | + public function isPhpValid() |
|
53 | + { |
|
54 | + return !version_compare(PHP_VERSION, $this->versions['php'], '<'); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function isValid() |
|
61 | - { |
|
62 | - return $this->isPhpValid() && $this->isWpValid(); |
|
63 | - } |
|
57 | + /** |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function isValid() |
|
61 | + { |
|
62 | + return $this->isPhpValid() && $this->isWpValid(); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return bool |
|
67 | - */ |
|
68 | - public function isWpValid() |
|
69 | - { |
|
70 | - global $wp_version; |
|
71 | - return !version_compare($wp_version, $this->versions['wordpress'], '<'); |
|
72 | - } |
|
65 | + /** |
|
66 | + * @return bool |
|
67 | + */ |
|
68 | + public function isWpValid() |
|
69 | + { |
|
70 | + global $wp_version; |
|
71 | + return !version_compare($wp_version, $this->versions['wordpress'], '<'); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param string $plugin |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - public function deactivate($plugin) |
|
79 | - { |
|
80 | - if ($this->isValid()) { |
|
81 | - return; |
|
82 | - } |
|
83 | - $pluginSlug = plugin_basename($this->file); |
|
84 | - if ($plugin == $pluginSlug) { |
|
85 | - $this->redirect(); //exit |
|
86 | - } |
|
87 | - $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin'); |
|
88 | - deactivate_plugins($pluginSlug); |
|
89 | - $this->printNotice($pluginData['name']); |
|
90 | - } |
|
74 | + /** |
|
75 | + * @param string $plugin |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + public function deactivate($plugin) |
|
79 | + { |
|
80 | + if ($this->isValid()) { |
|
81 | + return; |
|
82 | + } |
|
83 | + $pluginSlug = plugin_basename($this->file); |
|
84 | + if ($plugin == $pluginSlug) { |
|
85 | + $this->redirect(); //exit |
|
86 | + } |
|
87 | + $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin'); |
|
88 | + deactivate_plugins($pluginSlug); |
|
89 | + $this->printNotice($pluginData['name']); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - protected function getMessages() |
|
96 | - { |
|
97 | - return array( |
|
98 | - __('The %s plugin was deactivated.', 'site-reviews'), |
|
99 | - __('This plugin requires %s or greater in order to work properly.', 'site-reviews'), |
|
100 | - __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'), |
|
101 | - __('PHP version', 'site-reviews'), |
|
102 | - __('WordPress version', 'site-reviews'), |
|
103 | - __('Update WordPress', 'site-reviews'), |
|
104 | - __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'), |
|
105 | - ); |
|
106 | - } |
|
92 | + /** |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + protected function getMessages() |
|
96 | + { |
|
97 | + return array( |
|
98 | + __('The %s plugin was deactivated.', 'site-reviews'), |
|
99 | + __('This plugin requires %s or greater in order to work properly.', 'site-reviews'), |
|
100 | + __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'), |
|
101 | + __('PHP version', 'site-reviews'), |
|
102 | + __('WordPress version', 'site-reviews'), |
|
103 | + __('Update WordPress', 'site-reviews'), |
|
104 | + __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'), |
|
105 | + ); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * @param string $pluginName |
|
110 | - * @return void |
|
111 | - */ |
|
112 | - protected function printNotice($pluginName) |
|
113 | - { |
|
114 | - $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>'; |
|
115 | - $messages = $this->getMessages(); |
|
116 | - $rollbackMessage = sprintf('<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName); |
|
117 | - if (!$this->isPhpValid()) { |
|
118 | - printf($noticeTemplate, |
|
119 | - sprintf($messages[0], $pluginName), |
|
120 | - sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
|
121 | - sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
|
122 | - ); |
|
123 | - } elseif (!$this->isWpValid()) { |
|
124 | - printf($noticeTemplate, |
|
125 | - sprintf($messages[0], $pluginName), |
|
126 | - sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
|
127 | - $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5]) |
|
128 | - ); |
|
129 | - } |
|
130 | - } |
|
108 | + /** |
|
109 | + * @param string $pluginName |
|
110 | + * @return void |
|
111 | + */ |
|
112 | + protected function printNotice($pluginName) |
|
113 | + { |
|
114 | + $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>'; |
|
115 | + $messages = $this->getMessages(); |
|
116 | + $rollbackMessage = sprintf('<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName); |
|
117 | + if (!$this->isPhpValid()) { |
|
118 | + printf($noticeTemplate, |
|
119 | + sprintf($messages[0], $pluginName), |
|
120 | + sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
|
121 | + sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
|
122 | + ); |
|
123 | + } elseif (!$this->isWpValid()) { |
|
124 | + printf($noticeTemplate, |
|
125 | + sprintf($messages[0], $pluginName), |
|
126 | + sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
|
127 | + $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5]) |
|
128 | + ); |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - protected function redirect() |
|
136 | - { |
|
137 | - wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
138 | - filter_input(INPUT_GET, 'plugin_status'), |
|
139 | - filter_input(INPUT_GET, 'paged'), |
|
140 | - filter_input(INPUT_GET, 's') |
|
141 | - ))); |
|
142 | - exit; |
|
143 | - } |
|
132 | + /** |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + protected function redirect() |
|
136 | + { |
|
137 | + wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
138 | + filter_input(INPUT_GET, 'plugin_status'), |
|
139 | + filter_input(INPUT_GET, 'paged'), |
|
140 | + filter_input(INPUT_GET, 's') |
|
141 | + ))); |
|
142 | + exit; |
|
143 | + } |
|
144 | 144 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Check for minimum system requirments on plugin activation. |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @param string $file |
26 | 26 | */ |
27 | - public function __construct($file, array $versions = array()) |
|
27 | + public function __construct( $file, array $versions = array() ) |
|
28 | 28 | { |
29 | - $this->file = realpath($file); |
|
30 | - $this->versions = wp_parse_args($versions, array( |
|
29 | + $this->file = realpath( $file ); |
|
30 | + $this->versions = wp_parse_args( $versions, array( |
|
31 | 31 | 'php' => static::MIN_PHP_VERSION, |
32 | 32 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
33 | - )); |
|
33 | + ) ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function canProceed() |
40 | 40 | { |
41 | - if ($this->isValid()) { |
|
41 | + if( $this->isValid() ) { |
|
42 | 42 | return true; |
43 | 43 | } |
44 | - add_action('activated_plugin', array($this, 'deactivate')); |
|
45 | - add_action('admin_notices', array($this, 'deactivate')); |
|
44 | + add_action( 'activated_plugin', array( $this, 'deactivate' ) ); |
|
45 | + add_action( 'admin_notices', array( $this, 'deactivate' ) ); |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function isPhpValid() |
53 | 53 | { |
54 | - return !version_compare(PHP_VERSION, $this->versions['php'], '<'); |
|
54 | + return !version_compare( PHP_VERSION, $this->versions['php'], '<' ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -68,25 +68,25 @@ discard block |
||
68 | 68 | public function isWpValid() |
69 | 69 | { |
70 | 70 | global $wp_version; |
71 | - return !version_compare($wp_version, $this->versions['wordpress'], '<'); |
|
71 | + return !version_compare( $wp_version, $this->versions['wordpress'], '<' ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @param string $plugin |
76 | 76 | * @return void |
77 | 77 | */ |
78 | - public function deactivate($plugin) |
|
78 | + public function deactivate( $plugin ) |
|
79 | 79 | { |
80 | - if ($this->isValid()) { |
|
80 | + if( $this->isValid() ) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | - $pluginSlug = plugin_basename($this->file); |
|
84 | - if ($plugin == $pluginSlug) { |
|
83 | + $pluginSlug = plugin_basename( $this->file ); |
|
84 | + if( $plugin == $pluginSlug ) { |
|
85 | 85 | $this->redirect(); //exit |
86 | 86 | } |
87 | - $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin'); |
|
88 | - deactivate_plugins($pluginSlug); |
|
89 | - $this->printNotice($pluginData['name']); |
|
87 | + $pluginData = get_file_data( $this->file, array( 'name' => 'Plugin Name' ), 'plugin' ); |
|
88 | + deactivate_plugins( $pluginSlug ); |
|
89 | + $this->printNotice( $pluginData['name'] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | protected function getMessages() |
96 | 96 | { |
97 | 97 | return array( |
98 | - __('The %s plugin was deactivated.', 'site-reviews'), |
|
99 | - __('This plugin requires %s or greater in order to work properly.', 'site-reviews'), |
|
100 | - __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'), |
|
101 | - __('PHP version', 'site-reviews'), |
|
102 | - __('WordPress version', 'site-reviews'), |
|
103 | - __('Update WordPress', 'site-reviews'), |
|
104 | - __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'), |
|
98 | + __( 'The %s plugin was deactivated.', 'site-reviews' ), |
|
99 | + __( 'This plugin requires %s or greater in order to work properly.', 'site-reviews' ), |
|
100 | + __( 'Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews' ), |
|
101 | + __( 'PHP version', 'site-reviews' ), |
|
102 | + __( 'WordPress version', 'site-reviews' ), |
|
103 | + __( 'Update WordPress', 'site-reviews' ), |
|
104 | + __( 'You can use the %s plugin to restore %s to the previous version.', 'site-reviews' ), |
|
105 | 105 | ); |
106 | 106 | } |
107 | 107 | |
@@ -109,22 +109,22 @@ discard block |
||
109 | 109 | * @param string $pluginName |
110 | 110 | * @return void |
111 | 111 | */ |
112 | - protected function printNotice($pluginName) |
|
112 | + protected function printNotice( $pluginName ) |
|
113 | 113 | { |
114 | 114 | $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>'; |
115 | 115 | $messages = $this->getMessages(); |
116 | - $rollbackMessage = sprintf('<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName); |
|
117 | - if (!$this->isPhpValid()) { |
|
118 | - printf($noticeTemplate, |
|
119 | - sprintf($messages[0], $pluginName), |
|
120 | - sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
|
121 | - sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
|
116 | + $rollbackMessage = sprintf( '<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName ); |
|
117 | + if( !$this->isPhpValid() ) { |
|
118 | + printf( $noticeTemplate, |
|
119 | + sprintf( $messages[0], $pluginName ), |
|
120 | + sprintf( $messages[1], $messages[3].' '.$this->versions['php'] ), |
|
121 | + sprintf( $messages[2], PHP_VERSION ).'</p><p>'.$rollbackMessage |
|
122 | 122 | ); |
123 | - } elseif (!$this->isWpValid()) { |
|
124 | - printf($noticeTemplate, |
|
125 | - sprintf($messages[0], $pluginName), |
|
126 | - sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
|
127 | - $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5]) |
|
123 | + } elseif( !$this->isWpValid() ) { |
|
124 | + printf( $noticeTemplate, |
|
125 | + sprintf( $messages[0], $pluginName ), |
|
126 | + sprintf( $messages[1], $messages[4].' '.$this->versions['wordpress'] ), |
|
127 | + $rollbackMessage.'</p><p>'.sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[5] ) |
|
128 | 128 | ); |
129 | 129 | } |
130 | 130 | } |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function redirect() |
136 | 136 | { |
137 | - wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
138 | - filter_input(INPUT_GET, 'plugin_status'), |
|
139 | - filter_input(INPUT_GET, 'paged'), |
|
140 | - filter_input(INPUT_GET, 's') |
|
141 | - ))); |
|
137 | + wp_safe_redirect( self_admin_url( sprintf( 'plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
138 | + filter_input( INPUT_GET, 'plugin_status' ), |
|
139 | + filter_input( INPUT_GET, 'paged' ), |
|
140 | + filter_input( INPUT_GET, 's' ) |
|
141 | + ) ) ); |
|
142 | 142 | exit; |
143 | 143 | } |
144 | 144 | } |
@@ -120,7 +120,8 @@ |
||
120 | 120 | sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
121 | 121 | sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
122 | 122 | ); |
123 | - } elseif (!$this->isWpValid()) { |
|
123 | + } |
|
124 | + elseif (!$this->isWpValid()) { |
|
124 | 125 | printf($noticeTemplate, |
125 | 126 | sprintf($messages[0], $pluginName), |
126 | 127 | sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-form-wrap"> |
4 | 4 | <form class="{{ class }}" id="{{ id }}" method="post" enctype="multipart/form-data"> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-form-message {{ class }}"> |
4 | 4 | {{ message }} |
@@ -7,135 +7,135 @@ |
||
7 | 7 | |
8 | 8 | class ReviewsHtml extends ArrayObject |
9 | 9 | { |
10 | - /** |
|
11 | - * @var array |
|
12 | - */ |
|
13 | - public $args; |
|
10 | + /** |
|
11 | + * @var array |
|
12 | + */ |
|
13 | + public $args; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @var int |
|
17 | - */ |
|
18 | - public $max_num_pages; |
|
15 | + /** |
|
16 | + * @var int |
|
17 | + */ |
|
18 | + public $max_num_pages; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - public $pagination; |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + public $pagination; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - public $reviews; |
|
25 | + /** |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + public $reviews; |
|
29 | 29 | |
30 | - public function __construct(array $reviews, $maxPageCount, array $args) |
|
31 | - { |
|
32 | - $this->args = $args; |
|
33 | - $this->max_num_pages = $maxPageCount; |
|
34 | - $this->reviews = $reviews; |
|
35 | - $this->pagination = $this->buildPagination(); |
|
36 | - parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
37 | - } |
|
30 | + public function __construct(array $reviews, $maxPageCount, array $args) |
|
31 | + { |
|
32 | + $this->args = $args; |
|
33 | + $this->max_num_pages = $maxPageCount; |
|
34 | + $this->reviews = $reviews; |
|
35 | + $this->pagination = $this->buildPagination(); |
|
36 | + parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function __toString() |
|
43 | - { |
|
44 | - return glsr(Template::class)->build('templates/reviews', [ |
|
45 | - 'args' => $this->args, |
|
46 | - 'context' => [ |
|
47 | - 'assigned_to' => $this->args['assigned_to'], |
|
48 | - 'category' => $this->args['category'], |
|
49 | - 'class' => $this->getClass(), |
|
50 | - 'id' => $this->args['id'], |
|
51 | - 'pagination' => $this->getPagination(), |
|
52 | - 'reviews' => $this->getReviews(), |
|
53 | - ], |
|
54 | - ]); |
|
55 | - } |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function __toString() |
|
43 | + { |
|
44 | + return glsr(Template::class)->build('templates/reviews', [ |
|
45 | + 'args' => $this->args, |
|
46 | + 'context' => [ |
|
47 | + 'assigned_to' => $this->args['assigned_to'], |
|
48 | + 'category' => $this->args['category'], |
|
49 | + 'class' => $this->getClass(), |
|
50 | + 'id' => $this->args['id'], |
|
51 | + 'pagination' => $this->getPagination(), |
|
52 | + 'reviews' => $this->getReviews(), |
|
53 | + ], |
|
54 | + ]); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getPagination() |
|
61 | - { |
|
62 | - return wp_validate_boolean($this->args['pagination']) |
|
63 | - ? $this->pagination |
|
64 | - : ''; |
|
65 | - } |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getPagination() |
|
61 | + { |
|
62 | + return wp_validate_boolean($this->args['pagination']) |
|
63 | + ? $this->pagination |
|
64 | + : ''; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - public function getReviews() |
|
71 | - { |
|
72 | - $html = empty($this->reviews) |
|
73 | - ? $this->getReviewsFallback() |
|
74 | - : implode(PHP_EOL, $this->reviews); |
|
75 | - $wrapper = '<div class="glsr-reviews">%s</div>'; |
|
76 | - $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper); |
|
77 | - return sprintf($wrapper, $html); |
|
78 | - } |
|
67 | + /** |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + public function getReviews() |
|
71 | + { |
|
72 | + $html = empty($this->reviews) |
|
73 | + ? $this->getReviewsFallback() |
|
74 | + : implode(PHP_EOL, $this->reviews); |
|
75 | + $wrapper = '<div class="glsr-reviews">%s</div>'; |
|
76 | + $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper); |
|
77 | + return sprintf($wrapper, $html); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param mixed $key |
|
82 | - * @return mixed |
|
83 | - */ |
|
84 | - public function offsetGet($key) |
|
85 | - { |
|
86 | - if ('navigation' == $key) { |
|
87 | - glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
|
88 | - return $this->pagination; |
|
89 | - } |
|
90 | - if (property_exists($this, $key)) { |
|
91 | - return $this->{$key}; |
|
92 | - } |
|
93 | - return array_key_exists($key, $this->reviews) |
|
94 | - ? $this->reviews[$key] |
|
95 | - : null; |
|
96 | - } |
|
80 | + /** |
|
81 | + * @param mixed $key |
|
82 | + * @return mixed |
|
83 | + */ |
|
84 | + public function offsetGet($key) |
|
85 | + { |
|
86 | + if ('navigation' == $key) { |
|
87 | + glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
|
88 | + return $this->pagination; |
|
89 | + } |
|
90 | + if (property_exists($this, $key)) { |
|
91 | + return $this->{$key}; |
|
92 | + } |
|
93 | + return array_key_exists($key, $this->reviews) |
|
94 | + ? $this->reviews[$key] |
|
95 | + : null; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - protected function buildPagination() |
|
102 | - { |
|
103 | - $html = glsr(Partial::class)->build('pagination', [ |
|
104 | - 'baseUrl' => glsr_get($this->args, 'pagedUrl'), |
|
105 | - 'current' => glsr_get($this->args, 'paged'), |
|
106 | - 'total' => $this->max_num_pages, |
|
107 | - ]); |
|
108 | - $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']); |
|
109 | - $wrapper = '<div class="glsr-pagination">%s</div>'; |
|
110 | - $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper); |
|
111 | - return sprintf($wrapper, $html); |
|
112 | - } |
|
98 | + /** |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + protected function buildPagination() |
|
102 | + { |
|
103 | + $html = glsr(Partial::class)->build('pagination', [ |
|
104 | + 'baseUrl' => glsr_get($this->args, 'pagedUrl'), |
|
105 | + 'current' => glsr_get($this->args, 'paged'), |
|
106 | + 'total' => $this->max_num_pages, |
|
107 | + ]); |
|
108 | + $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']); |
|
109 | + $wrapper = '<div class="glsr-pagination">%s</div>'; |
|
110 | + $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper); |
|
111 | + return sprintf($wrapper, $html); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - protected function getClass() |
|
118 | - { |
|
119 | - $defaults = [ |
|
120 | - 'glsr-default', |
|
121 | - ]; |
|
122 | - if ('ajax' == $this->args['pagination']) { |
|
123 | - $defaults[] = 'glsr-ajax-pagination'; |
|
124 | - } |
|
125 | - $classes = explode(' ', $this->args['class']); |
|
126 | - $classes = array_unique(array_merge($defaults, array_filter($classes))); |
|
127 | - return implode(' ', $classes); |
|
128 | - } |
|
114 | + /** |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + protected function getClass() |
|
118 | + { |
|
119 | + $defaults = [ |
|
120 | + 'glsr-default', |
|
121 | + ]; |
|
122 | + if ('ajax' == $this->args['pagination']) { |
|
123 | + $defaults[] = 'glsr-ajax-pagination'; |
|
124 | + } |
|
125 | + $classes = explode(' ', $this->args['class']); |
|
126 | + $classes = array_unique(array_merge($defaults, array_filter($classes))); |
|
127 | + return implode(' ', $classes); |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - protected function getReviewsFallback() |
|
134 | - { |
|
135 | - if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) { |
|
136 | - $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews'); |
|
137 | - } |
|
138 | - $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
|
139 | - return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args); |
|
140 | - } |
|
130 | + /** |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + protected function getReviewsFallback() |
|
134 | + { |
|
135 | + if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) { |
|
136 | + $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews'); |
|
137 | + } |
|
138 | + $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
|
139 | + return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args); |
|
140 | + } |
|
141 | 141 | } |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public $reviews; |
29 | 29 | |
30 | - public function __construct(array $reviews, $maxPageCount, array $args) |
|
30 | + public function __construct( array $reviews, $maxPageCount, array $args ) |
|
31 | 31 | { |
32 | 32 | $this->args = $args; |
33 | 33 | $this->max_num_pages = $maxPageCount; |
34 | 34 | $this->reviews = $reviews; |
35 | 35 | $this->pagination = $this->buildPagination(); |
36 | - parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
36 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __toString() |
43 | 43 | { |
44 | - return glsr(Template::class)->build('templates/reviews', [ |
|
44 | + return glsr( Template::class )->build( 'templates/reviews', [ |
|
45 | 45 | 'args' => $this->args, |
46 | 46 | 'context' => [ |
47 | 47 | 'assigned_to' => $this->args['assigned_to'], |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | 'pagination' => $this->getPagination(), |
52 | 52 | 'reviews' => $this->getReviews(), |
53 | 53 | ], |
54 | - ]); |
|
54 | + ] ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function getPagination() |
61 | 61 | { |
62 | - return wp_validate_boolean($this->args['pagination']) |
|
62 | + return wp_validate_boolean( $this->args['pagination'] ) |
|
63 | 63 | ? $this->pagination |
64 | 64 | : ''; |
65 | 65 | } |
@@ -71,26 +71,26 @@ discard block |
||
71 | 71 | { |
72 | 72 | $html = empty($this->reviews) |
73 | 73 | ? $this->getReviewsFallback() |
74 | - : implode(PHP_EOL, $this->reviews); |
|
74 | + : implode( PHP_EOL, $this->reviews ); |
|
75 | 75 | $wrapper = '<div class="glsr-reviews">%s</div>'; |
76 | - $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper); |
|
77 | - return sprintf($wrapper, $html); |
|
76 | + $wrapper = apply_filters( 'site-reviews/reviews/reviews-wrapper', $wrapper ); |
|
77 | + return sprintf( $wrapper, $html ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | 81 | * @param mixed $key |
82 | 82 | * @return mixed |
83 | 83 | */ |
84 | - public function offsetGet($key) |
|
84 | + public function offsetGet( $key ) |
|
85 | 85 | { |
86 | - if ('navigation' == $key) { |
|
86 | + if( 'navigation' == $key ) { |
|
87 | 87 | glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
88 | 88 | return $this->pagination; |
89 | 89 | } |
90 | - if (property_exists($this, $key)) { |
|
90 | + if( property_exists( $this, $key ) ) { |
|
91 | 91 | return $this->{$key}; |
92 | 92 | } |
93 | - return array_key_exists($key, $this->reviews) |
|
93 | + return array_key_exists( $key, $this->reviews ) |
|
94 | 94 | ? $this->reviews[$key] |
95 | 95 | : null; |
96 | 96 | } |
@@ -100,15 +100,15 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function buildPagination() |
102 | 102 | { |
103 | - $html = glsr(Partial::class)->build('pagination', [ |
|
104 | - 'baseUrl' => glsr_get($this->args, 'pagedUrl'), |
|
105 | - 'current' => glsr_get($this->args, 'paged'), |
|
103 | + $html = glsr( Partial::class )->build( 'pagination', [ |
|
104 | + 'baseUrl' => glsr_get( $this->args, 'pagedUrl' ), |
|
105 | + 'current' => glsr_get( $this->args, 'paged' ), |
|
106 | 106 | 'total' => $this->max_num_pages, |
107 | - ]); |
|
108 | - $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']); |
|
107 | + ] ); |
|
108 | + $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] ); |
|
109 | 109 | $wrapper = '<div class="glsr-pagination">%s</div>'; |
110 | - $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper); |
|
111 | - return sprintf($wrapper, $html); |
|
110 | + $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper ); |
|
111 | + return sprintf( $wrapper, $html ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | $defaults = [ |
120 | 120 | 'glsr-default', |
121 | 121 | ]; |
122 | - if ('ajax' == $this->args['pagination']) { |
|
122 | + if( 'ajax' == $this->args['pagination'] ) { |
|
123 | 123 | $defaults[] = 'glsr-ajax-pagination'; |
124 | 124 | } |
125 | - $classes = explode(' ', $this->args['class']); |
|
126 | - $classes = array_unique(array_merge($defaults, array_filter($classes))); |
|
127 | - return implode(' ', $classes); |
|
125 | + $classes = explode( ' ', $this->args['class'] ); |
|
126 | + $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) ); |
|
127 | + return implode( ' ', $classes ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected function getReviewsFallback() |
134 | 134 | { |
135 | - if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) { |
|
136 | - $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews'); |
|
135 | + if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) { |
|
136 | + $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' ); |
|
137 | 137 | } |
138 | 138 | $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
139 | - return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args); |
|
139 | + return apply_filters( 'site-reviews/reviews/fallback', $fallback, $this->args ); |
|
140 | 140 | } |
141 | 141 | } |
@@ -8,114 +8,114 @@ |
||
8 | 8 | |
9 | 9 | class Notice |
10 | 10 | { |
11 | - /** |
|
12 | - * @param string $type |
|
13 | - * @param string|array|WP_Error $message |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function add($type, $message, array $args = []) |
|
17 | - { |
|
18 | - if (empty(array_filter([$message, $type]))) { |
|
19 | - return; |
|
20 | - } |
|
21 | - $args['message'] = $message; |
|
22 | - $args['type'] = $type; |
|
23 | - add_settings_error(Application::ID, '', json_encode($this->normalize($args))); |
|
24 | - } |
|
11 | + /** |
|
12 | + * @param string $type |
|
13 | + * @param string|array|WP_Error $message |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function add($type, $message, array $args = []) |
|
17 | + { |
|
18 | + if (empty(array_filter([$message, $type]))) { |
|
19 | + return; |
|
20 | + } |
|
21 | + $args['message'] = $message; |
|
22 | + $args['type'] = $type; |
|
23 | + add_settings_error(Application::ID, '', json_encode($this->normalize($args))); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param string|array|WP_Error $message |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function addError($message, array $args = []) |
|
31 | - { |
|
32 | - $this->add('error', $message, $args); |
|
33 | - } |
|
26 | + /** |
|
27 | + * @param string|array|WP_Error $message |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function addError($message, array $args = []) |
|
31 | + { |
|
32 | + $this->add('error', $message, $args); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param string|array|WP_Error $message |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - public function addSuccess($message, array $args = []) |
|
40 | - { |
|
41 | - $this->add('success', $message, $args); |
|
42 | - } |
|
35 | + /** |
|
36 | + * @param string|array|WP_Error $message |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + public function addSuccess($message, array $args = []) |
|
40 | + { |
|
41 | + $this->add('success', $message, $args); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param string|array|WP_Error $message |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - public function addWarning($message, array $args = []) |
|
49 | - { |
|
50 | - $this->add('warning', $message, $args); |
|
51 | - } |
|
44 | + /** |
|
45 | + * @param string|array|WP_Error $message |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + public function addWarning($message, array $args = []) |
|
49 | + { |
|
50 | + $this->add('warning', $message, $args); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return static |
|
55 | - */ |
|
56 | - public function clear() |
|
57 | - { |
|
58 | - global $wp_settings_errors; |
|
59 | - $wp_settings_errors = []; |
|
60 | - delete_transient('settings_errors'); |
|
61 | - return $this; |
|
62 | - } |
|
53 | + /** |
|
54 | + * @return static |
|
55 | + */ |
|
56 | + public function clear() |
|
57 | + { |
|
58 | + global $wp_settings_errors; |
|
59 | + $wp_settings_errors = []; |
|
60 | + delete_transient('settings_errors'); |
|
61 | + return $this; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function get() |
|
68 | - { |
|
69 | - $notices = array_map('unserialize', |
|
70 | - array_unique(array_map('serialize', get_settings_errors(Application::ID))) |
|
71 | - ); |
|
72 | - if (empty($notices)) { |
|
73 | - return; |
|
74 | - } |
|
75 | - return array_reduce($notices, function ($carry, $notice) { |
|
76 | - return $carry.$this->buildNotice(json_decode($notice['message'], true)); |
|
77 | - }); |
|
78 | - } |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function get() |
|
68 | + { |
|
69 | + $notices = array_map('unserialize', |
|
70 | + array_unique(array_map('serialize', get_settings_errors(Application::ID))) |
|
71 | + ); |
|
72 | + if (empty($notices)) { |
|
73 | + return; |
|
74 | + } |
|
75 | + return array_reduce($notices, function ($carry, $notice) { |
|
76 | + return $carry.$this->buildNotice(json_decode($notice['message'], true)); |
|
77 | + }); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - protected function buildNotice(array $args) |
|
84 | - { |
|
85 | - $messages = array_reduce($args['messages'], function ($carry, $message) { |
|
86 | - return $carry.glsr(Builder::class)->p($message); |
|
87 | - }); |
|
88 | - $class = 'notice notice-'.$args['type']; |
|
89 | - if ($args['inline']) { |
|
90 | - $class.= ' inline'; |
|
91 | - } |
|
92 | - if ($args['dismissible']) { |
|
93 | - $class.= ' is-dismissible'; |
|
94 | - } |
|
95 | - return glsr(Builder::class)->div($messages, [ |
|
96 | - 'class' => $class, |
|
97 | - ]); |
|
98 | - } |
|
80 | + /** |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + protected function buildNotice(array $args) |
|
84 | + { |
|
85 | + $messages = array_reduce($args['messages'], function ($carry, $message) { |
|
86 | + return $carry.glsr(Builder::class)->p($message); |
|
87 | + }); |
|
88 | + $class = 'notice notice-'.$args['type']; |
|
89 | + if ($args['inline']) { |
|
90 | + $class.= ' inline'; |
|
91 | + } |
|
92 | + if ($args['dismissible']) { |
|
93 | + $class.= ' is-dismissible'; |
|
94 | + } |
|
95 | + return glsr(Builder::class)->div($messages, [ |
|
96 | + 'class' => $class, |
|
97 | + ]); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return array |
|
102 | - */ |
|
103 | - protected function normalize(array $args) |
|
104 | - { |
|
105 | - $defaults = [ |
|
106 | - 'dismissible' => true, |
|
107 | - 'inline' => true, |
|
108 | - 'message' => '', |
|
109 | - 'type' => '', |
|
110 | - ]; |
|
111 | - $args = shortcode_atts($defaults, $args); |
|
112 | - if (!in_array($args['type'], ['error', 'warning', 'success'])) { |
|
113 | - $args['type'] = 'success'; |
|
114 | - } |
|
115 | - $args['messages'] = is_wp_error($args['message']) |
|
116 | - ? (array) $args['message']->get_error_message() |
|
117 | - : (array) $args['message']; |
|
118 | - unset($args['message']); |
|
119 | - return $args; |
|
120 | - } |
|
100 | + /** |
|
101 | + * @return array |
|
102 | + */ |
|
103 | + protected function normalize(array $args) |
|
104 | + { |
|
105 | + $defaults = [ |
|
106 | + 'dismissible' => true, |
|
107 | + 'inline' => true, |
|
108 | + 'message' => '', |
|
109 | + 'type' => '', |
|
110 | + ]; |
|
111 | + $args = shortcode_atts($defaults, $args); |
|
112 | + if (!in_array($args['type'], ['error', 'warning', 'success'])) { |
|
113 | + $args['type'] = 'success'; |
|
114 | + } |
|
115 | + $args['messages'] = is_wp_error($args['message']) |
|
116 | + ? (array) $args['message']->get_error_message() |
|
117 | + : (array) $args['message']; |
|
118 | + unset($args['message']); |
|
119 | + return $args; |
|
120 | + } |
|
121 | 121 | } |
@@ -13,41 +13,41 @@ discard block |
||
13 | 13 | * @param string|array|WP_Error $message |
14 | 14 | * @return void |
15 | 15 | */ |
16 | - public function add($type, $message, array $args = []) |
|
16 | + public function add( $type, $message, array $args = [] ) |
|
17 | 17 | { |
18 | - if (empty(array_filter([$message, $type]))) { |
|
18 | + if( empty(array_filter( [$message, $type] )) ) { |
|
19 | 19 | return; |
20 | 20 | } |
21 | 21 | $args['message'] = $message; |
22 | 22 | $args['type'] = $type; |
23 | - add_settings_error(Application::ID, '', json_encode($this->normalize($args))); |
|
23 | + add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @param string|array|WP_Error $message |
28 | 28 | * @return void |
29 | 29 | */ |
30 | - public function addError($message, array $args = []) |
|
30 | + public function addError( $message, array $args = [] ) |
|
31 | 31 | { |
32 | - $this->add('error', $message, $args); |
|
32 | + $this->add( 'error', $message, $args ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @param string|array|WP_Error $message |
37 | 37 | * @return void |
38 | 38 | */ |
39 | - public function addSuccess($message, array $args = []) |
|
39 | + public function addSuccess( $message, array $args = [] ) |
|
40 | 40 | { |
41 | - $this->add('success', $message, $args); |
|
41 | + $this->add( 'success', $message, $args ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @param string|array|WP_Error $message |
46 | 46 | * @return void |
47 | 47 | */ |
48 | - public function addWarning($message, array $args = []) |
|
48 | + public function addWarning( $message, array $args = [] ) |
|
49 | 49 | { |
50 | - $this->add('warning', $message, $args); |
|
50 | + $this->add( 'warning', $message, $args ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | global $wp_settings_errors; |
59 | 59 | $wp_settings_errors = []; |
60 | - delete_transient('settings_errors'); |
|
60 | + delete_transient( 'settings_errors' ); |
|
61 | 61 | return $this; |
62 | 62 | } |
63 | 63 | |
@@ -66,41 +66,41 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function get() |
68 | 68 | { |
69 | - $notices = array_map('unserialize', |
|
70 | - array_unique(array_map('serialize', get_settings_errors(Application::ID))) |
|
69 | + $notices = array_map( 'unserialize', |
|
70 | + array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) ) |
|
71 | 71 | ); |
72 | - if (empty($notices)) { |
|
72 | + if( empty($notices) ) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | - return array_reduce($notices, function ($carry, $notice) { |
|
76 | - return $carry.$this->buildNotice(json_decode($notice['message'], true)); |
|
75 | + return array_reduce( $notices, function( $carry, $notice ) { |
|
76 | + return $carry.$this->buildNotice( json_decode( $notice['message'], true ) ); |
|
77 | 77 | }); |
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - protected function buildNotice(array $args) |
|
83 | + protected function buildNotice( array $args ) |
|
84 | 84 | { |
85 | - $messages = array_reduce($args['messages'], function ($carry, $message) { |
|
86 | - return $carry.glsr(Builder::class)->p($message); |
|
85 | + $messages = array_reduce( $args['messages'], function( $carry, $message ) { |
|
86 | + return $carry.glsr( Builder::class )->p( $message ); |
|
87 | 87 | }); |
88 | 88 | $class = 'notice notice-'.$args['type']; |
89 | - if ($args['inline']) { |
|
90 | - $class.= ' inline'; |
|
89 | + if( $args['inline'] ) { |
|
90 | + $class .= ' inline'; |
|
91 | 91 | } |
92 | - if ($args['dismissible']) { |
|
93 | - $class.= ' is-dismissible'; |
|
92 | + if( $args['dismissible'] ) { |
|
93 | + $class .= ' is-dismissible'; |
|
94 | 94 | } |
95 | - return glsr(Builder::class)->div($messages, [ |
|
95 | + return glsr( Builder::class )->div( $messages, [ |
|
96 | 96 | 'class' => $class, |
97 | - ]); |
|
97 | + ] ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @return array |
102 | 102 | */ |
103 | - protected function normalize(array $args) |
|
103 | + protected function normalize( array $args ) |
|
104 | 104 | { |
105 | 105 | $defaults = [ |
106 | 106 | 'dismissible' => true, |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | 'message' => '', |
109 | 109 | 'type' => '', |
110 | 110 | ]; |
111 | - $args = shortcode_atts($defaults, $args); |
|
112 | - if (!in_array($args['type'], ['error', 'warning', 'success'])) { |
|
111 | + $args = shortcode_atts( $defaults, $args ); |
|
112 | + if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) { |
|
113 | 113 | $args['type'] = 'success'; |
114 | 114 | } |
115 | - $args['messages'] = is_wp_error($args['message']) |
|
116 | - ? (array) $args['message']->get_error_message() |
|
117 | - : (array) $args['message']; |
|
115 | + $args['messages'] = is_wp_error( $args['message'] ) |
|
116 | + ? (array)$args['message']->get_error_message() |
|
117 | + : (array)$args['message']; |
|
118 | 118 | unset($args['message']); |
119 | 119 | return $args; |
120 | 120 | } |
@@ -7,283 +7,283 @@ |
||
7 | 7 | |
8 | 8 | final class Application extends Container |
9 | 9 | { |
10 | - const CAPABILITY = 'edit_others_posts'; |
|
11 | - const CRON_EVENT = 'site-reviews/schedule/session/purge'; |
|
12 | - const ID = 'site-reviews'; |
|
13 | - const PAGED_QUERY_VAR = 'reviews-page'; |
|
14 | - const POST_TYPE = 'site-review'; |
|
15 | - const PREFIX = 'glsr_'; |
|
16 | - const TAXONOMY = 'site-review-category'; |
|
10 | + const CAPABILITY = 'edit_others_posts'; |
|
11 | + const CRON_EVENT = 'site-reviews/schedule/session/purge'; |
|
12 | + const ID = 'site-reviews'; |
|
13 | + const PAGED_QUERY_VAR = 'reviews-page'; |
|
14 | + const POST_TYPE = 'site-review'; |
|
15 | + const PREFIX = 'glsr_'; |
|
16 | + const TAXONOMY = 'site-review-category'; |
|
17 | 17 | |
18 | - public $defaults; |
|
19 | - public $deprecated = []; |
|
20 | - public $file; |
|
21 | - public $languages; |
|
22 | - public $mceShortcodes = []; //defined elsewhere |
|
23 | - public $name; |
|
24 | - public $reviewTypes; |
|
25 | - public $schemas = []; //defined elsewhere |
|
26 | - public $version; |
|
18 | + public $defaults; |
|
19 | + public $deprecated = []; |
|
20 | + public $file; |
|
21 | + public $languages; |
|
22 | + public $mceShortcodes = []; //defined elsewhere |
|
23 | + public $name; |
|
24 | + public $reviewTypes; |
|
25 | + public $schemas = []; //defined elsewhere |
|
26 | + public $version; |
|
27 | 27 | |
28 | - public function __construct() |
|
29 | - { |
|
30 | - static::$instance = $this; |
|
31 | - $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
32 | - $plugin = get_file_data($this->file, [ |
|
33 | - 'languages' => 'Domain Path', |
|
34 | - 'name' => 'Plugin Name', |
|
35 | - 'version' => 'Version', |
|
36 | - ], 'plugin'); |
|
37 | - array_walk($plugin, function ($value, $key) { |
|
38 | - $this->$key = $value; |
|
39 | - }); |
|
40 | - } |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + static::$instance = $this; |
|
31 | + $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
32 | + $plugin = get_file_data($this->file, [ |
|
33 | + 'languages' => 'Domain Path', |
|
34 | + 'name' => 'Plugin Name', |
|
35 | + 'version' => 'Version', |
|
36 | + ], 'plugin'); |
|
37 | + array_walk($plugin, function ($value, $key) { |
|
38 | + $this->$key = $value; |
|
39 | + }); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public function activate() |
|
46 | - { |
|
47 | - $this->make(DefaultsManager::class)->set(); |
|
48 | - $this->scheduleCronJob(); |
|
49 | - $this->upgrade(); |
|
50 | - } |
|
42 | + /** |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public function activate() |
|
46 | + { |
|
47 | + $this->make(DefaultsManager::class)->set(); |
|
48 | + $this->scheduleCronJob(); |
|
49 | + $this->upgrade(); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function catchFatalError() |
|
56 | - { |
|
57 | - $error = error_get_last(); |
|
58 | - if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) { |
|
59 | - return; |
|
60 | - } |
|
61 | - glsr_log()->error($error['message']); |
|
62 | - } |
|
52 | + /** |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function catchFatalError() |
|
56 | + { |
|
57 | + $error = error_get_last(); |
|
58 | + if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) { |
|
59 | + return; |
|
60 | + } |
|
61 | + glsr_log()->error($error['message']); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string $name |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - public function config($name) |
|
69 | - { |
|
70 | - $configFile = $this->path('config/'.$name.'.php'); |
|
71 | - $config = file_exists($configFile) |
|
72 | - ? include $configFile |
|
73 | - : []; |
|
74 | - return apply_filters('site-reviews/config/'.$name, $config); |
|
75 | - } |
|
64 | + /** |
|
65 | + * @param string $name |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + public function config($name) |
|
69 | + { |
|
70 | + $configFile = $this->path('config/'.$name.'.php'); |
|
71 | + $config = file_exists($configFile) |
|
72 | + ? include $configFile |
|
73 | + : []; |
|
74 | + return apply_filters('site-reviews/config/'.$name, $config); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @param string $property |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function constant($property, $className = 'static') |
|
82 | - { |
|
83 | - $constant = $className.'::'.$property; |
|
84 | - return defined($constant) |
|
85 | - ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
86 | - : ''; |
|
87 | - } |
|
77 | + /** |
|
78 | + * @param string $property |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function constant($property, $className = 'static') |
|
82 | + { |
|
83 | + $constant = $className.'::'.$property; |
|
84 | + return defined($constant) |
|
85 | + ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
86 | + : ''; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return void |
|
91 | - */ |
|
92 | - public function deactivate() |
|
93 | - { |
|
94 | - $this->unscheduleCronJob(); |
|
95 | - } |
|
89 | + /** |
|
90 | + * @return void |
|
91 | + */ |
|
92 | + public function deactivate() |
|
93 | + { |
|
94 | + $this->unscheduleCronJob(); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * @param string $view |
|
99 | - * @return void|string |
|
100 | - */ |
|
101 | - public function file($view) |
|
102 | - { |
|
103 | - $view.= '.php'; |
|
104 | - $filePaths = []; |
|
105 | - if (glsr(Helper::class)->startsWith('templates/', $view)) { |
|
106 | - $filePaths[] = $this->themePath(glsr(Helper::class)->removePrefix('templates/', $view)); |
|
107 | - } |
|
108 | - $filePaths[] = $this->path($view); |
|
109 | - $filePaths[] = $this->path('views/'.$view); |
|
110 | - foreach ($filePaths as $file) { |
|
111 | - if (!file_exists($file)) { |
|
112 | - continue; |
|
113 | - } |
|
114 | - return $file; |
|
115 | - } |
|
116 | - } |
|
97 | + /** |
|
98 | + * @param string $view |
|
99 | + * @return void|string |
|
100 | + */ |
|
101 | + public function file($view) |
|
102 | + { |
|
103 | + $view.= '.php'; |
|
104 | + $filePaths = []; |
|
105 | + if (glsr(Helper::class)->startsWith('templates/', $view)) { |
|
106 | + $filePaths[] = $this->themePath(glsr(Helper::class)->removePrefix('templates/', $view)); |
|
107 | + } |
|
108 | + $filePaths[] = $this->path($view); |
|
109 | + $filePaths[] = $this->path('views/'.$view); |
|
110 | + foreach ($filePaths as $file) { |
|
111 | + if (!file_exists($file)) { |
|
112 | + continue; |
|
113 | + } |
|
114 | + return $file; |
|
115 | + } |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * @return array |
|
120 | - */ |
|
121 | - public function getDefaults() |
|
122 | - { |
|
123 | - if (empty($this->defaults)) { |
|
124 | - $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
125 | - $this->upgrade(); |
|
126 | - } |
|
127 | - return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
128 | - } |
|
118 | + /** |
|
119 | + * @return array |
|
120 | + */ |
|
121 | + public function getDefaults() |
|
122 | + { |
|
123 | + if (empty($this->defaults)) { |
|
124 | + $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
125 | + $this->upgrade(); |
|
126 | + } |
|
127 | + return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * @return bool |
|
132 | - */ |
|
133 | - public function getPermission($page = '') |
|
134 | - { |
|
135 | - $permissions = [ |
|
136 | - 'addons' => 'install_plugins', |
|
137 | - 'settings' => 'manage_options', |
|
138 | - ]; |
|
139 | - return glsr_get($permissions, $page, $this->constant('CAPABILITY')); |
|
140 | - } |
|
130 | + /** |
|
131 | + * @return bool |
|
132 | + */ |
|
133 | + public function getPermission($page = '') |
|
134 | + { |
|
135 | + $permissions = [ |
|
136 | + 'addons' => 'install_plugins', |
|
137 | + 'settings' => 'manage_options', |
|
138 | + ]; |
|
139 | + return glsr_get($permissions, $page, $this->constant('CAPABILITY')); |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * @return bool |
|
144 | - */ |
|
145 | - public function hasPermission($page = '') |
|
146 | - { |
|
147 | - $isAdmin = $this->isAdmin(); |
|
148 | - return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page))); |
|
149 | - } |
|
142 | + /** |
|
143 | + * @return bool |
|
144 | + */ |
|
145 | + public function hasPermission($page = '') |
|
146 | + { |
|
147 | + $isAdmin = $this->isAdmin(); |
|
148 | + return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page))); |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @return void |
|
153 | - */ |
|
154 | - public function init() |
|
155 | - { |
|
156 | - $this->make(Actions::class)->run(); |
|
157 | - $this->make(Filters::class)->run(); |
|
158 | - } |
|
151 | + /** |
|
152 | + * @return void |
|
153 | + */ |
|
154 | + public function init() |
|
155 | + { |
|
156 | + $this->make(Actions::class)->run(); |
|
157 | + $this->make(Filters::class)->run(); |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * @return bool |
|
162 | - */ |
|
163 | - public function isAdmin() |
|
164 | - { |
|
165 | - return is_admin() && !wp_doing_ajax(); |
|
166 | - } |
|
160 | + /** |
|
161 | + * @return bool |
|
162 | + */ |
|
163 | + public function isAdmin() |
|
164 | + { |
|
165 | + return is_admin() && !wp_doing_ajax(); |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * @param string $file |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public function path($file = '', $realpath = true) |
|
173 | - { |
|
174 | - $path = plugin_dir_path($this->file); |
|
175 | - if (!$realpath) { |
|
176 | - $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
177 | - } |
|
178 | - $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
179 | - return apply_filters('site-reviews/path', $path, $file); |
|
180 | - } |
|
168 | + /** |
|
169 | + * @param string $file |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public function path($file = '', $realpath = true) |
|
173 | + { |
|
174 | + $path = plugin_dir_path($this->file); |
|
175 | + if (!$realpath) { |
|
176 | + $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
177 | + } |
|
178 | + $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
179 | + return apply_filters('site-reviews/path', $path, $file); |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * @return void |
|
184 | - */ |
|
185 | - public function registerAddons() |
|
186 | - { |
|
187 | - do_action('site-reviews/addon/register', $this); |
|
188 | - } |
|
182 | + /** |
|
183 | + * @return void |
|
184 | + */ |
|
185 | + public function registerAddons() |
|
186 | + { |
|
187 | + do_action('site-reviews/addon/register', $this); |
|
188 | + } |
|
189 | 189 | |
190 | - /** |
|
191 | - * @return void |
|
192 | - */ |
|
193 | - public function registerLanguages() |
|
194 | - { |
|
195 | - load_plugin_textdomain(static::ID, false, |
|
196 | - trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
197 | - ); |
|
198 | - } |
|
190 | + /** |
|
191 | + * @return void |
|
192 | + */ |
|
193 | + public function registerLanguages() |
|
194 | + { |
|
195 | + load_plugin_textdomain(static::ID, false, |
|
196 | + trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
197 | + ); |
|
198 | + } |
|
199 | 199 | |
200 | - /** |
|
201 | - * @return void |
|
202 | - */ |
|
203 | - public function registerReviewTypes() |
|
204 | - { |
|
205 | - $types = apply_filters('site-reviews/addon/types', []); |
|
206 | - $this->reviewTypes = wp_parse_args($types, [ |
|
207 | - 'local' => __('Local', 'site-reviews'), |
|
208 | - ]); |
|
209 | - } |
|
200 | + /** |
|
201 | + * @return void |
|
202 | + */ |
|
203 | + public function registerReviewTypes() |
|
204 | + { |
|
205 | + $types = apply_filters('site-reviews/addon/types', []); |
|
206 | + $this->reviewTypes = wp_parse_args($types, [ |
|
207 | + 'local' => __('Local', 'site-reviews'), |
|
208 | + ]); |
|
209 | + } |
|
210 | 210 | |
211 | - /** |
|
212 | - * @param string $view |
|
213 | - * @return void |
|
214 | - */ |
|
215 | - public function render($view, array $data = []) |
|
216 | - { |
|
217 | - $view = apply_filters('site-reviews/render/view', $view, $data); |
|
218 | - $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
219 | - if (!file_exists($file)) { |
|
220 | - glsr_log()->error('File not found: '.$file); |
|
221 | - return; |
|
222 | - } |
|
223 | - $data = apply_filters('site-reviews/views/data', $data, $view); |
|
224 | - extract($data); |
|
225 | - include $file; |
|
226 | - } |
|
211 | + /** |
|
212 | + * @param string $view |
|
213 | + * @return void |
|
214 | + */ |
|
215 | + public function render($view, array $data = []) |
|
216 | + { |
|
217 | + $view = apply_filters('site-reviews/render/view', $view, $data); |
|
218 | + $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
219 | + if (!file_exists($file)) { |
|
220 | + glsr_log()->error('File not found: '.$file); |
|
221 | + return; |
|
222 | + } |
|
223 | + $data = apply_filters('site-reviews/views/data', $data, $view); |
|
224 | + extract($data); |
|
225 | + include $file; |
|
226 | + } |
|
227 | 227 | |
228 | - /** |
|
229 | - * @return void |
|
230 | - */ |
|
231 | - public function scheduleCronJob() |
|
232 | - { |
|
233 | - if (wp_next_scheduled(static::CRON_EVENT)) { |
|
234 | - return; |
|
235 | - } |
|
236 | - wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
237 | - } |
|
228 | + /** |
|
229 | + * @return void |
|
230 | + */ |
|
231 | + public function scheduleCronJob() |
|
232 | + { |
|
233 | + if (wp_next_scheduled(static::CRON_EVENT)) { |
|
234 | + return; |
|
235 | + } |
|
236 | + wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
237 | + } |
|
238 | 238 | |
239 | - /** |
|
240 | - * @param string $file |
|
241 | - * @return string |
|
242 | - */ |
|
243 | - public function themePath($file = '') |
|
244 | - { |
|
245 | - return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
246 | - } |
|
239 | + /** |
|
240 | + * @param string $file |
|
241 | + * @return string |
|
242 | + */ |
|
243 | + public function themePath($file = '') |
|
244 | + { |
|
245 | + return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * @return void |
|
250 | - */ |
|
251 | - public function unscheduleCronJob() |
|
252 | - { |
|
253 | - wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
254 | - } |
|
248 | + /** |
|
249 | + * @return void |
|
250 | + */ |
|
251 | + public function unscheduleCronJob() |
|
252 | + { |
|
253 | + wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * @return void |
|
258 | - */ |
|
259 | - public function upgrade() |
|
260 | - { |
|
261 | - $this->make(Upgrader::class)->run(); |
|
262 | - } |
|
256 | + /** |
|
257 | + * @return void |
|
258 | + */ |
|
259 | + public function upgrade() |
|
260 | + { |
|
261 | + $this->make(Upgrader::class)->run(); |
|
262 | + } |
|
263 | 263 | |
264 | - /** |
|
265 | - * @param mixed $upgrader |
|
266 | - * @return void |
|
267 | - * @action upgrader_process_complete |
|
268 | - */ |
|
269 | - public function upgraded($upgrader, array $data) |
|
270 | - { |
|
271 | - if (array_key_exists('plugins', $data) |
|
272 | - && in_array(plugin_basename($this->file), $data['plugins']) |
|
273 | - && 'update' === $data['action'] |
|
274 | - && 'plugin' === $data['type'] |
|
275 | - ) { |
|
276 | - $this->upgrade(); |
|
277 | - } |
|
278 | - } |
|
264 | + /** |
|
265 | + * @param mixed $upgrader |
|
266 | + * @return void |
|
267 | + * @action upgrader_process_complete |
|
268 | + */ |
|
269 | + public function upgraded($upgrader, array $data) |
|
270 | + { |
|
271 | + if (array_key_exists('plugins', $data) |
|
272 | + && in_array(plugin_basename($this->file), $data['plugins']) |
|
273 | + && 'update' === $data['action'] |
|
274 | + && 'plugin' === $data['type'] |
|
275 | + ) { |
|
276 | + $this->upgrade(); |
|
277 | + } |
|
278 | + } |
|
279 | 279 | |
280 | - /** |
|
281 | - * @param string $path |
|
282 | - * @return string |
|
283 | - */ |
|
284 | - public function url($path = '') |
|
285 | - { |
|
286 | - $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
287 | - return apply_filters('site-reviews/url', $url, $path); |
|
288 | - } |
|
280 | + /** |
|
281 | + * @param string $path |
|
282 | + * @return string |
|
283 | + */ |
|
284 | + public function url($path = '') |
|
285 | + { |
|
286 | + $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
287 | + return apply_filters('site-reviews/url', $url, $path); |
|
288 | + } |
|
289 | 289 | } |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | public function __construct() |
29 | 29 | { |
30 | 30 | static::$instance = $this; |
31 | - $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
32 | - $plugin = get_file_data($this->file, [ |
|
31 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
32 | + $plugin = get_file_data( $this->file, [ |
|
33 | 33 | 'languages' => 'Domain Path', |
34 | 34 | 'name' => 'Plugin Name', |
35 | 35 | 'version' => 'Version', |
36 | - ], 'plugin'); |
|
37 | - array_walk($plugin, function ($value, $key) { |
|
36 | + ], 'plugin' ); |
|
37 | + array_walk( $plugin, function( $value, $key ) { |
|
38 | 38 | $this->$key = $value; |
39 | 39 | }); |
40 | 40 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function activate() |
46 | 46 | { |
47 | - $this->make(DefaultsManager::class)->set(); |
|
47 | + $this->make( DefaultsManager::class )->set(); |
|
48 | 48 | $this->scheduleCronJob(); |
49 | 49 | $this->upgrade(); |
50 | 50 | } |
@@ -55,34 +55,34 @@ discard block |
||
55 | 55 | public function catchFatalError() |
56 | 56 | { |
57 | 57 | $error = error_get_last(); |
58 | - if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) { |
|
58 | + if( E_ERROR !== $error['type'] || false === strpos( $error['message'], $this->path() ) ) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | - glsr_log()->error($error['message']); |
|
61 | + glsr_log()->error( $error['message'] ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @param string $name |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - public function config($name) |
|
68 | + public function config( $name ) |
|
69 | 69 | { |
70 | - $configFile = $this->path('config/'.$name.'.php'); |
|
71 | - $config = file_exists($configFile) |
|
70 | + $configFile = $this->path( 'config/'.$name.'.php' ); |
|
71 | + $config = file_exists( $configFile ) |
|
72 | 72 | ? include $configFile |
73 | 73 | : []; |
74 | - return apply_filters('site-reviews/config/'.$name, $config); |
|
74 | + return apply_filters( 'site-reviews/config/'.$name, $config ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @param string $property |
79 | 79 | * @return string |
80 | 80 | */ |
81 | - public function constant($property, $className = 'static') |
|
81 | + public function constant( $property, $className = 'static' ) |
|
82 | 82 | { |
83 | 83 | $constant = $className.'::'.$property; |
84 | - return defined($constant) |
|
85 | - ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
84 | + return defined( $constant ) |
|
85 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
86 | 86 | : ''; |
87 | 87 | } |
88 | 88 | |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | * @param string $view |
99 | 99 | * @return void|string |
100 | 100 | */ |
101 | - public function file($view) |
|
101 | + public function file( $view ) |
|
102 | 102 | { |
103 | - $view.= '.php'; |
|
103 | + $view .= '.php'; |
|
104 | 104 | $filePaths = []; |
105 | - if (glsr(Helper::class)->startsWith('templates/', $view)) { |
|
106 | - $filePaths[] = $this->themePath(glsr(Helper::class)->removePrefix('templates/', $view)); |
|
105 | + if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) { |
|
106 | + $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) ); |
|
107 | 107 | } |
108 | - $filePaths[] = $this->path($view); |
|
109 | - $filePaths[] = $this->path('views/'.$view); |
|
110 | - foreach ($filePaths as $file) { |
|
111 | - if (!file_exists($file)) { |
|
108 | + $filePaths[] = $this->path( $view ); |
|
109 | + $filePaths[] = $this->path( 'views/'.$view ); |
|
110 | + foreach( $filePaths as $file ) { |
|
111 | + if( !file_exists( $file ) ) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | return $file; |
@@ -120,32 +120,32 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getDefaults() |
122 | 122 | { |
123 | - if (empty($this->defaults)) { |
|
124 | - $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
123 | + if( empty($this->defaults) ) { |
|
124 | + $this->defaults = $this->make( DefaultsManager::class )->get(); |
|
125 | 125 | $this->upgrade(); |
126 | 126 | } |
127 | - return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
127 | + return apply_filters( 'site-reviews/get/defaults', $this->defaults ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @return bool |
132 | 132 | */ |
133 | - public function getPermission($page = '') |
|
133 | + public function getPermission( $page = '' ) |
|
134 | 134 | { |
135 | 135 | $permissions = [ |
136 | 136 | 'addons' => 'install_plugins', |
137 | 137 | 'settings' => 'manage_options', |
138 | 138 | ]; |
139 | - return glsr_get($permissions, $page, $this->constant('CAPABILITY')); |
|
139 | + return glsr_get( $permissions, $page, $this->constant( 'CAPABILITY' ) ); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | 143 | * @return bool |
144 | 144 | */ |
145 | - public function hasPermission($page = '') |
|
145 | + public function hasPermission( $page = '' ) |
|
146 | 146 | { |
147 | 147 | $isAdmin = $this->isAdmin(); |
148 | - return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page))); |
|
148 | + return !$isAdmin || ($isAdmin && current_user_can( $this->getPermission( $page ) )); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function init() |
155 | 155 | { |
156 | - $this->make(Actions::class)->run(); |
|
157 | - $this->make(Filters::class)->run(); |
|
156 | + $this->make( Actions::class )->run(); |
|
157 | + $this->make( Filters::class )->run(); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | * @param string $file |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function path($file = '', $realpath = true) |
|
172 | + public function path( $file = '', $realpath = true ) |
|
173 | 173 | { |
174 | - $path = plugin_dir_path($this->file); |
|
175 | - if (!$realpath) { |
|
176 | - $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
174 | + $path = plugin_dir_path( $this->file ); |
|
175 | + if( !$realpath ) { |
|
176 | + $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) ); |
|
177 | 177 | } |
178 | - $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
179 | - return apply_filters('site-reviews/path', $path, $file); |
|
178 | + $path = trailingslashit( $path ).ltrim( trim( $file ), '/' ); |
|
179 | + return apply_filters( 'site-reviews/path', $path, $file ); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function registerAddons() |
186 | 186 | { |
187 | - do_action('site-reviews/addon/register', $this); |
|
187 | + do_action( 'site-reviews/addon/register', $this ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function registerLanguages() |
194 | 194 | { |
195 | - load_plugin_textdomain(static::ID, false, |
|
196 | - trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
195 | + load_plugin_textdomain( static::ID, false, |
|
196 | + trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages ) |
|
197 | 197 | ); |
198 | 198 | } |
199 | 199 | |
@@ -202,26 +202,26 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function registerReviewTypes() |
204 | 204 | { |
205 | - $types = apply_filters('site-reviews/addon/types', []); |
|
206 | - $this->reviewTypes = wp_parse_args($types, [ |
|
207 | - 'local' => __('Local', 'site-reviews'), |
|
208 | - ]); |
|
205 | + $types = apply_filters( 'site-reviews/addon/types', [] ); |
|
206 | + $this->reviewTypes = wp_parse_args( $types, [ |
|
207 | + 'local' => __( 'Local', 'site-reviews' ), |
|
208 | + ] ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
212 | 212 | * @param string $view |
213 | 213 | * @return void |
214 | 214 | */ |
215 | - public function render($view, array $data = []) |
|
215 | + public function render( $view, array $data = [] ) |
|
216 | 216 | { |
217 | - $view = apply_filters('site-reviews/render/view', $view, $data); |
|
218 | - $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
219 | - if (!file_exists($file)) { |
|
220 | - glsr_log()->error('File not found: '.$file); |
|
217 | + $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
|
218 | + $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
|
219 | + if( !file_exists( $file ) ) { |
|
220 | + glsr_log()->error( 'File not found: '.$file ); |
|
221 | 221 | return; |
222 | 222 | } |
223 | - $data = apply_filters('site-reviews/views/data', $data, $view); |
|
224 | - extract($data); |
|
223 | + $data = apply_filters( 'site-reviews/views/data', $data, $view ); |
|
224 | + extract( $data ); |
|
225 | 225 | include $file; |
226 | 226 | } |
227 | 227 | |
@@ -230,19 +230,19 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function scheduleCronJob() |
232 | 232 | { |
233 | - if (wp_next_scheduled(static::CRON_EVENT)) { |
|
233 | + if( wp_next_scheduled( static::CRON_EVENT ) ) { |
|
234 | 234 | return; |
235 | 235 | } |
236 | - wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
236 | + wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
240 | 240 | * @param string $file |
241 | 241 | * @return string |
242 | 242 | */ |
243 | - public function themePath($file = '') |
|
243 | + public function themePath( $file = '' ) |
|
244 | 244 | { |
245 | - return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
245 | + return get_stylesheet_directory().'/'.static::ID.'/'.ltrim( trim( $file ), '/' ); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function unscheduleCronJob() |
252 | 252 | { |
253 | - wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
253 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function upgrade() |
260 | 260 | { |
261 | - $this->make(Upgrader::class)->run(); |
|
261 | + $this->make( Upgrader::class )->run(); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | * @return void |
267 | 267 | * @action upgrader_process_complete |
268 | 268 | */ |
269 | - public function upgraded($upgrader, array $data) |
|
269 | + public function upgraded( $upgrader, array $data ) |
|
270 | 270 | { |
271 | - if (array_key_exists('plugins', $data) |
|
272 | - && in_array(plugin_basename($this->file), $data['plugins']) |
|
271 | + if( array_key_exists( 'plugins', $data ) |
|
272 | + && in_array( plugin_basename( $this->file ), $data['plugins'] ) |
|
273 | 273 | && 'update' === $data['action'] |
274 | 274 | && 'plugin' === $data['type'] |
275 | 275 | ) { |
@@ -281,9 +281,9 @@ discard block |
||
281 | 281 | * @param string $path |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - public function url($path = '') |
|
284 | + public function url( $path = '' ) |
|
285 | 285 | { |
286 | - $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
287 | - return apply_filters('site-reviews/url', $url, $path); |
|
286 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
287 | + return apply_filters( 'site-reviews/url', $url, $path ); |
|
288 | 288 | } |
289 | 289 | } |
@@ -9,148 +9,148 @@ |
||
9 | 9 | |
10 | 10 | class EnqueuePublicAssets |
11 | 11 | { |
12 | - /** |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function handle() |
|
16 | - { |
|
17 | - $this->enqueueAssets(); |
|
18 | - $this->enqueuePolyfillService(); |
|
19 | - $this->enqueueRecaptchaScript(); |
|
20 | - $this->inlineScript(); |
|
21 | - $this->inlineStyles(); |
|
22 | - } |
|
12 | + /** |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function handle() |
|
16 | + { |
|
17 | + $this->enqueueAssets(); |
|
18 | + $this->enqueuePolyfillService(); |
|
19 | + $this->enqueueRecaptchaScript(); |
|
20 | + $this->inlineScript(); |
|
21 | + $this->inlineStyles(); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function enqueueAssets() |
|
28 | - { |
|
29 | - if (apply_filters('site-reviews/assets/css', true)) { |
|
30 | - wp_enqueue_style( |
|
31 | - Application::ID, |
|
32 | - $this->getStylesheet(), |
|
33 | - [], |
|
34 | - glsr()->version |
|
35 | - ); |
|
36 | - } |
|
37 | - if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | - $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
39 | - ? [Application::ID.'/polyfill'] |
|
40 | - : []; |
|
41 | - $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
42 | - wp_enqueue_script( |
|
43 | - Application::ID, |
|
44 | - glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
45 | - $dependencies, |
|
46 | - glsr()->version, |
|
47 | - true |
|
48 | - ); |
|
49 | - } |
|
50 | - } |
|
24 | + /** |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function enqueueAssets() |
|
28 | + { |
|
29 | + if (apply_filters('site-reviews/assets/css', true)) { |
|
30 | + wp_enqueue_style( |
|
31 | + Application::ID, |
|
32 | + $this->getStylesheet(), |
|
33 | + [], |
|
34 | + glsr()->version |
|
35 | + ); |
|
36 | + } |
|
37 | + if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | + $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
39 | + ? [Application::ID.'/polyfill'] |
|
40 | + : []; |
|
41 | + $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
42 | + wp_enqueue_script( |
|
43 | + Application::ID, |
|
44 | + glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
45 | + $dependencies, |
|
46 | + glsr()->version, |
|
47 | + true |
|
48 | + ); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function enqueuePolyfillService() |
|
56 | - { |
|
57 | - if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
58 | - return; |
|
59 | - } |
|
60 | - wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
61 | - 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
|
62 | - 'flags' => 'gated', |
|
63 | - ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
64 | - } |
|
52 | + /** |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function enqueuePolyfillService() |
|
56 | + { |
|
57 | + if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
58 | + return; |
|
59 | + } |
|
60 | + wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
61 | + 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
|
62 | + 'flags' => 'gated', |
|
63 | + ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function enqueueRecaptchaScript() |
|
70 | - { |
|
71 | - // wpforms-recaptcha |
|
72 | - // google-recaptcha |
|
73 | - // nf-google-recaptcha |
|
74 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
75 | - return; |
|
76 | - } |
|
77 | - $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | - wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
79 | - 'hl' => $language, |
|
80 | - 'render' => 'explicit', |
|
81 | - ], 'https://www.google.com/recaptcha/api.js')); |
|
82 | - } |
|
66 | + /** |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function enqueueRecaptchaScript() |
|
70 | + { |
|
71 | + // wpforms-recaptcha |
|
72 | + // google-recaptcha |
|
73 | + // nf-google-recaptcha |
|
74 | + if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
75 | + return; |
|
76 | + } |
|
77 | + $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | + wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
79 | + 'hl' => $language, |
|
80 | + 'render' => 'explicit', |
|
81 | + ], 'https://www.google.com/recaptcha/api.js')); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public function inlineScript() |
|
88 | - { |
|
89 | - $variables = [ |
|
90 | - 'action' => Application::PREFIX.'action', |
|
91 | - 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
|
92 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
93 | - 'nameprefix' => Application::ID, |
|
94 | - 'validationconfig' => glsr(Style::class)->validation, |
|
95 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
96 | - ]; |
|
97 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
98 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
99 | - } |
|
84 | + /** |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public function inlineScript() |
|
88 | + { |
|
89 | + $variables = [ |
|
90 | + 'action' => Application::PREFIX.'action', |
|
91 | + 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
|
92 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
93 | + 'nameprefix' => Application::ID, |
|
94 | + 'validationconfig' => glsr(Style::class)->validation, |
|
95 | + 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
96 | + ]; |
|
97 | + $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
98 | + wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @return void |
|
103 | - */ |
|
104 | - public function inlineStyles() |
|
105 | - { |
|
106 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
107 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
108 | - return; |
|
109 | - } |
|
110 | - if (!file_exists($inlineStylesheetPath)) { |
|
111 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
112 | - return; |
|
113 | - } |
|
114 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
115 | - $stylesheet = str_replace( |
|
116 | - array_keys($inlineStylesheetValues), |
|
117 | - array_values($inlineStylesheetValues), |
|
118 | - file_get_contents($inlineStylesheetPath) |
|
119 | - ); |
|
120 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
121 | - } |
|
101 | + /** |
|
102 | + * @return void |
|
103 | + */ |
|
104 | + public function inlineStyles() |
|
105 | + { |
|
106 | + $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
107 | + if (!apply_filters('site-reviews/assets/css', true)) { |
|
108 | + return; |
|
109 | + } |
|
110 | + if (!file_exists($inlineStylesheetPath)) { |
|
111 | + glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
112 | + return; |
|
113 | + } |
|
114 | + $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
115 | + $stylesheet = str_replace( |
|
116 | + array_keys($inlineStylesheetValues), |
|
117 | + array_values($inlineStylesheetValues), |
|
118 | + file_get_contents($inlineStylesheetPath) |
|
119 | + ); |
|
120 | + wp_add_inline_style(Application::ID, $stylesheet); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @return string |
|
125 | - */ |
|
126 | - protected function buildInlineScript(array $variables) |
|
127 | - { |
|
128 | - $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
129 | - foreach ($variables as $key => $value) { |
|
130 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
131 | - } |
|
132 | - $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
133 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
134 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
135 | - } |
|
123 | + /** |
|
124 | + * @return string |
|
125 | + */ |
|
126 | + protected function buildInlineScript(array $variables) |
|
127 | + { |
|
128 | + $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
129 | + foreach ($variables as $key => $value) { |
|
130 | + $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
131 | + } |
|
132 | + $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
133 | + $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
134 | + return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - protected function getFixedSelectorsForPagination() |
|
141 | - { |
|
142 | - $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
143 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
144 | - } |
|
137 | + /** |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + protected function getFixedSelectorsForPagination() |
|
141 | + { |
|
142 | + $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
143 | + return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - protected function getStylesheet() |
|
150 | - { |
|
151 | - $currentStyle = glsr(Style::class)->style; |
|
152 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
153 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
154 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
155 | - } |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + protected function getStylesheet() |
|
150 | + { |
|
151 | + $currentStyle = glsr(Style::class)->style; |
|
152 | + return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
153 | + ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
154 | + : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
155 | + } |
|
156 | 156 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function enqueueAssets() |
28 | 28 | { |
29 | - if (apply_filters('site-reviews/assets/css', true)) { |
|
29 | + if( apply_filters( 'site-reviews/assets/css', true ) ) { |
|
30 | 30 | wp_enqueue_style( |
31 | 31 | Application::ID, |
32 | 32 | $this->getStylesheet(), |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | glsr()->version |
35 | 35 | ); |
36 | 36 | } |
37 | - if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | - $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
37 | + if( apply_filters( 'site-reviews/assets/js', true ) ) { |
|
38 | + $dependencies = apply_filters( 'site-reviews/assets/polyfill', true ) |
|
39 | 39 | ? [Application::ID.'/polyfill'] |
40 | 40 | : []; |
41 | - $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
41 | + $dependencies = apply_filters( 'site-reviews/enqueue/public/dependencies', $dependencies ); |
|
42 | 42 | wp_enqueue_script( |
43 | 43 | Application::ID, |
44 | - glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
44 | + glsr()->url( 'assets/scripts/'.Application::ID.'.js' ), |
|
45 | 45 | $dependencies, |
46 | 46 | glsr()->version, |
47 | 47 | true |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function enqueuePolyfillService() |
56 | 56 | { |
57 | - if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
57 | + if( !apply_filters( 'site-reviews/assets/polyfill', true ) ) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | - wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
60 | + wp_enqueue_script( Application::ID.'/polyfill', add_query_arg( [ |
|
61 | 61 | 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
62 | 62 | 'flags' => 'gated', |
63 | - ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
63 | + ], 'https://polyfill.io/v3/polyfill.min.js' ) ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | // wpforms-recaptcha |
72 | 72 | // google-recaptcha |
73 | 73 | // nf-google-recaptcha |
74 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
74 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | - $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | - wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
77 | + $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
|
78 | + wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [ |
|
79 | 79 | 'hl' => $language, |
80 | 80 | 'render' => 'explicit', |
81 | - ], 'https://www.google.com/recaptcha/api.js')); |
|
81 | + ], 'https://www.google.com/recaptcha/api.js' ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | $variables = [ |
90 | 90 | 'action' => Application::PREFIX.'action', |
91 | 91 | 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
92 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
92 | + 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
93 | 93 | 'nameprefix' => Application::ID, |
94 | - 'validationconfig' => glsr(Style::class)->validation, |
|
95 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
94 | + 'validationconfig' => glsr( Style::class )->validation, |
|
95 | + 'validationstrings' => glsr( ValidationStringsDefaults::class )->defaults(), |
|
96 | 96 | ]; |
97 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
98 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
97 | + $variables = apply_filters( 'site-reviews/enqueue/public/localize', $variables ); |
|
98 | + wp_add_inline_script( Application::ID, $this->buildInlineScript( $variables ), 'before' ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,35 +103,35 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function inlineStyles() |
105 | 105 | { |
106 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
107 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
106 | + $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
|
107 | + if( !apply_filters( 'site-reviews/assets/css', true ) ) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | - if (!file_exists($inlineStylesheetPath)) { |
|
111 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
110 | + if( !file_exists( $inlineStylesheetPath ) ) { |
|
111 | + glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
|
112 | 112 | return; |
113 | 113 | } |
114 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
114 | + $inlineStylesheetValues = glsr()->config( 'inline-styles' ); |
|
115 | 115 | $stylesheet = str_replace( |
116 | - array_keys($inlineStylesheetValues), |
|
117 | - array_values($inlineStylesheetValues), |
|
118 | - file_get_contents($inlineStylesheetPath) |
|
116 | + array_keys( $inlineStylesheetValues ), |
|
117 | + array_values( $inlineStylesheetValues ), |
|
118 | + file_get_contents( $inlineStylesheetPath ) |
|
119 | 119 | ); |
120 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
120 | + wp_add_inline_style( Application::ID, $stylesheet ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return string |
125 | 125 | */ |
126 | - protected function buildInlineScript(array $variables) |
|
126 | + protected function buildInlineScript( array $variables ) |
|
127 | 127 | { |
128 | 128 | $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
129 | - foreach ($variables as $key => $value) { |
|
130 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
129 | + foreach( $variables as $key => $value ) { |
|
130 | + $script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ); |
|
131 | 131 | } |
132 | 132 | $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
133 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
134 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
133 | + $optimizedScript = preg_replace( $pattern, '$1$2', $script ); |
|
134 | + return apply_filters( 'site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | protected function getFixedSelectorsForPagination() |
141 | 141 | { |
142 | 142 | $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
143 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
143 | + return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | */ |
149 | 149 | protected function getStylesheet() |
150 | 150 | { |
151 | - $currentStyle = glsr(Style::class)->style; |
|
152 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
153 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
154 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
151 | + $currentStyle = glsr( Style::class )->style; |
|
152 | + return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) ) |
|
153 | + ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' ) |
|
154 | + : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
|
155 | 155 | } |
156 | 156 | } |
@@ -5,23 +5,23 @@ |
||
5 | 5 | require_once ABSPATH.WPINC.'/class-phpass.php'; |
6 | 6 | |
7 | 7 | spl_autoload_register(function ($className) { |
8 | - $namespaces = [ |
|
9 | - 'GeminiLabs\\SiteReviews\\' => __DIR__.'/plugin/', |
|
10 | - 'GeminiLabs\\SiteReviews\\Tests\\' => __DIR__.'/tests/', |
|
11 | - 'GeminiLabs\\Sepia\\PoParser\\' => __DIR__.'/vendors/sepia/po-parser/', |
|
12 | - 'GeminiLabs\\Sinergi\\BrowserDetector\\' => __DIR__.'/vendors/sinergi/browser-detector/', |
|
13 | - 'GeminiLabs\\Vectorface\\Whip\\' => __DIR__.'/vendors/vectorface/whip/', |
|
14 | - ]; |
|
15 | - foreach ($namespaces as $prefix => $baseDir) { |
|
16 | - $len = strlen($prefix); |
|
17 | - if (0 !== strncmp($prefix, $className, $len)) { |
|
18 | - continue; |
|
19 | - } |
|
20 | - $file = $baseDir.str_replace('\\', '/', substr($className, $len)).'.php'; |
|
21 | - if (!file_exists($file)) { |
|
22 | - continue; |
|
23 | - } |
|
24 | - require $file; |
|
25 | - break; |
|
26 | - } |
|
8 | + $namespaces = [ |
|
9 | + 'GeminiLabs\\SiteReviews\\' => __DIR__.'/plugin/', |
|
10 | + 'GeminiLabs\\SiteReviews\\Tests\\' => __DIR__.'/tests/', |
|
11 | + 'GeminiLabs\\Sepia\\PoParser\\' => __DIR__.'/vendors/sepia/po-parser/', |
|
12 | + 'GeminiLabs\\Sinergi\\BrowserDetector\\' => __DIR__.'/vendors/sinergi/browser-detector/', |
|
13 | + 'GeminiLabs\\Vectorface\\Whip\\' => __DIR__.'/vendors/vectorface/whip/', |
|
14 | + ]; |
|
15 | + foreach ($namespaces as $prefix => $baseDir) { |
|
16 | + $len = strlen($prefix); |
|
17 | + if (0 !== strncmp($prefix, $className, $len)) { |
|
18 | + continue; |
|
19 | + } |
|
20 | + $file = $baseDir.str_replace('\\', '/', substr($className, $len)).'.php'; |
|
21 | + if (!file_exists($file)) { |
|
22 | + continue; |
|
23 | + } |
|
24 | + require $file; |
|
25 | + break; |
|
26 | + } |
|
27 | 27 | }); |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | 5 | require_once ABSPATH.WPINC.'/class-phpass.php'; |
6 | 6 | |
7 | -spl_autoload_register(function ($className) { |
|
7 | +spl_autoload_register( function( $className ) { |
|
8 | 8 | $namespaces = [ |
9 | 9 | 'GeminiLabs\\SiteReviews\\' => __DIR__.'/plugin/', |
10 | 10 | 'GeminiLabs\\SiteReviews\\Tests\\' => __DIR__.'/tests/', |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | 'GeminiLabs\\Sinergi\\BrowserDetector\\' => __DIR__.'/vendors/sinergi/browser-detector/', |
13 | 13 | 'GeminiLabs\\Vectorface\\Whip\\' => __DIR__.'/vendors/vectorface/whip/', |
14 | 14 | ]; |
15 | - foreach ($namespaces as $prefix => $baseDir) { |
|
16 | - $len = strlen($prefix); |
|
17 | - if (0 !== strncmp($prefix, $className, $len)) { |
|
15 | + foreach( $namespaces as $prefix => $baseDir ) { |
|
16 | + $len = strlen( $prefix ); |
|
17 | + if( 0 !== strncmp( $prefix, $className, $len ) ) { |
|
18 | 18 | continue; |
19 | 19 | } |
20 | - $file = $baseDir.str_replace('\\', '/', substr($className, $len)).'.php'; |
|
21 | - if (!file_exists($file)) { |
|
20 | + $file = $baseDir.str_replace( '\\', '/', substr( $className, $len ) ).'.php'; |
|
21 | + if( !file_exists( $file ) ) { |
|
22 | 22 | continue; |
23 | 23 | } |
24 | 24 | require $file; |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | * @see https://www.elegantthemes.com/gallery/divi/ |
9 | 9 | */ |
10 | 10 | add_action('site-reviews/customize/divi', function ($instance) { |
11 | - if ('label' != $instance->tag || 'checkbox' != $instance->args['type']) { |
|
12 | - return; |
|
13 | - } |
|
14 | - $instance->args['text'] = '<i></i>'.$instance->args['text']; |
|
11 | + if ('label' != $instance->tag || 'checkbox' != $instance->args['type']) { |
|
12 | + return; |
|
13 | + } |
|
14 | + $instance->args['text'] = '<i></i>'.$instance->args['text']; |
|
15 | 15 | }); |
16 | 16 | |
17 | 17 | /* |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | * @see https://wordpress.org/plugins/wp-super-cache/ |
23 | 23 | */ |
24 | 24 | add_action('site-reviews/review/created', function ($review, $request) { |
25 | - if (!function_exists('wp_cache_post_change')) { |
|
26 | - return; |
|
27 | - } |
|
28 | - wp_cache_post_change($request->post_id); |
|
29 | - if (empty($review->assigned_to) || $review->assigned_to == $request->post_id) { |
|
30 | - return; |
|
31 | - } |
|
32 | - wp_cache_post_change($review->assigned_to); |
|
25 | + if (!function_exists('wp_cache_post_change')) { |
|
26 | + return; |
|
27 | + } |
|
28 | + wp_cache_post_change($request->post_id); |
|
29 | + if (empty($review->assigned_to) || $review->assigned_to == $request->post_id) { |
|
30 | + return; |
|
31 | + } |
|
32 | + wp_cache_post_change($review->assigned_to); |
|
33 | 33 | }, 10, 2); |
34 | 34 | |
35 | 35 | /* |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @see https://wordpress.org/plugins/speed-booster-pack/ |
39 | 39 | */ |
40 | 40 | add_filter('sbp_exclude_defer_scripts', function ($scriptHandles) { |
41 | - $scriptHandles[] = 'site-reviews/google-recaptcha'; |
|
42 | - return array_keys(array_flip($scriptHandles)); |
|
41 | + $scriptHandles[] = 'site-reviews/google-recaptcha'; |
|
42 | + return array_keys(array_flip($scriptHandles)); |
|
43 | 43 | }); |
44 | 44 | |
45 | 45 | /* |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @see https://searchandfilter.com/ |
50 | 50 | */ |
51 | 51 | add_filter('sf_edit_query_args', function ($query) { |
52 | - if (!empty($query['meta_key']) && '_glsr_ranking' == $query['meta_key']) { |
|
53 | - unset($query['meta_key']); |
|
54 | - $query['meta_query'] = [ |
|
55 | - 'relation' => 'OR', |
|
56 | - ['key' => '_glsr_ranking', 'compare' => 'NOT EXISTS'], // this comes first! |
|
57 | - ['key' => '_glsr_ranking', 'compare' => 'EXISTS'], |
|
58 | - ]; |
|
59 | - } |
|
60 | - return $query; |
|
52 | + if (!empty($query['meta_key']) && '_glsr_ranking' == $query['meta_key']) { |
|
53 | + unset($query['meta_key']); |
|
54 | + $query['meta_query'] = [ |
|
55 | + 'relation' => 'OR', |
|
56 | + ['key' => '_glsr_ranking', 'compare' => 'NOT EXISTS'], // this comes first! |
|
57 | + ['key' => '_glsr_ranking', 'compare' => 'EXISTS'], |
|
58 | + ]; |
|
59 | + } |
|
60 | + return $query; |
|
61 | 61 | }, 20); |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | 5 | /* |
6 | 6 | * @param \GeminiLabs\SiteReviews\Modules\Html\Builder $instance |
7 | 7 | * @return void |
8 | 8 | * @see https://www.elegantthemes.com/gallery/divi/ |
9 | 9 | */ |
10 | -add_action('site-reviews/customize/divi', function ($instance) { |
|
11 | - if ('label' != $instance->tag || 'checkbox' != $instance->args['type']) { |
|
10 | +add_action( 'site-reviews/customize/divi', function( $instance ) { |
|
11 | + if( 'label' != $instance->tag || 'checkbox' != $instance->args['type'] ) { |
|
12 | 12 | return; |
13 | 13 | } |
14 | 14 | $instance->args['text'] = '<i></i>'.$instance->args['text']; |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | * @see https://wordpress.org/plugins/wp-super-cache/ |
23 | 23 | */ |
24 | -add_action('site-reviews/review/created', function ($review, $request) { |
|
25 | - if (!function_exists('wp_cache_post_change')) { |
|
24 | +add_action( 'site-reviews/review/created', function( $review, $request ) { |
|
25 | + if( !function_exists( 'wp_cache_post_change' ) ) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | - wp_cache_post_change($request->post_id); |
|
29 | - if (empty($review->assigned_to) || $review->assigned_to == $request->post_id) { |
|
28 | + wp_cache_post_change( $request->post_id ); |
|
29 | + if( empty($review->assigned_to) || $review->assigned_to == $request->post_id ) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | - wp_cache_post_change($review->assigned_to); |
|
33 | -}, 10, 2); |
|
32 | + wp_cache_post_change( $review->assigned_to ); |
|
33 | +}, 10, 2 ); |
|
34 | 34 | |
35 | 35 | /* |
36 | 36 | * @param array $scriptHandles |
37 | 37 | * @return array |
38 | 38 | * @see https://wordpress.org/plugins/speed-booster-pack/ |
39 | 39 | */ |
40 | -add_filter('sbp_exclude_defer_scripts', function ($scriptHandles) { |
|
40 | +add_filter( 'sbp_exclude_defer_scripts', function( $scriptHandles ) { |
|
41 | 41 | $scriptHandles[] = 'site-reviews/google-recaptcha'; |
42 | - return array_keys(array_flip($scriptHandles)); |
|
42 | + return array_keys( array_flip( $scriptHandles ) ); |
|
43 | 43 | }); |
44 | 44 | |
45 | 45 | /* |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @return array |
49 | 49 | * @see https://searchandfilter.com/ |
50 | 50 | */ |
51 | -add_filter('sf_edit_query_args', function ($query) { |
|
52 | - if (!empty($query['meta_key']) && '_glsr_ranking' == $query['meta_key']) { |
|
51 | +add_filter( 'sf_edit_query_args', function( $query ) { |
|
52 | + if( !empty($query['meta_key']) && '_glsr_ranking' == $query['meta_key'] ) { |
|
53 | 53 | unset($query['meta_key']); |
54 | 54 | $query['meta_query'] = [ |
55 | 55 | 'relation' => 'OR', |
@@ -58,4 +58,4 @@ discard block |
||
58 | 58 | ]; |
59 | 59 | } |
60 | 60 | return $query; |
61 | -}, 20); |
|
61 | +}, 20 ); |