@@ -6,60 +6,60 @@ |
||
6 | 6 | |
7 | 7 | class DefaultsManager |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function defaults() |
|
13 | - { |
|
14 | - $settings = $this->settings(); |
|
15 | - $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | - return wp_parse_args($defaults, [ |
|
17 | - 'version' => '', |
|
18 | - 'version_upgraded_from' => '', |
|
19 | - ]); |
|
20 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function defaults() |
|
13 | + { |
|
14 | + $settings = $this->settings(); |
|
15 | + $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | + return wp_parse_args($defaults, [ |
|
17 | + 'version' => '', |
|
18 | + 'version_upgraded_from' => '', |
|
19 | + ]); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @return array |
|
24 | - */ |
|
25 | - public function get() |
|
26 | - { |
|
27 | - return Arr::convertFromDotNotation($this->defaults()); |
|
28 | - } |
|
22 | + /** |
|
23 | + * @return array |
|
24 | + */ |
|
25 | + public function get() |
|
26 | + { |
|
27 | + return Arr::convertFromDotNotation($this->defaults()); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function set() |
|
34 | - { |
|
35 | - $settings = glsr(OptionManager::class)->all(); |
|
36 | - $currentSettings = Arr::removeEmptyValues($settings); |
|
37 | - $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | - $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | - update_option(OptionManager::databaseKey(), $updatedSettings); |
|
40 | - return $defaultSettings; |
|
41 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function set() |
|
34 | + { |
|
35 | + $settings = glsr(OptionManager::class)->all(); |
|
36 | + $currentSettings = Arr::removeEmptyValues($settings); |
|
37 | + $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | + $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | + update_option(OptionManager::databaseKey(), $updatedSettings); |
|
40 | + return $defaultSettings; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function settings() |
|
47 | - { |
|
48 | - $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | - return $this->normalize($settings); |
|
50 | - } |
|
43 | + /** |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function settings() |
|
47 | + { |
|
48 | + $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | + return $this->normalize($settings); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - protected function normalize(array $settings) |
|
56 | - { |
|
57 | - array_walk($settings, function (&$setting) { |
|
58 | - if (isset($setting['default'])) { |
|
59 | - return; |
|
60 | - } |
|
61 | - $setting['default'] = ''; |
|
62 | - }); |
|
63 | - return $settings; |
|
64 | - } |
|
52 | + /** |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + protected function normalize(array $settings) |
|
56 | + { |
|
57 | + array_walk($settings, function (&$setting) { |
|
58 | + if (isset($setting['default'])) { |
|
59 | + return; |
|
60 | + } |
|
61 | + $setting['default'] = ''; |
|
62 | + }); |
|
63 | + return $settings; |
|
64 | + } |
|
65 | 65 | } |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | public function defaults() |
13 | 13 | { |
14 | 14 | $settings = $this->settings(); |
15 | - $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | - return wp_parse_args($defaults, [ |
|
15 | + $defaults = (array)array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ) ); |
|
16 | + return wp_parse_args( $defaults, [ |
|
17 | 17 | 'version' => '', |
18 | 18 | 'version_upgraded_from' => '', |
19 | - ]); |
|
19 | + ] ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function get() |
26 | 26 | { |
27 | - return Arr::convertFromDotNotation($this->defaults()); |
|
27 | + return Arr::convertFromDotNotation( $this->defaults() ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function set() |
34 | 34 | { |
35 | - $settings = glsr(OptionManager::class)->all(); |
|
36 | - $currentSettings = Arr::removeEmptyValues($settings); |
|
37 | - $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | - $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | - update_option(OptionManager::databaseKey(), $updatedSettings); |
|
35 | + $settings = glsr( OptionManager::class )->all(); |
|
36 | + $currentSettings = Arr::removeEmptyValues( $settings ); |
|
37 | + $defaultSettings = array_replace_recursive( $this->get(), $currentSettings ); |
|
38 | + $updatedSettings = array_replace_recursive( $settings, $defaultSettings ); |
|
39 | + update_option( OptionManager::databaseKey(), $updatedSettings ); |
|
40 | 40 | return $defaultSettings; |
41 | 41 | } |
42 | 42 | |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function settings() |
47 | 47 | { |
48 | - $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | - return $this->normalize($settings); |
|
48 | + $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ) ); |
|
49 | + return $this->normalize( $settings ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @return array |
54 | 54 | */ |
55 | - protected function normalize(array $settings) |
|
55 | + protected function normalize( array $settings ) |
|
56 | 56 | { |
57 | - array_walk($settings, function (&$setting) { |
|
58 | - if (isset($setting['default'])) { |
|
57 | + array_walk( $settings, function( &$setting ) { |
|
58 | + if( isset($setting['default']) ) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | $setting['default'] = ''; |
@@ -9,157 +9,157 @@ |
||
9 | 9 | |
10 | 10 | class OptionManager |
11 | 11 | { |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - protected $options; |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + protected $options; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public static function databaseKey($version = null) |
|
21 | - { |
|
22 | - if (1 == $version) { |
|
23 | - return 'geminilabs_site_reviews_settings'; |
|
24 | - } |
|
25 | - if (2 == $version) { |
|
26 | - return 'geminilabs_site_reviews-v2'; |
|
27 | - } |
|
28 | - if (null === $version) { |
|
29 | - $version = explode('.', glsr()->version); |
|
30 | - $version = array_shift($version); |
|
31 | - } |
|
32 | - return Str::snakeCase(Application::ID.'-v'.intval($version)); |
|
33 | - } |
|
17 | + /** |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public static function databaseKey($version = null) |
|
21 | + { |
|
22 | + if (1 == $version) { |
|
23 | + return 'geminilabs_site_reviews_settings'; |
|
24 | + } |
|
25 | + if (2 == $version) { |
|
26 | + return 'geminilabs_site_reviews-v2'; |
|
27 | + } |
|
28 | + if (null === $version) { |
|
29 | + $version = explode('.', glsr()->version); |
|
30 | + $version = array_shift($version); |
|
31 | + } |
|
32 | + return Str::snakeCase(Application::ID.'-v'.intval($version)); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return array |
|
37 | - */ |
|
38 | - public function all() |
|
39 | - { |
|
40 | - if (empty($this->options)) { |
|
41 | - $this->reset(); |
|
42 | - } |
|
43 | - return $this->options; |
|
44 | - } |
|
35 | + /** |
|
36 | + * @return array |
|
37 | + */ |
|
38 | + public function all() |
|
39 | + { |
|
40 | + if (empty($this->options)) { |
|
41 | + $this->reset(); |
|
42 | + } |
|
43 | + return $this->options; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param string $path |
|
48 | - * @return bool |
|
49 | - */ |
|
50 | - public function delete($path) |
|
51 | - { |
|
52 | - $keys = explode('.', $path); |
|
53 | - $last = array_pop($keys); |
|
54 | - $options = $this->all(); |
|
55 | - $pointer = &$options; |
|
56 | - foreach ($keys as $key) { |
|
57 | - if (!isset($pointer[$key]) || !is_array($pointer[$key])) { |
|
58 | - continue; |
|
59 | - } |
|
60 | - $pointer = &$pointer[$key]; |
|
61 | - } |
|
62 | - unset($pointer[$last]); |
|
63 | - return $this->set($options); |
|
64 | - } |
|
46 | + /** |
|
47 | + * @param string $path |
|
48 | + * @return bool |
|
49 | + */ |
|
50 | + public function delete($path) |
|
51 | + { |
|
52 | + $keys = explode('.', $path); |
|
53 | + $last = array_pop($keys); |
|
54 | + $options = $this->all(); |
|
55 | + $pointer = &$options; |
|
56 | + foreach ($keys as $key) { |
|
57 | + if (!isset($pointer[$key]) || !is_array($pointer[$key])) { |
|
58 | + continue; |
|
59 | + } |
|
60 | + $pointer = &$pointer[$key]; |
|
61 | + } |
|
62 | + unset($pointer[$last]); |
|
63 | + return $this->set($options); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param string $path |
|
68 | - * @param mixed $fallback |
|
69 | - * @param string $cast |
|
70 | - * @return mixed |
|
71 | - */ |
|
72 | - public function get($path = '', $fallback = '', $cast = '') |
|
73 | - { |
|
74 | - $result = Arr::get($this->all(), $path, $fallback); |
|
75 | - return Helper::castTo($cast, $result); |
|
76 | - } |
|
66 | + /** |
|
67 | + * @param string $path |
|
68 | + * @param mixed $fallback |
|
69 | + * @param string $cast |
|
70 | + * @return mixed |
|
71 | + */ |
|
72 | + public function get($path = '', $fallback = '', $cast = '') |
|
73 | + { |
|
74 | + $result = Arr::get($this->all(), $path, $fallback); |
|
75 | + return Helper::castTo($cast, $result); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param string $path |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function getBool($path) |
|
83 | - { |
|
84 | - return Helper::castToBool($this->get($path)); |
|
85 | - } |
|
78 | + /** |
|
79 | + * @param string $path |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function getBool($path) |
|
83 | + { |
|
84 | + return Helper::castToBool($this->get($path)); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param string $path |
|
89 | - * @param mixed $fallback |
|
90 | - * @param string $cast |
|
91 | - * @return mixed |
|
92 | - */ |
|
93 | - public function getWP($path, $fallback = '', $cast = '') |
|
94 | - { |
|
95 | - $option = get_option($path, $fallback); |
|
96 | - if (empty($option)) { |
|
97 | - $option = $fallback; |
|
98 | - } |
|
99 | - return Helper::castTo($cast, $option); |
|
100 | - } |
|
87 | + /** |
|
88 | + * @param string $path |
|
89 | + * @param mixed $fallback |
|
90 | + * @param string $cast |
|
91 | + * @return mixed |
|
92 | + */ |
|
93 | + public function getWP($path, $fallback = '', $cast = '') |
|
94 | + { |
|
95 | + $option = get_option($path, $fallback); |
|
96 | + if (empty($option)) { |
|
97 | + $option = $fallback; |
|
98 | + } |
|
99 | + return Helper::castTo($cast, $option); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @return string |
|
104 | - */ |
|
105 | - public function json() |
|
106 | - { |
|
107 | - return json_encode($this->all()); |
|
108 | - } |
|
102 | + /** |
|
103 | + * @return string |
|
104 | + */ |
|
105 | + public function json() |
|
106 | + { |
|
107 | + return json_encode($this->all()); |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @return array |
|
112 | - */ |
|
113 | - public function normalize(array $options = []) |
|
114 | - { |
|
115 | - $options = wp_parse_args( |
|
116 | - Arr::flatten($options), |
|
117 | - glsr(DefaultsManager::class)->defaults() |
|
118 | - ); |
|
119 | - array_walk($options, function (&$value) { |
|
120 | - if (!is_string($value)) { |
|
121 | - return; |
|
122 | - } |
|
123 | - $value = wp_kses($value, wp_kses_allowed_html('post')); |
|
124 | - }); |
|
125 | - return Arr::convertFromDotNotation($options); |
|
126 | - } |
|
110 | + /** |
|
111 | + * @return array |
|
112 | + */ |
|
113 | + public function normalize(array $options = []) |
|
114 | + { |
|
115 | + $options = wp_parse_args( |
|
116 | + Arr::flatten($options), |
|
117 | + glsr(DefaultsManager::class)->defaults() |
|
118 | + ); |
|
119 | + array_walk($options, function (&$value) { |
|
120 | + if (!is_string($value)) { |
|
121 | + return; |
|
122 | + } |
|
123 | + $value = wp_kses($value, wp_kses_allowed_html('post')); |
|
124 | + }); |
|
125 | + return Arr::convertFromDotNotation($options); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * @return bool |
|
130 | - */ |
|
131 | - public function isRecaptchaEnabled() |
|
132 | - { |
|
133 | - $integration = $this->get('settings.submissions.recaptcha.integration'); |
|
134 | - return 'all' == $integration || ('guest' == $integration && !is_user_logged_in()); |
|
135 | - } |
|
128 | + /** |
|
129 | + * @return bool |
|
130 | + */ |
|
131 | + public function isRecaptchaEnabled() |
|
132 | + { |
|
133 | + $integration = $this->get('settings.submissions.recaptcha.integration'); |
|
134 | + return 'all' == $integration || ('guest' == $integration && !is_user_logged_in()); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - public function reset() |
|
141 | - { |
|
142 | - $options = $this->getWP(static::databaseKey(), []); |
|
143 | - if (!is_array($options) || empty($options)) { |
|
144 | - delete_option(static::databaseKey()); |
|
145 | - $options = glsr()->defaults ?: []; |
|
146 | - } |
|
147 | - $this->options = $options; |
|
148 | - } |
|
137 | + /** |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + public function reset() |
|
141 | + { |
|
142 | + $options = $this->getWP(static::databaseKey(), []); |
|
143 | + if (!is_array($options) || empty($options)) { |
|
144 | + delete_option(static::databaseKey()); |
|
145 | + $options = glsr()->defaults ?: []; |
|
146 | + } |
|
147 | + $this->options = $options; |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * @param string|array $pathOrOptions |
|
152 | - * @param mixed $value |
|
153 | - * @return bool |
|
154 | - */ |
|
155 | - public function set($pathOrOptions, $value = '') |
|
156 | - { |
|
157 | - if (is_string($pathOrOptions)) { |
|
158 | - $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value); |
|
159 | - } |
|
160 | - if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) { |
|
161 | - $this->reset(); |
|
162 | - } |
|
163 | - return $result; |
|
164 | - } |
|
150 | + /** |
|
151 | + * @param string|array $pathOrOptions |
|
152 | + * @param mixed $value |
|
153 | + * @return bool |
|
154 | + */ |
|
155 | + public function set($pathOrOptions, $value = '') |
|
156 | + { |
|
157 | + if (is_string($pathOrOptions)) { |
|
158 | + $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value); |
|
159 | + } |
|
160 | + if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) { |
|
161 | + $this->reset(); |
|
162 | + } |
|
163 | + return $result; |
|
164 | + } |
|
165 | 165 | } |
@@ -17,19 +17,19 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @return string |
19 | 19 | */ |
20 | - public static function databaseKey($version = null) |
|
20 | + public static function databaseKey( $version = null ) |
|
21 | 21 | { |
22 | - if (1 == $version) { |
|
22 | + if( 1 == $version ) { |
|
23 | 23 | return 'geminilabs_site_reviews_settings'; |
24 | 24 | } |
25 | - if (2 == $version) { |
|
25 | + if( 2 == $version ) { |
|
26 | 26 | return 'geminilabs_site_reviews-v2'; |
27 | 27 | } |
28 | - if (null === $version) { |
|
29 | - $version = explode('.', glsr()->version); |
|
30 | - $version = array_shift($version); |
|
28 | + if( null === $version ) { |
|
29 | + $version = explode( '.', glsr()->version ); |
|
30 | + $version = array_shift( $version ); |
|
31 | 31 | } |
32 | - return Str::snakeCase(Application::ID.'-v'.intval($version)); |
|
32 | + return Str::snakeCase( Application::ID.'-v'.intval( $version ) ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function all() |
39 | 39 | { |
40 | - if (empty($this->options)) { |
|
40 | + if( empty($this->options) ) { |
|
41 | 41 | $this->reset(); |
42 | 42 | } |
43 | 43 | return $this->options; |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | * @param string $path |
48 | 48 | * @return bool |
49 | 49 | */ |
50 | - public function delete($path) |
|
50 | + public function delete( $path ) |
|
51 | 51 | { |
52 | - $keys = explode('.', $path); |
|
53 | - $last = array_pop($keys); |
|
52 | + $keys = explode( '.', $path ); |
|
53 | + $last = array_pop( $keys ); |
|
54 | 54 | $options = $this->all(); |
55 | 55 | $pointer = &$options; |
56 | - foreach ($keys as $key) { |
|
57 | - if (!isset($pointer[$key]) || !is_array($pointer[$key])) { |
|
56 | + foreach( $keys as $key ) { |
|
57 | + if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) ) { |
|
58 | 58 | continue; |
59 | 59 | } |
60 | 60 | $pointer = &$pointer[$key]; |
61 | 61 | } |
62 | 62 | unset($pointer[$last]); |
63 | - return $this->set($options); |
|
63 | + return $this->set( $options ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | * @param string $cast |
70 | 70 | * @return mixed |
71 | 71 | */ |
72 | - public function get($path = '', $fallback = '', $cast = '') |
|
72 | + public function get( $path = '', $fallback = '', $cast = '' ) |
|
73 | 73 | { |
74 | - $result = Arr::get($this->all(), $path, $fallback); |
|
75 | - return Helper::castTo($cast, $result); |
|
74 | + $result = Arr::get( $this->all(), $path, $fallback ); |
|
75 | + return Helper::castTo( $cast, $result ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @param string $path |
80 | 80 | * @return bool |
81 | 81 | */ |
82 | - public function getBool($path) |
|
82 | + public function getBool( $path ) |
|
83 | 83 | { |
84 | - return Helper::castToBool($this->get($path)); |
|
84 | + return Helper::castToBool( $this->get( $path ) ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | * @param string $cast |
91 | 91 | * @return mixed |
92 | 92 | */ |
93 | - public function getWP($path, $fallback = '', $cast = '') |
|
93 | + public function getWP( $path, $fallback = '', $cast = '' ) |
|
94 | 94 | { |
95 | - $option = get_option($path, $fallback); |
|
96 | - if (empty($option)) { |
|
95 | + $option = get_option( $path, $fallback ); |
|
96 | + if( empty($option) ) { |
|
97 | 97 | $option = $fallback; |
98 | 98 | } |
99 | - return Helper::castTo($cast, $option); |
|
99 | + return Helper::castTo( $cast, $option ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,25 +104,25 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function json() |
106 | 106 | { |
107 | - return json_encode($this->all()); |
|
107 | + return json_encode( $this->all() ); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @return array |
112 | 112 | */ |
113 | - public function normalize(array $options = []) |
|
113 | + public function normalize( array $options = [] ) |
|
114 | 114 | { |
115 | 115 | $options = wp_parse_args( |
116 | - Arr::flatten($options), |
|
117 | - glsr(DefaultsManager::class)->defaults() |
|
116 | + Arr::flatten( $options ), |
|
117 | + glsr( DefaultsManager::class )->defaults() |
|
118 | 118 | ); |
119 | - array_walk($options, function (&$value) { |
|
120 | - if (!is_string($value)) { |
|
119 | + array_walk( $options, function( &$value ) { |
|
120 | + if( !is_string( $value ) ) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | - $value = wp_kses($value, wp_kses_allowed_html('post')); |
|
123 | + $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) ); |
|
124 | 124 | }); |
125 | - return Arr::convertFromDotNotation($options); |
|
125 | + return Arr::convertFromDotNotation( $options ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function isRecaptchaEnabled() |
132 | 132 | { |
133 | - $integration = $this->get('settings.submissions.recaptcha.integration'); |
|
133 | + $integration = $this->get( 'settings.submissions.recaptcha.integration' ); |
|
134 | 134 | return 'all' == $integration || ('guest' == $integration && !is_user_logged_in()); |
135 | 135 | } |
136 | 136 | |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function reset() |
141 | 141 | { |
142 | - $options = $this->getWP(static::databaseKey(), []); |
|
143 | - if (!is_array($options) || empty($options)) { |
|
144 | - delete_option(static::databaseKey()); |
|
142 | + $options = $this->getWP( static::databaseKey(), [] ); |
|
143 | + if( !is_array( $options ) || empty($options) ) { |
|
144 | + delete_option( static::databaseKey() ); |
|
145 | 145 | $options = glsr()->defaults ?: []; |
146 | 146 | } |
147 | 147 | $this->options = $options; |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @param mixed $value |
153 | 153 | * @return bool |
154 | 154 | */ |
155 | - public function set($pathOrOptions, $value = '') |
|
155 | + public function set( $pathOrOptions, $value = '' ) |
|
156 | 156 | { |
157 | - if (is_string($pathOrOptions)) { |
|
158 | - $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value); |
|
157 | + if( is_string( $pathOrOptions ) ) { |
|
158 | + $pathOrOptions = Arr::set( $this->all(), $pathOrOptions, $value ); |
|
159 | 159 | } |
160 | - if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) { |
|
160 | + if( $result = update_option( static::databaseKey(), (array)$pathOrOptions ) ) { |
|
161 | 161 | $this->reset(); |
162 | 162 | } |
163 | 163 | return $result; |
@@ -11,83 +11,83 @@ |
||
11 | 11 | */ |
12 | 12 | abstract class Addon |
13 | 13 | { |
14 | - const ID = ''; |
|
15 | - const SLUG = ''; |
|
16 | - const UPDATE_URL = ''; |
|
14 | + const ID = ''; |
|
15 | + const SLUG = ''; |
|
16 | + const UPDATE_URL = ''; |
|
17 | 17 | |
18 | - public $file; |
|
19 | - public $languages; |
|
20 | - public $name; |
|
21 | - public $testedTo; |
|
22 | - public $updater; |
|
23 | - public $version; |
|
18 | + public $file; |
|
19 | + public $languages; |
|
20 | + public $name; |
|
21 | + public $testedTo; |
|
22 | + public $updater; |
|
23 | + public $version; |
|
24 | 24 | |
25 | - public function __construct() |
|
26 | - { |
|
27 | - $this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName()); |
|
28 | - $plugin = get_file_data($this->file, [ |
|
29 | - 'languages' => 'Domain Path', |
|
30 | - 'name' => 'Plugin Name', |
|
31 | - 'testedTo' => 'Tested up to', |
|
32 | - 'version' => 'Version', |
|
33 | - ], 'plugin'); |
|
34 | - array_walk($plugin, function ($value, $key) { |
|
35 | - if (property_exists($this, $key)) { |
|
36 | - $this->$key = $value; |
|
37 | - } |
|
38 | - }); |
|
39 | - } |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + $this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName()); |
|
28 | + $plugin = get_file_data($this->file, [ |
|
29 | + 'languages' => 'Domain Path', |
|
30 | + 'name' => 'Plugin Name', |
|
31 | + 'testedTo' => 'Tested up to', |
|
32 | + 'version' => 'Version', |
|
33 | + ], 'plugin'); |
|
34 | + array_walk($plugin, function ($value, $key) { |
|
35 | + if (property_exists($this, $key)) { |
|
36 | + $this->$key = $value; |
|
37 | + } |
|
38 | + }); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string $property |
|
43 | - * @return void|string |
|
44 | - */ |
|
45 | - public function __get($property) |
|
46 | - { |
|
47 | - if (property_exists($this, $property)) { |
|
48 | - return $this->$property; |
|
49 | - } |
|
50 | - $constant = 'static::'.strtoupper($property); |
|
51 | - if (defined($constant)) { |
|
52 | - return constant($constant); |
|
53 | - } |
|
54 | - } |
|
41 | + /** |
|
42 | + * @param string $property |
|
43 | + * @return void|string |
|
44 | + */ |
|
45 | + public function __get($property) |
|
46 | + { |
|
47 | + if (property_exists($this, $property)) { |
|
48 | + return $this->$property; |
|
49 | + } |
|
50 | + $constant = 'static::'.strtoupper($property); |
|
51 | + if (defined($constant)) { |
|
52 | + return constant($constant); |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | - public function make($class) |
|
57 | - {} |
|
56 | + public function make($class) |
|
57 | + {} |
|
58 | 58 | |
59 | - /** |
|
60 | - * @return void |
|
61 | - */ |
|
62 | - abstract public function init(); |
|
59 | + /** |
|
60 | + * @return void |
|
61 | + */ |
|
62 | + abstract public function init(); |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string $file |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function path($file = '') |
|
69 | - { |
|
70 | - return plugin_dir_path($this->file).ltrim(trim($file), '/'); |
|
71 | - } |
|
64 | + /** |
|
65 | + * @param string $file |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function path($file = '') |
|
69 | + { |
|
70 | + return plugin_dir_path($this->file).ltrim(trim($file), '/'); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return void |
|
75 | - */ |
|
76 | - public function update() |
|
77 | - { |
|
78 | - $this->updater = new Updater(static::UPDATE_URL, $this->file, [ |
|
79 | - 'license' => glsr_get_option('settings.licenses.'.static::ID), |
|
80 | - 'testedTo' => $this->testedTo, |
|
81 | - ]); |
|
82 | - $this->updater->init(); |
|
83 | - } |
|
73 | + /** |
|
74 | + * @return void |
|
75 | + */ |
|
76 | + public function update() |
|
77 | + { |
|
78 | + $this->updater = new Updater(static::UPDATE_URL, $this->file, [ |
|
79 | + 'license' => glsr_get_option('settings.licenses.'.static::ID), |
|
80 | + 'testedTo' => $this->testedTo, |
|
81 | + ]); |
|
82 | + $this->updater->init(); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $path |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function url($path = '') |
|
90 | - { |
|
91 | - return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
92 | - } |
|
85 | + /** |
|
86 | + * @param string $path |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function url($path = '') |
|
90 | + { |
|
91 | + return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
92 | + } |
|
93 | 93 | } |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | |
25 | 25 | public function __construct() |
26 | 26 | { |
27 | - $this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName()); |
|
28 | - $plugin = get_file_data($this->file, [ |
|
27 | + $this->file = str_replace( 'plugin/Application', static::ID, (new ReflectionClass( $this ))->getFileName() ); |
|
28 | + $plugin = get_file_data( $this->file, [ |
|
29 | 29 | 'languages' => 'Domain Path', |
30 | 30 | 'name' => 'Plugin Name', |
31 | 31 | 'testedTo' => 'Tested up to', |
32 | 32 | 'version' => 'Version', |
33 | - ], 'plugin'); |
|
34 | - array_walk($plugin, function ($value, $key) { |
|
35 | - if (property_exists($this, $key)) { |
|
33 | + ], 'plugin' ); |
|
34 | + array_walk( $plugin, function( $value, $key ) { |
|
35 | + if( property_exists( $this, $key ) ) { |
|
36 | 36 | $this->$key = $value; |
37 | 37 | } |
38 | 38 | }); |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | * @param string $property |
43 | 43 | * @return void|string |
44 | 44 | */ |
45 | - public function __get($property) |
|
45 | + public function __get( $property ) |
|
46 | 46 | { |
47 | - if (property_exists($this, $property)) { |
|
47 | + if( property_exists( $this, $property ) ) { |
|
48 | 48 | return $this->$property; |
49 | 49 | } |
50 | - $constant = 'static::'.strtoupper($property); |
|
51 | - if (defined($constant)) { |
|
52 | - return constant($constant); |
|
50 | + $constant = 'static::'.strtoupper( $property ); |
|
51 | + if( defined( $constant ) ) { |
|
52 | + return constant( $constant ); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - public function make($class) |
|
56 | + public function make( $class ) |
|
57 | 57 | {} |
58 | 58 | |
59 | 59 | /** |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @param string $file |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function path($file = '') |
|
68 | + public function path( $file = '' ) |
|
69 | 69 | { |
70 | - return plugin_dir_path($this->file).ltrim(trim($file), '/'); |
|
70 | + return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function update() |
77 | 77 | { |
78 | - $this->updater = new Updater(static::UPDATE_URL, $this->file, [ |
|
79 | - 'license' => glsr_get_option('settings.licenses.'.static::ID), |
|
78 | + $this->updater = new Updater( static::UPDATE_URL, $this->file, [ |
|
79 | + 'license' => glsr_get_option( 'settings.licenses.'.static::ID ), |
|
80 | 80 | 'testedTo' => $this->testedTo, |
81 | - ]); |
|
81 | + ] ); |
|
82 | 82 | $this->updater->init(); |
83 | 83 | } |
84 | 84 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @param string $path |
87 | 87 | * @return string |
88 | 88 | */ |
89 | - public function url($path = '') |
|
89 | + public function url( $path = '' ) |
|
90 | 90 | { |
91 | - return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
91 | + return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
92 | 92 | } |
93 | 93 | } |
@@ -54,7 +54,8 @@ |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function make($class) |
57 | - {} |
|
57 | + { |
|
58 | +} |
|
58 | 59 | |
59 | 60 | /** |
60 | 61 | * @return void |
@@ -12,325 +12,325 @@ |
||
12 | 12 | |
13 | 13 | abstract class Controller extends BaseController |
14 | 14 | { |
15 | - /** |
|
16 | - * @var Addon |
|
17 | - */ |
|
18 | - protected $addon; |
|
15 | + /** |
|
16 | + * @var Addon |
|
17 | + */ |
|
18 | + protected $addon; |
|
19 | 19 | |
20 | - public function __construct() |
|
21 | - { |
|
22 | - $this->setAddon(); |
|
23 | - } |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + $this->setAddon(); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * @return void |
|
27 | - * @action admin_enqueue_scripts |
|
28 | - */ |
|
29 | - public function enqueueAdminAssets() |
|
30 | - { |
|
31 | - if (!$this->isReviewAdminPage()) { |
|
32 | - return; |
|
33 | - } |
|
34 | - $this->enqueueAsset('css', ['suffix' => 'admin']); |
|
35 | - $this->enqueueAsset('js', ['suffix' => 'admin']); |
|
36 | - } |
|
25 | + /** |
|
26 | + * @return void |
|
27 | + * @action admin_enqueue_scripts |
|
28 | + */ |
|
29 | + public function enqueueAdminAssets() |
|
30 | + { |
|
31 | + if (!$this->isReviewAdminPage()) { |
|
32 | + return; |
|
33 | + } |
|
34 | + $this->enqueueAsset('css', ['suffix' => 'admin']); |
|
35 | + $this->enqueueAsset('js', ['suffix' => 'admin']); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return void |
|
40 | - * @action enqueue_block_editor_assets |
|
41 | - */ |
|
42 | - public function enqueueBlockAssets() |
|
43 | - { |
|
44 | - $this->registerAsset('css', ['suffix' => 'blocks']); |
|
45 | - $this->registerAsset('js', ['suffix' => 'blocks']); |
|
46 | - } |
|
38 | + /** |
|
39 | + * @return void |
|
40 | + * @action enqueue_block_editor_assets |
|
41 | + */ |
|
42 | + public function enqueueBlockAssets() |
|
43 | + { |
|
44 | + $this->registerAsset('css', ['suffix' => 'blocks']); |
|
45 | + $this->registerAsset('js', ['suffix' => 'blocks']); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return void |
|
50 | - * @action wp_enqueue_scripts |
|
51 | - */ |
|
52 | - public function enqueuePublicAssets() |
|
53 | - { |
|
54 | - $this->enqueueAsset('css'); |
|
55 | - $this->enqueueAsset('js'); |
|
56 | - } |
|
48 | + /** |
|
49 | + * @return void |
|
50 | + * @action wp_enqueue_scripts |
|
51 | + */ |
|
52 | + public function enqueuePublicAssets() |
|
53 | + { |
|
54 | + $this->enqueueAsset('css'); |
|
55 | + $this->enqueueAsset('js'); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return array |
|
60 | - * @filter plugin_action_links_{addon_id}/{addon_id}.php |
|
61 | - */ |
|
62 | - public function filterActionLinks(array $links) |
|
63 | - { |
|
64 | - $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
65 | - 'href' => admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons'), |
|
66 | - ]); |
|
67 | - return $links; |
|
68 | - } |
|
58 | + /** |
|
59 | + * @return array |
|
60 | + * @filter plugin_action_links_{addon_id}/{addon_id}.php |
|
61 | + */ |
|
62 | + public function filterActionLinks(array $links) |
|
63 | + { |
|
64 | + $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
65 | + 'href' => admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons'), |
|
66 | + ]); |
|
67 | + return $links; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @param string $path |
|
72 | - * @return string |
|
73 | - * @filter site-reviews/config |
|
74 | - */ |
|
75 | - public function filterConfigPath($path) |
|
76 | - { |
|
77 | - $addonPrefix = $this->addon->id.'/'; |
|
78 | - return Str::contains($path, $addonPrefix) |
|
79 | - ? $addonPrefix.str_replace($addonPrefix, '', $path) |
|
80 | - : $path; |
|
81 | - } |
|
70 | + /** |
|
71 | + * @param string $path |
|
72 | + * @return string |
|
73 | + * @filter site-reviews/config |
|
74 | + */ |
|
75 | + public function filterConfigPath($path) |
|
76 | + { |
|
77 | + $addonPrefix = $this->addon->id.'/'; |
|
78 | + return Str::contains($path, $addonPrefix) |
|
79 | + ? $addonPrefix.str_replace($addonPrefix, '', $path) |
|
80 | + : $path; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @return array |
|
85 | - * @filter site-reviews/addon/documentation |
|
86 | - */ |
|
87 | - public function filterDocumentation(array $documentation) |
|
88 | - { |
|
89 | - $documentation[$this->addon->name] = glsr(Template::class)->build($this->addon->id.'/documentation'); |
|
90 | - return $documentation; |
|
91 | - } |
|
83 | + /** |
|
84 | + * @return array |
|
85 | + * @filter site-reviews/addon/documentation |
|
86 | + */ |
|
87 | + public function filterDocumentation(array $documentation) |
|
88 | + { |
|
89 | + $documentation[$this->addon->name] = glsr(Template::class)->build($this->addon->id.'/documentation'); |
|
90 | + return $documentation; |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @param string $path |
|
95 | - * @param string $file |
|
96 | - * @return string |
|
97 | - * @filter site-reviews/path |
|
98 | - */ |
|
99 | - public function filterFilePaths($path, $file) |
|
100 | - { |
|
101 | - $addonPrefix = $this->addon->id.'/'; |
|
102 | - return Str::startsWith($addonPrefix, $file) |
|
103 | - ? $this->addon->path(Str::replaceFirst($addonPrefix, '', $file)) |
|
104 | - : $path; |
|
105 | - } |
|
93 | + /** |
|
94 | + * @param string $path |
|
95 | + * @param string $file |
|
96 | + * @return string |
|
97 | + * @filter site-reviews/path |
|
98 | + */ |
|
99 | + public function filterFilePaths($path, $file) |
|
100 | + { |
|
101 | + $addonPrefix = $this->addon->id.'/'; |
|
102 | + return Str::startsWith($addonPrefix, $file) |
|
103 | + ? $this->addon->path(Str::replaceFirst($addonPrefix, '', $file)) |
|
104 | + : $path; |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @param string $translation |
|
109 | - * @param string $text |
|
110 | - * @return string |
|
111 | - * @filter site-reviews/gettext/{addon_id} |
|
112 | - */ |
|
113 | - public function filterGettext($translation, $text) |
|
114 | - { |
|
115 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
116 | - 'single' => $text, |
|
117 | - ]); |
|
118 | - } |
|
107 | + /** |
|
108 | + * @param string $translation |
|
109 | + * @param string $text |
|
110 | + * @return string |
|
111 | + * @filter site-reviews/gettext/{addon_id} |
|
112 | + */ |
|
113 | + public function filterGettext($translation, $text) |
|
114 | + { |
|
115 | + return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
116 | + 'single' => $text, |
|
117 | + ]); |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * @param string $translation |
|
122 | - * @param string $text |
|
123 | - * @param string $context |
|
124 | - * @return string |
|
125 | - * @filter site-reviews/gettext_with_context/{addon_id} |
|
126 | - */ |
|
127 | - public function filterGettextWithContext($translation, $text, $context) |
|
128 | - { |
|
129 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
130 | - 'context' => $context, |
|
131 | - 'single' => $text, |
|
132 | - ]); |
|
133 | - } |
|
120 | + /** |
|
121 | + * @param string $translation |
|
122 | + * @param string $text |
|
123 | + * @param string $context |
|
124 | + * @return string |
|
125 | + * @filter site-reviews/gettext_with_context/{addon_id} |
|
126 | + */ |
|
127 | + public function filterGettextWithContext($translation, $text, $context) |
|
128 | + { |
|
129 | + return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
130 | + 'context' => $context, |
|
131 | + 'single' => $text, |
|
132 | + ]); |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * @param string $translation |
|
137 | - * @param string $single |
|
138 | - * @param string $plural |
|
139 | - * @param int $number |
|
140 | - * @return string |
|
141 | - * @filter site-reviews/ngettext/{addon_id} |
|
142 | - */ |
|
143 | - public function filterNgettext($translation, $single, $plural, $number) |
|
144 | - { |
|
145 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
146 | - 'number' => $number, |
|
147 | - 'plural' => $plural, |
|
148 | - 'single' => $single, |
|
149 | - ]); |
|
150 | - } |
|
135 | + /** |
|
136 | + * @param string $translation |
|
137 | + * @param string $single |
|
138 | + * @param string $plural |
|
139 | + * @param int $number |
|
140 | + * @return string |
|
141 | + * @filter site-reviews/ngettext/{addon_id} |
|
142 | + */ |
|
143 | + public function filterNgettext($translation, $single, $plural, $number) |
|
144 | + { |
|
145 | + return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
146 | + 'number' => $number, |
|
147 | + 'plural' => $plural, |
|
148 | + 'single' => $single, |
|
149 | + ]); |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * @param string $translation |
|
154 | - * @param string $single |
|
155 | - * @param string $plural |
|
156 | - * @param int $number |
|
157 | - * @param string $context |
|
158 | - * @return string |
|
159 | - * @filter site-reviews/ngettext_with_context/{addon_id} |
|
160 | - */ |
|
161 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
162 | - { |
|
163 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
164 | - 'context' => $context, |
|
165 | - 'number' => $number, |
|
166 | - 'plural' => $plural, |
|
167 | - 'single' => $single, |
|
168 | - ]); |
|
169 | - } |
|
152 | + /** |
|
153 | + * @param string $translation |
|
154 | + * @param string $single |
|
155 | + * @param string $plural |
|
156 | + * @param int $number |
|
157 | + * @param string $context |
|
158 | + * @return string |
|
159 | + * @filter site-reviews/ngettext_with_context/{addon_id} |
|
160 | + */ |
|
161 | + public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
162 | + { |
|
163 | + return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
164 | + 'context' => $context, |
|
165 | + 'number' => $number, |
|
166 | + 'plural' => $plural, |
|
167 | + 'single' => $single, |
|
168 | + ]); |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * @return array |
|
173 | - * @filter site-reviews/addon/settings |
|
174 | - */ |
|
175 | - public function filterSettings(array $settings) |
|
176 | - { |
|
177 | - $settingsFile = $this->addon->path('config/settings.php'); |
|
178 | - if (file_exists($settingsFile)) { |
|
179 | - $settings = array_merge((include $settingsFile), $settings); |
|
180 | - } |
|
181 | - return $settings; |
|
182 | - } |
|
171 | + /** |
|
172 | + * @return array |
|
173 | + * @filter site-reviews/addon/settings |
|
174 | + */ |
|
175 | + public function filterSettings(array $settings) |
|
176 | + { |
|
177 | + $settingsFile = $this->addon->path('config/settings.php'); |
|
178 | + if (file_exists($settingsFile)) { |
|
179 | + $settings = array_merge((include $settingsFile), $settings); |
|
180 | + } |
|
181 | + return $settings; |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * @return array |
|
186 | - * @filter site-reviews/addon/system-info |
|
187 | - */ |
|
188 | - public function filterSystemInfo(array $details) |
|
189 | - { |
|
190 | - $version = $this->addon->version; |
|
191 | - $previousVersion = glsr(OptionManager::class)->get('addons.'.$this->addon->id.'.version_upgraded_from'); |
|
192 | - if (empty($previousVersion)) { |
|
193 | - $previousVersion = $version; |
|
194 | - } |
|
195 | - $details[$this->addon->name] = sprintf('%s (%s)', $this->addon->version, $previousVersion); |
|
196 | - return $details; |
|
197 | - } |
|
184 | + /** |
|
185 | + * @return array |
|
186 | + * @filter site-reviews/addon/system-info |
|
187 | + */ |
|
188 | + public function filterSystemInfo(array $details) |
|
189 | + { |
|
190 | + $version = $this->addon->version; |
|
191 | + $previousVersion = glsr(OptionManager::class)->get('addons.'.$this->addon->id.'.version_upgraded_from'); |
|
192 | + if (empty($previousVersion)) { |
|
193 | + $previousVersion = $version; |
|
194 | + } |
|
195 | + $details[$this->addon->name] = sprintf('%s (%s)', $this->addon->version, $previousVersion); |
|
196 | + return $details; |
|
197 | + } |
|
198 | 198 | |
199 | - /** |
|
200 | - * @return array |
|
201 | - * @filter site-reviews/translation/entries |
|
202 | - */ |
|
203 | - public function filterTranslationEntries(array $entries) |
|
204 | - { |
|
205 | - $potFile = $this->addon->path($this->addon->languages.'/'.$this->addon->id.'.pot'); |
|
206 | - return glsr(Translation::class)->extractEntriesFromPotFile($potFile, $entries); |
|
207 | - } |
|
199 | + /** |
|
200 | + * @return array |
|
201 | + * @filter site-reviews/translation/entries |
|
202 | + */ |
|
203 | + public function filterTranslationEntries(array $entries) |
|
204 | + { |
|
205 | + $potFile = $this->addon->path($this->addon->languages.'/'.$this->addon->id.'.pot'); |
|
206 | + return glsr(Translation::class)->extractEntriesFromPotFile($potFile, $entries); |
|
207 | + } |
|
208 | 208 | |
209 | - /** |
|
210 | - * @return array |
|
211 | - * @filter site-reviews/translator/domains |
|
212 | - */ |
|
213 | - public function filterTranslatorDomains(array $domains) |
|
214 | - { |
|
215 | - $domains[] = $this->addon->id; |
|
216 | - return $domains; |
|
217 | - } |
|
209 | + /** |
|
210 | + * @return array |
|
211 | + * @filter site-reviews/translator/domains |
|
212 | + */ |
|
213 | + public function filterTranslatorDomains(array $domains) |
|
214 | + { |
|
215 | + $domains[] = $this->addon->id; |
|
216 | + return $domains; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * @return void |
|
221 | - * @action init |
|
222 | - */ |
|
223 | - public function registerBlocks() |
|
224 | - { |
|
225 | - } |
|
219 | + /** |
|
220 | + * @return void |
|
221 | + * @action init |
|
222 | + */ |
|
223 | + public function registerBlocks() |
|
224 | + { |
|
225 | + } |
|
226 | 226 | |
227 | - /** |
|
228 | - * @return void |
|
229 | - * @action plugins_loaded |
|
230 | - */ |
|
231 | - public function registerLanguages() |
|
232 | - { |
|
233 | - load_plugin_textdomain($this->addon->id, false, |
|
234 | - trailingslashit(plugin_basename($this->addon->path()).'/'.$this->addon->languages) |
|
235 | - ); |
|
236 | - } |
|
227 | + /** |
|
228 | + * @return void |
|
229 | + * @action plugins_loaded |
|
230 | + */ |
|
231 | + public function registerLanguages() |
|
232 | + { |
|
233 | + load_plugin_textdomain($this->addon->id, false, |
|
234 | + trailingslashit(plugin_basename($this->addon->path()).'/'.$this->addon->languages) |
|
235 | + ); |
|
236 | + } |
|
237 | 237 | |
238 | - /** |
|
239 | - * @return void |
|
240 | - * @action init |
|
241 | - */ |
|
242 | - public function registerShortcodes() |
|
243 | - { |
|
244 | - } |
|
238 | + /** |
|
239 | + * @return void |
|
240 | + * @action init |
|
241 | + */ |
|
242 | + public function registerShortcodes() |
|
243 | + { |
|
244 | + } |
|
245 | 245 | |
246 | - /** |
|
247 | - * @return void |
|
248 | - * @action admin_init |
|
249 | - */ |
|
250 | - public function registerTinymcePopups() |
|
251 | - { |
|
252 | - } |
|
246 | + /** |
|
247 | + * @return void |
|
248 | + * @action admin_init |
|
249 | + */ |
|
250 | + public function registerTinymcePopups() |
|
251 | + { |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * @return void |
|
256 | - * @action widgets_init |
|
257 | - */ |
|
258 | - public function registerWidgets() |
|
259 | - { |
|
260 | - } |
|
254 | + /** |
|
255 | + * @return void |
|
256 | + * @action widgets_init |
|
257 | + */ |
|
258 | + public function registerWidgets() |
|
259 | + { |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * @param string $rows |
|
264 | - * @return void |
|
265 | - * @action site-reviews/addon/settings/{addon_slug} |
|
266 | - */ |
|
267 | - public function renderSettings($rows) |
|
268 | - { |
|
269 | - glsr(Template::class)->render($this->addon->id.'/views/settings', [ |
|
270 | - 'context' => [ |
|
271 | - 'rows' => $rows, |
|
272 | - 'title' => $this->addon->name, |
|
273 | - ], |
|
274 | - ]); |
|
275 | - } |
|
262 | + /** |
|
263 | + * @param string $rows |
|
264 | + * @return void |
|
265 | + * @action site-reviews/addon/settings/{addon_slug} |
|
266 | + */ |
|
267 | + public function renderSettings($rows) |
|
268 | + { |
|
269 | + glsr(Template::class)->render($this->addon->id.'/views/settings', [ |
|
270 | + 'context' => [ |
|
271 | + 'rows' => $rows, |
|
272 | + 'title' => $this->addon->name, |
|
273 | + ], |
|
274 | + ]); |
|
275 | + } |
|
276 | 276 | |
277 | - /** |
|
278 | - * @param string $extension |
|
279 | - * @return array |
|
280 | - */ |
|
281 | - protected function buildAssetArgs($extension, array $args = []) |
|
282 | - { |
|
283 | - $args = wp_parse_args($args, [ |
|
284 | - 'dependencies' => [], |
|
285 | - 'in_footer' => true, |
|
286 | - 'suffix' => '', |
|
287 | - ]); |
|
288 | - $path = 'assets/'.$this->addon->id.Str::prefix('-', $args['suffix']).'.'.$extension; |
|
289 | - if (!file_exists($this->addon->path($path)) || !in_array($extension, ['css', 'js'])) { |
|
290 | - return []; |
|
291 | - } |
|
292 | - $funcArgs = [ |
|
293 | - $this->addon->id.Str::prefix('/', $args['suffix']), |
|
294 | - $this->addon->url($path), |
|
295 | - array_merge([glsr()->id.Str::prefix('/', $args['suffix'])], $args['dependencies']), |
|
296 | - $this->addon->version, |
|
297 | - ]; |
|
298 | - if ('js' === $extension && $args['in_footer']) { |
|
299 | - $funcArgs[] = true; // load script in the footer |
|
300 | - } |
|
301 | - return $funcArgs; |
|
302 | - } |
|
277 | + /** |
|
278 | + * @param string $extension |
|
279 | + * @return array |
|
280 | + */ |
|
281 | + protected function buildAssetArgs($extension, array $args = []) |
|
282 | + { |
|
283 | + $args = wp_parse_args($args, [ |
|
284 | + 'dependencies' => [], |
|
285 | + 'in_footer' => true, |
|
286 | + 'suffix' => '', |
|
287 | + ]); |
|
288 | + $path = 'assets/'.$this->addon->id.Str::prefix('-', $args['suffix']).'.'.$extension; |
|
289 | + if (!file_exists($this->addon->path($path)) || !in_array($extension, ['css', 'js'])) { |
|
290 | + return []; |
|
291 | + } |
|
292 | + $funcArgs = [ |
|
293 | + $this->addon->id.Str::prefix('/', $args['suffix']), |
|
294 | + $this->addon->url($path), |
|
295 | + array_merge([glsr()->id.Str::prefix('/', $args['suffix'])], $args['dependencies']), |
|
296 | + $this->addon->version, |
|
297 | + ]; |
|
298 | + if ('js' === $extension && $args['in_footer']) { |
|
299 | + $funcArgs[] = true; // load script in the footer |
|
300 | + } |
|
301 | + return $funcArgs; |
|
302 | + } |
|
303 | 303 | |
304 | - /** |
|
305 | - * @param string $extension |
|
306 | - * @return void |
|
307 | - */ |
|
308 | - protected function enqueueAsset($extension, array $args = []) |
|
309 | - { |
|
310 | - if ($args = $this->buildAssetArgs($extension, $args)) { |
|
311 | - $function = 'js' === $extension |
|
312 | - ? 'wp_enqueue_script' |
|
313 | - : 'wp_enqueue_style'; |
|
314 | - call_user_func_array($function, $args); |
|
315 | - } |
|
316 | - } |
|
304 | + /** |
|
305 | + * @param string $extension |
|
306 | + * @return void |
|
307 | + */ |
|
308 | + protected function enqueueAsset($extension, array $args = []) |
|
309 | + { |
|
310 | + if ($args = $this->buildAssetArgs($extension, $args)) { |
|
311 | + $function = 'js' === $extension |
|
312 | + ? 'wp_enqueue_script' |
|
313 | + : 'wp_enqueue_style'; |
|
314 | + call_user_func_array($function, $args); |
|
315 | + } |
|
316 | + } |
|
317 | 317 | |
318 | - /** |
|
319 | - * @param string $extension |
|
320 | - * @return void |
|
321 | - */ |
|
322 | - protected function registerAsset($extension, array $args = []) |
|
323 | - { |
|
324 | - if ($args = $this->buildAssetArgs($extension, $args)) { |
|
325 | - $function = 'js' === $extension |
|
326 | - ? 'wp_register_script' |
|
327 | - : 'wp_register_style'; |
|
328 | - call_user_func_array($function, $args); |
|
329 | - } |
|
330 | - } |
|
318 | + /** |
|
319 | + * @param string $extension |
|
320 | + * @return void |
|
321 | + */ |
|
322 | + protected function registerAsset($extension, array $args = []) |
|
323 | + { |
|
324 | + if ($args = $this->buildAssetArgs($extension, $args)) { |
|
325 | + $function = 'js' === $extension |
|
326 | + ? 'wp_register_script' |
|
327 | + : 'wp_register_style'; |
|
328 | + call_user_func_array($function, $args); |
|
329 | + } |
|
330 | + } |
|
331 | 331 | |
332 | - /** |
|
333 | - * @return void |
|
334 | - */ |
|
335 | - abstract protected function setAddon(); |
|
332 | + /** |
|
333 | + * @return void |
|
334 | + */ |
|
335 | + abstract protected function setAddon(); |
|
336 | 336 | } |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function enqueueAdminAssets() |
30 | 30 | { |
31 | - if (!$this->isReviewAdminPage()) { |
|
31 | + if( !$this->isReviewAdminPage() ) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | - $this->enqueueAsset('css', ['suffix' => 'admin']); |
|
35 | - $this->enqueueAsset('js', ['suffix' => 'admin']); |
|
34 | + $this->enqueueAsset( 'css', ['suffix' => 'admin'] ); |
|
35 | + $this->enqueueAsset( 'js', ['suffix' => 'admin'] ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function enqueueBlockAssets() |
43 | 43 | { |
44 | - $this->registerAsset('css', ['suffix' => 'blocks']); |
|
45 | - $this->registerAsset('js', ['suffix' => 'blocks']); |
|
44 | + $this->registerAsset( 'css', ['suffix' => 'blocks'] ); |
|
45 | + $this->registerAsset( 'js', ['suffix' => 'blocks'] ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -51,19 +51,19 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function enqueuePublicAssets() |
53 | 53 | { |
54 | - $this->enqueueAsset('css'); |
|
55 | - $this->enqueueAsset('js'); |
|
54 | + $this->enqueueAsset( 'css' ); |
|
55 | + $this->enqueueAsset( 'js' ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @return array |
60 | 60 | * @filter plugin_action_links_{addon_id}/{addon_id}.php |
61 | 61 | */ |
62 | - public function filterActionLinks(array $links) |
|
62 | + public function filterActionLinks( array $links ) |
|
63 | 63 | { |
64 | - $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
65 | - 'href' => admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons'), |
|
66 | - ]); |
|
64 | + $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
|
65 | + 'href' => admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons' ), |
|
66 | + ] ); |
|
67 | 67 | return $links; |
68 | 68 | } |
69 | 69 | |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | * @return string |
73 | 73 | * @filter site-reviews/config |
74 | 74 | */ |
75 | - public function filterConfigPath($path) |
|
75 | + public function filterConfigPath( $path ) |
|
76 | 76 | { |
77 | 77 | $addonPrefix = $this->addon->id.'/'; |
78 | - return Str::contains($path, $addonPrefix) |
|
79 | - ? $addonPrefix.str_replace($addonPrefix, '', $path) |
|
78 | + return Str::contains( $path, $addonPrefix ) |
|
79 | + ? $addonPrefix.str_replace( $addonPrefix, '', $path ) |
|
80 | 80 | : $path; |
81 | 81 | } |
82 | 82 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @return array |
85 | 85 | * @filter site-reviews/addon/documentation |
86 | 86 | */ |
87 | - public function filterDocumentation(array $documentation) |
|
87 | + public function filterDocumentation( array $documentation ) |
|
88 | 88 | { |
89 | - $documentation[$this->addon->name] = glsr(Template::class)->build($this->addon->id.'/documentation'); |
|
89 | + $documentation[$this->addon->name] = glsr( Template::class )->build( $this->addon->id.'/documentation' ); |
|
90 | 90 | return $documentation; |
91 | 91 | } |
92 | 92 | |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * @return string |
97 | 97 | * @filter site-reviews/path |
98 | 98 | */ |
99 | - public function filterFilePaths($path, $file) |
|
99 | + public function filterFilePaths( $path, $file ) |
|
100 | 100 | { |
101 | 101 | $addonPrefix = $this->addon->id.'/'; |
102 | - return Str::startsWith($addonPrefix, $file) |
|
103 | - ? $this->addon->path(Str::replaceFirst($addonPrefix, '', $file)) |
|
102 | + return Str::startsWith( $addonPrefix, $file ) |
|
103 | + ? $this->addon->path( Str::replaceFirst( $addonPrefix, '', $file ) ) |
|
104 | 104 | : $path; |
105 | 105 | } |
106 | 106 | |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | * @return string |
111 | 111 | * @filter site-reviews/gettext/{addon_id} |
112 | 112 | */ |
113 | - public function filterGettext($translation, $text) |
|
113 | + public function filterGettext( $translation, $text ) |
|
114 | 114 | { |
115 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
115 | + return glsr( Translator::class )->translate( $translation, $this->addon->id, [ |
|
116 | 116 | 'single' => $text, |
117 | - ]); |
|
117 | + ] ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | * @return string |
125 | 125 | * @filter site-reviews/gettext_with_context/{addon_id} |
126 | 126 | */ |
127 | - public function filterGettextWithContext($translation, $text, $context) |
|
127 | + public function filterGettextWithContext( $translation, $text, $context ) |
|
128 | 128 | { |
129 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
129 | + return glsr( Translator::class )->translate( $translation, $this->addon->id, [ |
|
130 | 130 | 'context' => $context, |
131 | 131 | 'single' => $text, |
132 | - ]); |
|
132 | + ] ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | * @return string |
141 | 141 | * @filter site-reviews/ngettext/{addon_id} |
142 | 142 | */ |
143 | - public function filterNgettext($translation, $single, $plural, $number) |
|
143 | + public function filterNgettext( $translation, $single, $plural, $number ) |
|
144 | 144 | { |
145 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
145 | + return glsr( Translator::class )->translate( $translation, $this->addon->id, [ |
|
146 | 146 | 'number' => $number, |
147 | 147 | 'plural' => $plural, |
148 | 148 | 'single' => $single, |
149 | - ]); |
|
149 | + ] ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -158,25 +158,25 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | * @filter site-reviews/ngettext_with_context/{addon_id} |
160 | 160 | */ |
161 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
161 | + public function filterNgettextWithContextSiteReviews( $translation, $single, $plural, $number, $context ) |
|
162 | 162 | { |
163 | - return glsr(Translator::class)->translate($translation, $this->addon->id, [ |
|
163 | + return glsr( Translator::class )->translate( $translation, $this->addon->id, [ |
|
164 | 164 | 'context' => $context, |
165 | 165 | 'number' => $number, |
166 | 166 | 'plural' => $plural, |
167 | 167 | 'single' => $single, |
168 | - ]); |
|
168 | + ] ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | 172 | * @return array |
173 | 173 | * @filter site-reviews/addon/settings |
174 | 174 | */ |
175 | - public function filterSettings(array $settings) |
|
175 | + public function filterSettings( array $settings ) |
|
176 | 176 | { |
177 | - $settingsFile = $this->addon->path('config/settings.php'); |
|
178 | - if (file_exists($settingsFile)) { |
|
179 | - $settings = array_merge((include $settingsFile), $settings); |
|
177 | + $settingsFile = $this->addon->path( 'config/settings.php' ); |
|
178 | + if( file_exists( $settingsFile ) ) { |
|
179 | + $settings = array_merge( (include $settingsFile), $settings ); |
|
180 | 180 | } |
181 | 181 | return $settings; |
182 | 182 | } |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | * @return array |
186 | 186 | * @filter site-reviews/addon/system-info |
187 | 187 | */ |
188 | - public function filterSystemInfo(array $details) |
|
188 | + public function filterSystemInfo( array $details ) |
|
189 | 189 | { |
190 | 190 | $version = $this->addon->version; |
191 | - $previousVersion = glsr(OptionManager::class)->get('addons.'.$this->addon->id.'.version_upgraded_from'); |
|
192 | - if (empty($previousVersion)) { |
|
191 | + $previousVersion = glsr( OptionManager::class )->get( 'addons.'.$this->addon->id.'.version_upgraded_from' ); |
|
192 | + if( empty($previousVersion) ) { |
|
193 | 193 | $previousVersion = $version; |
194 | 194 | } |
195 | - $details[$this->addon->name] = sprintf('%s (%s)', $this->addon->version, $previousVersion); |
|
195 | + $details[$this->addon->name] = sprintf( '%s (%s)', $this->addon->version, $previousVersion ); |
|
196 | 196 | return $details; |
197 | 197 | } |
198 | 198 | |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | * @return array |
201 | 201 | * @filter site-reviews/translation/entries |
202 | 202 | */ |
203 | - public function filterTranslationEntries(array $entries) |
|
203 | + public function filterTranslationEntries( array $entries ) |
|
204 | 204 | { |
205 | - $potFile = $this->addon->path($this->addon->languages.'/'.$this->addon->id.'.pot'); |
|
206 | - return glsr(Translation::class)->extractEntriesFromPotFile($potFile, $entries); |
|
205 | + $potFile = $this->addon->path( $this->addon->languages.'/'.$this->addon->id.'.pot' ); |
|
206 | + return glsr( Translation::class )->extractEntriesFromPotFile( $potFile, $entries ); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | 210 | * @return array |
211 | 211 | * @filter site-reviews/translator/domains |
212 | 212 | */ |
213 | - public function filterTranslatorDomains(array $domains) |
|
213 | + public function filterTranslatorDomains( array $domains ) |
|
214 | 214 | { |
215 | 215 | $domains[] = $this->addon->id; |
216 | 216 | return $domains; |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function registerLanguages() |
232 | 232 | { |
233 | - load_plugin_textdomain($this->addon->id, false, |
|
234 | - trailingslashit(plugin_basename($this->addon->path()).'/'.$this->addon->languages) |
|
233 | + load_plugin_textdomain( $this->addon->id, false, |
|
234 | + trailingslashit( plugin_basename( $this->addon->path() ).'/'.$this->addon->languages ) |
|
235 | 235 | ); |
236 | 236 | } |
237 | 237 | |
@@ -264,38 +264,38 @@ discard block |
||
264 | 264 | * @return void |
265 | 265 | * @action site-reviews/addon/settings/{addon_slug} |
266 | 266 | */ |
267 | - public function renderSettings($rows) |
|
267 | + public function renderSettings( $rows ) |
|
268 | 268 | { |
269 | - glsr(Template::class)->render($this->addon->id.'/views/settings', [ |
|
269 | + glsr( Template::class )->render( $this->addon->id.'/views/settings', [ |
|
270 | 270 | 'context' => [ |
271 | 271 | 'rows' => $rows, |
272 | 272 | 'title' => $this->addon->name, |
273 | 273 | ], |
274 | - ]); |
|
274 | + ] ); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
278 | 278 | * @param string $extension |
279 | 279 | * @return array |
280 | 280 | */ |
281 | - protected function buildAssetArgs($extension, array $args = []) |
|
281 | + protected function buildAssetArgs( $extension, array $args = [] ) |
|
282 | 282 | { |
283 | - $args = wp_parse_args($args, [ |
|
283 | + $args = wp_parse_args( $args, [ |
|
284 | 284 | 'dependencies' => [], |
285 | 285 | 'in_footer' => true, |
286 | 286 | 'suffix' => '', |
287 | - ]); |
|
288 | - $path = 'assets/'.$this->addon->id.Str::prefix('-', $args['suffix']).'.'.$extension; |
|
289 | - if (!file_exists($this->addon->path($path)) || !in_array($extension, ['css', 'js'])) { |
|
287 | + ] ); |
|
288 | + $path = 'assets/'.$this->addon->id.Str::prefix( '-', $args['suffix'] ).'.'.$extension; |
|
289 | + if( !file_exists( $this->addon->path( $path ) ) || !in_array( $extension, ['css', 'js'] ) ) { |
|
290 | 290 | return []; |
291 | 291 | } |
292 | 292 | $funcArgs = [ |
293 | - $this->addon->id.Str::prefix('/', $args['suffix']), |
|
294 | - $this->addon->url($path), |
|
295 | - array_merge([glsr()->id.Str::prefix('/', $args['suffix'])], $args['dependencies']), |
|
293 | + $this->addon->id.Str::prefix( '/', $args['suffix'] ), |
|
294 | + $this->addon->url( $path ), |
|
295 | + array_merge( [glsr()->id.Str::prefix( '/', $args['suffix'] )], $args['dependencies'] ), |
|
296 | 296 | $this->addon->version, |
297 | 297 | ]; |
298 | - if ('js' === $extension && $args['in_footer']) { |
|
298 | + if( 'js' === $extension && $args['in_footer'] ) { |
|
299 | 299 | $funcArgs[] = true; // load script in the footer |
300 | 300 | } |
301 | 301 | return $funcArgs; |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | * @param string $extension |
306 | 306 | * @return void |
307 | 307 | */ |
308 | - protected function enqueueAsset($extension, array $args = []) |
|
308 | + protected function enqueueAsset( $extension, array $args = [] ) |
|
309 | 309 | { |
310 | - if ($args = $this->buildAssetArgs($extension, $args)) { |
|
310 | + if( $args = $this->buildAssetArgs( $extension, $args ) ) { |
|
311 | 311 | $function = 'js' === $extension |
312 | 312 | ? 'wp_enqueue_script' |
313 | 313 | : 'wp_enqueue_style'; |
314 | - call_user_func_array($function, $args); |
|
314 | + call_user_func_array( $function, $args ); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | * @param string $extension |
320 | 320 | * @return void |
321 | 321 | */ |
322 | - protected function registerAsset($extension, array $args = []) |
|
322 | + protected function registerAsset( $extension, array $args = [] ) |
|
323 | 323 | { |
324 | - if ($args = $this->buildAssetArgs($extension, $args)) { |
|
324 | + if( $args = $this->buildAssetArgs( $extension, $args ) ) { |
|
325 | 325 | $function = 'js' === $extension |
326 | 326 | ? 'wp_register_script' |
327 | 327 | : 'wp_register_style'; |
328 | - call_user_func_array($function, $args); |
|
328 | + call_user_func_array( $function, $args ); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 |
@@ -4,36 +4,36 @@ |
||
4 | 4 | |
5 | 5 | abstract class Hooks |
6 | 6 | { |
7 | - protected $addon; |
|
8 | - protected $basename; |
|
9 | - protected $controller; |
|
7 | + protected $addon; |
|
8 | + protected $basename; |
|
9 | + protected $controller; |
|
10 | 10 | |
11 | - /** |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - add_action('init', [$this->addon, 'update']); |
|
17 | - add_action('admin_enqueue_scripts', [$this->controller, 'enqueueAdminAssets']); |
|
18 | - add_action('enqueue_block_editor_assets', [$this->controller, 'enqueueBlockAssets']); |
|
19 | - add_action('wp_enqueue_scripts', [$this->controller, 'enqueuePublicAssets']); |
|
20 | - add_filter('plugin_action_links_'.$this->basename, [$this->controller, 'filterActionLinks']); |
|
21 | - add_filter('site-reviews/config', [$this->controller, 'filterConfigPath']); |
|
22 | - add_filter('site-reviews/addon/documentation', [$this->controller, 'filterDocumentation']); |
|
23 | - add_filter('site-reviews/gettext/site-reviews-images', [$this->controller, 'filterGettext'], 10, 2); |
|
24 | - add_filter('site-reviews/gettext_with_context/site-reviews-images', [$this->controller, 'filterGettextWithContext'], 10, 3); |
|
25 | - add_filter('site-reviews/ngettext/site-reviews-images', [$this->controller, 'filterNgettext'], 10, 4); |
|
26 | - add_filter('site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5); |
|
27 | - add_filter('site-reviews/path', [$this->controller, 'filterFilePaths'], 10, 2); |
|
28 | - add_filter('site-reviews/addon/settings', [$this->controller, 'filterSettings']); |
|
29 | - add_filter('site-reviews/addon/system-info', [$this->controller, 'filterSystemInfo']); |
|
30 | - add_filter('site-reviews/translation/entries', [$this->controller, 'filterTranslationEntries']); |
|
31 | - add_filter('site-reviews/translator/domains', [$this->controller, 'filterTranslatorDomains']); |
|
32 | - add_action('init', [$this->controller, 'registerBlocks']); |
|
33 | - add_action('plugins_loaded', [$this->controller, 'registerLanguages']); |
|
34 | - add_action('init', [$this->controller, 'registerShortcodes']); |
|
35 | - add_action('init', [$this->controller, 'registerTinymcePopups']); |
|
36 | - add_action('widgets_init', [$this->controller, 'registerWidgets']); |
|
37 | - add_action('site-reviews/addon/settings/'.$this->addon->slug, [$this->controller, 'renderSettings']); |
|
38 | - } |
|
11 | + /** |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + add_action('init', [$this->addon, 'update']); |
|
17 | + add_action('admin_enqueue_scripts', [$this->controller, 'enqueueAdminAssets']); |
|
18 | + add_action('enqueue_block_editor_assets', [$this->controller, 'enqueueBlockAssets']); |
|
19 | + add_action('wp_enqueue_scripts', [$this->controller, 'enqueuePublicAssets']); |
|
20 | + add_filter('plugin_action_links_'.$this->basename, [$this->controller, 'filterActionLinks']); |
|
21 | + add_filter('site-reviews/config', [$this->controller, 'filterConfigPath']); |
|
22 | + add_filter('site-reviews/addon/documentation', [$this->controller, 'filterDocumentation']); |
|
23 | + add_filter('site-reviews/gettext/site-reviews-images', [$this->controller, 'filterGettext'], 10, 2); |
|
24 | + add_filter('site-reviews/gettext_with_context/site-reviews-images', [$this->controller, 'filterGettextWithContext'], 10, 3); |
|
25 | + add_filter('site-reviews/ngettext/site-reviews-images', [$this->controller, 'filterNgettext'], 10, 4); |
|
26 | + add_filter('site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5); |
|
27 | + add_filter('site-reviews/path', [$this->controller, 'filterFilePaths'], 10, 2); |
|
28 | + add_filter('site-reviews/addon/settings', [$this->controller, 'filterSettings']); |
|
29 | + add_filter('site-reviews/addon/system-info', [$this->controller, 'filterSystemInfo']); |
|
30 | + add_filter('site-reviews/translation/entries', [$this->controller, 'filterTranslationEntries']); |
|
31 | + add_filter('site-reviews/translator/domains', [$this->controller, 'filterTranslatorDomains']); |
|
32 | + add_action('init', [$this->controller, 'registerBlocks']); |
|
33 | + add_action('plugins_loaded', [$this->controller, 'registerLanguages']); |
|
34 | + add_action('init', [$this->controller, 'registerShortcodes']); |
|
35 | + add_action('init', [$this->controller, 'registerTinymcePopups']); |
|
36 | + add_action('widgets_init', [$this->controller, 'registerWidgets']); |
|
37 | + add_action('site-reviews/addon/settings/'.$this->addon->slug, [$this->controller, 'renderSettings']); |
|
38 | + } |
|
39 | 39 | } |
@@ -13,27 +13,27 @@ |
||
13 | 13 | */ |
14 | 14 | public function run() |
15 | 15 | { |
16 | - add_action('init', [$this->addon, 'update']); |
|
17 | - add_action('admin_enqueue_scripts', [$this->controller, 'enqueueAdminAssets']); |
|
18 | - add_action('enqueue_block_editor_assets', [$this->controller, 'enqueueBlockAssets']); |
|
19 | - add_action('wp_enqueue_scripts', [$this->controller, 'enqueuePublicAssets']); |
|
20 | - add_filter('plugin_action_links_'.$this->basename, [$this->controller, 'filterActionLinks']); |
|
21 | - add_filter('site-reviews/config', [$this->controller, 'filterConfigPath']); |
|
22 | - add_filter('site-reviews/addon/documentation', [$this->controller, 'filterDocumentation']); |
|
23 | - add_filter('site-reviews/gettext/site-reviews-images', [$this->controller, 'filterGettext'], 10, 2); |
|
24 | - add_filter('site-reviews/gettext_with_context/site-reviews-images', [$this->controller, 'filterGettextWithContext'], 10, 3); |
|
25 | - add_filter('site-reviews/ngettext/site-reviews-images', [$this->controller, 'filterNgettext'], 10, 4); |
|
26 | - add_filter('site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5); |
|
27 | - add_filter('site-reviews/path', [$this->controller, 'filterFilePaths'], 10, 2); |
|
28 | - add_filter('site-reviews/addon/settings', [$this->controller, 'filterSettings']); |
|
29 | - add_filter('site-reviews/addon/system-info', [$this->controller, 'filterSystemInfo']); |
|
30 | - add_filter('site-reviews/translation/entries', [$this->controller, 'filterTranslationEntries']); |
|
31 | - add_filter('site-reviews/translator/domains', [$this->controller, 'filterTranslatorDomains']); |
|
32 | - add_action('init', [$this->controller, 'registerBlocks']); |
|
33 | - add_action('plugins_loaded', [$this->controller, 'registerLanguages']); |
|
34 | - add_action('init', [$this->controller, 'registerShortcodes']); |
|
35 | - add_action('init', [$this->controller, 'registerTinymcePopups']); |
|
36 | - add_action('widgets_init', [$this->controller, 'registerWidgets']); |
|
37 | - add_action('site-reviews/addon/settings/'.$this->addon->slug, [$this->controller, 'renderSettings']); |
|
16 | + add_action( 'init', [$this->addon, 'update'] ); |
|
17 | + add_action( 'admin_enqueue_scripts', [$this->controller, 'enqueueAdminAssets'] ); |
|
18 | + add_action( 'enqueue_block_editor_assets', [$this->controller, 'enqueueBlockAssets'] ); |
|
19 | + add_action( 'wp_enqueue_scripts', [$this->controller, 'enqueuePublicAssets'] ); |
|
20 | + add_filter( 'plugin_action_links_'.$this->basename, [$this->controller, 'filterActionLinks'] ); |
|
21 | + add_filter( 'site-reviews/config', [$this->controller, 'filterConfigPath'] ); |
|
22 | + add_filter( 'site-reviews/addon/documentation', [$this->controller, 'filterDocumentation'] ); |
|
23 | + add_filter( 'site-reviews/gettext/site-reviews-images', [$this->controller, 'filterGettext'], 10, 2 ); |
|
24 | + add_filter( 'site-reviews/gettext_with_context/site-reviews-images', [$this->controller, 'filterGettextWithContext'], 10, 3 ); |
|
25 | + add_filter( 'site-reviews/ngettext/site-reviews-images', [$this->controller, 'filterNgettext'], 10, 4 ); |
|
26 | + add_filter( 'site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5 ); |
|
27 | + add_filter( 'site-reviews/path', [$this->controller, 'filterFilePaths'], 10, 2 ); |
|
28 | + add_filter( 'site-reviews/addon/settings', [$this->controller, 'filterSettings'] ); |
|
29 | + add_filter( 'site-reviews/addon/system-info', [$this->controller, 'filterSystemInfo'] ); |
|
30 | + add_filter( 'site-reviews/translation/entries', [$this->controller, 'filterTranslationEntries'] ); |
|
31 | + add_filter( 'site-reviews/translator/domains', [$this->controller, 'filterTranslatorDomains'] ); |
|
32 | + add_action( 'init', [$this->controller, 'registerBlocks'] ); |
|
33 | + add_action( 'plugins_loaded', [$this->controller, 'registerLanguages'] ); |
|
34 | + add_action( 'init', [$this->controller, 'registerShortcodes'] ); |
|
35 | + add_action( 'init', [$this->controller, 'registerTinymcePopups'] ); |
|
36 | + add_action( 'widgets_init', [$this->controller, 'registerWidgets'] ); |
|
37 | + add_action( 'site-reviews/addon/settings/'.$this->addon->slug, [$this->controller, 'renderSettings'] ); |
|
38 | 38 | } |
39 | 39 | } |
@@ -8,266 +8,266 @@ |
||
8 | 8 | |
9 | 9 | class Updater |
10 | 10 | { |
11 | - /** |
|
12 | - * @var string |
|
13 | - */ |
|
14 | - protected $apiUrl; |
|
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - protected $data; |
|
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $plugin; |
|
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $transientName; |
|
11 | + /** |
|
12 | + * @var string |
|
13 | + */ |
|
14 | + protected $apiUrl; |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + protected $data; |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $plugin; |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $transientName; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @param string $apiUrl |
|
30 | - * @param string $file |
|
31 | - */ |
|
32 | - public function __construct($apiUrl, $file, array $data = []) |
|
33 | - { |
|
34 | - if (!function_exists('get_plugin_data')) { |
|
35 | - require_once ABSPATH.WPINC.'/plugin.php'; |
|
36 | - } |
|
37 | - $this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl)); |
|
38 | - $this->data = wp_parse_args($data, get_plugin_data($file)); |
|
39 | - $this->plugin = plugin_basename($file); |
|
40 | - $this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain')); |
|
41 | - } |
|
28 | + /** |
|
29 | + * @param string $apiUrl |
|
30 | + * @param string $file |
|
31 | + */ |
|
32 | + public function __construct($apiUrl, $file, array $data = []) |
|
33 | + { |
|
34 | + if (!function_exists('get_plugin_data')) { |
|
35 | + require_once ABSPATH.WPINC.'/plugin.php'; |
|
36 | + } |
|
37 | + $this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl)); |
|
38 | + $this->data = wp_parse_args($data, get_plugin_data($file)); |
|
39 | + $this->plugin = plugin_basename($file); |
|
40 | + $this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain')); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return object |
|
45 | - */ |
|
46 | - public function activateLicense(array $data = []) |
|
47 | - { |
|
48 | - return $this->request('activate_license', $data); |
|
49 | - } |
|
43 | + /** |
|
44 | + * @return object |
|
45 | + */ |
|
46 | + public function activateLicense(array $data = []) |
|
47 | + { |
|
48 | + return $this->request('activate_license', $data); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return object |
|
53 | - */ |
|
54 | - public function checkLicense(array $data = []) |
|
55 | - { |
|
56 | - $response = $this->request('check_license', $data); |
|
57 | - if ('valid' === Arr::get($response, 'license')) { |
|
58 | - $this->getPluginUpdate(true); |
|
59 | - } |
|
60 | - return $response; |
|
61 | - } |
|
51 | + /** |
|
52 | + * @return object |
|
53 | + */ |
|
54 | + public function checkLicense(array $data = []) |
|
55 | + { |
|
56 | + $response = $this->request('check_license', $data); |
|
57 | + if ('valid' === Arr::get($response, 'license')) { |
|
58 | + $this->getPluginUpdate(true); |
|
59 | + } |
|
60 | + return $response; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return object |
|
65 | - */ |
|
66 | - public function deactivateLicense(array $data = []) |
|
67 | - { |
|
68 | - return $this->request('deactivate_license', $data); |
|
69 | - } |
|
63 | + /** |
|
64 | + * @return object |
|
65 | + */ |
|
66 | + public function deactivateLicense(array $data = []) |
|
67 | + { |
|
68 | + return $this->request('deactivate_license', $data); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param false|object|array $result |
|
73 | - * @param string $action |
|
74 | - * @param object $args |
|
75 | - * @return mixed |
|
76 | - */ |
|
77 | - public function filterPluginUpdateDetails($result, $action, $args) |
|
78 | - { |
|
79 | - if ('plugin_information' != $action |
|
80 | - || Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) { |
|
81 | - return $result; |
|
82 | - } |
|
83 | - if ($updateInfo = $this->getPluginUpdate()) { |
|
84 | - return $this->modifyUpdateDetails($updateInfo); |
|
85 | - } |
|
86 | - return $result; |
|
87 | - } |
|
71 | + /** |
|
72 | + * @param false|object|array $result |
|
73 | + * @param string $action |
|
74 | + * @param object $args |
|
75 | + * @return mixed |
|
76 | + */ |
|
77 | + public function filterPluginUpdateDetails($result, $action, $args) |
|
78 | + { |
|
79 | + if ('plugin_information' != $action |
|
80 | + || Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) { |
|
81 | + return $result; |
|
82 | + } |
|
83 | + if ($updateInfo = $this->getPluginUpdate()) { |
|
84 | + return $this->modifyUpdateDetails($updateInfo); |
|
85 | + } |
|
86 | + return $result; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param object $transient |
|
91 | - * @return object |
|
92 | - */ |
|
93 | - public function filterPluginUpdates($transient) |
|
94 | - { |
|
95 | - if ($updateInfo = $this->getPluginUpdate()) { |
|
96 | - return $this->modifyPluginUpdates($transient, $updateInfo); |
|
97 | - } |
|
98 | - return $transient; |
|
99 | - } |
|
89 | + /** |
|
90 | + * @param object $transient |
|
91 | + * @return object |
|
92 | + */ |
|
93 | + public function filterPluginUpdates($transient) |
|
94 | + { |
|
95 | + if ($updateInfo = $this->getPluginUpdate()) { |
|
96 | + return $this->modifyPluginUpdates($transient, $updateInfo); |
|
97 | + } |
|
98 | + return $transient; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @return object |
|
103 | - */ |
|
104 | - public function getVersion(array $data = []) |
|
105 | - { |
|
106 | - return $this->request('get_version', $data); |
|
107 | - } |
|
101 | + /** |
|
102 | + * @return object |
|
103 | + */ |
|
104 | + public function getVersion(array $data = []) |
|
105 | + { |
|
106 | + return $this->request('get_version', $data); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @return void |
|
111 | - */ |
|
112 | - public function init() |
|
113 | - { |
|
114 | - if ($this->apiUrl === trailingslashit(home_url())) { |
|
115 | - return; |
|
116 | - } |
|
117 | - add_filter('plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3); |
|
118 | - add_filter('pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999); |
|
119 | - add_action('load-update-core.php', [$this, 'onForceUpdateCheck'], 9); |
|
120 | - add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']); |
|
121 | - } |
|
109 | + /** |
|
110 | + * @return void |
|
111 | + */ |
|
112 | + public function init() |
|
113 | + { |
|
114 | + if ($this->apiUrl === trailingslashit(home_url())) { |
|
115 | + return; |
|
116 | + } |
|
117 | + add_filter('plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3); |
|
118 | + add_filter('pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999); |
|
119 | + add_action('load-update-core.php', [$this, 'onForceUpdateCheck'], 9); |
|
120 | + add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @return bool |
|
125 | - */ |
|
126 | - public function isLicenseValid() |
|
127 | - { |
|
128 | - $result = $this->checkLicense(); |
|
129 | - return 'valid' === Arr::get($result, 'license'); |
|
130 | - } |
|
123 | + /** |
|
124 | + * @return bool |
|
125 | + */ |
|
126 | + public function isLicenseValid() |
|
127 | + { |
|
128 | + $result = $this->checkLicense(); |
|
129 | + return 'valid' === Arr::get($result, 'license'); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - public function onForceUpdateCheck() |
|
136 | - { |
|
137 | - if (!filter_input(INPUT_GET, 'force-check')) { |
|
138 | - return; |
|
139 | - } |
|
140 | - foreach (glsr()->addons as $addon) { |
|
141 | - try { |
|
142 | - glsr($addon)->updater->getPluginUpdate(true); |
|
143 | - } catch (\Exception $e) { |
|
144 | - glsr_log()->error($e->getMessage()); |
|
145 | - } |
|
146 | - } |
|
147 | - } |
|
132 | + /** |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + public function onForceUpdateCheck() |
|
136 | + { |
|
137 | + if (!filter_input(INPUT_GET, 'force-check')) { |
|
138 | + return; |
|
139 | + } |
|
140 | + foreach (glsr()->addons as $addon) { |
|
141 | + try { |
|
142 | + glsr($addon)->updater->getPluginUpdate(true); |
|
143 | + } catch (\Exception $e) { |
|
144 | + glsr_log()->error($e->getMessage()); |
|
145 | + } |
|
146 | + } |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @return void |
|
151 | - */ |
|
152 | - public function renderLicenseMissingLink() |
|
153 | - { |
|
154 | - if (!$this->isLicenseValid()) { |
|
155 | - glsr()->render('partials/addons/license-missing'); |
|
156 | - } |
|
157 | - } |
|
149 | + /** |
|
150 | + * @return void |
|
151 | + */ |
|
152 | + public function renderLicenseMissingLink() |
|
153 | + { |
|
154 | + if (!$this->isLicenseValid()) { |
|
155 | + glsr()->render('partials/addons/license-missing'); |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * @return false|object |
|
161 | - */ |
|
162 | - protected function getCachedVersion() |
|
163 | - { |
|
164 | - return get_transient($this->transientName); |
|
165 | - } |
|
159 | + /** |
|
160 | + * @return false|object |
|
161 | + */ |
|
162 | + protected function getCachedVersion() |
|
163 | + { |
|
164 | + return get_transient($this->transientName); |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @param bool $force |
|
169 | - * @return false|object |
|
170 | - */ |
|
171 | - protected function getPluginUpdate($force = false) |
|
172 | - { |
|
173 | - $version = $this->getCachedVersion(); |
|
174 | - if (false === $version || $force) { |
|
175 | - $version = $this->getVersion(); |
|
176 | - $this->setCachedVersion($version); |
|
177 | - } |
|
178 | - if (isset($version->error)) { |
|
179 | - glsr_log()->error($version->error); |
|
180 | - return false; |
|
181 | - } |
|
182 | - return $version; |
|
183 | - } |
|
167 | + /** |
|
168 | + * @param bool $force |
|
169 | + * @return false|object |
|
170 | + */ |
|
171 | + protected function getPluginUpdate($force = false) |
|
172 | + { |
|
173 | + $version = $this->getCachedVersion(); |
|
174 | + if (false === $version || $force) { |
|
175 | + $version = $this->getVersion(); |
|
176 | + $this->setCachedVersion($version); |
|
177 | + } |
|
178 | + if (isset($version->error)) { |
|
179 | + glsr_log()->error($version->error); |
|
180 | + return false; |
|
181 | + } |
|
182 | + return $version; |
|
183 | + } |
|
184 | 184 | |
185 | - /** |
|
186 | - * @param object $transient |
|
187 | - * @param object $updateInfo |
|
188 | - * @return object |
|
189 | - */ |
|
190 | - protected function modifyPluginUpdates($transient, $updateInfo) |
|
191 | - { |
|
192 | - $updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain'); |
|
193 | - $updateInfo->plugin = $this->plugin; |
|
194 | - $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP'); |
|
195 | - $updateInfo->tested = Arr::get($this->data, 'testedTo'); |
|
196 | - $transient->checked[$this->plugin] = Arr::get($this->data, 'Version'); |
|
197 | - $transient->last_checked = time(); |
|
198 | - if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) { |
|
199 | - unset($transient->no_update[$this->plugin]); |
|
200 | - $updateInfo->update = true; |
|
201 | - $transient->response[$this->plugin] = $updateInfo; |
|
202 | - } else { |
|
203 | - unset($transient->response[$this->plugin]); |
|
204 | - $transient->no_update[$this->plugin] = $updateInfo; |
|
205 | - } |
|
206 | - return $transient; |
|
207 | - } |
|
185 | + /** |
|
186 | + * @param object $transient |
|
187 | + * @param object $updateInfo |
|
188 | + * @return object |
|
189 | + */ |
|
190 | + protected function modifyPluginUpdates($transient, $updateInfo) |
|
191 | + { |
|
192 | + $updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain'); |
|
193 | + $updateInfo->plugin = $this->plugin; |
|
194 | + $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP'); |
|
195 | + $updateInfo->tested = Arr::get($this->data, 'testedTo'); |
|
196 | + $transient->checked[$this->plugin] = Arr::get($this->data, 'Version'); |
|
197 | + $transient->last_checked = time(); |
|
198 | + if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) { |
|
199 | + unset($transient->no_update[$this->plugin]); |
|
200 | + $updateInfo->update = true; |
|
201 | + $transient->response[$this->plugin] = $updateInfo; |
|
202 | + } else { |
|
203 | + unset($transient->response[$this->plugin]); |
|
204 | + $transient->no_update[$this->plugin] = $updateInfo; |
|
205 | + } |
|
206 | + return $transient; |
|
207 | + } |
|
208 | 208 | |
209 | - /** |
|
210 | - * @param object $updateInfo |
|
211 | - * @return object |
|
212 | - */ |
|
213 | - protected function modifyUpdateDetails($updateInfo) |
|
214 | - { |
|
215 | - $updateInfo->author = Arr::get($this->data, 'Author'); |
|
216 | - $updateInfo->author_profile = Arr::get($this->data, 'AuthorURI'); |
|
217 | - $updateInfo->requires = Arr::get($this->data, 'RequiresWP'); |
|
218 | - $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP'); |
|
219 | - $updateInfo->tested = Arr::get($this->data, 'testedTo'); |
|
220 | - $updateInfo->version = $updateInfo->new_version; |
|
221 | - return $updateInfo; |
|
222 | - } |
|
209 | + /** |
|
210 | + * @param object $updateInfo |
|
211 | + * @return object |
|
212 | + */ |
|
213 | + protected function modifyUpdateDetails($updateInfo) |
|
214 | + { |
|
215 | + $updateInfo->author = Arr::get($this->data, 'Author'); |
|
216 | + $updateInfo->author_profile = Arr::get($this->data, 'AuthorURI'); |
|
217 | + $updateInfo->requires = Arr::get($this->data, 'RequiresWP'); |
|
218 | + $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP'); |
|
219 | + $updateInfo->tested = Arr::get($this->data, 'testedTo'); |
|
220 | + $updateInfo->version = $updateInfo->new_version; |
|
221 | + return $updateInfo; |
|
222 | + } |
|
223 | 223 | |
224 | - /** |
|
225 | - * @param \WP_Error|array $response |
|
226 | - * @return object |
|
227 | - */ |
|
228 | - protected function normalizeResponse($response) |
|
229 | - { |
|
230 | - $body = wp_remote_retrieve_body($response); |
|
231 | - if ($data = json_decode($body)) { |
|
232 | - $data = array_map('maybe_unserialize', (array) $data); |
|
233 | - return (object) $data; |
|
234 | - } |
|
235 | - $error = is_wp_error($response) |
|
236 | - ? $response->get_error_message() |
|
237 | - : 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')'; |
|
238 | - return (object) ['error' => $error]; |
|
239 | - } |
|
224 | + /** |
|
225 | + * @param \WP_Error|array $response |
|
226 | + * @return object |
|
227 | + */ |
|
228 | + protected function normalizeResponse($response) |
|
229 | + { |
|
230 | + $body = wp_remote_retrieve_body($response); |
|
231 | + if ($data = json_decode($body)) { |
|
232 | + $data = array_map('maybe_unserialize', (array) $data); |
|
233 | + return (object) $data; |
|
234 | + } |
|
235 | + $error = is_wp_error($response) |
|
236 | + ? $response->get_error_message() |
|
237 | + : 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')'; |
|
238 | + return (object) ['error' => $error]; |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * @param string $action activate_license|check_license|deactivate_license|get_version |
|
243 | - * @return object |
|
244 | - */ |
|
245 | - protected function request($action, array $data = []) |
|
246 | - { |
|
247 | - $data = wp_parse_args($data, $this->data); |
|
248 | - $response = wp_remote_post($this->apiUrl, [ |
|
249 | - 'body' => [ |
|
250 | - 'edd_action' => $action, |
|
251 | - 'item_id' => Arr::get($data, 'item_id'), |
|
252 | - 'item_name' => Arr::get($data, 'Name'), |
|
253 | - 'license' => Arr::get($data, 'license'), |
|
254 | - 'slug' => Arr::get($data, 'TextDomain'), |
|
255 | - 'url' => home_url(), |
|
256 | - ], |
|
257 | - 'sslverify' => apply_filters('site-reviews/sslverify/post', false), |
|
258 | - 'timeout' => 15, |
|
259 | - ]); |
|
260 | - return $this->normalizeResponse($response); |
|
261 | - } |
|
241 | + /** |
|
242 | + * @param string $action activate_license|check_license|deactivate_license|get_version |
|
243 | + * @return object |
|
244 | + */ |
|
245 | + protected function request($action, array $data = []) |
|
246 | + { |
|
247 | + $data = wp_parse_args($data, $this->data); |
|
248 | + $response = wp_remote_post($this->apiUrl, [ |
|
249 | + 'body' => [ |
|
250 | + 'edd_action' => $action, |
|
251 | + 'item_id' => Arr::get($data, 'item_id'), |
|
252 | + 'item_name' => Arr::get($data, 'Name'), |
|
253 | + 'license' => Arr::get($data, 'license'), |
|
254 | + 'slug' => Arr::get($data, 'TextDomain'), |
|
255 | + 'url' => home_url(), |
|
256 | + ], |
|
257 | + 'sslverify' => apply_filters('site-reviews/sslverify/post', false), |
|
258 | + 'timeout' => 15, |
|
259 | + ]); |
|
260 | + return $this->normalizeResponse($response); |
|
261 | + } |
|
262 | 262 | |
263 | - /** |
|
264 | - * @param object $version |
|
265 | - * @return void |
|
266 | - */ |
|
267 | - protected function setCachedVersion($version) |
|
268 | - { |
|
269 | - if (!isset($version->error)) { |
|
270 | - set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS); |
|
271 | - } |
|
272 | - } |
|
263 | + /** |
|
264 | + * @param object $version |
|
265 | + * @return void |
|
266 | + */ |
|
267 | + protected function setCachedVersion($version) |
|
268 | + { |
|
269 | + if (!isset($version->error)) { |
|
270 | + set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS); |
|
271 | + } |
|
272 | + } |
|
273 | 273 | } |
@@ -29,33 +29,33 @@ discard block |
||
29 | 29 | * @param string $apiUrl |
30 | 30 | * @param string $file |
31 | 31 | */ |
32 | - public function __construct($apiUrl, $file, array $data = []) |
|
32 | + public function __construct( $apiUrl, $file, array $data = [] ) |
|
33 | 33 | { |
34 | - if (!function_exists('get_plugin_data')) { |
|
34 | + if( !function_exists( 'get_plugin_data' ) ) { |
|
35 | 35 | require_once ABSPATH.WPINC.'/plugin.php'; |
36 | 36 | } |
37 | - $this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl)); |
|
38 | - $this->data = wp_parse_args($data, get_plugin_data($file)); |
|
39 | - $this->plugin = plugin_basename($file); |
|
40 | - $this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain')); |
|
37 | + $this->apiUrl = trailingslashit( apply_filters( 'site-reviews/addon/api-url', $apiUrl ) ); |
|
38 | + $this->data = wp_parse_args( $data, get_plugin_data( $file ) ); |
|
39 | + $this->plugin = plugin_basename( $file ); |
|
40 | + $this->transientName = Application::PREFIX.md5( Arr::get( $data, 'TextDomain' ) ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @return object |
45 | 45 | */ |
46 | - public function activateLicense(array $data = []) |
|
46 | + public function activateLicense( array $data = [] ) |
|
47 | 47 | { |
48 | - return $this->request('activate_license', $data); |
|
48 | + return $this->request( 'activate_license', $data ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @return object |
53 | 53 | */ |
54 | - public function checkLicense(array $data = []) |
|
54 | + public function checkLicense( array $data = [] ) |
|
55 | 55 | { |
56 | - $response = $this->request('check_license', $data); |
|
57 | - if ('valid' === Arr::get($response, 'license')) { |
|
58 | - $this->getPluginUpdate(true); |
|
56 | + $response = $this->request( 'check_license', $data ); |
|
57 | + if( 'valid' === Arr::get( $response, 'license' ) ) { |
|
58 | + $this->getPluginUpdate( true ); |
|
59 | 59 | } |
60 | 60 | return $response; |
61 | 61 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @return object |
65 | 65 | */ |
66 | - public function deactivateLicense(array $data = []) |
|
66 | + public function deactivateLicense( array $data = [] ) |
|
67 | 67 | { |
68 | - return $this->request('deactivate_license', $data); |
|
68 | + return $this->request( 'deactivate_license', $data ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * @param object $args |
75 | 75 | * @return mixed |
76 | 76 | */ |
77 | - public function filterPluginUpdateDetails($result, $action, $args) |
|
77 | + public function filterPluginUpdateDetails( $result, $action, $args ) |
|
78 | 78 | { |
79 | - if ('plugin_information' != $action |
|
80 | - || Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) { |
|
79 | + if( 'plugin_information' != $action |
|
80 | + || Arr::get( $this->data, 'TextDomain' ) != Arr::get( $args, 'slug' ) ) { |
|
81 | 81 | return $result; |
82 | 82 | } |
83 | - if ($updateInfo = $this->getPluginUpdate()) { |
|
84 | - return $this->modifyUpdateDetails($updateInfo); |
|
83 | + if( $updateInfo = $this->getPluginUpdate() ) { |
|
84 | + return $this->modifyUpdateDetails( $updateInfo ); |
|
85 | 85 | } |
86 | 86 | return $result; |
87 | 87 | } |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | * @param object $transient |
91 | 91 | * @return object |
92 | 92 | */ |
93 | - public function filterPluginUpdates($transient) |
|
93 | + public function filterPluginUpdates( $transient ) |
|
94 | 94 | { |
95 | - if ($updateInfo = $this->getPluginUpdate()) { |
|
96 | - return $this->modifyPluginUpdates($transient, $updateInfo); |
|
95 | + if( $updateInfo = $this->getPluginUpdate() ) { |
|
96 | + return $this->modifyPluginUpdates( $transient, $updateInfo ); |
|
97 | 97 | } |
98 | 98 | return $transient; |
99 | 99 | } |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * @return object |
103 | 103 | */ |
104 | - public function getVersion(array $data = []) |
|
104 | + public function getVersion( array $data = [] ) |
|
105 | 105 | { |
106 | - return $this->request('get_version', $data); |
|
106 | + return $this->request( 'get_version', $data ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function init() |
113 | 113 | { |
114 | - if ($this->apiUrl === trailingslashit(home_url())) { |
|
114 | + if( $this->apiUrl === trailingslashit( home_url() ) ) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | - add_filter('plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3); |
|
118 | - add_filter('pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999); |
|
119 | - add_action('load-update-core.php', [$this, 'onForceUpdateCheck'], 9); |
|
120 | - add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']); |
|
117 | + add_filter( 'plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3 ); |
|
118 | + add_filter( 'pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999 ); |
|
119 | + add_action( 'load-update-core.php', [$this, 'onForceUpdateCheck'], 9 ); |
|
120 | + add_action( 'in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink'] ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | public function isLicenseValid() |
127 | 127 | { |
128 | 128 | $result = $this->checkLicense(); |
129 | - return 'valid' === Arr::get($result, 'license'); |
|
129 | + return 'valid' === Arr::get( $result, 'license' ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function onForceUpdateCheck() |
136 | 136 | { |
137 | - if (!filter_input(INPUT_GET, 'force-check')) { |
|
137 | + if( !filter_input( INPUT_GET, 'force-check' ) ) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | - foreach (glsr()->addons as $addon) { |
|
140 | + foreach( glsr()->addons as $addon ) { |
|
141 | 141 | try { |
142 | - glsr($addon)->updater->getPluginUpdate(true); |
|
143 | - } catch (\Exception $e) { |
|
144 | - glsr_log()->error($e->getMessage()); |
|
142 | + glsr( $addon )->updater->getPluginUpdate( true ); |
|
143 | + } catch( \Exception $e ) { |
|
144 | + glsr_log()->error( $e->getMessage() ); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function renderLicenseMissingLink() |
153 | 153 | { |
154 | - if (!$this->isLicenseValid()) { |
|
155 | - glsr()->render('partials/addons/license-missing'); |
|
154 | + if( !$this->isLicenseValid() ) { |
|
155 | + glsr()->render( 'partials/addons/license-missing' ); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
@@ -161,22 +161,22 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function getCachedVersion() |
163 | 163 | { |
164 | - return get_transient($this->transientName); |
|
164 | + return get_transient( $this->transientName ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | 168 | * @param bool $force |
169 | 169 | * @return false|object |
170 | 170 | */ |
171 | - protected function getPluginUpdate($force = false) |
|
171 | + protected function getPluginUpdate( $force = false ) |
|
172 | 172 | { |
173 | 173 | $version = $this->getCachedVersion(); |
174 | - if (false === $version || $force) { |
|
174 | + if( false === $version || $force ) { |
|
175 | 175 | $version = $this->getVersion(); |
176 | - $this->setCachedVersion($version); |
|
176 | + $this->setCachedVersion( $version ); |
|
177 | 177 | } |
178 | - if (isset($version->error)) { |
|
179 | - glsr_log()->error($version->error); |
|
178 | + if( isset($version->error) ) { |
|
179 | + glsr_log()->error( $version->error ); |
|
180 | 180 | return false; |
181 | 181 | } |
182 | 182 | return $version; |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | * @param object $updateInfo |
188 | 188 | * @return object |
189 | 189 | */ |
190 | - protected function modifyPluginUpdates($transient, $updateInfo) |
|
190 | + protected function modifyPluginUpdates( $transient, $updateInfo ) |
|
191 | 191 | { |
192 | - $updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain'); |
|
192 | + $updateInfo->id = Application::ID.'/'.Arr::get( $this->data, 'TextDomain' ); |
|
193 | 193 | $updateInfo->plugin = $this->plugin; |
194 | - $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP'); |
|
195 | - $updateInfo->tested = Arr::get($this->data, 'testedTo'); |
|
196 | - $transient->checked[$this->plugin] = Arr::get($this->data, 'Version'); |
|
194 | + $updateInfo->requires_php = Arr::get( $this->data, 'RequiresPHP' ); |
|
195 | + $updateInfo->tested = Arr::get( $this->data, 'testedTo' ); |
|
196 | + $transient->checked[$this->plugin] = Arr::get( $this->data, 'Version' ); |
|
197 | 197 | $transient->last_checked = time(); |
198 | - if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) { |
|
198 | + if( Helper::isGreaterThan( $updateInfo->new_version, Arr::get( $this->data, 'Version' ) ) ) { |
|
199 | 199 | unset($transient->no_update[$this->plugin]); |
200 | 200 | $updateInfo->update = true; |
201 | 201 | $transient->response[$this->plugin] = $updateInfo; |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | * @param object $updateInfo |
211 | 211 | * @return object |
212 | 212 | */ |
213 | - protected function modifyUpdateDetails($updateInfo) |
|
213 | + protected function modifyUpdateDetails( $updateInfo ) |
|
214 | 214 | { |
215 | - $updateInfo->author = Arr::get($this->data, 'Author'); |
|
216 | - $updateInfo->author_profile = Arr::get($this->data, 'AuthorURI'); |
|
217 | - $updateInfo->requires = Arr::get($this->data, 'RequiresWP'); |
|
218 | - $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP'); |
|
219 | - $updateInfo->tested = Arr::get($this->data, 'testedTo'); |
|
215 | + $updateInfo->author = Arr::get( $this->data, 'Author' ); |
|
216 | + $updateInfo->author_profile = Arr::get( $this->data, 'AuthorURI' ); |
|
217 | + $updateInfo->requires = Arr::get( $this->data, 'RequiresWP' ); |
|
218 | + $updateInfo->requires_php = Arr::get( $this->data, 'RequiresPHP' ); |
|
219 | + $updateInfo->tested = Arr::get( $this->data, 'testedTo' ); |
|
220 | 220 | $updateInfo->version = $updateInfo->new_version; |
221 | 221 | return $updateInfo; |
222 | 222 | } |
@@ -225,49 +225,49 @@ discard block |
||
225 | 225 | * @param \WP_Error|array $response |
226 | 226 | * @return object |
227 | 227 | */ |
228 | - protected function normalizeResponse($response) |
|
228 | + protected function normalizeResponse( $response ) |
|
229 | 229 | { |
230 | - $body = wp_remote_retrieve_body($response); |
|
231 | - if ($data = json_decode($body)) { |
|
232 | - $data = array_map('maybe_unserialize', (array) $data); |
|
233 | - return (object) $data; |
|
230 | + $body = wp_remote_retrieve_body( $response ); |
|
231 | + if( $data = json_decode( $body ) ) { |
|
232 | + $data = array_map( 'maybe_unserialize', (array)$data ); |
|
233 | + return (object)$data; |
|
234 | 234 | } |
235 | - $error = is_wp_error($response) |
|
235 | + $error = is_wp_error( $response ) |
|
236 | 236 | ? $response->get_error_message() |
237 | - : 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')'; |
|
238 | - return (object) ['error' => $error]; |
|
237 | + : 'Update server not responding ('.Arr::get( $this->data, 'TextDomain' ).')'; |
|
238 | + return (object)['error' => $error]; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | 242 | * @param string $action activate_license|check_license|deactivate_license|get_version |
243 | 243 | * @return object |
244 | 244 | */ |
245 | - protected function request($action, array $data = []) |
|
245 | + protected function request( $action, array $data = [] ) |
|
246 | 246 | { |
247 | - $data = wp_parse_args($data, $this->data); |
|
248 | - $response = wp_remote_post($this->apiUrl, [ |
|
247 | + $data = wp_parse_args( $data, $this->data ); |
|
248 | + $response = wp_remote_post( $this->apiUrl, [ |
|
249 | 249 | 'body' => [ |
250 | 250 | 'edd_action' => $action, |
251 | - 'item_id' => Arr::get($data, 'item_id'), |
|
252 | - 'item_name' => Arr::get($data, 'Name'), |
|
253 | - 'license' => Arr::get($data, 'license'), |
|
254 | - 'slug' => Arr::get($data, 'TextDomain'), |
|
251 | + 'item_id' => Arr::get( $data, 'item_id' ), |
|
252 | + 'item_name' => Arr::get( $data, 'Name' ), |
|
253 | + 'license' => Arr::get( $data, 'license' ), |
|
254 | + 'slug' => Arr::get( $data, 'TextDomain' ), |
|
255 | 255 | 'url' => home_url(), |
256 | 256 | ], |
257 | - 'sslverify' => apply_filters('site-reviews/sslverify/post', false), |
|
257 | + 'sslverify' => apply_filters( 'site-reviews/sslverify/post', false ), |
|
258 | 258 | 'timeout' => 15, |
259 | - ]); |
|
260 | - return $this->normalizeResponse($response); |
|
259 | + ] ); |
|
260 | + return $this->normalizeResponse( $response ); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | 264 | * @param object $version |
265 | 265 | * @return void |
266 | 266 | */ |
267 | - protected function setCachedVersion($version) |
|
267 | + protected function setCachedVersion( $version ) |
|
268 | 268 | { |
269 | - if (!isset($version->error)) { |
|
270 | - set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS); |
|
269 | + if( !isset($version->error) ) { |
|
270 | + set_transient( $this->transientName, $version, 3 * HOUR_IN_SECONDS ); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
@@ -139,7 +139,8 @@ discard block |
||
139 | 139 | foreach (glsr()->addons as $addon) { |
140 | 140 | try { |
141 | 141 | glsr($addon)->updater->getPluginUpdate(true); |
142 | - } catch (\Exception $e) { |
|
142 | + } |
|
143 | + catch (\Exception $e) { |
|
143 | 144 | glsr_log()->error($e->getMessage()); |
144 | 145 | } |
145 | 146 | } |
@@ -198,7 +199,8 @@ discard block |
||
198 | 199 | unset($transient->no_update[$this->plugin]); |
199 | 200 | $updateInfo->update = true; |
200 | 201 | $transient->response[$this->plugin] = $updateInfo; |
201 | - } else { |
|
202 | + } |
|
203 | + else { |
|
202 | 204 | unset($transient->response[$this->plugin]); |
203 | 205 | $transient->no_update[$this->plugin] = $updateInfo; |
204 | 206 | } |
@@ -7,105 +7,105 @@ |
||
7 | 7 | |
8 | 8 | class SiteReviewsFormBlock extends BlockGenerator |
9 | 9 | { |
10 | - /** |
|
11 | - * @return array |
|
12 | - */ |
|
13 | - public function attributes() |
|
14 | - { |
|
15 | - return [ |
|
16 | - 'assign_to' => [ |
|
17 | - 'default' => '', |
|
18 | - 'type' => 'string', |
|
19 | - ], |
|
20 | - 'category' => [ |
|
21 | - 'default' => '', |
|
22 | - 'type' => 'string', |
|
23 | - ], |
|
24 | - 'className' => [ |
|
25 | - 'default' => '', |
|
26 | - 'type' => 'string', |
|
27 | - ], |
|
28 | - 'hide' => [ |
|
29 | - 'default' => '', |
|
30 | - 'type' => 'string', |
|
31 | - ], |
|
32 | - 'id' => [ |
|
33 | - 'default' => '', |
|
34 | - 'type' => 'string', |
|
35 | - ], |
|
36 | - ]; |
|
37 | - } |
|
10 | + /** |
|
11 | + * @return array |
|
12 | + */ |
|
13 | + public function attributes() |
|
14 | + { |
|
15 | + return [ |
|
16 | + 'assign_to' => [ |
|
17 | + 'default' => '', |
|
18 | + 'type' => 'string', |
|
19 | + ], |
|
20 | + 'category' => [ |
|
21 | + 'default' => '', |
|
22 | + 'type' => 'string', |
|
23 | + ], |
|
24 | + 'className' => [ |
|
25 | + 'default' => '', |
|
26 | + 'type' => 'string', |
|
27 | + ], |
|
28 | + 'hide' => [ |
|
29 | + 'default' => '', |
|
30 | + 'type' => 'string', |
|
31 | + ], |
|
32 | + 'id' => [ |
|
33 | + 'default' => '', |
|
34 | + 'type' => 'string', |
|
35 | + ], |
|
36 | + ]; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function render(array $attributes) |
|
43 | - { |
|
44 | - $attributes['class'] = $attributes['className']; |
|
45 | - $shortcode = glsr(Shortcode::class); |
|
46 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
47 | - $this->filterBlockClass(); |
|
48 | - $this->filterFormFields(); |
|
49 | - $this->filterRatingField(); |
|
50 | - $this->filterSubmitButton(); |
|
51 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
52 | - $this->filterInterpolation(); |
|
53 | - } |
|
54 | - } |
|
55 | - return $shortcode->buildBlock($attributes); |
|
56 | - } |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function render(array $attributes) |
|
43 | + { |
|
44 | + $attributes['class'] = $attributes['className']; |
|
45 | + $shortcode = glsr(Shortcode::class); |
|
46 | + if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
47 | + $this->filterBlockClass(); |
|
48 | + $this->filterFormFields(); |
|
49 | + $this->filterRatingField(); |
|
50 | + $this->filterSubmitButton(); |
|
51 | + if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
52 | + $this->filterInterpolation(); |
|
53 | + } |
|
54 | + } |
|
55 | + return $shortcode->buildBlock($attributes); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - protected function filterFormFields() |
|
62 | - { |
|
63 | - add_filter('site-reviews/config/forms/submission-form', function (array $config) { |
|
64 | - array_walk($config, function (&$field) { |
|
65 | - $field['disabled'] = true; |
|
66 | - $field['tabindex'] = '-1'; |
|
67 | - }); |
|
68 | - return $config; |
|
69 | - }); |
|
70 | - } |
|
58 | + /** |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + protected function filterFormFields() |
|
62 | + { |
|
63 | + add_filter('site-reviews/config/forms/submission-form', function (array $config) { |
|
64 | + array_walk($config, function (&$field) { |
|
65 | + $field['disabled'] = true; |
|
66 | + $field['tabindex'] = '-1'; |
|
67 | + }); |
|
68 | + return $config; |
|
69 | + }); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - protected function filterInterpolation() |
|
76 | - { |
|
77 | - add_filter('site-reviews/interpolate/reviews-form', function ($context) { |
|
78 | - $context['class'] = 'glsr-default glsr-block-disabled'; |
|
79 | - $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
80 | - $context['response'] = ''; |
|
81 | - $context['submit_button'] = ''; |
|
82 | - return $context; |
|
83 | - }); |
|
84 | - } |
|
72 | + /** |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + protected function filterInterpolation() |
|
76 | + { |
|
77 | + add_filter('site-reviews/interpolate/reviews-form', function ($context) { |
|
78 | + $context['class'] = 'glsr-default glsr-block-disabled'; |
|
79 | + $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
80 | + $context['response'] = ''; |
|
81 | + $context['submit_button'] = ''; |
|
82 | + return $context; |
|
83 | + }); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - protected function filterRatingField() |
|
90 | - { |
|
91 | - add_filter('site-reviews/rendered/field', function ($html, $type, $args) { |
|
92 | - if ('rating' == $args['path']) { |
|
93 | - $stars = '<span class="glsr-stars">'; |
|
94 | - $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class)); |
|
95 | - $stars.= '</span>'; |
|
96 | - $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html); |
|
97 | - } |
|
98 | - return $html; |
|
99 | - }, 10, 3); |
|
100 | - } |
|
86 | + /** |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + protected function filterRatingField() |
|
90 | + { |
|
91 | + add_filter('site-reviews/rendered/field', function ($html, $type, $args) { |
|
92 | + if ('rating' == $args['path']) { |
|
93 | + $stars = '<span class="glsr-stars">'; |
|
94 | + $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class)); |
|
95 | + $stars.= '</span>'; |
|
96 | + $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html); |
|
97 | + } |
|
98 | + return $html; |
|
99 | + }, 10, 3); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - protected function filterSubmitButton() |
|
106 | - { |
|
107 | - add_filter('site-reviews/rendered/template/form/submit-button', function ($template) { |
|
108 | - return str_replace('type="submit"', 'tabindex="-1"', $template); |
|
109 | - }); |
|
110 | - } |
|
102 | + /** |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + protected function filterSubmitButton() |
|
106 | + { |
|
107 | + add_filter('site-reviews/rendered/template/form/submit-button', function ($template) { |
|
108 | + return str_replace('type="submit"', 'tabindex="-1"', $template); |
|
109 | + }); |
|
110 | + } |
|
111 | 111 | } |
@@ -39,20 +39,20 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - public function render(array $attributes) |
|
42 | + public function render( array $attributes ) |
|
43 | 43 | { |
44 | 44 | $attributes['class'] = $attributes['className']; |
45 | - $shortcode = glsr(Shortcode::class); |
|
46 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
45 | + $shortcode = glsr( Shortcode::class ); |
|
46 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
47 | 47 | $this->filterBlockClass(); |
48 | 48 | $this->filterFormFields(); |
49 | 49 | $this->filterRatingField(); |
50 | 50 | $this->filterSubmitButton(); |
51 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
51 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
52 | 52 | $this->filterInterpolation(); |
53 | 53 | } |
54 | 54 | } |
55 | - return $shortcode->buildBlock($attributes); |
|
55 | + return $shortcode->buildBlock( $attributes ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | */ |
61 | 61 | protected function filterFormFields() |
62 | 62 | { |
63 | - add_filter('site-reviews/config/forms/submission-form', function (array $config) { |
|
64 | - array_walk($config, function (&$field) { |
|
63 | + add_filter( 'site-reviews/config/forms/submission-form', function( array $config ) { |
|
64 | + array_walk( $config, function( &$field ) { |
|
65 | 65 | $field['disabled'] = true; |
66 | 66 | $field['tabindex'] = '-1'; |
67 | 67 | }); |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected function filterInterpolation() |
76 | 76 | { |
77 | - add_filter('site-reviews/interpolate/reviews-form', function ($context) { |
|
77 | + add_filter( 'site-reviews/interpolate/reviews-form', function( $context ) { |
|
78 | 78 | $context['class'] = 'glsr-default glsr-block-disabled'; |
79 | - $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
79 | + $context['fields'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
80 | 80 | $context['response'] = ''; |
81 | 81 | $context['submit_button'] = ''; |
82 | 82 | return $context; |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function filterRatingField() |
90 | 90 | { |
91 | - add_filter('site-reviews/rendered/field', function ($html, $type, $args) { |
|
92 | - if ('rating' == $args['path']) { |
|
91 | + add_filter( 'site-reviews/rendered/field', function( $html, $type, $args ) { |
|
92 | + if( 'rating' == $args['path'] ) { |
|
93 | 93 | $stars = '<span class="glsr-stars">'; |
94 | - $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class)); |
|
95 | - $stars.= '</span>'; |
|
96 | - $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html); |
|
94 | + $stars .= str_repeat( '<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int)glsr()->constant( 'MAX_RATING', Rating::class ) ); |
|
95 | + $stars .= '</span>'; |
|
96 | + $html = preg_replace( '/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html ); |
|
97 | 97 | } |
98 | 98 | return $html; |
99 | - }, 10, 3); |
|
99 | + }, 10, 3 ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function filterSubmitButton() |
106 | 106 | { |
107 | - add_filter('site-reviews/rendered/template/form/submit-button', function ($template) { |
|
108 | - return str_replace('type="submit"', 'tabindex="-1"', $template); |
|
107 | + add_filter( 'site-reviews/rendered/template/form/submit-button', function( $template ) { |
|
108 | + return str_replace( 'type="submit"', 'tabindex="-1"', $template ); |
|
109 | 109 | }); |
110 | 110 | } |
111 | 111 | } |
@@ -6,114 +6,114 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsBlock extends BlockGenerator |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function attributes() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'assigned_to' => [ |
|
16 | - 'default' => '', |
|
17 | - 'type' => 'string', |
|
18 | - ], |
|
19 | - 'category' => [ |
|
20 | - 'default' => '', |
|
21 | - 'type' => 'string', |
|
22 | - ], |
|
23 | - 'className' => [ |
|
24 | - 'default' => '', |
|
25 | - 'type' => 'string', |
|
26 | - ], |
|
27 | - 'display' => [ |
|
28 | - 'default' => 5, |
|
29 | - 'type' => 'number', |
|
30 | - ], |
|
31 | - 'hide' => [ |
|
32 | - 'default' => '', |
|
33 | - 'type' => 'string', |
|
34 | - ], |
|
35 | - 'id' => [ |
|
36 | - 'default' => '', |
|
37 | - 'type' => 'string', |
|
38 | - ], |
|
39 | - 'pagination' => [ |
|
40 | - 'default' => '', |
|
41 | - 'type' => 'string', |
|
42 | - ], |
|
43 | - 'post_id' => [ |
|
44 | - 'default' => '', |
|
45 | - 'type' => 'string', |
|
46 | - ], |
|
47 | - 'rating' => [ |
|
48 | - 'default' => 0, |
|
49 | - 'type' => 'number', |
|
50 | - ], |
|
51 | - 'schema' => [ |
|
52 | - 'default' => false, |
|
53 | - 'type' => 'boolean', |
|
54 | - ], |
|
55 | - 'type' => [ |
|
56 | - 'default' => 'local', |
|
57 | - 'type' => 'string', |
|
58 | - ], |
|
59 | - ]; |
|
60 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function attributes() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'assigned_to' => [ |
|
16 | + 'default' => '', |
|
17 | + 'type' => 'string', |
|
18 | + ], |
|
19 | + 'category' => [ |
|
20 | + 'default' => '', |
|
21 | + 'type' => 'string', |
|
22 | + ], |
|
23 | + 'className' => [ |
|
24 | + 'default' => '', |
|
25 | + 'type' => 'string', |
|
26 | + ], |
|
27 | + 'display' => [ |
|
28 | + 'default' => 5, |
|
29 | + 'type' => 'number', |
|
30 | + ], |
|
31 | + 'hide' => [ |
|
32 | + 'default' => '', |
|
33 | + 'type' => 'string', |
|
34 | + ], |
|
35 | + 'id' => [ |
|
36 | + 'default' => '', |
|
37 | + 'type' => 'string', |
|
38 | + ], |
|
39 | + 'pagination' => [ |
|
40 | + 'default' => '', |
|
41 | + 'type' => 'string', |
|
42 | + ], |
|
43 | + 'post_id' => [ |
|
44 | + 'default' => '', |
|
45 | + 'type' => 'string', |
|
46 | + ], |
|
47 | + 'rating' => [ |
|
48 | + 'default' => 0, |
|
49 | + 'type' => 'number', |
|
50 | + ], |
|
51 | + 'schema' => [ |
|
52 | + 'default' => false, |
|
53 | + 'type' => 'boolean', |
|
54 | + ], |
|
55 | + 'type' => [ |
|
56 | + 'default' => 'local', |
|
57 | + 'type' => 'string', |
|
58 | + ], |
|
59 | + ]; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function render(array $attributes) |
|
66 | - { |
|
67 | - $attributes['class'] = $attributes['className']; |
|
68 | - $shortcode = glsr(Shortcode::class); |
|
69 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | - $attributes = $this->normalize($attributes); |
|
71 | - $this->filterBlockClass(); |
|
72 | - $this->filterReviewLinks(); |
|
73 | - $this->filterShowMoreLinks('content'); |
|
74 | - $this->filterShowMoreLinks('response'); |
|
75 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
76 | - $this->filterInterpolation(); |
|
77 | - } |
|
78 | - } |
|
79 | - return $shortcode->buildBlock($attributes); |
|
80 | - } |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function render(array $attributes) |
|
66 | + { |
|
67 | + $attributes['class'] = $attributes['className']; |
|
68 | + $shortcode = glsr(Shortcode::class); |
|
69 | + if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | + $attributes = $this->normalize($attributes); |
|
71 | + $this->filterBlockClass(); |
|
72 | + $this->filterReviewLinks(); |
|
73 | + $this->filterShowMoreLinks('content'); |
|
74 | + $this->filterShowMoreLinks('response'); |
|
75 | + if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
76 | + $this->filterInterpolation(); |
|
77 | + } |
|
78 | + } |
|
79 | + return $shortcode->buildBlock($attributes); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return void |
|
84 | - */ |
|
85 | - protected function filterInterpolation() |
|
86 | - { |
|
87 | - add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
88 | - $context['class'] = 'glsr-default glsr-block-disabled'; |
|
89 | - $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
90 | - return $context; |
|
91 | - }); |
|
92 | - } |
|
82 | + /** |
|
83 | + * @return void |
|
84 | + */ |
|
85 | + protected function filterInterpolation() |
|
86 | + { |
|
87 | + add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
88 | + $context['class'] = 'glsr-default glsr-block-disabled'; |
|
89 | + $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
90 | + return $context; |
|
91 | + }); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - protected function filterReviewLinks() |
|
98 | - { |
|
99 | - add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | - return str_replace('<a', '<a tabindex="-1"', $template); |
|
101 | - }); |
|
102 | - } |
|
94 | + /** |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + protected function filterReviewLinks() |
|
98 | + { |
|
99 | + add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | + return str_replace('<a', '<a tabindex="-1"', $template); |
|
101 | + }); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @param string $field |
|
106 | - * @return void |
|
107 | - */ |
|
108 | - protected function filterShowMoreLinks($field) |
|
109 | - { |
|
110 | - add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
111 | - $value = preg_replace( |
|
112 | - '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s', |
|
113 | - '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
114 | - $value |
|
115 | - ); |
|
116 | - return $value; |
|
117 | - }); |
|
118 | - } |
|
104 | + /** |
|
105 | + * @param string $field |
|
106 | + * @return void |
|
107 | + */ |
|
108 | + protected function filterShowMoreLinks($field) |
|
109 | + { |
|
110 | + add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
111 | + $value = preg_replace( |
|
112 | + '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s', |
|
113 | + '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
114 | + $value |
|
115 | + ); |
|
116 | + return $value; |
|
117 | + }); |
|
118 | + } |
|
119 | 119 | } |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function render(array $attributes) |
|
65 | + public function render( array $attributes ) |
|
66 | 66 | { |
67 | 67 | $attributes['class'] = $attributes['className']; |
68 | - $shortcode = glsr(Shortcode::class); |
|
69 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | - $attributes = $this->normalize($attributes); |
|
68 | + $shortcode = glsr( Shortcode::class ); |
|
69 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
70 | + $attributes = $this->normalize( $attributes ); |
|
71 | 71 | $this->filterBlockClass(); |
72 | 72 | $this->filterReviewLinks(); |
73 | - $this->filterShowMoreLinks('content'); |
|
74 | - $this->filterShowMoreLinks('response'); |
|
75 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
73 | + $this->filterShowMoreLinks( 'content' ); |
|
74 | + $this->filterShowMoreLinks( 'response' ); |
|
75 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
76 | 76 | $this->filterInterpolation(); |
77 | 77 | } |
78 | 78 | } |
79 | - return $shortcode->buildBlock($attributes); |
|
79 | + return $shortcode->buildBlock( $attributes ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function filterInterpolation() |
86 | 86 | { |
87 | - add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
87 | + add_filter( 'site-reviews/interpolate/reviews', function( $context ) { |
|
88 | 88 | $context['class'] = 'glsr-default glsr-block-disabled'; |
89 | - $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
89 | + $context['reviews'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
90 | 90 | return $context; |
91 | 91 | }); |
92 | 92 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function filterReviewLinks() |
98 | 98 | { |
99 | - add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | - return str_replace('<a', '<a tabindex="-1"', $template); |
|
99 | + add_filter( 'site-reviews/rendered/template/reviews', function( $template ) { |
|
100 | + return str_replace( '<a', '<a tabindex="-1"', $template ); |
|
101 | 101 | }); |
102 | 102 | } |
103 | 103 | |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | * @param string $field |
106 | 106 | * @return void |
107 | 107 | */ |
108 | - protected function filterShowMoreLinks($field) |
|
108 | + protected function filterShowMoreLinks( $field ) |
|
109 | 109 | { |
110 | - add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
110 | + add_filter( 'site-reviews/review/wrap/'.$field, function( $value ) { |
|
111 | 111 | $value = preg_replace( |
112 | 112 | '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/s', |
113 | - '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
113 | + '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__( 'Show more', 'site-reviews' ).'</a>$5', |
|
114 | 114 | $value |
115 | 115 | ); |
116 | 116 | return $value; |
@@ -6,73 +6,73 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsSummaryBlock extends BlockGenerator |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function attributes() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'assigned_to' => [ |
|
16 | - 'default' => '', |
|
17 | - 'type' => 'string', |
|
18 | - ], |
|
19 | - 'category' => [ |
|
20 | - 'default' => '', |
|
21 | - 'type' => 'string', |
|
22 | - ], |
|
23 | - 'className' => [ |
|
24 | - 'default' => '', |
|
25 | - 'type' => 'string', |
|
26 | - ], |
|
27 | - 'hide' => [ |
|
28 | - 'default' => '', |
|
29 | - 'type' => 'string', |
|
30 | - ], |
|
31 | - 'post_id' => [ |
|
32 | - 'default' => '', |
|
33 | - 'type' => 'string', |
|
34 | - ], |
|
35 | - 'rating' => [ |
|
36 | - 'default' => '1', |
|
37 | - 'type' => 'number', |
|
38 | - ], |
|
39 | - 'schema' => [ |
|
40 | - 'default' => false, |
|
41 | - 'type' => 'boolean', |
|
42 | - ], |
|
43 | - 'type' => [ |
|
44 | - 'default' => 'local', |
|
45 | - 'type' => 'string', |
|
46 | - ], |
|
47 | - ]; |
|
48 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function attributes() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'assigned_to' => [ |
|
16 | + 'default' => '', |
|
17 | + 'type' => 'string', |
|
18 | + ], |
|
19 | + 'category' => [ |
|
20 | + 'default' => '', |
|
21 | + 'type' => 'string', |
|
22 | + ], |
|
23 | + 'className' => [ |
|
24 | + 'default' => '', |
|
25 | + 'type' => 'string', |
|
26 | + ], |
|
27 | + 'hide' => [ |
|
28 | + 'default' => '', |
|
29 | + 'type' => 'string', |
|
30 | + ], |
|
31 | + 'post_id' => [ |
|
32 | + 'default' => '', |
|
33 | + 'type' => 'string', |
|
34 | + ], |
|
35 | + 'rating' => [ |
|
36 | + 'default' => '1', |
|
37 | + 'type' => 'number', |
|
38 | + ], |
|
39 | + 'schema' => [ |
|
40 | + 'default' => false, |
|
41 | + 'type' => 'boolean', |
|
42 | + ], |
|
43 | + 'type' => [ |
|
44 | + 'default' => 'local', |
|
45 | + 'type' => 'string', |
|
46 | + ], |
|
47 | + ]; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function render(array $attributes) |
|
54 | - { |
|
55 | - $attributes['class'] = $attributes['className']; |
|
56 | - $shortcode = glsr(Shortcode::class); |
|
57 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
58 | - $attributes = $this->normalize($attributes); |
|
59 | - $this->filterBlockClass(); |
|
60 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
61 | - $this->filterInterpolation(); |
|
62 | - } |
|
63 | - } |
|
64 | - return $shortcode->buildBlock($attributes); |
|
65 | - } |
|
50 | + /** |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function render(array $attributes) |
|
54 | + { |
|
55 | + $attributes['class'] = $attributes['className']; |
|
56 | + $shortcode = glsr(Shortcode::class); |
|
57 | + if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
58 | + $attributes = $this->normalize($attributes); |
|
59 | + $this->filterBlockClass(); |
|
60 | + if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
61 | + $this->filterInterpolation(); |
|
62 | + } |
|
63 | + } |
|
64 | + return $shortcode->buildBlock($attributes); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - protected function filterInterpolation() |
|
71 | - { |
|
72 | - add_filter('site-reviews/interpolate/reviews-summary', function ($context) { |
|
73 | - $context['class'] = 'glsr-default glsr-block-disabled'; |
|
74 | - $context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
75 | - return $context; |
|
76 | - }); |
|
77 | - } |
|
67 | + /** |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + protected function filterInterpolation() |
|
71 | + { |
|
72 | + add_filter('site-reviews/interpolate/reviews-summary', function ($context) { |
|
73 | + $context['class'] = 'glsr-default glsr-block-disabled'; |
|
74 | + $context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
75 | + return $context; |
|
76 | + }); |
|
77 | + } |
|
78 | 78 | } |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @return string |
52 | 52 | */ |
53 | - public function render(array $attributes) |
|
53 | + public function render( array $attributes ) |
|
54 | 54 | { |
55 | 55 | $attributes['class'] = $attributes['className']; |
56 | - $shortcode = glsr(Shortcode::class); |
|
57 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
58 | - $attributes = $this->normalize($attributes); |
|
56 | + $shortcode = glsr( Shortcode::class ); |
|
57 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
58 | + $attributes = $this->normalize( $attributes ); |
|
59 | 59 | $this->filterBlockClass(); |
60 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
60 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
61 | 61 | $this->filterInterpolation(); |
62 | 62 | } |
63 | 63 | } |
64 | - return $shortcode->buildBlock($attributes); |
|
64 | + return $shortcode->buildBlock( $attributes ); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | */ |
70 | 70 | protected function filterInterpolation() |
71 | 71 | { |
72 | - add_filter('site-reviews/interpolate/reviews-summary', function ($context) { |
|
72 | + add_filter( 'site-reviews/interpolate/reviews-summary', function( $context ) { |
|
73 | 73 | $context['class'] = 'glsr-default glsr-block-disabled'; |
74 | - $context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
74 | + $context['text'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
75 | 75 | return $context; |
76 | 76 | }); |
77 | 77 | } |