@@ -1,10 +1,10 @@ |
||
1 | 1 | <div class="notice is-dismissible glsr-notice" data-dismiss="rebusify"> |
2 | 2 | <div class="glsr-notice-icon"> |
3 | - <img width="96" height="96" src="<?= glsr()->url('assets/images/rebusify-badge.png'); ?>"> |
|
3 | + <img width="96" height="96" src="<?= glsr()->url( 'assets/images/rebusify-badge.png' ); ?>"> |
|
4 | 4 | </div> |
5 | 5 | <div class="glsr-notice-content"> |
6 | 6 | <h3>Validate Your Reviews on the Blockchain With the Rebusify Confidence System</h3> |
7 | - <p>Site Reviews now integrates with the Rebusify Confidence System which uses blockchain technology to verify to your visitors and customers that your reviews are authentic. Simply create a free Rebusify account and <a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!general'); ?>">enter your credentials in the Settings</a>. Site Reviews will take care of the rest!</p> |
|
7 | + <p>Site Reviews now integrates with the Rebusify Confidence System which uses blockchain technology to verify to your visitors and customers that your reviews are authentic. Simply create a free Rebusify account and <a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!general' ); ?>">enter your credentials in the Settings</a>. Site Reviews will take care of the rest!</p> |
|
8 | 8 | <a href="https://rebusify.com/plans?ref=105" class="button" target="_blank">Create Your Rebusify Account</a> |
9 | 9 | </div> |
10 | 10 | </div> |
@@ -4,164 +4,164 @@ |
||
4 | 4 | |
5 | 5 | trait Str |
6 | 6 | { |
7 | - /** |
|
8 | - * @param string $string |
|
9 | - * @return string |
|
10 | - */ |
|
11 | - public function camelCase($string) |
|
12 | - { |
|
13 | - $string = ucwords(str_replace(['-', '_'], ' ', trim($string))); |
|
14 | - return str_replace(' ', '', $string); |
|
15 | - } |
|
7 | + /** |
|
8 | + * @param string $string |
|
9 | + * @return string |
|
10 | + */ |
|
11 | + public function camelCase($string) |
|
12 | + { |
|
13 | + $string = ucwords(str_replace(['-', '_'], ' ', trim($string))); |
|
14 | + return str_replace(' ', '', $string); |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * @param string $name |
|
19 | - * @param string $nameType first|first_initial|initials|last|last_initial |
|
20 | - * @param string $initialType period|period_space|space |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function convertName($name, $nameType = '', $initialType = '') |
|
24 | - { |
|
25 | - $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY); |
|
26 | - $firstName = array_shift($names); |
|
27 | - $lastName = array_pop($names); |
|
28 | - $initialTypes = [ |
|
29 | - 'period' => '.', |
|
30 | - 'period_space' => '. ', |
|
31 | - 'space' => ' ', |
|
32 | - ]; |
|
33 | - $initialPunctuation = glsr_get($initialTypes, $initialType, ' '); |
|
34 | - if ('initials' == $nameType) { |
|
35 | - return $this->convertToInitials($name, $initialPunctuation); |
|
36 | - } |
|
37 | - $nameTypes = [ |
|
38 | - 'first' => $firstName, |
|
39 | - 'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName, |
|
40 | - 'last' => $lastName, |
|
41 | - 'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation, |
|
42 | - ]; |
|
43 | - return trim(glsr_get($nameTypes, $nameType, $name)); |
|
44 | - } |
|
17 | + /** |
|
18 | + * @param string $name |
|
19 | + * @param string $nameType first|first_initial|initials|last|last_initial |
|
20 | + * @param string $initialType period|period_space|space |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function convertName($name, $nameType = '', $initialType = '') |
|
24 | + { |
|
25 | + $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY); |
|
26 | + $firstName = array_shift($names); |
|
27 | + $lastName = array_pop($names); |
|
28 | + $initialTypes = [ |
|
29 | + 'period' => '.', |
|
30 | + 'period_space' => '. ', |
|
31 | + 'space' => ' ', |
|
32 | + ]; |
|
33 | + $initialPunctuation = glsr_get($initialTypes, $initialType, ' '); |
|
34 | + if ('initials' == $nameType) { |
|
35 | + return $this->convertToInitials($name, $initialPunctuation); |
|
36 | + } |
|
37 | + $nameTypes = [ |
|
38 | + 'first' => $firstName, |
|
39 | + 'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName, |
|
40 | + 'last' => $lastName, |
|
41 | + 'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation, |
|
42 | + ]; |
|
43 | + return trim(glsr_get($nameTypes, $nameType, $name)); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param string $path |
|
48 | - * @param string $prefix |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function convertPathToId($path, $prefix = '') |
|
52 | - { |
|
53 | - return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix)); |
|
54 | - } |
|
46 | + /** |
|
47 | + * @param string $path |
|
48 | + * @param string $prefix |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function convertPathToId($path, $prefix = '') |
|
52 | + { |
|
53 | + return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix)); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $path |
|
58 | - * @param string $prefix |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function convertPathToName($path, $prefix = '') |
|
62 | - { |
|
63 | - $levels = explode('.', $path); |
|
64 | - return array_reduce($levels, function ($result, $value) { |
|
65 | - return $result .= '['.$value.']'; |
|
66 | - }, $prefix); |
|
67 | - } |
|
56 | + /** |
|
57 | + * @param string $path |
|
58 | + * @param string $prefix |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function convertPathToName($path, $prefix = '') |
|
62 | + { |
|
63 | + $levels = explode('.', $path); |
|
64 | + return array_reduce($levels, function ($result, $value) { |
|
65 | + return $result .= '['.$value.']'; |
|
66 | + }, $prefix); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $name |
|
71 | - * @param string $initialPunctuation |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function convertToInitials($name, $initialPunctuation = '') |
|
75 | - { |
|
76 | - preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches); |
|
77 | - return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) { |
|
78 | - return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation; |
|
79 | - }); |
|
80 | - } |
|
69 | + /** |
|
70 | + * @param string $name |
|
71 | + * @param string $initialPunctuation |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function convertToInitials($name, $initialPunctuation = '') |
|
75 | + { |
|
76 | + preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches); |
|
77 | + return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) { |
|
78 | + return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation; |
|
79 | + }); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @param string $string |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public function dashCase($string) |
|
87 | - { |
|
88 | - return str_replace('_', '-', $this->snakeCase($string)); |
|
89 | - } |
|
82 | + /** |
|
83 | + * @param string $string |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public function dashCase($string) |
|
87 | + { |
|
88 | + return str_replace('_', '-', $this->snakeCase($string)); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @param string $needle |
|
93 | - * @param string $haystack |
|
94 | - * @return bool |
|
95 | - */ |
|
96 | - public function endsWith($needle, $haystack) |
|
97 | - { |
|
98 | - $length = strlen($needle); |
|
99 | - return 0 != $length |
|
100 | - ? substr($haystack, -$length) === $needle |
|
101 | - : true; |
|
102 | - } |
|
91 | + /** |
|
92 | + * @param string $needle |
|
93 | + * @param string $haystack |
|
94 | + * @return bool |
|
95 | + */ |
|
96 | + public function endsWith($needle, $haystack) |
|
97 | + { |
|
98 | + $length = strlen($needle); |
|
99 | + return 0 != $length |
|
100 | + ? substr($haystack, -$length) === $needle |
|
101 | + : true; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @param string $prefix |
|
106 | - * @param string $string |
|
107 | - * @param string|null $trim |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function prefix($prefix, $string, $trim = null) |
|
111 | - { |
|
112 | - if (null === $trim) { |
|
113 | - $trim = $prefix; |
|
114 | - } |
|
115 | - return $prefix.trim($this->removePrefix($trim, $string)); |
|
116 | - } |
|
104 | + /** |
|
105 | + * @param string $prefix |
|
106 | + * @param string $string |
|
107 | + * @param string|null $trim |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function prefix($prefix, $string, $trim = null) |
|
111 | + { |
|
112 | + if (null === $trim) { |
|
113 | + $trim = $prefix; |
|
114 | + } |
|
115 | + return $prefix.trim($this->removePrefix($trim, $string)); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * @param string $prefix |
|
120 | - * @param string $string |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function removePrefix($prefix, $string) |
|
124 | - { |
|
125 | - return $this->startsWith($prefix, $string) |
|
126 | - ? substr($string, strlen($prefix)) |
|
127 | - : $string; |
|
128 | - } |
|
118 | + /** |
|
119 | + * @param string $prefix |
|
120 | + * @param string $string |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function removePrefix($prefix, $string) |
|
124 | + { |
|
125 | + return $this->startsWith($prefix, $string) |
|
126 | + ? substr($string, strlen($prefix)) |
|
127 | + : $string; |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * @param string $string |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function snakeCase($string) |
|
135 | - { |
|
136 | - if (!ctype_lower($string)) { |
|
137 | - $string = preg_replace('/\s+/u', '', $string); |
|
138 | - $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string); |
|
139 | - $string = function_exists('mb_strtolower') |
|
140 | - ? mb_strtolower($string, 'UTF-8') |
|
141 | - : strtolower($string); |
|
142 | - } |
|
143 | - return str_replace('-', '_', $string); |
|
144 | - } |
|
130 | + /** |
|
131 | + * @param string $string |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function snakeCase($string) |
|
135 | + { |
|
136 | + if (!ctype_lower($string)) { |
|
137 | + $string = preg_replace('/\s+/u', '', $string); |
|
138 | + $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string); |
|
139 | + $string = function_exists('mb_strtolower') |
|
140 | + ? mb_strtolower($string, 'UTF-8') |
|
141 | + : strtolower($string); |
|
142 | + } |
|
143 | + return str_replace('-', '_', $string); |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @param string $needle |
|
148 | - * @param string $haystack |
|
149 | - * @return bool |
|
150 | - */ |
|
151 | - public function startsWith($needle, $haystack) |
|
152 | - { |
|
153 | - return substr($haystack, 0, strlen($needle)) === $needle; |
|
154 | - } |
|
146 | + /** |
|
147 | + * @param string $needle |
|
148 | + * @param string $haystack |
|
149 | + * @return bool |
|
150 | + */ |
|
151 | + public function startsWith($needle, $haystack) |
|
152 | + { |
|
153 | + return substr($haystack, 0, strlen($needle)) === $needle; |
|
154 | + } |
|
155 | 155 | |
156 | - /** |
|
157 | - * @param string $string |
|
158 | - * @param int $length |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - public function truncate($string, $length) |
|
162 | - { |
|
163 | - return strlen($string) > $length |
|
164 | - ? substr($string, 0, $length) |
|
165 | - : $string; |
|
166 | - } |
|
156 | + /** |
|
157 | + * @param string $string |
|
158 | + * @param int $length |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + public function truncate($string, $length) |
|
162 | + { |
|
163 | + return strlen($string) > $length |
|
164 | + ? substr($string, 0, $length) |
|
165 | + : $string; |
|
166 | + } |
|
167 | 167 | } |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | * @param string $string |
9 | 9 | * @return string |
10 | 10 | */ |
11 | - public function camelCase($string) |
|
11 | + public function camelCase( $string ) |
|
12 | 12 | { |
13 | - $string = ucwords(str_replace(['-', '_'], ' ', trim($string))); |
|
14 | - return str_replace(' ', '', $string); |
|
13 | + $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) ); |
|
14 | + return str_replace( ' ', '', $string ); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -20,27 +20,27 @@ discard block |
||
20 | 20 | * @param string $initialType period|period_space|space |
21 | 21 | * @return string |
22 | 22 | */ |
23 | - public function convertName($name, $nameType = '', $initialType = '') |
|
23 | + public function convertName( $name, $nameType = '', $initialType = '' ) |
|
24 | 24 | { |
25 | - $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY); |
|
26 | - $firstName = array_shift($names); |
|
27 | - $lastName = array_pop($names); |
|
25 | + $names = preg_split( '/\W/', $name, 0, PREG_SPLIT_NO_EMPTY ); |
|
26 | + $firstName = array_shift( $names ); |
|
27 | + $lastName = array_pop( $names ); |
|
28 | 28 | $initialTypes = [ |
29 | 29 | 'period' => '.', |
30 | 30 | 'period_space' => '. ', |
31 | 31 | 'space' => ' ', |
32 | 32 | ]; |
33 | - $initialPunctuation = glsr_get($initialTypes, $initialType, ' '); |
|
34 | - if ('initials' == $nameType) { |
|
35 | - return $this->convertToInitials($name, $initialPunctuation); |
|
33 | + $initialPunctuation = glsr_get( $initialTypes, $initialType, ' ' ); |
|
34 | + if( 'initials' == $nameType ) { |
|
35 | + return $this->convertToInitials( $name, $initialPunctuation ); |
|
36 | 36 | } |
37 | 37 | $nameTypes = [ |
38 | 38 | 'first' => $firstName, |
39 | - 'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName, |
|
39 | + 'first_initial' => substr( $firstName, 0, 1 ).$initialPunctuation.$lastName, |
|
40 | 40 | 'last' => $lastName, |
41 | - 'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation, |
|
41 | + 'last_initial' => $firstName.' '.substr( $lastName, 0, 1 ).$initialPunctuation, |
|
42 | 42 | ]; |
43 | - return trim(glsr_get($nameTypes, $nameType, $name)); |
|
43 | + return trim( glsr_get( $nameTypes, $nameType, $name ) ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @param string $prefix |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public function convertPathToId($path, $prefix = '') |
|
51 | + public function convertPathToId( $path, $prefix = '' ) |
|
52 | 52 | { |
53 | - return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix)); |
|
53 | + return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * @param string $prefix |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - public function convertPathToName($path, $prefix = '') |
|
61 | + public function convertPathToName( $path, $prefix = '' ) |
|
62 | 62 | { |
63 | - $levels = explode('.', $path); |
|
64 | - return array_reduce($levels, function ($result, $value) { |
|
63 | + $levels = explode( '.', $path ); |
|
64 | + return array_reduce( $levels, function( $result, $value ) { |
|
65 | 65 | return $result .= '['.$value.']'; |
66 | - }, $prefix); |
|
66 | + }, $prefix ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | * @param string $initialPunctuation |
72 | 72 | * @return string |
73 | 73 | */ |
74 | - public function convertToInitials($name, $initialPunctuation = '') |
|
74 | + public function convertToInitials( $name, $initialPunctuation = '' ) |
|
75 | 75 | { |
76 | - preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches); |
|
77 | - return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) { |
|
78 | - return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation; |
|
76 | + preg_match_all( '/(?<=\s|\b)\pL/u', $name, $matches ); |
|
77 | + return array_reduce( $matches[0], function( $carry, $word ) use ($initialPunctuation) { |
|
78 | + return $carry.strtoupper( substr( $word, 0, 1 ) ).$initialPunctuation; |
|
79 | 79 | }); |
80 | 80 | } |
81 | 81 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @param string $string |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - public function dashCase($string) |
|
86 | + public function dashCase( $string ) |
|
87 | 87 | { |
88 | - return str_replace('_', '-', $this->snakeCase($string)); |
|
88 | + return str_replace( '_', '-', $this->snakeCase( $string ) ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * @param string $haystack |
94 | 94 | * @return bool |
95 | 95 | */ |
96 | - public function endsWith($needle, $haystack) |
|
96 | + public function endsWith( $needle, $haystack ) |
|
97 | 97 | { |
98 | - $length = strlen($needle); |
|
98 | + $length = strlen( $needle ); |
|
99 | 99 | return 0 != $length |
100 | - ? substr($haystack, -$length) === $needle |
|
100 | + ? substr( $haystack, -$length ) === $needle |
|
101 | 101 | : true; |
102 | 102 | } |
103 | 103 | |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | * @param string|null $trim |
108 | 108 | * @return string |
109 | 109 | */ |
110 | - public function prefix($prefix, $string, $trim = null) |
|
110 | + public function prefix( $prefix, $string, $trim = null ) |
|
111 | 111 | { |
112 | - if (null === $trim) { |
|
112 | + if( null === $trim ) { |
|
113 | 113 | $trim = $prefix; |
114 | 114 | } |
115 | - return $prefix.trim($this->removePrefix($trim, $string)); |
|
115 | + return $prefix.trim( $this->removePrefix( $trim, $string ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | * @param string $string |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function removePrefix($prefix, $string) |
|
123 | + public function removePrefix( $prefix, $string ) |
|
124 | 124 | { |
125 | - return $this->startsWith($prefix, $string) |
|
126 | - ? substr($string, strlen($prefix)) |
|
125 | + return $this->startsWith( $prefix, $string ) |
|
126 | + ? substr( $string, strlen( $prefix ) ) |
|
127 | 127 | : $string; |
128 | 128 | } |
129 | 129 | |
@@ -131,16 +131,16 @@ discard block |
||
131 | 131 | * @param string $string |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function snakeCase($string) |
|
134 | + public function snakeCase( $string ) |
|
135 | 135 | { |
136 | - if (!ctype_lower($string)) { |
|
137 | - $string = preg_replace('/\s+/u', '', $string); |
|
138 | - $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string); |
|
139 | - $string = function_exists('mb_strtolower') |
|
140 | - ? mb_strtolower($string, 'UTF-8') |
|
141 | - : strtolower($string); |
|
136 | + if( !ctype_lower( $string ) ) { |
|
137 | + $string = preg_replace( '/\s+/u', '', $string ); |
|
138 | + $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
|
139 | + $string = function_exists( 'mb_strtolower' ) |
|
140 | + ? mb_strtolower( $string, 'UTF-8' ) |
|
141 | + : strtolower( $string ); |
|
142 | 142 | } |
143 | - return str_replace('-', '_', $string); |
|
143 | + return str_replace( '-', '_', $string ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param string $haystack |
149 | 149 | * @return bool |
150 | 150 | */ |
151 | - public function startsWith($needle, $haystack) |
|
151 | + public function startsWith( $needle, $haystack ) |
|
152 | 152 | { |
153 | - return substr($haystack, 0, strlen($needle)) === $needle; |
|
153 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | * @param int $length |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function truncate($string, $length) |
|
161 | + public function truncate( $string, $length ) |
|
162 | 162 | { |
163 | - return strlen($string) > $length |
|
164 | - ? substr($string, 0, $length) |
|
163 | + return strlen( $string ) > $length |
|
164 | + ? substr( $string, 0, $length ) |
|
165 | 165 | : $string; |
166 | 166 | } |
167 | 167 | } |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p class="about-description">If you are using any Site Reviews code snippets or have built any custom integrations with Site Reviews, please make sure to read this upgrade guide.</p> |
4 | 4 | <div class="is-fullwidth"> |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <div class="notice notice-warning is-dismissible"> |
2 | - <p><?= __('Expect to see these add-ons released in the coming months! Thank you again for your continued patience.', 'site-reviews'); ?></p> |
|
2 | + <p><?= __( 'Expect to see these add-ons released in the coming months! Thank you again for your continued patience.', 'site-reviews' ); ?></p> |
|
3 | 3 | </div> |
@@ -9,65 +9,65 @@ |
||
9 | 9 | |
10 | 10 | class Reviews extends ArrayObject |
11 | 11 | { |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - public $args; |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + public $args; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @var int |
|
19 | - */ |
|
20 | - public $max_num_pages; |
|
17 | + /** |
|
18 | + * @var int |
|
19 | + */ |
|
20 | + public $max_num_pages; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - public $reviews; |
|
22 | + /** |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + public $reviews; |
|
26 | 26 | |
27 | - public function __construct(array $reviews, $maxPageCount, array $args) |
|
28 | - { |
|
29 | - $this->args = $args; |
|
30 | - $this->max_num_pages = $maxPageCount; |
|
31 | - $this->reviews = $reviews; |
|
32 | - parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
33 | - } |
|
27 | + public function __construct(array $reviews, $maxPageCount, array $args) |
|
28 | + { |
|
29 | + $this->args = $args; |
|
30 | + $this->max_num_pages = $maxPageCount; |
|
31 | + $this->reviews = $reviews; |
|
32 | + parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function __toString() |
|
39 | - { |
|
40 | - return (string) $this->build(); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function __toString() |
|
39 | + { |
|
40 | + return (string) $this->build(); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return ReviewsHtml |
|
45 | - */ |
|
46 | - public function build() |
|
47 | - { |
|
48 | - $args = glsr(SiteReviewsDefaults::class)->merge($this->args); |
|
49 | - return glsr(SiteReviewsPartial::class)->build($args, $this); |
|
50 | - } |
|
43 | + /** |
|
44 | + * @return ReviewsHtml |
|
45 | + */ |
|
46 | + public function build() |
|
47 | + { |
|
48 | + $args = glsr(SiteReviewsDefaults::class)->merge($this->args); |
|
49 | + return glsr(SiteReviewsPartial::class)->build($args, $this); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param mixed $key |
|
54 | - * @return mixed |
|
55 | - */ |
|
56 | - public function offsetGet($key) |
|
57 | - { |
|
58 | - if (property_exists($this, $key)) { |
|
59 | - return $this->$key; |
|
60 | - } |
|
61 | - return array_key_exists($key, $this->reviews) |
|
62 | - ? $this->reviews[$key] |
|
63 | - : null; |
|
64 | - } |
|
52 | + /** |
|
53 | + * @param mixed $key |
|
54 | + * @return mixed |
|
55 | + */ |
|
56 | + public function offsetGet($key) |
|
57 | + { |
|
58 | + if (property_exists($this, $key)) { |
|
59 | + return $this->$key; |
|
60 | + } |
|
61 | + return array_key_exists($key, $this->reviews) |
|
62 | + ? $this->reviews[$key] |
|
63 | + : null; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function render() |
|
70 | - { |
|
71 | - echo $this->build(); |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function render() |
|
70 | + { |
|
71 | + echo $this->build(); |
|
72 | + } |
|
73 | 73 | } |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public $reviews; |
26 | 26 | |
27 | - public function __construct(array $reviews, $maxPageCount, array $args) |
|
27 | + public function __construct( array $reviews, $maxPageCount, array $args ) |
|
28 | 28 | { |
29 | 29 | $this->args = $args; |
30 | 30 | $this->max_num_pages = $maxPageCount; |
31 | 31 | $this->reviews = $reviews; |
32 | - parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
32 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __toString() |
39 | 39 | { |
40 | - return (string) $this->build(); |
|
40 | + return (string)$this->build(); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function build() |
47 | 47 | { |
48 | - $args = glsr(SiteReviewsDefaults::class)->merge($this->args); |
|
49 | - return glsr(SiteReviewsPartial::class)->build($args, $this); |
|
48 | + $args = glsr( SiteReviewsDefaults::class )->merge( $this->args ); |
|
49 | + return glsr( SiteReviewsPartial::class )->build( $args, $this ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param mixed $key |
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | - public function offsetGet($key) |
|
56 | + public function offsetGet( $key ) |
|
57 | 57 | { |
58 | - if (property_exists($this, $key)) { |
|
58 | + if( property_exists( $this, $key ) ) { |
|
59 | 59 | return $this->$key; |
60 | 60 | } |
61 | - return array_key_exists($key, $this->reviews) |
|
61 | + return array_key_exists( $key, $this->reviews ) |
|
62 | 62 | ? $this->reviews[$key] |
63 | 63 | : null; |
64 | 64 | } |
@@ -27,37 +27,37 @@ discard block |
||
27 | 27 | public $title; |
28 | 28 | public $url; |
29 | 29 | |
30 | - public function __construct($input) |
|
30 | + public function __construct( $input ) |
|
31 | 31 | { |
32 | 32 | $this->request = $input; |
33 | 33 | $this->ajax_request = isset($input['_ajax_request']); |
34 | - $this->assigned_to = $this->getNumeric('assign_to'); |
|
35 | - $this->author = sanitize_text_field($this->getUser('name')); |
|
34 | + $this->assigned_to = $this->getNumeric( 'assign_to' ); |
|
35 | + $this->author = sanitize_text_field( $this->getUser( 'name' ) ); |
|
36 | 36 | $this->avatar = $this->getAvatar(); |
37 | 37 | $this->blacklisted = isset($input['blacklisted']); |
38 | 38 | $this->category = $this->getCategory(); |
39 | - $this->content = sanitize_textarea_field($this->get('content')); |
|
39 | + $this->content = sanitize_textarea_field( $this->get( 'content' ) ); |
|
40 | 40 | $this->custom = $this->getCustom(); |
41 | - $this->date = $this->getDate('date'); |
|
42 | - $this->email = sanitize_email($this->getUser('email')); |
|
43 | - $this->form_id = sanitize_key($this->get('form_id')); |
|
44 | - $this->ip_address = $this->get('ip_address'); |
|
45 | - $this->post_id = intval($this->get('_post_id')); |
|
46 | - $this->rating = intval($this->get('rating')); |
|
47 | - $this->referer = $this->get('_referer'); |
|
48 | - $this->response = sanitize_textarea_field($this->get('response')); |
|
41 | + $this->date = $this->getDate( 'date' ); |
|
42 | + $this->email = sanitize_email( $this->getUser( 'email' ) ); |
|
43 | + $this->form_id = sanitize_key( $this->get( 'form_id' ) ); |
|
44 | + $this->ip_address = $this->get( 'ip_address' ); |
|
45 | + $this->post_id = intval( $this->get( '_post_id' ) ); |
|
46 | + $this->rating = intval( $this->get( 'rating' ) ); |
|
47 | + $this->referer = $this->get( '_referer' ); |
|
48 | + $this->response = sanitize_textarea_field( $this->get( 'response' ) ); |
|
49 | 49 | $this->terms = !empty($input['terms']); |
50 | - $this->title = sanitize_text_field($this->get('title')); |
|
51 | - $this->url = esc_url_raw($this->get('url')); |
|
50 | + $this->title = sanitize_text_field( $this->get( 'title' ) ); |
|
51 | + $this->url = esc_url_raw( $this->get( 'url' ) ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @param string $key |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - protected function get($key) |
|
58 | + protected function get( $key ) |
|
59 | 59 | { |
60 | - return (string) glsr_get($this->request, $key); |
|
60 | + return (string)glsr_get( $this->request, $key ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function getAvatar() |
67 | 67 | { |
68 | - $avatar = $this->get('avatar'); |
|
69 | - return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) |
|
70 | - ? (string) get_avatar_url($this->get('email')) |
|
68 | + $avatar = $this->get( 'avatar' ); |
|
69 | + return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED ) |
|
70 | + ? (string)get_avatar_url( $this->get( 'email' ) ) |
|
71 | 71 | : $avatar; |
72 | 72 | } |
73 | 73 | |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | */ |
77 | 77 | protected function getCategory() |
78 | 78 | { |
79 | - $categories = glsr(Helper::class)->convertStringToArray($this->get('category')); |
|
80 | - return sanitize_key(glsr_get($categories, 0)); |
|
79 | + $categories = glsr( Helper::class )->convertStringToArray( $this->get( 'category' ) ); |
|
80 | + return sanitize_key( glsr_get( $categories, 0 ) ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | '_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id', |
91 | 91 | 'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url', |
92 | 92 | ]; |
93 | - $unset = apply_filters('site-reviews/create/unset-keys-from-custom', $unset); |
|
93 | + $unset = apply_filters( 'site-reviews/create/unset-keys-from-custom', $unset ); |
|
94 | 94 | $custom = $this->request; |
95 | - foreach ($unset as $value) { |
|
95 | + foreach( $unset as $value ) { |
|
96 | 96 | unset($custom[$value]); |
97 | 97 | } |
98 | 98 | return $custom; |
@@ -102,29 +102,29 @@ discard block |
||
102 | 102 | * @param string $key |
103 | 103 | * @return string |
104 | 104 | */ |
105 | - protected function getDate($key) |
|
105 | + protected function getDate( $key ) |
|
106 | 106 | { |
107 | - $date = strtotime($this->get($key)); |
|
108 | - if (false === $date) { |
|
107 | + $date = strtotime( $this->get( $key ) ); |
|
108 | + if( false === $date ) { |
|
109 | 109 | $date = time(); |
110 | 110 | } |
111 | - return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date)); |
|
111 | + return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @param string $key |
116 | 116 | * @return string |
117 | 117 | */ |
118 | - protected function getUser($key) |
|
118 | + protected function getUser( $key ) |
|
119 | 119 | { |
120 | - $value = $this->get($key); |
|
121 | - if (empty($value)) { |
|
120 | + $value = $this->get( $key ); |
|
121 | + if( empty($value) ) { |
|
122 | 122 | $user = wp_get_current_user(); |
123 | 123 | $userValues = [ |
124 | 124 | 'email' => 'user_email', |
125 | 125 | 'name' => 'display_name', |
126 | 126 | ]; |
127 | - if ($user->exists() && array_key_exists($key, $userValues)) { |
|
127 | + if( $user->exists() && array_key_exists( $key, $userValues ) ) { |
|
128 | 128 | return $user->{$userValues[$key]}; |
129 | 129 | } |
130 | 130 | } |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * @param string $key |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - protected function getNumeric($key) |
|
138 | + protected function getNumeric( $key ) |
|
139 | 139 | { |
140 | - $value = $this->get($key); |
|
141 | - return is_numeric($value) |
|
140 | + $value = $this->get( $key ); |
|
141 | + return is_numeric( $value ) |
|
142 | 142 | ? $value |
143 | 143 | : ''; |
144 | 144 | } |
@@ -6,140 +6,140 @@ |
||
6 | 6 | |
7 | 7 | class CreateReview |
8 | 8 | { |
9 | - public $ajax_request; |
|
10 | - public $assigned_to; |
|
11 | - public $author; |
|
12 | - public $avatar; |
|
13 | - public $blacklisted; |
|
14 | - public $category; |
|
15 | - public $content; |
|
16 | - public $custom; |
|
17 | - public $date; |
|
18 | - public $email; |
|
19 | - public $form_id; |
|
20 | - public $ip_address; |
|
21 | - public $post_id; |
|
22 | - public $rating; |
|
23 | - public $referer; |
|
24 | - public $request; |
|
25 | - public $response; |
|
26 | - public $terms; |
|
27 | - public $title; |
|
28 | - public $url; |
|
9 | + public $ajax_request; |
|
10 | + public $assigned_to; |
|
11 | + public $author; |
|
12 | + public $avatar; |
|
13 | + public $blacklisted; |
|
14 | + public $category; |
|
15 | + public $content; |
|
16 | + public $custom; |
|
17 | + public $date; |
|
18 | + public $email; |
|
19 | + public $form_id; |
|
20 | + public $ip_address; |
|
21 | + public $post_id; |
|
22 | + public $rating; |
|
23 | + public $referer; |
|
24 | + public $request; |
|
25 | + public $response; |
|
26 | + public $terms; |
|
27 | + public $title; |
|
28 | + public $url; |
|
29 | 29 | |
30 | - public function __construct($input) |
|
31 | - { |
|
32 | - $this->request = $input; |
|
33 | - $this->ajax_request = isset($input['_ajax_request']); |
|
34 | - $this->assigned_to = $this->getNumeric('assign_to'); |
|
35 | - $this->author = sanitize_text_field($this->getUser('name')); |
|
36 | - $this->avatar = $this->getAvatar(); |
|
37 | - $this->blacklisted = isset($input['blacklisted']); |
|
38 | - $this->category = $this->getCategory(); |
|
39 | - $this->content = sanitize_textarea_field($this->get('content')); |
|
40 | - $this->custom = $this->getCustom(); |
|
41 | - $this->date = $this->getDate('date'); |
|
42 | - $this->email = sanitize_email($this->getUser('email')); |
|
43 | - $this->form_id = sanitize_key($this->get('form_id')); |
|
44 | - $this->ip_address = $this->get('ip_address'); |
|
45 | - $this->post_id = intval($this->get('_post_id')); |
|
46 | - $this->rating = intval($this->get('rating')); |
|
47 | - $this->referer = $this->get('_referer'); |
|
48 | - $this->response = sanitize_textarea_field($this->get('response')); |
|
49 | - $this->terms = !empty($input['terms']); |
|
50 | - $this->title = sanitize_text_field($this->get('title')); |
|
51 | - $this->url = esc_url_raw($this->get('url')); |
|
52 | - } |
|
30 | + public function __construct($input) |
|
31 | + { |
|
32 | + $this->request = $input; |
|
33 | + $this->ajax_request = isset($input['_ajax_request']); |
|
34 | + $this->assigned_to = $this->getNumeric('assign_to'); |
|
35 | + $this->author = sanitize_text_field($this->getUser('name')); |
|
36 | + $this->avatar = $this->getAvatar(); |
|
37 | + $this->blacklisted = isset($input['blacklisted']); |
|
38 | + $this->category = $this->getCategory(); |
|
39 | + $this->content = sanitize_textarea_field($this->get('content')); |
|
40 | + $this->custom = $this->getCustom(); |
|
41 | + $this->date = $this->getDate('date'); |
|
42 | + $this->email = sanitize_email($this->getUser('email')); |
|
43 | + $this->form_id = sanitize_key($this->get('form_id')); |
|
44 | + $this->ip_address = $this->get('ip_address'); |
|
45 | + $this->post_id = intval($this->get('_post_id')); |
|
46 | + $this->rating = intval($this->get('rating')); |
|
47 | + $this->referer = $this->get('_referer'); |
|
48 | + $this->response = sanitize_textarea_field($this->get('response')); |
|
49 | + $this->terms = !empty($input['terms']); |
|
50 | + $this->title = sanitize_text_field($this->get('title')); |
|
51 | + $this->url = esc_url_raw($this->get('url')); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param string $key |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - protected function get($key) |
|
59 | - { |
|
60 | - return (string) glsr_get($this->request, $key); |
|
61 | - } |
|
54 | + /** |
|
55 | + * @param string $key |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + protected function get($key) |
|
59 | + { |
|
60 | + return (string) glsr_get($this->request, $key); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - protected function getAvatar() |
|
67 | - { |
|
68 | - $avatar = $this->get('avatar'); |
|
69 | - return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) |
|
70 | - ? (string) get_avatar_url($this->get('email')) |
|
71 | - : $avatar; |
|
72 | - } |
|
63 | + /** |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + protected function getAvatar() |
|
67 | + { |
|
68 | + $avatar = $this->get('avatar'); |
|
69 | + return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) |
|
70 | + ? (string) get_avatar_url($this->get('email')) |
|
71 | + : $avatar; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - protected function getCategory() |
|
78 | - { |
|
79 | - $categories = glsr(Helper::class)->convertStringToArray($this->get('category')); |
|
80 | - return sanitize_key(glsr_get($categories, 0)); |
|
81 | - } |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + protected function getCategory() |
|
78 | + { |
|
79 | + $categories = glsr(Helper::class)->convertStringToArray($this->get('category')); |
|
80 | + return sanitize_key(glsr_get($categories, 0)); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @return array |
|
85 | - */ |
|
86 | - protected function getCustom() |
|
87 | - { |
|
88 | - $unset = [ |
|
89 | - '_action', '_ajax_request', '_counter', '_nonce', '_post_id', '_recaptcha-token', |
|
90 | - '_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id', |
|
91 | - 'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url', |
|
92 | - ]; |
|
93 | - $unset = apply_filters('site-reviews/create/unset-keys-from-custom', $unset); |
|
94 | - $custom = $this->request; |
|
95 | - foreach ($unset as $value) { |
|
96 | - unset($custom[$value]); |
|
97 | - } |
|
98 | - return $custom; |
|
99 | - } |
|
83 | + /** |
|
84 | + * @return array |
|
85 | + */ |
|
86 | + protected function getCustom() |
|
87 | + { |
|
88 | + $unset = [ |
|
89 | + '_action', '_ajax_request', '_counter', '_nonce', '_post_id', '_recaptcha-token', |
|
90 | + '_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id', |
|
91 | + 'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url', |
|
92 | + ]; |
|
93 | + $unset = apply_filters('site-reviews/create/unset-keys-from-custom', $unset); |
|
94 | + $custom = $this->request; |
|
95 | + foreach ($unset as $value) { |
|
96 | + unset($custom[$value]); |
|
97 | + } |
|
98 | + return $custom; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @param string $key |
|
103 | - * @return string |
|
104 | - */ |
|
105 | - protected function getDate($key) |
|
106 | - { |
|
107 | - $date = strtotime($this->get($key)); |
|
108 | - if (false === $date) { |
|
109 | - $date = time(); |
|
110 | - } |
|
111 | - return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date)); |
|
112 | - } |
|
101 | + /** |
|
102 | + * @param string $key |
|
103 | + * @return string |
|
104 | + */ |
|
105 | + protected function getDate($key) |
|
106 | + { |
|
107 | + $date = strtotime($this->get($key)); |
|
108 | + if (false === $date) { |
|
109 | + $date = time(); |
|
110 | + } |
|
111 | + return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date)); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @param string $key |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - protected function getUser($key) |
|
119 | - { |
|
120 | - $value = $this->get($key); |
|
121 | - if (empty($value)) { |
|
122 | - $user = wp_get_current_user(); |
|
123 | - $userValues = [ |
|
124 | - 'email' => 'user_email', |
|
125 | - 'name' => 'display_name', |
|
126 | - ]; |
|
127 | - if ($user->exists() && array_key_exists($key, $userValues)) { |
|
128 | - return $user->{$userValues[$key]}; |
|
129 | - } |
|
130 | - } |
|
131 | - return $value; |
|
132 | - } |
|
114 | + /** |
|
115 | + * @param string $key |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + protected function getUser($key) |
|
119 | + { |
|
120 | + $value = $this->get($key); |
|
121 | + if (empty($value)) { |
|
122 | + $user = wp_get_current_user(); |
|
123 | + $userValues = [ |
|
124 | + 'email' => 'user_email', |
|
125 | + 'name' => 'display_name', |
|
126 | + ]; |
|
127 | + if ($user->exists() && array_key_exists($key, $userValues)) { |
|
128 | + return $user->{$userValues[$key]}; |
|
129 | + } |
|
130 | + } |
|
131 | + return $value; |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * @param string $key |
|
136 | - * @return string |
|
137 | - */ |
|
138 | - protected function getNumeric($key) |
|
139 | - { |
|
140 | - $value = $this->get($key); |
|
141 | - return is_numeric($value) |
|
142 | - ? $value |
|
143 | - : ''; |
|
144 | - } |
|
134 | + /** |
|
135 | + * @param string $key |
|
136 | + * @return string |
|
137 | + */ |
|
138 | + protected function getNumeric($key) |
|
139 | + { |
|
140 | + $value = $this->get($key); |
|
141 | + return is_numeric($value) |
|
142 | + ? $value |
|
143 | + : ''; |
|
144 | + } |
|
145 | 145 | } |
@@ -55,7 +55,8 @@ |
||
55 | 55 | $review = glsr_get_review($post); |
56 | 56 | if ('publish' == $post->post_status) { |
57 | 57 | glsr(CountsManager::class)->increase($review); |
58 | - } else { |
|
58 | + } |
|
59 | + else { |
|
59 | 60 | glsr(CountsManager::class)->decrease($review); |
60 | 61 | } |
61 | 62 | } |
@@ -11,139 +11,139 @@ |
||
11 | 11 | |
12 | 12 | class ReviewController extends Controller |
13 | 13 | { |
14 | - /** |
|
15 | - * @param int $postId |
|
16 | - * @param array $terms |
|
17 | - * @param array $newTTIds |
|
18 | - * @param string $taxonomy |
|
19 | - * @param bool $append |
|
20 | - * @param array $oldTTIds |
|
21 | - * @return void |
|
22 | - * @action set_object_terms |
|
23 | - */ |
|
24 | - public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
25 | - { |
|
26 | - sort($newTTIds); |
|
27 | - sort($oldTTIds); |
|
28 | - if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) { |
|
29 | - return; |
|
30 | - } |
|
31 | - $review = glsr_get_review($postId); |
|
32 | - $ignoredIds = array_intersect($oldTTIds, $newTTIds); |
|
33 | - $decreasedIds = array_diff($oldTTIds, $ignoredIds); |
|
34 | - $increasedIds = array_diff($newTTIds, $ignoredIds); |
|
35 | - if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) { |
|
36 | - glsr(CountsManager::class)->decreaseTermCounts($review); |
|
37 | - } |
|
38 | - if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) { |
|
39 | - glsr(CountsManager::class)->increaseTermCounts($review); |
|
40 | - } |
|
41 | - } |
|
14 | + /** |
|
15 | + * @param int $postId |
|
16 | + * @param array $terms |
|
17 | + * @param array $newTTIds |
|
18 | + * @param string $taxonomy |
|
19 | + * @param bool $append |
|
20 | + * @param array $oldTTIds |
|
21 | + * @return void |
|
22 | + * @action set_object_terms |
|
23 | + */ |
|
24 | + public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
25 | + { |
|
26 | + sort($newTTIds); |
|
27 | + sort($oldTTIds); |
|
28 | + if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) { |
|
29 | + return; |
|
30 | + } |
|
31 | + $review = glsr_get_review($postId); |
|
32 | + $ignoredIds = array_intersect($oldTTIds, $newTTIds); |
|
33 | + $decreasedIds = array_diff($oldTTIds, $ignoredIds); |
|
34 | + $increasedIds = array_diff($newTTIds, $ignoredIds); |
|
35 | + if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) { |
|
36 | + glsr(CountsManager::class)->decreaseTermCounts($review); |
|
37 | + } |
|
38 | + if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) { |
|
39 | + glsr(CountsManager::class)->increaseTermCounts($review); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $oldStatus |
|
45 | - * @param string $newStatus |
|
46 | - * @param WP_Post $post |
|
47 | - * @return void |
|
48 | - * @action transition_post_status |
|
49 | - */ |
|
50 | - public function onAfterChangeStatus($newStatus, $oldStatus, $post) |
|
51 | - { |
|
52 | - if (Application::POST_TYPE != glsr_get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) { |
|
53 | - return; |
|
54 | - } |
|
55 | - $review = glsr_get_review($post); |
|
56 | - if ('publish' == $post->post_status) { |
|
57 | - glsr(CountsManager::class)->increase($review); |
|
58 | - } else { |
|
59 | - glsr(CountsManager::class)->decrease($review); |
|
60 | - } |
|
61 | - } |
|
43 | + /** |
|
44 | + * @param string $oldStatus |
|
45 | + * @param string $newStatus |
|
46 | + * @param WP_Post $post |
|
47 | + * @return void |
|
48 | + * @action transition_post_status |
|
49 | + */ |
|
50 | + public function onAfterChangeStatus($newStatus, $oldStatus, $post) |
|
51 | + { |
|
52 | + if (Application::POST_TYPE != glsr_get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) { |
|
53 | + return; |
|
54 | + } |
|
55 | + $review = glsr_get_review($post); |
|
56 | + if ('publish' == $post->post_status) { |
|
57 | + glsr(CountsManager::class)->increase($review); |
|
58 | + } else { |
|
59 | + glsr(CountsManager::class)->decrease($review); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return void |
|
65 | - * @action site-reviews/review/created |
|
66 | - */ |
|
67 | - public function onAfterCreate(Review $review) |
|
68 | - { |
|
69 | - if ('publish' !== $review->status) { |
|
70 | - return; |
|
71 | - } |
|
72 | - glsr(CountsManager::class)->increaseCounts($review); |
|
73 | - glsr(CountsManager::class)->increasePostCounts($review); |
|
74 | - } |
|
63 | + /** |
|
64 | + * @return void |
|
65 | + * @action site-reviews/review/created |
|
66 | + */ |
|
67 | + public function onAfterCreate(Review $review) |
|
68 | + { |
|
69 | + if ('publish' !== $review->status) { |
|
70 | + return; |
|
71 | + } |
|
72 | + glsr(CountsManager::class)->increaseCounts($review); |
|
73 | + glsr(CountsManager::class)->increasePostCounts($review); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param int $postId |
|
78 | - * @return void |
|
79 | - * @action before_delete_post |
|
80 | - */ |
|
81 | - public function onBeforeDelete($postId) |
|
82 | - { |
|
83 | - if (!$this->isReviewPostId($postId)) { |
|
84 | - return; |
|
85 | - } |
|
86 | - $review = glsr_get_review($postId); |
|
87 | - if ('trash' !== $review->status) { // do not run for trashed posts |
|
88 | - glsr(CountsManager::class)->decrease($review); |
|
89 | - } |
|
90 | - } |
|
76 | + /** |
|
77 | + * @param int $postId |
|
78 | + * @return void |
|
79 | + * @action before_delete_post |
|
80 | + */ |
|
81 | + public function onBeforeDelete($postId) |
|
82 | + { |
|
83 | + if (!$this->isReviewPostId($postId)) { |
|
84 | + return; |
|
85 | + } |
|
86 | + $review = glsr_get_review($postId); |
|
87 | + if ('trash' !== $review->status) { // do not run for trashed posts |
|
88 | + glsr(CountsManager::class)->decrease($review); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @param int $metaId |
|
94 | - * @param int $postId |
|
95 | - * @param string $metaKey |
|
96 | - * @param mixed $metaValue |
|
97 | - * @return void |
|
98 | - * @action update_postmeta |
|
99 | - */ |
|
100 | - public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue) |
|
101 | - { |
|
102 | - if (!$this->isReviewPostId($postId)) { |
|
103 | - return; |
|
104 | - } |
|
105 | - $metaKey = glsr(Helper::class)->removePrefix('_', $metaKey); |
|
106 | - if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) { |
|
107 | - return; |
|
108 | - } |
|
109 | - $review = glsr_get_review($postId); |
|
110 | - if ($review->$metaKey == $metaValue) { |
|
111 | - return; |
|
112 | - } |
|
113 | - $method = glsr(Helper::class)->buildMethodName($metaKey, 'onBeforeChange'); |
|
114 | - call_user_func([$this, $method], $review, $metaValue); |
|
115 | - } |
|
92 | + /** |
|
93 | + * @param int $metaId |
|
94 | + * @param int $postId |
|
95 | + * @param string $metaKey |
|
96 | + * @param mixed $metaValue |
|
97 | + * @return void |
|
98 | + * @action update_postmeta |
|
99 | + */ |
|
100 | + public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue) |
|
101 | + { |
|
102 | + if (!$this->isReviewPostId($postId)) { |
|
103 | + return; |
|
104 | + } |
|
105 | + $metaKey = glsr(Helper::class)->removePrefix('_', $metaKey); |
|
106 | + if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) { |
|
107 | + return; |
|
108 | + } |
|
109 | + $review = glsr_get_review($postId); |
|
110 | + if ($review->$metaKey == $metaValue) { |
|
111 | + return; |
|
112 | + } |
|
113 | + $method = glsr(Helper::class)->buildMethodName($metaKey, 'onBeforeChange'); |
|
114 | + call_user_func([$this, $method], $review, $metaValue); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * @param string|int $assignedTo |
|
119 | - * @return void |
|
120 | - */ |
|
121 | - public function onBeforeChangeAssignedTo(Review $review, $assignedTo) |
|
122 | - { |
|
123 | - glsr(CountsManager::class)->decreasePostCounts($review); |
|
124 | - $review->assigned_to = $assignedTo; |
|
125 | - glsr(CountsManager::class)->increasePostCounts($review); |
|
126 | - } |
|
117 | + /** |
|
118 | + * @param string|int $assignedTo |
|
119 | + * @return void |
|
120 | + */ |
|
121 | + public function onBeforeChangeAssignedTo(Review $review, $assignedTo) |
|
122 | + { |
|
123 | + glsr(CountsManager::class)->decreasePostCounts($review); |
|
124 | + $review->assigned_to = $assignedTo; |
|
125 | + glsr(CountsManager::class)->increasePostCounts($review); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * @param string|int $rating |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - public function onBeforeChangeRating(Review $review, $rating) |
|
133 | - { |
|
134 | - glsr(CountsManager::class)->decrease($review); |
|
135 | - $review->rating = $rating; |
|
136 | - glsr(CountsManager::class)->increase($review); |
|
137 | - } |
|
128 | + /** |
|
129 | + * @param string|int $rating |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + public function onBeforeChangeRating(Review $review, $rating) |
|
133 | + { |
|
134 | + glsr(CountsManager::class)->decrease($review); |
|
135 | + $review->rating = $rating; |
|
136 | + glsr(CountsManager::class)->increase($review); |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * @param string $reviewType |
|
141 | - * @return void |
|
142 | - */ |
|
143 | - public function onBeforeChangeReviewType(Review $review, $reviewType) |
|
144 | - { |
|
145 | - glsr(CountsManager::class)->decrease($review); |
|
146 | - $review->review_type = $reviewType; |
|
147 | - glsr(CountsManager::class)->increase($review); |
|
148 | - } |
|
139 | + /** |
|
140 | + * @param string $reviewType |
|
141 | + * @return void |
|
142 | + */ |
|
143 | + public function onBeforeChangeReviewType(Review $review, $reviewType) |
|
144 | + { |
|
145 | + glsr(CountsManager::class)->decrease($review); |
|
146 | + $review->review_type = $reviewType; |
|
147 | + glsr(CountsManager::class)->increase($review); |
|
148 | + } |
|
149 | 149 | } |
@@ -21,22 +21,22 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | * @action set_object_terms |
23 | 23 | */ |
24 | - public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
24 | + public function onAfterChangeCategory( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds ) |
|
25 | 25 | { |
26 | - sort($newTTIds); |
|
27 | - sort($oldTTIds); |
|
28 | - if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) { |
|
26 | + sort( $newTTIds ); |
|
27 | + sort( $oldTTIds ); |
|
28 | + if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId ) ) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | - $review = glsr_get_review($postId); |
|
32 | - $ignoredIds = array_intersect($oldTTIds, $newTTIds); |
|
33 | - $decreasedIds = array_diff($oldTTIds, $ignoredIds); |
|
34 | - $increasedIds = array_diff($newTTIds, $ignoredIds); |
|
35 | - if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) { |
|
36 | - glsr(CountsManager::class)->decreaseTermCounts($review); |
|
31 | + $review = glsr_get_review( $postId ); |
|
32 | + $ignoredIds = array_intersect( $oldTTIds, $newTTIds ); |
|
33 | + $decreasedIds = array_diff( $oldTTIds, $ignoredIds ); |
|
34 | + $increasedIds = array_diff( $newTTIds, $ignoredIds ); |
|
35 | + if( $review->term_ids = glsr( Database::class )->getTermIds( $decreasedIds, 'term_taxonomy_id' ) ) { |
|
36 | + glsr( CountsManager::class )->decreaseTermCounts( $review ); |
|
37 | 37 | } |
38 | - if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) { |
|
39 | - glsr(CountsManager::class)->increaseTermCounts($review); |
|
38 | + if( $review->term_ids = glsr( Database::class )->getTermIds( $increasedIds, 'term_taxonomy_id' ) ) { |
|
39 | + glsr( CountsManager::class )->increaseTermCounts( $review ); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | * @return void |
48 | 48 | * @action transition_post_status |
49 | 49 | */ |
50 | - public function onAfterChangeStatus($newStatus, $oldStatus, $post) |
|
50 | + public function onAfterChangeStatus( $newStatus, $oldStatus, $post ) |
|
51 | 51 | { |
52 | - if (Application::POST_TYPE != glsr_get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) { |
|
52 | + if( Application::POST_TYPE != glsr_get( $post, 'post_type' ) || in_array( $oldStatus, ['new', $newStatus] ) ) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | - $review = glsr_get_review($post); |
|
56 | - if ('publish' == $post->post_status) { |
|
57 | - glsr(CountsManager::class)->increase($review); |
|
55 | + $review = glsr_get_review( $post ); |
|
56 | + if( 'publish' == $post->post_status ) { |
|
57 | + glsr( CountsManager::class )->increase( $review ); |
|
58 | 58 | } else { |
59 | - glsr(CountsManager::class)->decrease($review); |
|
59 | + glsr( CountsManager::class )->decrease( $review ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | * @return void |
65 | 65 | * @action site-reviews/review/created |
66 | 66 | */ |
67 | - public function onAfterCreate(Review $review) |
|
67 | + public function onAfterCreate( Review $review ) |
|
68 | 68 | { |
69 | - if ('publish' !== $review->status) { |
|
69 | + if( 'publish' !== $review->status ) { |
|
70 | 70 | return; |
71 | 71 | } |
72 | - glsr(CountsManager::class)->increaseCounts($review); |
|
73 | - glsr(CountsManager::class)->increasePostCounts($review); |
|
72 | + glsr( CountsManager::class )->increaseCounts( $review ); |
|
73 | + glsr( CountsManager::class )->increasePostCounts( $review ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * @return void |
79 | 79 | * @action before_delete_post |
80 | 80 | */ |
81 | - public function onBeforeDelete($postId) |
|
81 | + public function onBeforeDelete( $postId ) |
|
82 | 82 | { |
83 | - if (!$this->isReviewPostId($postId)) { |
|
83 | + if( !$this->isReviewPostId( $postId ) ) { |
|
84 | 84 | return; |
85 | 85 | } |
86 | - $review = glsr_get_review($postId); |
|
87 | - if ('trash' !== $review->status) { // do not run for trashed posts |
|
88 | - glsr(CountsManager::class)->decrease($review); |
|
86 | + $review = glsr_get_review( $postId ); |
|
87 | + if( 'trash' !== $review->status ) { // do not run for trashed posts |
|
88 | + glsr( CountsManager::class )->decrease( $review ); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -97,53 +97,53 @@ discard block |
||
97 | 97 | * @return void |
98 | 98 | * @action update_postmeta |
99 | 99 | */ |
100 | - public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue) |
|
100 | + public function onBeforeUpdate( $metaId, $postId, $metaKey, $metaValue ) |
|
101 | 101 | { |
102 | - if (!$this->isReviewPostId($postId)) { |
|
102 | + if( !$this->isReviewPostId( $postId ) ) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | - $metaKey = glsr(Helper::class)->removePrefix('_', $metaKey); |
|
106 | - if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) { |
|
105 | + $metaKey = glsr( Helper::class )->removePrefix( '_', $metaKey ); |
|
106 | + if( !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) ) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | - $review = glsr_get_review($postId); |
|
110 | - if ($review->$metaKey == $metaValue) { |
|
109 | + $review = glsr_get_review( $postId ); |
|
110 | + if( $review->$metaKey == $metaValue ) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | - $method = glsr(Helper::class)->buildMethodName($metaKey, 'onBeforeChange'); |
|
114 | - call_user_func([$this, $method], $review, $metaValue); |
|
113 | + $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
|
114 | + call_user_func( [$this, $method], $review, $metaValue ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @param string|int $assignedTo |
119 | 119 | * @return void |
120 | 120 | */ |
121 | - public function onBeforeChangeAssignedTo(Review $review, $assignedTo) |
|
121 | + public function onBeforeChangeAssignedTo( Review $review, $assignedTo ) |
|
122 | 122 | { |
123 | - glsr(CountsManager::class)->decreasePostCounts($review); |
|
123 | + glsr( CountsManager::class )->decreasePostCounts( $review ); |
|
124 | 124 | $review->assigned_to = $assignedTo; |
125 | - glsr(CountsManager::class)->increasePostCounts($review); |
|
125 | + glsr( CountsManager::class )->increasePostCounts( $review ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
129 | 129 | * @param string|int $rating |
130 | 130 | * @return void |
131 | 131 | */ |
132 | - public function onBeforeChangeRating(Review $review, $rating) |
|
132 | + public function onBeforeChangeRating( Review $review, $rating ) |
|
133 | 133 | { |
134 | - glsr(CountsManager::class)->decrease($review); |
|
134 | + glsr( CountsManager::class )->decrease( $review ); |
|
135 | 135 | $review->rating = $rating; |
136 | - glsr(CountsManager::class)->increase($review); |
|
136 | + glsr( CountsManager::class )->increase( $review ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | 140 | * @param string $reviewType |
141 | 141 | * @return void |
142 | 142 | */ |
143 | - public function onBeforeChangeReviewType(Review $review, $reviewType) |
|
143 | + public function onBeforeChangeReviewType( Review $review, $reviewType ) |
|
144 | 144 | { |
145 | - glsr(CountsManager::class)->decrease($review); |
|
145 | + glsr( CountsManager::class )->decrease( $review ); |
|
146 | 146 | $review->review_type = $reviewType; |
147 | - glsr(CountsManager::class)->increase($review); |
|
147 | + glsr( CountsManager::class )->increase( $review ); |
|
148 | 148 | } |
149 | 149 | } |
@@ -8,99 +8,99 @@ |
||
8 | 8 | |
9 | 9 | class WelcomeController extends Controller |
10 | 10 | { |
11 | - /** |
|
12 | - * @return array |
|
13 | - * @filter plugin_action_links_site-reviews/site-reviews.php |
|
14 | - */ |
|
15 | - public function filterActionLinks(array $links) |
|
16 | - { |
|
17 | - $links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [ |
|
18 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'), |
|
19 | - ]); |
|
20 | - return $links; |
|
21 | - } |
|
11 | + /** |
|
12 | + * @return array |
|
13 | + * @filter plugin_action_links_site-reviews/site-reviews.php |
|
14 | + */ |
|
15 | + public function filterActionLinks(array $links) |
|
16 | + { |
|
17 | + $links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [ |
|
18 | + 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'), |
|
19 | + ]); |
|
20 | + return $links; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return string |
|
25 | - * @filter admin_title |
|
26 | - */ |
|
27 | - public function filterAdminTitle($title) |
|
28 | - { |
|
29 | - return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id |
|
30 | - ? sprintf(__('Welcome to %s — WordPress', 'site-reviews'), glsr()->name) |
|
31 | - : $title; |
|
32 | - } |
|
23 | + /** |
|
24 | + * @return string |
|
25 | + * @filter admin_title |
|
26 | + */ |
|
27 | + public function filterAdminTitle($title) |
|
28 | + { |
|
29 | + return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id |
|
30 | + ? sprintf(__('Welcome to %s — WordPress', 'site-reviews'), glsr()->name) |
|
31 | + : $title; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param string $text |
|
36 | - * @return string |
|
37 | - * @filter admin_footer_text |
|
38 | - */ |
|
39 | - public function filterFooterText($text) |
|
40 | - { |
|
41 | - if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) { |
|
42 | - return $text; |
|
43 | - } |
|
44 | - $url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post'; |
|
45 | - return wp_kses_post(sprintf( |
|
46 | - __('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'), |
|
47 | - '<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">★★★★★</a>', |
|
48 | - '<a href="'.$url.'" target="_blank">wordpress.org</a>' |
|
49 | - )); |
|
50 | - } |
|
34 | + /** |
|
35 | + * @param string $text |
|
36 | + * @return string |
|
37 | + * @filter admin_footer_text |
|
38 | + */ |
|
39 | + public function filterFooterText($text) |
|
40 | + { |
|
41 | + if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) { |
|
42 | + return $text; |
|
43 | + } |
|
44 | + $url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post'; |
|
45 | + return wp_kses_post(sprintf( |
|
46 | + __('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'), |
|
47 | + '<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">★★★★★</a>', |
|
48 | + '<a href="'.$url.'" target="_blank">wordpress.org</a>' |
|
49 | + )); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param string $plugin |
|
54 | - * @param bool $isNetworkActivation |
|
55 | - * @return void |
|
56 | - * @action activated_plugin |
|
57 | - */ |
|
58 | - public function redirectOnActivation($plugin, $isNetworkActivation) |
|
59 | - { |
|
60 | - if (!$isNetworkActivation |
|
61 | - && 'cli' !== php_sapi_name() |
|
62 | - && $plugin === plugin_basename(glsr()->file)) { |
|
63 | - wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome')); |
|
64 | - exit; |
|
65 | - } |
|
66 | - } |
|
52 | + /** |
|
53 | + * @param string $plugin |
|
54 | + * @param bool $isNetworkActivation |
|
55 | + * @return void |
|
56 | + * @action activated_plugin |
|
57 | + */ |
|
58 | + public function redirectOnActivation($plugin, $isNetworkActivation) |
|
59 | + { |
|
60 | + if (!$isNetworkActivation |
|
61 | + && 'cli' !== php_sapi_name() |
|
62 | + && $plugin === plugin_basename(glsr()->file)) { |
|
63 | + wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome')); |
|
64 | + exit; |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return void |
|
70 | - * @action admin_menu |
|
71 | - */ |
|
72 | - public function registerPage() |
|
73 | - { |
|
74 | - add_submenu_page('edit.php?post_type='.Application::POST_TYPE, |
|
75 | - sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name), |
|
76 | - glsr()->name, |
|
77 | - glsr()->getPermission('welcome'), |
|
78 | - 'welcome', |
|
79 | - [$this, 'renderPage'] |
|
80 | - ); |
|
81 | - remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome'); |
|
82 | - } |
|
68 | + /** |
|
69 | + * @return void |
|
70 | + * @action admin_menu |
|
71 | + */ |
|
72 | + public function registerPage() |
|
73 | + { |
|
74 | + add_submenu_page('edit.php?post_type='.Application::POST_TYPE, |
|
75 | + sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name), |
|
76 | + glsr()->name, |
|
77 | + glsr()->getPermission('welcome'), |
|
78 | + 'welcome', |
|
79 | + [$this, 'renderPage'] |
|
80 | + ); |
|
81 | + remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome'); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return void |
|
86 | - * @see $this->registerPage() |
|
87 | - * @callback add_submenu_page |
|
88 | - */ |
|
89 | - public function renderPage() |
|
90 | - { |
|
91 | - $tabs = apply_filters('site-reviews/addon/welcome/tabs', [ |
|
92 | - 'getting-started' => __('Getting Started', 'site-reviews'), |
|
93 | - 'whatsnew' => __('What\'s New', 'site-reviews'), |
|
94 | - 'upgrade-guide' => __('Upgrade Guide', 'site-reviews'), |
|
95 | - 'support' => __('Support', 'site-reviews'), |
|
96 | - ]); |
|
97 | - glsr()->render('pages/welcome/index', [ |
|
98 | - 'data' => [ |
|
99 | - 'context' => [], |
|
100 | - ], |
|
101 | - 'http_referer' => (string) wp_get_referer(), |
|
102 | - 'tabs' => $tabs, |
|
103 | - 'template' => glsr(Template::class), |
|
104 | - ]); |
|
105 | - } |
|
84 | + /** |
|
85 | + * @return void |
|
86 | + * @see $this->registerPage() |
|
87 | + * @callback add_submenu_page |
|
88 | + */ |
|
89 | + public function renderPage() |
|
90 | + { |
|
91 | + $tabs = apply_filters('site-reviews/addon/welcome/tabs', [ |
|
92 | + 'getting-started' => __('Getting Started', 'site-reviews'), |
|
93 | + 'whatsnew' => __('What\'s New', 'site-reviews'), |
|
94 | + 'upgrade-guide' => __('Upgrade Guide', 'site-reviews'), |
|
95 | + 'support' => __('Support', 'site-reviews'), |
|
96 | + ]); |
|
97 | + glsr()->render('pages/welcome/index', [ |
|
98 | + 'data' => [ |
|
99 | + 'context' => [], |
|
100 | + ], |
|
101 | + 'http_referer' => (string) wp_get_referer(), |
|
102 | + 'tabs' => $tabs, |
|
103 | + 'template' => glsr(Template::class), |
|
104 | + ]); |
|
105 | + } |
|
106 | 106 | } |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | * @filter plugin_action_links_site-reviews/site-reviews.php |
14 | 14 | */ |
15 | - public function filterActionLinks(array $links) |
|
15 | + public function filterActionLinks( array $links ) |
|
16 | 16 | { |
17 | - $links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [ |
|
18 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'), |
|
19 | - ]); |
|
17 | + $links['welcome'] = glsr( Builder::class )->a( __( 'About', 'site-reviews' ), [ |
|
18 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=welcome' ), |
|
19 | + ] ); |
|
20 | 20 | return $links; |
21 | 21 | } |
22 | 22 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @return string |
25 | 25 | * @filter admin_title |
26 | 26 | */ |
27 | - public function filterAdminTitle($title) |
|
27 | + public function filterAdminTitle( $title ) |
|
28 | 28 | { |
29 | 29 | return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id |
30 | - ? sprintf(__('Welcome to %s — WordPress', 'site-reviews'), glsr()->name) |
|
30 | + ? sprintf( __( 'Welcome to %s — WordPress', 'site-reviews' ), glsr()->name ) |
|
31 | 31 | : $title; |
32 | 32 | } |
33 | 33 | |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | * @return string |
37 | 37 | * @filter admin_footer_text |
38 | 38 | */ |
39 | - public function filterFooterText($text) |
|
39 | + public function filterFooterText( $text ) |
|
40 | 40 | { |
41 | - if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) { |
|
41 | + if( Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id ) { |
|
42 | 42 | return $text; |
43 | 43 | } |
44 | 44 | $url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post'; |
45 | - return wp_kses_post(sprintf( |
|
46 | - __('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'), |
|
45 | + return wp_kses_post( sprintf( |
|
46 | + __( 'Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews' ), |
|
47 | 47 | '<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">★★★★★</a>', |
48 | 48 | '<a href="'.$url.'" target="_blank">wordpress.org</a>' |
49 | - )); |
|
49 | + ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * @return void |
56 | 56 | * @action activated_plugin |
57 | 57 | */ |
58 | - public function redirectOnActivation($plugin, $isNetworkActivation) |
|
58 | + public function redirectOnActivation( $plugin, $isNetworkActivation ) |
|
59 | 59 | { |
60 | - if (!$isNetworkActivation |
|
60 | + if( !$isNetworkActivation |
|
61 | 61 | && 'cli' !== php_sapi_name() |
62 | - && $plugin === plugin_basename(glsr()->file)) { |
|
63 | - wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome')); |
|
62 | + && $plugin === plugin_basename( glsr()->file ) ) { |
|
63 | + wp_safe_redirect( admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=welcome' ) ); |
|
64 | 64 | exit; |
65 | 65 | } |
66 | 66 | } |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function registerPage() |
73 | 73 | { |
74 | - add_submenu_page('edit.php?post_type='.Application::POST_TYPE, |
|
75 | - sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name), |
|
74 | + add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, |
|
75 | + sprintf( __( 'Welcome to %s', 'site-reviews' ), glsr()->name ), |
|
76 | 76 | glsr()->name, |
77 | - glsr()->getPermission('welcome'), |
|
77 | + glsr()->getPermission( 'welcome' ), |
|
78 | 78 | 'welcome', |
79 | 79 | [$this, 'renderPage'] |
80 | 80 | ); |
81 | - remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome'); |
|
81 | + remove_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, 'welcome' ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -88,19 +88,19 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function renderPage() |
90 | 90 | { |
91 | - $tabs = apply_filters('site-reviews/addon/welcome/tabs', [ |
|
92 | - 'getting-started' => __('Getting Started', 'site-reviews'), |
|
93 | - 'whatsnew' => __('What\'s New', 'site-reviews'), |
|
94 | - 'upgrade-guide' => __('Upgrade Guide', 'site-reviews'), |
|
95 | - 'support' => __('Support', 'site-reviews'), |
|
96 | - ]); |
|
97 | - glsr()->render('pages/welcome/index', [ |
|
91 | + $tabs = apply_filters( 'site-reviews/addon/welcome/tabs', [ |
|
92 | + 'getting-started' => __( 'Getting Started', 'site-reviews' ), |
|
93 | + 'whatsnew' => __( 'What\'s New', 'site-reviews' ), |
|
94 | + 'upgrade-guide' => __( 'Upgrade Guide', 'site-reviews' ), |
|
95 | + 'support' => __( 'Support', 'site-reviews' ), |
|
96 | + ] ); |
|
97 | + glsr()->render( 'pages/welcome/index', [ |
|
98 | 98 | 'data' => [ |
99 | 99 | 'context' => [], |
100 | 100 | ], |
101 | - 'http_referer' => (string) wp_get_referer(), |
|
101 | + 'http_referer' => (string)wp_get_referer(), |
|
102 | 102 | 'tabs' => $tabs, |
103 | - 'template' => glsr(Template::class), |
|
104 | - ]); |
|
103 | + 'template' => glsr( Template::class ), |
|
104 | + ] ); |
|
105 | 105 | } |
106 | 106 | } |
@@ -19,434 +19,434 @@ |
||
19 | 19 | |
20 | 20 | class EditorController extends Controller |
21 | 21 | { |
22 | - /** |
|
23 | - * @return void |
|
24 | - * @action admin_enqueue_scripts |
|
25 | - */ |
|
26 | - public function customizePostStatusLabels() |
|
27 | - { |
|
28 | - glsr(Labels::class)->customizePostStatusLabels(); |
|
29 | - } |
|
22 | + /** |
|
23 | + * @return void |
|
24 | + * @action admin_enqueue_scripts |
|
25 | + */ |
|
26 | + public function customizePostStatusLabels() |
|
27 | + { |
|
28 | + glsr(Labels::class)->customizePostStatusLabels(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param array $settings |
|
33 | - * @return array |
|
34 | - * @filter wp_editor_settings |
|
35 | - */ |
|
36 | - public function filterEditorSettings($settings) |
|
37 | - { |
|
38 | - return glsr(Customization::class)->filterEditorSettings( |
|
39 | - glsr(Helper::class)->consolidateArray($settings) |
|
40 | - ); |
|
41 | - } |
|
31 | + /** |
|
32 | + * @param array $settings |
|
33 | + * @return array |
|
34 | + * @filter wp_editor_settings |
|
35 | + */ |
|
36 | + public function filterEditorSettings($settings) |
|
37 | + { |
|
38 | + return glsr(Customization::class)->filterEditorSettings( |
|
39 | + glsr(Helper::class)->consolidateArray($settings) |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script. |
|
45 | - * @param string $html |
|
46 | - * @return string |
|
47 | - * @filter the_editor |
|
48 | - */ |
|
49 | - public function filterEditorTextarea($html) |
|
50 | - { |
|
51 | - return glsr(Customization::class)->filterEditorTextarea($html); |
|
52 | - } |
|
43 | + /** |
|
44 | + * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script. |
|
45 | + * @param string $html |
|
46 | + * @return string |
|
47 | + * @filter the_editor |
|
48 | + */ |
|
49 | + public function filterEditorTextarea($html) |
|
50 | + { |
|
51 | + return glsr(Customization::class)->filterEditorTextarea($html); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param bool $protected |
|
56 | - * @param string $metaKey |
|
57 | - * @param string $metaType |
|
58 | - * @return bool |
|
59 | - * @filter is_protected_meta |
|
60 | - */ |
|
61 | - public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
62 | - { |
|
63 | - if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
64 | - $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
65 | - $values = glsr(Helper::class)->prefixArrayKeys($values); |
|
66 | - if (array_key_exists($metaKey, $values)) { |
|
67 | - $protected = false; |
|
68 | - } |
|
69 | - } |
|
70 | - return $protected; |
|
71 | - } |
|
54 | + /** |
|
55 | + * @param bool $protected |
|
56 | + * @param string $metaKey |
|
57 | + * @param string $metaType |
|
58 | + * @return bool |
|
59 | + * @filter is_protected_meta |
|
60 | + */ |
|
61 | + public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
62 | + { |
|
63 | + if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
64 | + $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
65 | + $values = glsr(Helper::class)->prefixArrayKeys($values); |
|
66 | + if (array_key_exists($metaKey, $values)) { |
|
67 | + $protected = false; |
|
68 | + } |
|
69 | + } |
|
70 | + return $protected; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param string $translation |
|
75 | - * @param string $test |
|
76 | - * @param string $domain |
|
77 | - * @return string |
|
78 | - * @filter gettext |
|
79 | - */ |
|
80 | - public function filterPostStatusLabels($translation, $text, $domain) |
|
81 | - { |
|
82 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
83 | - } |
|
73 | + /** |
|
74 | + * @param string $translation |
|
75 | + * @param string $test |
|
76 | + * @param string $domain |
|
77 | + * @return string |
|
78 | + * @filter gettext |
|
79 | + */ |
|
80 | + public function filterPostStatusLabels($translation, $text, $domain) |
|
81 | + { |
|
82 | + return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $translation |
|
87 | - * @param string $test |
|
88 | - * @param string $domain |
|
89 | - * @return string |
|
90 | - * @filter gettext_with_context |
|
91 | - */ |
|
92 | - public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain) |
|
93 | - { |
|
94 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
95 | - } |
|
85 | + /** |
|
86 | + * @param string $translation |
|
87 | + * @param string $test |
|
88 | + * @param string $domain |
|
89 | + * @return string |
|
90 | + * @filter gettext_with_context |
|
91 | + */ |
|
92 | + public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain) |
|
93 | + { |
|
94 | + return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * @param array $messages |
|
99 | - * @return array |
|
100 | - * @filter post_updated_messages |
|
101 | - */ |
|
102 | - public function filterUpdateMessages($messages) |
|
103 | - { |
|
104 | - return glsr(Labels::class)->filterUpdateMessages( |
|
105 | - glsr(Helper::class)->consolidateArray($messages) |
|
106 | - ); |
|
107 | - } |
|
97 | + /** |
|
98 | + * @param array $messages |
|
99 | + * @return array |
|
100 | + * @filter post_updated_messages |
|
101 | + */ |
|
102 | + public function filterUpdateMessages($messages) |
|
103 | + { |
|
104 | + return glsr(Labels::class)->filterUpdateMessages( |
|
105 | + glsr(Helper::class)->consolidateArray($messages) |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @return void |
|
111 | - * @action add_meta_boxes_{Application::POST_TYPE} |
|
112 | - */ |
|
113 | - public function registerMetaBoxes($post) |
|
114 | - { |
|
115 | - add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
116 | - add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
117 | - if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
118 | - return; |
|
119 | - } |
|
120 | - add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
121 | - } |
|
109 | + /** |
|
110 | + * @return void |
|
111 | + * @action add_meta_boxes_{Application::POST_TYPE} |
|
112 | + */ |
|
113 | + public function registerMetaBoxes($post) |
|
114 | + { |
|
115 | + add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
116 | + add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
117 | + if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
118 | + return; |
|
119 | + } |
|
120 | + add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @return void |
|
125 | - * @action admin_print_scripts |
|
126 | - */ |
|
127 | - public function removeAutosave() |
|
128 | - { |
|
129 | - glsr(Customization::class)->removeAutosave(); |
|
130 | - } |
|
123 | + /** |
|
124 | + * @return void |
|
125 | + * @action admin_print_scripts |
|
126 | + */ |
|
127 | + public function removeAutosave() |
|
128 | + { |
|
129 | + glsr(Customization::class)->removeAutosave(); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @return void |
|
134 | - * @action admin_menu |
|
135 | - */ |
|
136 | - public function removeMetaBoxes() |
|
137 | - { |
|
138 | - glsr(Customization::class)->removeMetaBoxes(); |
|
139 | - } |
|
132 | + /** |
|
133 | + * @return void |
|
134 | + * @action admin_menu |
|
135 | + */ |
|
136 | + public function removeMetaBoxes() |
|
137 | + { |
|
138 | + glsr(Customization::class)->removeMetaBoxes(); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * @return void |
|
143 | - */ |
|
144 | - public function removePostTypeSupport() |
|
145 | - { |
|
146 | - glsr(Customization::class)->removePostTypeSupport(); |
|
147 | - } |
|
141 | + /** |
|
142 | + * @return void |
|
143 | + */ |
|
144 | + public function removePostTypeSupport() |
|
145 | + { |
|
146 | + glsr(Customization::class)->removePostTypeSupport(); |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @param WP_Post $post |
|
151 | - * @return void |
|
152 | - * @callback add_meta_box |
|
153 | - */ |
|
154 | - public function renderAssignedToMetabox($post) |
|
155 | - { |
|
156 | - if (!$this->isReviewPostType($post)) { |
|
157 | - return; |
|
158 | - } |
|
159 | - $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
160 | - wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
161 | - glsr()->render('partials/editor/metabox-assigned-to', [ |
|
162 | - 'id' => $assignedTo, |
|
163 | - 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
164 | - ]); |
|
165 | - } |
|
149 | + /** |
|
150 | + * @param WP_Post $post |
|
151 | + * @return void |
|
152 | + * @callback add_meta_box |
|
153 | + */ |
|
154 | + public function renderAssignedToMetabox($post) |
|
155 | + { |
|
156 | + if (!$this->isReviewPostType($post)) { |
|
157 | + return; |
|
158 | + } |
|
159 | + $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
160 | + wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
161 | + glsr()->render('partials/editor/metabox-assigned-to', [ |
|
162 | + 'id' => $assignedTo, |
|
163 | + 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
164 | + ]); |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @param WP_Post $post |
|
169 | - * @return void |
|
170 | - * @callback add_meta_box |
|
171 | - */ |
|
172 | - public function renderDetailsMetaBox($post) |
|
173 | - { |
|
174 | - if (!$this->isReviewPostType($post)) { |
|
175 | - return; |
|
176 | - } |
|
177 | - $review = glsr_get_review($post); |
|
178 | - glsr()->render('partials/editor/metabox-details', [ |
|
179 | - 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
180 | - 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
181 | - ]); |
|
182 | - } |
|
167 | + /** |
|
168 | + * @param WP_Post $post |
|
169 | + * @return void |
|
170 | + * @callback add_meta_box |
|
171 | + */ |
|
172 | + public function renderDetailsMetaBox($post) |
|
173 | + { |
|
174 | + if (!$this->isReviewPostType($post)) { |
|
175 | + return; |
|
176 | + } |
|
177 | + $review = glsr_get_review($post); |
|
178 | + glsr()->render('partials/editor/metabox-details', [ |
|
179 | + 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
180 | + 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
181 | + ]); |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * @return void |
|
186 | - * @action post_submitbox_misc_actions |
|
187 | - */ |
|
188 | - public function renderPinnedInPublishMetaBox() |
|
189 | - { |
|
190 | - if (!$this->isReviewPostType(get_post())) { |
|
191 | - return; |
|
192 | - } |
|
193 | - glsr(Template::class)->render('partials/editor/pinned', [ |
|
194 | - 'context' => [ |
|
195 | - 'no' => __('No', 'site-reviews'), |
|
196 | - 'yes' => __('Yes', 'site-reviews'), |
|
197 | - ], |
|
198 | - 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
199 | - ]); |
|
200 | - } |
|
184 | + /** |
|
185 | + * @return void |
|
186 | + * @action post_submitbox_misc_actions |
|
187 | + */ |
|
188 | + public function renderPinnedInPublishMetaBox() |
|
189 | + { |
|
190 | + if (!$this->isReviewPostType(get_post())) { |
|
191 | + return; |
|
192 | + } |
|
193 | + glsr(Template::class)->render('partials/editor/pinned', [ |
|
194 | + 'context' => [ |
|
195 | + 'no' => __('No', 'site-reviews'), |
|
196 | + 'yes' => __('Yes', 'site-reviews'), |
|
197 | + ], |
|
198 | + 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
199 | + ]); |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * @param WP_Post $post |
|
204 | - * @return void |
|
205 | - * @callback add_meta_box |
|
206 | - */ |
|
207 | - public function renderResponseMetaBox($post) |
|
208 | - { |
|
209 | - if (!$this->isReviewPostType($post)) { |
|
210 | - return; |
|
211 | - } |
|
212 | - wp_nonce_field('response', '_nonce-response', false); |
|
213 | - glsr()->render('partials/editor/metabox-response', [ |
|
214 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
215 | - ]); |
|
216 | - } |
|
202 | + /** |
|
203 | + * @param WP_Post $post |
|
204 | + * @return void |
|
205 | + * @callback add_meta_box |
|
206 | + */ |
|
207 | + public function renderResponseMetaBox($post) |
|
208 | + { |
|
209 | + if (!$this->isReviewPostType($post)) { |
|
210 | + return; |
|
211 | + } |
|
212 | + wp_nonce_field('response', '_nonce-response', false); |
|
213 | + glsr()->render('partials/editor/metabox-response', [ |
|
214 | + 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
215 | + ]); |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * @param WP_Post $post |
|
220 | - * @return void |
|
221 | - * @action edit_form_after_title |
|
222 | - */ |
|
223 | - public function renderReviewEditor($post) |
|
224 | - { |
|
225 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
226 | - return; |
|
227 | - } |
|
228 | - glsr()->render('partials/editor/review', [ |
|
229 | - 'post' => $post, |
|
230 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
231 | - ]); |
|
232 | - } |
|
218 | + /** |
|
219 | + * @param WP_Post $post |
|
220 | + * @return void |
|
221 | + * @action edit_form_after_title |
|
222 | + */ |
|
223 | + public function renderReviewEditor($post) |
|
224 | + { |
|
225 | + if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
226 | + return; |
|
227 | + } |
|
228 | + glsr()->render('partials/editor/review', [ |
|
229 | + 'post' => $post, |
|
230 | + 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
231 | + ]); |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * @return void |
|
236 | - * @action admin_head |
|
237 | - */ |
|
238 | - public function renderReviewFields() |
|
239 | - { |
|
240 | - $screen = glsr_current_screen(); |
|
241 | - if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
242 | - return; |
|
243 | - } |
|
244 | - add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
245 | - add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
246 | - } |
|
234 | + /** |
|
235 | + * @return void |
|
236 | + * @action admin_head |
|
237 | + */ |
|
238 | + public function renderReviewFields() |
|
239 | + { |
|
240 | + $screen = glsr_current_screen(); |
|
241 | + if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
242 | + return; |
|
243 | + } |
|
244 | + add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
245 | + add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * @param WP_Post $post |
|
250 | - * @return void |
|
251 | - * @action edit_form_top |
|
252 | - */ |
|
253 | - public function renderReviewNotice($post) |
|
254 | - { |
|
255 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
256 | - return; |
|
257 | - } |
|
258 | - glsr(Notice::class)->addWarning(sprintf( |
|
259 | - __('%s reviews are read-only.', 'site-reviews'), |
|
260 | - glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
261 | - )); |
|
262 | - glsr(Template::class)->render('partials/editor/notice', [ |
|
263 | - 'context' => [ |
|
264 | - 'notices' => glsr(Notice::class)->get(), |
|
265 | - ], |
|
266 | - ]); |
|
267 | - } |
|
248 | + /** |
|
249 | + * @param WP_Post $post |
|
250 | + * @return void |
|
251 | + * @action edit_form_top |
|
252 | + */ |
|
253 | + public function renderReviewNotice($post) |
|
254 | + { |
|
255 | + if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
256 | + return; |
|
257 | + } |
|
258 | + glsr(Notice::class)->addWarning(sprintf( |
|
259 | + __('%s reviews are read-only.', 'site-reviews'), |
|
260 | + glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
261 | + )); |
|
262 | + glsr(Template::class)->render('partials/editor/notice', [ |
|
263 | + 'context' => [ |
|
264 | + 'notices' => glsr(Notice::class)->get(), |
|
265 | + ], |
|
266 | + ]); |
|
267 | + } |
|
268 | 268 | |
269 | - /** |
|
270 | - * @param WP_Post $post |
|
271 | - * @return void |
|
272 | - * @see glsr_categories_meta_box() |
|
273 | - * @callback register_taxonomy |
|
274 | - */ |
|
275 | - public function renderTaxonomyMetabox($post) |
|
276 | - { |
|
277 | - if (!$this->isReviewPostType($post)) { |
|
278 | - return; |
|
279 | - } |
|
280 | - glsr()->render('partials/editor/metabox-categories', [ |
|
281 | - 'post' => $post, |
|
282 | - 'tax_name' => Application::TAXONOMY, |
|
283 | - 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
284 | - ]); |
|
285 | - } |
|
269 | + /** |
|
270 | + * @param WP_Post $post |
|
271 | + * @return void |
|
272 | + * @see glsr_categories_meta_box() |
|
273 | + * @callback register_taxonomy |
|
274 | + */ |
|
275 | + public function renderTaxonomyMetabox($post) |
|
276 | + { |
|
277 | + if (!$this->isReviewPostType($post)) { |
|
278 | + return; |
|
279 | + } |
|
280 | + glsr()->render('partials/editor/metabox-categories', [ |
|
281 | + 'post' => $post, |
|
282 | + 'tax_name' => Application::TAXONOMY, |
|
283 | + 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
284 | + ]); |
|
285 | + } |
|
286 | 286 | |
287 | - /** |
|
288 | - * @return void |
|
289 | - * @see $this->filterUpdateMessages() |
|
290 | - * @action admin_action_revert |
|
291 | - */ |
|
292 | - public function revertReview() |
|
293 | - { |
|
294 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
295 | - return; |
|
296 | - } |
|
297 | - check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
298 | - glsr(ReviewManager::class)->revert($postId); |
|
299 | - $this->redirect($postId, 52); |
|
300 | - } |
|
287 | + /** |
|
288 | + * @return void |
|
289 | + * @see $this->filterUpdateMessages() |
|
290 | + * @action admin_action_revert |
|
291 | + */ |
|
292 | + public function revertReview() |
|
293 | + { |
|
294 | + if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
295 | + return; |
|
296 | + } |
|
297 | + check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
298 | + glsr(ReviewManager::class)->revert($postId); |
|
299 | + $this->redirect($postId, 52); |
|
300 | + } |
|
301 | 301 | |
302 | - /** |
|
303 | - * @param int $postId |
|
304 | - * @param \WP_Post $post |
|
305 | - * @param bool $isUpdate |
|
306 | - * @return void |
|
307 | - * @action save_post_.Application::POST_TYPE |
|
308 | - */ |
|
309 | - public function saveMetaboxes($postId, $post, $isUpdating) |
|
310 | - { |
|
311 | - glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
312 | - glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
313 | - if ($isUpdating) { |
|
314 | - do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
315 | - } |
|
316 | - } |
|
302 | + /** |
|
303 | + * @param int $postId |
|
304 | + * @param \WP_Post $post |
|
305 | + * @param bool $isUpdate |
|
306 | + * @return void |
|
307 | + * @action save_post_.Application::POST_TYPE |
|
308 | + */ |
|
309 | + public function saveMetaboxes($postId, $post, $isUpdating) |
|
310 | + { |
|
311 | + glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
312 | + glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
313 | + if ($isUpdating) { |
|
314 | + do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
315 | + } |
|
316 | + } |
|
317 | 317 | |
318 | - /** |
|
319 | - * @param string $assignedTo |
|
320 | - * @return string |
|
321 | - */ |
|
322 | - protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
323 | - { |
|
324 | - $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
325 | - if (!($assignedPost instanceof WP_Post)) { |
|
326 | - return; |
|
327 | - } |
|
328 | - return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
329 | - 'context' => [ |
|
330 | - 'data.url' => (string) get_permalink($assignedPost), |
|
331 | - 'data.title' => get_the_title($assignedPost), |
|
332 | - ], |
|
333 | - ]); |
|
334 | - } |
|
318 | + /** |
|
319 | + * @param string $assignedTo |
|
320 | + * @return string |
|
321 | + */ |
|
322 | + protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
323 | + { |
|
324 | + $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
325 | + if (!($assignedPost instanceof WP_Post)) { |
|
326 | + return; |
|
327 | + } |
|
328 | + return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
329 | + 'context' => [ |
|
330 | + 'data.url' => (string) get_permalink($assignedPost), |
|
331 | + 'data.title' => get_the_title($assignedPost), |
|
332 | + ], |
|
333 | + ]); |
|
334 | + } |
|
335 | 335 | |
336 | - /** |
|
337 | - * @return string |
|
338 | - */ |
|
339 | - protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
340 | - { |
|
341 | - $isModified = !glsr(Helper::class)->compareArrays( |
|
342 | - [$review->title, $review->content, $review->date], |
|
343 | - [ |
|
344 | - glsr(Database::class)->get($post->ID, 'title'), |
|
345 | - glsr(Database::class)->get($post->ID, 'content'), |
|
346 | - glsr(Database::class)->get($post->ID, 'date'), |
|
347 | - ] |
|
348 | - ); |
|
349 | - if ($isModified) { |
|
350 | - $revertUrl = wp_nonce_url( |
|
351 | - admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
352 | - 'revert-review_'.$post->ID |
|
353 | - ); |
|
354 | - return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
355 | - 'class' => 'button button-large', |
|
356 | - 'href' => $revertUrl, |
|
357 | - 'id' => 'revert', |
|
358 | - ]); |
|
359 | - } |
|
360 | - return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
361 | - 'class' => 'button-large', |
|
362 | - 'disabled' => true, |
|
363 | - 'id' => 'revert', |
|
364 | - ]); |
|
365 | - } |
|
336 | + /** |
|
337 | + * @return string |
|
338 | + */ |
|
339 | + protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
340 | + { |
|
341 | + $isModified = !glsr(Helper::class)->compareArrays( |
|
342 | + [$review->title, $review->content, $review->date], |
|
343 | + [ |
|
344 | + glsr(Database::class)->get($post->ID, 'title'), |
|
345 | + glsr(Database::class)->get($post->ID, 'content'), |
|
346 | + glsr(Database::class)->get($post->ID, 'date'), |
|
347 | + ] |
|
348 | + ); |
|
349 | + if ($isModified) { |
|
350 | + $revertUrl = wp_nonce_url( |
|
351 | + admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
352 | + 'revert-review_'.$post->ID |
|
353 | + ); |
|
354 | + return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
355 | + 'class' => 'button button-large', |
|
356 | + 'href' => $revertUrl, |
|
357 | + 'id' => 'revert', |
|
358 | + ]); |
|
359 | + } |
|
360 | + return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
361 | + 'class' => 'button-large', |
|
362 | + 'disabled' => true, |
|
363 | + 'id' => 'revert', |
|
364 | + ]); |
|
365 | + } |
|
366 | 366 | |
367 | - /** |
|
368 | - * @param object $review |
|
369 | - * @return string|void |
|
370 | - */ |
|
371 | - protected function getReviewType($review) |
|
372 | - { |
|
373 | - if (count(glsr()->reviewTypes) < 2) { |
|
374 | - return; |
|
375 | - } |
|
376 | - $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
377 | - ? glsr()->reviewTypes[$review->review_type] |
|
378 | - : __('Unknown', 'site-reviews'); |
|
379 | - if (!empty($review->url)) { |
|
380 | - $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
381 | - 'href' => $review->url, |
|
382 | - 'target' => '_blank', |
|
383 | - ]); |
|
384 | - } |
|
385 | - return $reviewType; |
|
386 | - } |
|
367 | + /** |
|
368 | + * @param object $review |
|
369 | + * @return string|void |
|
370 | + */ |
|
371 | + protected function getReviewType($review) |
|
372 | + { |
|
373 | + if (count(glsr()->reviewTypes) < 2) { |
|
374 | + return; |
|
375 | + } |
|
376 | + $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
377 | + ? glsr()->reviewTypes[$review->review_type] |
|
378 | + : __('Unknown', 'site-reviews'); |
|
379 | + if (!empty($review->url)) { |
|
380 | + $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
381 | + 'href' => $review->url, |
|
382 | + 'target' => '_blank', |
|
383 | + ]); |
|
384 | + } |
|
385 | + return $reviewType; |
|
386 | + } |
|
387 | 387 | |
388 | - /** |
|
389 | - * @return bool |
|
390 | - */ |
|
391 | - protected function isReviewEditable($post) |
|
392 | - { |
|
393 | - return $this->isReviewPostType($post) |
|
394 | - && post_type_supports(Application::POST_TYPE, 'title') |
|
395 | - && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
396 | - } |
|
388 | + /** |
|
389 | + * @return bool |
|
390 | + */ |
|
391 | + protected function isReviewEditable($post) |
|
392 | + { |
|
393 | + return $this->isReviewPostType($post) |
|
394 | + && post_type_supports(Application::POST_TYPE, 'title') |
|
395 | + && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
396 | + } |
|
397 | 397 | |
398 | - /** |
|
399 | - * @param mixed $post |
|
400 | - * @return bool |
|
401 | - */ |
|
402 | - protected function isReviewPostType($post) |
|
403 | - { |
|
404 | - return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
|
405 | - } |
|
398 | + /** |
|
399 | + * @param mixed $post |
|
400 | + * @return bool |
|
401 | + */ |
|
402 | + protected function isReviewPostType($post) |
|
403 | + { |
|
404 | + return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
|
405 | + } |
|
406 | 406 | |
407 | - /** |
|
408 | - * @return array |
|
409 | - */ |
|
410 | - protected function normalizeDetailsMetaBox(Review $review) |
|
411 | - { |
|
412 | - $user = empty($review->user_id) |
|
413 | - ? __('Unregistered user', 'site-reviews') |
|
414 | - : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
415 | - 'href' => get_author_posts_url($review->user_id), |
|
416 | - ]); |
|
417 | - $email = empty($review->email) |
|
418 | - ? '—' |
|
419 | - : glsr(Builder::class)->a($review->email, [ |
|
420 | - 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
421 | - ]); |
|
422 | - $metabox = [ |
|
423 | - __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
424 | - __('Type', 'site-reviews') => $this->getReviewType($review), |
|
425 | - __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
426 | - __('Name', 'site-reviews') => $review->author, |
|
427 | - __('Email', 'site-reviews') => $email, |
|
428 | - __('User', 'site-reviews') => $user, |
|
429 | - __('IP Address', 'site-reviews') => $review->ip_address, |
|
430 | - __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
431 | - ]; |
|
432 | - return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
433 | - } |
|
407 | + /** |
|
408 | + * @return array |
|
409 | + */ |
|
410 | + protected function normalizeDetailsMetaBox(Review $review) |
|
411 | + { |
|
412 | + $user = empty($review->user_id) |
|
413 | + ? __('Unregistered user', 'site-reviews') |
|
414 | + : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
415 | + 'href' => get_author_posts_url($review->user_id), |
|
416 | + ]); |
|
417 | + $email = empty($review->email) |
|
418 | + ? '—' |
|
419 | + : glsr(Builder::class)->a($review->email, [ |
|
420 | + 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
421 | + ]); |
|
422 | + $metabox = [ |
|
423 | + __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
424 | + __('Type', 'site-reviews') => $this->getReviewType($review), |
|
425 | + __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
426 | + __('Name', 'site-reviews') => $review->author, |
|
427 | + __('Email', 'site-reviews') => $email, |
|
428 | + __('User', 'site-reviews') => $user, |
|
429 | + __('IP Address', 'site-reviews') => $review->ip_address, |
|
430 | + __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
431 | + ]; |
|
432 | + return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
433 | + } |
|
434 | 434 | |
435 | - /** |
|
436 | - * @param int $postId |
|
437 | - * @param int $messageIndex |
|
438 | - * @return void |
|
439 | - */ |
|
440 | - protected function redirect($postId, $messageIndex) |
|
441 | - { |
|
442 | - $referer = wp_get_referer(); |
|
443 | - $hasReferer = !$referer |
|
444 | - || false !== strpos($referer, 'post.php') |
|
445 | - || false !== strpos($referer, 'post-new.php'); |
|
446 | - $redirectUri = $hasReferer |
|
447 | - ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
448 | - : get_edit_post_link($postId); |
|
449 | - wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
450 | - exit; |
|
451 | - } |
|
435 | + /** |
|
436 | + * @param int $postId |
|
437 | + * @param int $messageIndex |
|
438 | + * @return void |
|
439 | + */ |
|
440 | + protected function redirect($postId, $messageIndex) |
|
441 | + { |
|
442 | + $referer = wp_get_referer(); |
|
443 | + $hasReferer = !$referer |
|
444 | + || false !== strpos($referer, 'post.php') |
|
445 | + || false !== strpos($referer, 'post-new.php'); |
|
446 | + $redirectUri = $hasReferer |
|
447 | + ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
448 | + : get_edit_post_link($postId); |
|
449 | + wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
450 | + exit; |
|
451 | + } |
|
452 | 452 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function customizePostStatusLabels() |
27 | 27 | { |
28 | - glsr(Labels::class)->customizePostStatusLabels(); |
|
28 | + glsr( Labels::class )->customizePostStatusLabels(); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | * @return array |
34 | 34 | * @filter wp_editor_settings |
35 | 35 | */ |
36 | - public function filterEditorSettings($settings) |
|
36 | + public function filterEditorSettings( $settings ) |
|
37 | 37 | { |
38 | - return glsr(Customization::class)->filterEditorSettings( |
|
39 | - glsr(Helper::class)->consolidateArray($settings) |
|
38 | + return glsr( Customization::class )->filterEditorSettings( |
|
39 | + glsr( Helper::class )->consolidateArray( $settings ) |
|
40 | 40 | ); |
41 | 41 | } |
42 | 42 | |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @return string |
47 | 47 | * @filter the_editor |
48 | 48 | */ |
49 | - public function filterEditorTextarea($html) |
|
49 | + public function filterEditorTextarea( $html ) |
|
50 | 50 | { |
51 | - return glsr(Customization::class)->filterEditorTextarea($html); |
|
51 | + return glsr( Customization::class )->filterEditorTextarea( $html ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * @return bool |
59 | 59 | * @filter is_protected_meta |
60 | 60 | */ |
61 | - public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
61 | + public function filterIsProtectedMeta( $protected, $metaKey, $metaType ) |
|
62 | 62 | { |
63 | - if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
64 | - $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
65 | - $values = glsr(Helper::class)->prefixArrayKeys($values); |
|
66 | - if (array_key_exists($metaKey, $values)) { |
|
63 | + if( 'post' == $metaType && Application::POST_TYPE == get_post_type() ) { |
|
64 | + $values = glsr( CreateReviewDefaults::class )->unguarded(); |
|
65 | + $values = glsr( Helper::class )->prefixArrayKeys( $values ); |
|
66 | + if( array_key_exists( $metaKey, $values ) ) { |
|
67 | 67 | $protected = false; |
68 | 68 | } |
69 | 69 | } |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * @return string |
78 | 78 | * @filter gettext |
79 | 79 | */ |
80 | - public function filterPostStatusLabels($translation, $text, $domain) |
|
80 | + public function filterPostStatusLabels( $translation, $text, $domain ) |
|
81 | 81 | { |
82 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
82 | + return glsr( Labels::class )->filterPostStatusLabels( $translation, $text, $domain ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * @return string |
90 | 90 | * @filter gettext_with_context |
91 | 91 | */ |
92 | - public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain) |
|
92 | + public function filterPostStatusLabelsWithContext( $translation, $text, $context, $domain ) |
|
93 | 93 | { |
94 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
94 | + return glsr( Labels::class )->filterPostStatusLabels( $translation, $text, $domain ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * @return array |
100 | 100 | * @filter post_updated_messages |
101 | 101 | */ |
102 | - public function filterUpdateMessages($messages) |
|
102 | + public function filterUpdateMessages( $messages ) |
|
103 | 103 | { |
104 | - return glsr(Labels::class)->filterUpdateMessages( |
|
105 | - glsr(Helper::class)->consolidateArray($messages) |
|
104 | + return glsr( Labels::class )->filterUpdateMessages( |
|
105 | + glsr( Helper::class )->consolidateArray( $messages ) |
|
106 | 106 | ); |
107 | 107 | } |
108 | 108 | |
@@ -110,14 +110,14 @@ discard block |
||
110 | 110 | * @return void |
111 | 111 | * @action add_meta_boxes_{Application::POST_TYPE} |
112 | 112 | */ |
113 | - public function registerMetaBoxes($post) |
|
113 | + public function registerMetaBoxes( $post ) |
|
114 | 114 | { |
115 | - add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
116 | - add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
117 | - if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
115 | + add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
|
116 | + add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
|
117 | + if( 'local' != glsr( Database::class )->get( $post->ID, 'review_type' ) ) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | - add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
120 | + add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function removeAutosave() |
128 | 128 | { |
129 | - glsr(Customization::class)->removeAutosave(); |
|
129 | + glsr( Customization::class )->removeAutosave(); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function removeMetaBoxes() |
137 | 137 | { |
138 | - glsr(Customization::class)->removeMetaBoxes(); |
|
138 | + glsr( Customization::class )->removeMetaBoxes(); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function removePostTypeSupport() |
145 | 145 | { |
146 | - glsr(Customization::class)->removePostTypeSupport(); |
|
146 | + glsr( Customization::class )->removePostTypeSupport(); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | * @return void |
152 | 152 | * @callback add_meta_box |
153 | 153 | */ |
154 | - public function renderAssignedToMetabox($post) |
|
154 | + public function renderAssignedToMetabox( $post ) |
|
155 | 155 | { |
156 | - if (!$this->isReviewPostType($post)) { |
|
156 | + if( !$this->isReviewPostType( $post ) ) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | - $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
160 | - wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
161 | - glsr()->render('partials/editor/metabox-assigned-to', [ |
|
159 | + $assignedTo = (string)glsr( Database::class )->get( $post->ID, 'assigned_to' ); |
|
160 | + wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
|
161 | + glsr()->render( 'partials/editor/metabox-assigned-to', [ |
|
162 | 162 | 'id' => $assignedTo, |
163 | - 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
164 | - ]); |
|
163 | + 'template' => $this->buildAssignedToTemplate( $assignedTo, $post ), |
|
164 | + ] ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | * @return void |
170 | 170 | * @callback add_meta_box |
171 | 171 | */ |
172 | - public function renderDetailsMetaBox($post) |
|
172 | + public function renderDetailsMetaBox( $post ) |
|
173 | 173 | { |
174 | - if (!$this->isReviewPostType($post)) { |
|
174 | + if( !$this->isReviewPostType( $post ) ) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | - $review = glsr_get_review($post); |
|
178 | - glsr()->render('partials/editor/metabox-details', [ |
|
179 | - 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
180 | - 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
181 | - ]); |
|
177 | + $review = glsr_get_review( $post ); |
|
178 | + glsr()->render( 'partials/editor/metabox-details', [ |
|
179 | + 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
|
180 | + 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
|
181 | + ] ); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function renderPinnedInPublishMetaBox() |
189 | 189 | { |
190 | - if (!$this->isReviewPostType(get_post())) { |
|
190 | + if( !$this->isReviewPostType( get_post() ) ) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | - glsr(Template::class)->render('partials/editor/pinned', [ |
|
193 | + glsr( Template::class )->render( 'partials/editor/pinned', [ |
|
194 | 194 | 'context' => [ |
195 | - 'no' => __('No', 'site-reviews'), |
|
196 | - 'yes' => __('Yes', 'site-reviews'), |
|
195 | + 'no' => __( 'No', 'site-reviews' ), |
|
196 | + 'yes' => __( 'Yes', 'site-reviews' ), |
|
197 | 197 | ], |
198 | - 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
199 | - ]); |
|
198 | + 'pinned' => wp_validate_boolean( glsr( Database::class )->get( get_the_ID(), 'pinned' ) ), |
|
199 | + ] ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -204,15 +204,15 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | * @callback add_meta_box |
206 | 206 | */ |
207 | - public function renderResponseMetaBox($post) |
|
207 | + public function renderResponseMetaBox( $post ) |
|
208 | 208 | { |
209 | - if (!$this->isReviewPostType($post)) { |
|
209 | + if( !$this->isReviewPostType( $post ) ) { |
|
210 | 210 | return; |
211 | 211 | } |
212 | - wp_nonce_field('response', '_nonce-response', false); |
|
213 | - glsr()->render('partials/editor/metabox-response', [ |
|
214 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
215 | - ]); |
|
212 | + wp_nonce_field( 'response', '_nonce-response', false ); |
|
213 | + glsr()->render( 'partials/editor/metabox-response', [ |
|
214 | + 'response' => glsr( Database::class )->get( $post->ID, 'response' ), |
|
215 | + ] ); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | * @return void |
221 | 221 | * @action edit_form_after_title |
222 | 222 | */ |
223 | - public function renderReviewEditor($post) |
|
223 | + public function renderReviewEditor( $post ) |
|
224 | 224 | { |
225 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
225 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | - glsr()->render('partials/editor/review', [ |
|
228 | + glsr()->render( 'partials/editor/review', [ |
|
229 | 229 | 'post' => $post, |
230 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
231 | - ]); |
|
230 | + 'response' => glsr( Database::class )->get( $post->ID, 'response' ), |
|
231 | + ] ); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | public function renderReviewFields() |
239 | 239 | { |
240 | 240 | $screen = glsr_current_screen(); |
241 | - if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
241 | + if( 'post' != $screen->base || Application::POST_TYPE != $screen->post_type ) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | - add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
245 | - add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
244 | + add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
|
245 | + add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -250,20 +250,20 @@ discard block |
||
250 | 250 | * @return void |
251 | 251 | * @action edit_form_top |
252 | 252 | */ |
253 | - public function renderReviewNotice($post) |
|
253 | + public function renderReviewNotice( $post ) |
|
254 | 254 | { |
255 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
255 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | - glsr(Notice::class)->addWarning(sprintf( |
|
259 | - __('%s reviews are read-only.', 'site-reviews'), |
|
260 | - glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
261 | - )); |
|
262 | - glsr(Template::class)->render('partials/editor/notice', [ |
|
258 | + glsr( Notice::class )->addWarning( sprintf( |
|
259 | + __( '%s reviews are read-only.', 'site-reviews' ), |
|
260 | + glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
|
261 | + ) ); |
|
262 | + glsr( Template::class )->render( 'partials/editor/notice', [ |
|
263 | 263 | 'context' => [ |
264 | - 'notices' => glsr(Notice::class)->get(), |
|
264 | + 'notices' => glsr( Notice::class )->get(), |
|
265 | 265 | ], |
266 | - ]); |
|
266 | + ] ); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | * @see glsr_categories_meta_box() |
273 | 273 | * @callback register_taxonomy |
274 | 274 | */ |
275 | - public function renderTaxonomyMetabox($post) |
|
275 | + public function renderTaxonomyMetabox( $post ) |
|
276 | 276 | { |
277 | - if (!$this->isReviewPostType($post)) { |
|
277 | + if( !$this->isReviewPostType( $post ) ) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | - glsr()->render('partials/editor/metabox-categories', [ |
|
280 | + glsr()->render( 'partials/editor/metabox-categories', [ |
|
281 | 281 | 'post' => $post, |
282 | 282 | 'tax_name' => Application::TAXONOMY, |
283 | - 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
284 | - ]); |
|
283 | + 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
|
284 | + ] ); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function revertReview() |
293 | 293 | { |
294 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
294 | + if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) { |
|
295 | 295 | return; |
296 | 296 | } |
297 | - check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
298 | - glsr(ReviewManager::class)->revert($postId); |
|
299 | - $this->redirect($postId, 52); |
|
297 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
298 | + glsr( ReviewManager::class )->revert( $postId ); |
|
299 | + $this->redirect( $postId, 52 ); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | * @return void |
307 | 307 | * @action save_post_.Application::POST_TYPE |
308 | 308 | */ |
309 | - public function saveMetaboxes($postId, $post, $isUpdating) |
|
309 | + public function saveMetaboxes( $postId, $post, $isUpdating ) |
|
310 | 310 | { |
311 | - glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
312 | - glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
313 | - if ($isUpdating) { |
|
314 | - do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
311 | + glsr( Metaboxes::class )->saveAssignedToMetabox( $postId ); |
|
312 | + glsr( Metaboxes::class )->saveResponseMetabox( $postId ); |
|
313 | + if( $isUpdating ) { |
|
314 | + do_action( 'site-reviews/review/saved', glsr_get_review( $postId ) ); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
@@ -319,68 +319,68 @@ discard block |
||
319 | 319 | * @param string $assignedTo |
320 | 320 | * @return string |
321 | 321 | */ |
322 | - protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
322 | + protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
|
323 | 323 | { |
324 | - $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
325 | - if (!($assignedPost instanceof WP_Post)) { |
|
324 | + $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
|
325 | + if( !($assignedPost instanceof WP_Post) ) { |
|
326 | 326 | return; |
327 | 327 | } |
328 | - return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
328 | + return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
|
329 | 329 | 'context' => [ |
330 | - 'data.url' => (string) get_permalink($assignedPost), |
|
331 | - 'data.title' => get_the_title($assignedPost), |
|
330 | + 'data.url' => (string)get_permalink( $assignedPost ), |
|
331 | + 'data.title' => get_the_title( $assignedPost ), |
|
332 | 332 | ], |
333 | - ]); |
|
333 | + ] ); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
337 | 337 | * @return string |
338 | 338 | */ |
339 | - protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
339 | + protected function buildDetailsMetaBoxRevertButton( Review $review, WP_Post $post ) |
|
340 | 340 | { |
341 | - $isModified = !glsr(Helper::class)->compareArrays( |
|
341 | + $isModified = !glsr( Helper::class )->compareArrays( |
|
342 | 342 | [$review->title, $review->content, $review->date], |
343 | 343 | [ |
344 | - glsr(Database::class)->get($post->ID, 'title'), |
|
345 | - glsr(Database::class)->get($post->ID, 'content'), |
|
346 | - glsr(Database::class)->get($post->ID, 'date'), |
|
344 | + glsr( Database::class )->get( $post->ID, 'title' ), |
|
345 | + glsr( Database::class )->get( $post->ID, 'content' ), |
|
346 | + glsr( Database::class )->get( $post->ID, 'date' ), |
|
347 | 347 | ] |
348 | 348 | ); |
349 | - if ($isModified) { |
|
349 | + if( $isModified ) { |
|
350 | 350 | $revertUrl = wp_nonce_url( |
351 | - admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
351 | + admin_url( 'post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID ), |
|
352 | 352 | 'revert-review_'.$post->ID |
353 | 353 | ); |
354 | - return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
354 | + return glsr( Builder::class )->a( __( 'Revert Changes', 'site-reviews' ), [ |
|
355 | 355 | 'class' => 'button button-large', |
356 | 356 | 'href' => $revertUrl, |
357 | 357 | 'id' => 'revert', |
358 | - ]); |
|
358 | + ] ); |
|
359 | 359 | } |
360 | - return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
360 | + return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
|
361 | 361 | 'class' => 'button-large', |
362 | 362 | 'disabled' => true, |
363 | 363 | 'id' => 'revert', |
364 | - ]); |
|
364 | + ] ); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
368 | 368 | * @param object $review |
369 | 369 | * @return string|void |
370 | 370 | */ |
371 | - protected function getReviewType($review) |
|
371 | + protected function getReviewType( $review ) |
|
372 | 372 | { |
373 | - if (count(glsr()->reviewTypes) < 2) { |
|
373 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | - $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
376 | + $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
|
377 | 377 | ? glsr()->reviewTypes[$review->review_type] |
378 | - : __('Unknown', 'site-reviews'); |
|
379 | - if (!empty($review->url)) { |
|
380 | - $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
378 | + : __( 'Unknown', 'site-reviews' ); |
|
379 | + if( !empty($review->url) ) { |
|
380 | + $reviewType = glsr( Builder::class )->a( $reviewType, [ |
|
381 | 381 | 'href' => $review->url, |
382 | 382 | 'target' => '_blank', |
383 | - ]); |
|
383 | + ] ); |
|
384 | 384 | } |
385 | 385 | return $reviewType; |
386 | 386 | } |
@@ -388,18 +388,18 @@ discard block |
||
388 | 388 | /** |
389 | 389 | * @return bool |
390 | 390 | */ |
391 | - protected function isReviewEditable($post) |
|
391 | + protected function isReviewEditable( $post ) |
|
392 | 392 | { |
393 | - return $this->isReviewPostType($post) |
|
394 | - && post_type_supports(Application::POST_TYPE, 'title') |
|
395 | - && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
393 | + return $this->isReviewPostType( $post ) |
|
394 | + && post_type_supports( Application::POST_TYPE, 'title' ) |
|
395 | + && 'local' == glsr( Database::class )->get( $post->ID, 'review_type' ); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
399 | 399 | * @param mixed $post |
400 | 400 | * @return bool |
401 | 401 | */ |
402 | - protected function isReviewPostType($post) |
|
402 | + protected function isReviewPostType( $post ) |
|
403 | 403 | { |
404 | 404 | return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
405 | 405 | } |
@@ -407,29 +407,29 @@ discard block |
||
407 | 407 | /** |
408 | 408 | * @return array |
409 | 409 | */ |
410 | - protected function normalizeDetailsMetaBox(Review $review) |
|
410 | + protected function normalizeDetailsMetaBox( Review $review ) |
|
411 | 411 | { |
412 | 412 | $user = empty($review->user_id) |
413 | - ? __('Unregistered user', 'site-reviews') |
|
414 | - : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
415 | - 'href' => get_author_posts_url($review->user_id), |
|
416 | - ]); |
|
413 | + ? __( 'Unregistered user', 'site-reviews' ) |
|
414 | + : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
|
415 | + 'href' => get_author_posts_url( $review->user_id ), |
|
416 | + ] ); |
|
417 | 417 | $email = empty($review->email) |
418 | 418 | ? '—' |
419 | - : glsr(Builder::class)->a($review->email, [ |
|
420 | - 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
421 | - ]); |
|
419 | + : glsr( Builder::class )->a( $review->email, [ |
|
420 | + 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
|
421 | + ] ); |
|
422 | 422 | $metabox = [ |
423 | - __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
424 | - __('Type', 'site-reviews') => $this->getReviewType($review), |
|
425 | - __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
426 | - __('Name', 'site-reviews') => $review->author, |
|
427 | - __('Email', 'site-reviews') => $email, |
|
428 | - __('User', 'site-reviews') => $user, |
|
429 | - __('IP Address', 'site-reviews') => $review->ip_address, |
|
430 | - __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
423 | + __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ), |
|
424 | + __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
|
425 | + __( 'Date', 'site-reviews' ) => get_date_from_gmt( $review->date, 'F j, Y' ), |
|
426 | + __( 'Name', 'site-reviews' ) => $review->author, |
|
427 | + __( 'Email', 'site-reviews' ) => $email, |
|
428 | + __( 'User', 'site-reviews' ) => $user, |
|
429 | + __( 'IP Address', 'site-reviews' ) => $review->ip_address, |
|
430 | + __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ), |
|
431 | 431 | ]; |
432 | - return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
432 | + return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) ); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -437,16 +437,16 @@ discard block |
||
437 | 437 | * @param int $messageIndex |
438 | 438 | * @return void |
439 | 439 | */ |
440 | - protected function redirect($postId, $messageIndex) |
|
440 | + protected function redirect( $postId, $messageIndex ) |
|
441 | 441 | { |
442 | 442 | $referer = wp_get_referer(); |
443 | 443 | $hasReferer = !$referer |
444 | - || false !== strpos($referer, 'post.php') |
|
445 | - || false !== strpos($referer, 'post-new.php'); |
|
444 | + || false !== strpos( $referer, 'post.php' ) |
|
445 | + || false !== strpos( $referer, 'post-new.php' ); |
|
446 | 446 | $redirectUri = $hasReferer |
447 | - ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
448 | - : get_edit_post_link($postId); |
|
449 | - wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
447 | + ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
|
448 | + : get_edit_post_link( $postId ); |
|
449 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
450 | 450 | exit; |
451 | 451 | } |
452 | 452 | } |