@@ -108,7 +108,9 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function render() |
110 | 110 | { |
111 | - if( is_null( glsr()->schemas ))return; |
|
111 | + if( is_null( glsr()->schemas )) { |
|
112 | + return; |
|
113 | + } |
|
112 | 114 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
113 | 115 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
114 | 116 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -181,7 +183,9 @@ discard block |
||
181 | 183 | if( $value != $fallback ) { |
182 | 184 | return $value; |
183 | 185 | } |
184 | - if( !is_single() && !is_page() )return; |
|
186 | + if( !is_single() && !is_page() ) { |
|
187 | + return; |
|
188 | + } |
|
185 | 189 | switch( $option ) { |
186 | 190 | case 'description': |
187 | 191 | return get_the_excerpt(); |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | // 'is_test' => 1, |
31 | 31 | ]; |
32 | 32 | foreach( $_SERVER as $key => $value ) { |
33 | - if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ))continue; |
|
33 | + if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] )) { |
|
34 | + continue; |
|
35 | + } |
|
34 | 36 | $submission[$key] = $value; |
35 | 37 | } |
36 | 38 | return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review )); |
@@ -56,12 +58,16 @@ discard block |
||
56 | 58 | { |
57 | 59 | $query = []; |
58 | 60 | foreach( $data as $key => $value ) { |
59 | - if( is_array( $value ) || is_object( $value ))continue; |
|
61 | + if( is_array( $value ) || is_object( $value )) { |
|
62 | + continue; |
|
63 | + } |
|
60 | 64 | if( $value === false ) { |
61 | 65 | $value = '0'; |
62 | 66 | } |
63 | 67 | $value = trim( $value ); |
64 | - if( !strlen( $value ))continue; |
|
68 | + if( !strlen( $value )) { |
|
69 | + continue; |
|
70 | + } |
|
65 | 71 | $query[] = urlencode( $key ).'='.urlencode( $value ); |
66 | 72 | } |
67 | 73 | return implode( '&', $query ); |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | $counts = array_fill_keys( [5,4,3,2,1], [] ); |
64 | 64 | array_walk( $counts, function( &$count, $key ) use( $reviews ) { |
65 | 65 | $count = count( array_filter( $reviews, function( $review ) use( $key ) { |
66 | - if( !isset( $review->rating ))return; |
|
66 | + if( !isset( $review->rating )) { |
|
67 | + return; |
|
68 | + } |
|
67 | 69 | return $review->rating == $key; |
68 | 70 | })); |
69 | 71 | }); |
@@ -83,7 +85,9 @@ discard block |
||
83 | 85 | public function getLowerBound( array $upDownRatings, $confidencePercentage = 95 ) |
84 | 86 | { |
85 | 87 | $numRatings = count( $upDownRatings ); |
86 | - if( !$numRatings )return 0; |
|
88 | + if( !$numRatings ) { |
|
89 | + return 0; |
|
90 | + } |
|
87 | 91 | $positiveRatings = count( array_filter( $upDownRatings, function( $value ) { |
88 | 92 | return $value > 0; |
89 | 93 | })); |
@@ -42,7 +42,9 @@ |
||
42 | 42 | $options = $this->all(); |
43 | 43 | $pointer = &$options; |
44 | 44 | foreach( $keys as $key ) { |
45 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
45 | + if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] )) { |
|
46 | + continue; |
|
47 | + } |
|
46 | 48 | $pointer = &$pointer[$key]; |
47 | 49 | } |
48 | 50 | unset( $pointer[$last] ); |
@@ -16,9 +16,13 @@ discard block |
||
16 | 16 | { |
17 | 17 | $queries = []; |
18 | 18 | foreach( $keys as $key ) { |
19 | - if( !array_key_exists( $key, $values ))continue; |
|
19 | + if( !array_key_exists( $key, $values )) { |
|
20 | + continue; |
|
21 | + } |
|
20 | 22 | $methodName = glsr( Helper::class )->buildMethodName( $key, $prefix = __METHOD__ ); |
21 | - if( !method_exists( $this, $methodName ))continue; |
|
23 | + if( !method_exists( $this, $methodName )) { |
|
24 | + continue; |
|
25 | + } |
|
22 | 26 | $query = call_user_func( [$this, $methodName], $values[$key] ); |
23 | 27 | if( is_array( $query )) { |
24 | 28 | $queries[] = $query; |
@@ -90,7 +94,9 @@ discard block |
||
90 | 94 | */ |
91 | 95 | protected function buildQueryAssignedTo( $value ) |
92 | 96 | { |
93 | - if( empty( $value ))return; |
|
97 | + if( empty( $value )) { |
|
98 | + return; |
|
99 | + } |
|
94 | 100 | return [ |
95 | 101 | 'compare' => 'IN', |
96 | 102 | 'key' => 'assigned_to', |
@@ -104,7 +110,9 @@ discard block |
||
104 | 110 | */ |
105 | 111 | protected function buildQueryCategory( $value ) |
106 | 112 | { |
107 | - if( empty( $value ))return; |
|
113 | + if( empty( $value )) { |
|
114 | + return; |
|
115 | + } |
|
108 | 116 | return [ |
109 | 117 | 'field' => 'term_id', |
110 | 118 | 'taxonomy' => Application::TAXONOMY, |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | */ |
119 | 127 | protected function buildQueryRating( $value ) |
120 | 128 | { |
121 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
129 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ))) { |
|
130 | + return; |
|
131 | + } |
|
122 | 132 | return [ |
123 | 133 | 'compare' => '>=', |
124 | 134 | 'key' => 'rating', |
@@ -132,7 +142,9 @@ discard block |
||
132 | 142 | */ |
133 | 143 | protected function buildQueryType( $value ) |
134 | 144 | { |
135 | - if( in_array( $value, ['','all'] ))return; |
|
145 | + if( in_array( $value, ['','all'] )) { |
|
146 | + return; |
|
147 | + } |
|
136 | 148 | return [ |
137 | 149 | 'key' => 'review_type', |
138 | 150 | 'value' => $value, |
@@ -38,7 +38,9 @@ |
||
38 | 38 | protected function normalize( array $settings ) |
39 | 39 | { |
40 | 40 | array_walk( $settings, function( &$setting ) { |
41 | - if( isset( $setting['default'] ))return; |
|
41 | + if( isset( $setting['default'] )) { |
|
42 | + return; |
|
43 | + } |
|
42 | 44 | $setting['default'] = null; |
43 | 45 | }); |
44 | 46 | return $settings; |
@@ -4,7 +4,8 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * @return mixed |
6 | 6 | */ |
7 | -function glsr( $alias = null ) { |
|
7 | +function glsr( $alias = null ) |
|
8 | +{ |
|
8 | 9 | $app = \GeminiLabs\SiteReviews\Application::load(); |
9 | 10 | return empty( $alias ) |
10 | 11 | ? $app |
@@ -15,7 +16,8 @@ discard block |
||
15 | 16 | * get_current_screen() is unreliable because it is not defined on all admin pages |
16 | 17 | * @return \WP_Screen|object |
17 | 18 | */ |
18 | -function glsr_current_screen() { |
|
19 | +function glsr_current_screen() |
|
20 | +{ |
|
19 | 21 | if( function_exists( 'get_current_screen' )) { |
20 | 22 | $screen = get_current_screen(); |
21 | 23 | } |
@@ -27,7 +29,8 @@ discard block |
||
27 | 29 | /** |
28 | 30 | * @return \GeminiLabs\SiteReviews\Database |
29 | 31 | */ |
30 | -function glsr_db() { |
|
32 | +function glsr_db() |
|
33 | +{ |
|
31 | 34 | return glsr( 'Database' ); |
32 | 35 | } |
33 | 36 | |
@@ -35,7 +38,8 @@ discard block |
||
35 | 38 | * @param mixed ...$vars |
36 | 39 | * @return void |
37 | 40 | */ |
38 | -function glsr_debug( ...$vars ) { |
|
41 | +function glsr_debug( ...$vars ) |
|
42 | +{ |
|
39 | 43 | if( count( $vars ) == 1 ) { |
40 | 44 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
41 | 45 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -52,7 +56,8 @@ discard block |
||
52 | 56 | /** |
53 | 57 | * @return \GeminiLabs\SiteReviews\Modules\Logger |
54 | 58 | */ |
55 | -function glsr_log() { |
|
59 | +function glsr_log() |
|
60 | +{ |
|
56 | 61 | $args = func_get_args(); |
57 | 62 | $context = isset( $args[1] ) |
58 | 63 | ? $args[1] |
@@ -68,7 +73,8 @@ discard block |
||
68 | 73 | * @return void |
69 | 74 | * @callback register_taxonomy() "meta_box_cb" |
70 | 75 | */ |
71 | -function glsr_categories_meta_box( $post, $box ) { |
|
76 | +function glsr_categories_meta_box( $post, $box ) |
|
77 | +{ |
|
72 | 78 | glsr( 'Controllers\EditorController' )->renderTaxonomyMetabox( $post, $box ); |
73 | 79 | } |
74 | 80 | |
@@ -77,14 +83,16 @@ discard block |
||
77 | 83 | * @param mixed $fallback |
78 | 84 | * @return string|array |
79 | 85 | */ |
80 | -function glsr_get_option( $option_path = '', $fallback = '' ) { |
|
86 | +function glsr_get_option( $option_path = '', $fallback = '' ) |
|
87 | +{ |
|
81 | 88 | return glsr( 'Database\OptionManager' )->get( 'settings.'.$option_path, $fallback ); |
82 | 89 | } |
83 | 90 | |
84 | 91 | /** |
85 | 92 | * @return array |
86 | 93 | */ |
87 | -function glsr_get_options() { |
|
94 | +function glsr_get_options() |
|
95 | +{ |
|
88 | 96 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
89 | 97 | } |
90 | 98 |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | public function routeAdminPostRequest() |
17 | 17 | { |
18 | 18 | $request = filter_input( INPUT_POST, Application::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
19 | - if( !isset( $request['action'] ))return; |
|
19 | + if( !isset( $request['action'] )) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | $this->checkNonce( $request['action'] ); |
21 | 23 | switch( $request['action'] ) { |
22 | 24 | case 'clear-log': |
@@ -75,7 +77,9 @@ discard block |
||
75 | 77 | public function routeWebhookRequest() |
76 | 78 | { |
77 | 79 | $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID )); |
78 | - if( !$request )return; |
|
80 | + if( !$request ) { |
|
81 | + return; |
|
82 | + } |
|
79 | 83 | // @todo manage webhook here |
80 | 84 | } |
81 | 85 |
@@ -15,7 +15,9 @@ |
||
15 | 15 | */ |
16 | 16 | public function download( $filename, $content ) |
17 | 17 | { |
18 | - if( !current_user_can( Application::CAPABILITY ))return; |
|
18 | + if( !current_user_can( Application::CAPABILITY )) { |
|
19 | + return; |
|
20 | + } |
|
19 | 21 | nocache_headers(); |
20 | 22 | header( 'Content-Type: text/plain' ); |
21 | 23 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |