@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | $filenames = []; |
21 | 21 | $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' ); |
22 | 22 | foreach( $iterator as $fileinfo ) { |
23 | - if( !$fileinfo->isFile() )continue; |
|
23 | + if( !$fileinfo->isFile() ) { |
|
24 | + continue; |
|
25 | + } |
|
24 | 26 | $filenames[] = $fileinfo->getFilename(); |
25 | 27 | } |
26 | 28 | natsort( $filenames ); |
@@ -28,7 +30,9 @@ discard block |
||
28 | 30 | $className = str_replace( '.php', '', $file ); |
29 | 31 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
30 | 32 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
31 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
33 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' )) { |
|
34 | + return; |
|
35 | + } |
|
32 | 36 | glsr( 'Modules\\Upgrader\\'.$className ); |
33 | 37 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
34 | 38 | }); |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | 'glsr_get_review', 'glsr_get_reviews', |
19 | 19 | 'glsr_log', |
20 | 20 | ); |
21 | - if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return; |
|
21 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook )) { |
|
22 | + return; |
|
23 | + } |
|
22 | 24 | add_filter( $hook, function() use( $hook, $args ) { |
23 | 25 | array_shift( $args ); // remove the fallback value |
24 | 26 | return call_user_func_array( $hook, $args ); |
@@ -28,7 +30,8 @@ discard block |
||
28 | 30 | /** |
29 | 31 | * @return mixed |
30 | 32 | */ |
31 | -function glsr( $alias = null ) { |
|
33 | +function glsr( $alias = null ) |
|
34 | +{ |
|
32 | 35 | $app = \GeminiLabs\SiteReviews\Application::load(); |
33 | 36 | return !empty( $alias ) |
34 | 37 | ? $app->make( $alias ) |
@@ -38,7 +41,8 @@ discard block |
||
38 | 41 | /** |
39 | 42 | * @return null|\GeminiLabs\SiteReviews\Review |
40 | 43 | */ |
41 | -function glsr_create_review( $reviewValues = array() ) { |
|
44 | +function glsr_create_review( $reviewValues = array() ) |
|
45 | +{ |
|
42 | 46 | if( !is_array( $reviewValues )) { |
43 | 47 | $reviewValues = array(); |
44 | 48 | } |
@@ -52,7 +56,8 @@ discard block |
||
52 | 56 | /** |
53 | 57 | * @return \WP_Screen|object |
54 | 58 | */ |
55 | -function glsr_current_screen() { |
|
59 | +function glsr_current_screen() |
|
60 | +{ |
|
56 | 61 | if( function_exists( 'get_current_screen' )) { |
57 | 62 | $screen = get_current_screen(); |
58 | 63 | } |
@@ -65,7 +70,8 @@ discard block |
||
65 | 70 | * @param mixed ...$vars |
66 | 71 | * @return void |
67 | 72 | */ |
68 | -function glsr_debug( ...$vars ) { |
|
73 | +function glsr_debug( ...$vars ) |
|
74 | +{ |
|
69 | 75 | if( count( $vars ) == 1 ) { |
70 | 76 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
71 | 77 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -84,7 +90,8 @@ discard block |
||
84 | 90 | * @param mixed $fallback |
85 | 91 | * @return string|array |
86 | 92 | */ |
87 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
93 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
94 | +{ |
|
88 | 95 | return is_string( $path ) |
89 | 96 | ? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ) |
90 | 97 | : $fallback; |
@@ -93,7 +100,8 @@ discard block |
||
93 | 100 | /** |
94 | 101 | * @return array |
95 | 102 | */ |
96 | -function glsr_get_options() { |
|
103 | +function glsr_get_options() |
|
104 | +{ |
|
97 | 105 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
98 | 106 | } |
99 | 107 | |
@@ -101,8 +109,11 @@ discard block |
||
101 | 109 | * @param int $post_id |
102 | 110 | * @return \GeminiLabs\SiteReviews\Review|void |
103 | 111 | */ |
104 | -function glsr_get_review( $post_id ) { |
|
105 | - if( !is_numeric( $post_id ))return; |
|
112 | +function glsr_get_review( $post_id ) |
|
113 | +{ |
|
114 | + if( !is_numeric( $post_id )) { |
|
115 | + return; |
|
116 | + } |
|
106 | 117 | $post = get_post( $post_id ); |
107 | 118 | if( $post instanceof WP_Post ) { |
108 | 119 | return glsr( 'Database\ReviewManager' )->single( $post ); |
@@ -113,7 +124,8 @@ discard block |
||
113 | 124 | * @return array |
114 | 125 | * @todo document change of $reviews->reviews to $reviews->results |
115 | 126 | */ |
116 | -function glsr_get_reviews( $args = array() ) { |
|
127 | +function glsr_get_reviews( $args = array() ) |
|
128 | +{ |
|
117 | 129 | if( !is_array( $args )) { |
118 | 130 | $args = []; |
119 | 131 | } |
@@ -123,7 +135,8 @@ discard block |
||
123 | 135 | /** |
124 | 136 | * @return \GeminiLabs\SiteReviews\Modules\Console |
125 | 137 | */ |
126 | -function glsr_log() { |
|
138 | +function glsr_log() |
|
139 | +{ |
|
127 | 140 | $args = func_get_args(); |
128 | 141 | $context = isset( $args[1] ) |
129 | 142 | ? $args[1] |
@@ -108,12 +108,16 @@ |
||
108 | 108 | public function renderTinymceButton( $editorId ) |
109 | 109 | { |
110 | 110 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId ); |
111 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
111 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors )) { |
|
112 | + return; |
|
113 | + } |
|
112 | 114 | $shortcodes = []; |
113 | 115 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
114 | 116 | $shortcodes[$shortcode] = $values; |
115 | 117 | } |
116 | - if( empty( $shortcodes ))return; |
|
118 | + if( empty( $shortcodes )) { |
|
119 | + return; |
|
120 | + } |
|
117 | 121 | glsr()->render( 'partials/editor/tinymce', [ |
118 | 122 | 'shortcodes' => $shortcodes, |
119 | 123 | ]); |
@@ -25,7 +25,9 @@ discard block |
||
25 | 25 | { |
26 | 26 | sort( $termIds ); |
27 | 27 | sort( $oldTermIds ); |
28 | - if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ))return; |
|
28 | + if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId )) { |
|
29 | + return; |
|
30 | + } |
|
29 | 31 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
30 | 32 | $ignoredTerms = array_intersect( $oldTermIds, $termIds ); |
31 | 33 | if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms )) { |
@@ -44,7 +46,9 @@ discard block |
||
44 | 46 | */ |
45 | 47 | public function onAfterChangeStatus( $newStatus, $oldStatus, WP_Post $post ) |
46 | 48 | { |
47 | - if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
49 | + if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
50 | + return; |
|
51 | + } |
|
48 | 52 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
49 | 53 | if( $post->post_status == 'publish' ) { |
50 | 54 | glsr( CountsManager::class )->increase( $review ); |
@@ -60,7 +64,9 @@ discard block |
||
60 | 64 | */ |
61 | 65 | public function onAfterCreate( Review $review ) |
62 | 66 | { |
63 | - if( $review->status !== 'publish' )return; |
|
67 | + if( $review->status !== 'publish' ) { |
|
68 | + return; |
|
69 | + } |
|
64 | 70 | glsr( CountsManager::class )->increase( $review ); |
65 | 71 | } |
66 | 72 | |
@@ -71,7 +77,9 @@ discard block |
||
71 | 77 | */ |
72 | 78 | public function onBeforeDelete( $postId ) |
73 | 79 | { |
74 | - if( !$this->isReviewPostId( $postId ))return; |
|
80 | + if( !$this->isReviewPostId( $postId )) { |
|
81 | + return; |
|
82 | + } |
|
75 | 83 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
76 | 84 | glsr( CountsManager::class )->decrease( $review ); |
77 | 85 | } |
@@ -88,9 +96,13 @@ discard block |
||
88 | 96 | { |
89 | 97 | if( !$this->isReviewPostId( $postId ) |
90 | 98 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
91 | - )return; |
|
99 | + ) { |
|
100 | + return; |
|
101 | + } |
|
92 | 102 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
93 | - if( $review->$metaKey == $metaValue )return; |
|
103 | + if( $review->$metaKey == $metaValue ) { |
|
104 | + return; |
|
105 | + } |
|
94 | 106 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
95 | 107 | call_user_func( [$this, $method], $review, $metaValue ); |
96 | 108 | } |
@@ -65,7 +65,9 @@ |
||
65 | 65 | $avail_post_stati = get_available_post_statuses( Application::POST_TYPE ); |
66 | 66 | $table = new \WP_Posts_List_Table( ['screen' => $hookName] ); |
67 | 67 | $views = apply_filters( 'views_'.$hookName, $table->get_views() ); // uses compat get_views() |
68 | - if( empty( $views ))return; |
|
68 | + if( empty( $views )) { |
|
69 | + return; |
|
70 | + } |
|
69 | 71 | foreach( $views as $class => $view ) { |
70 | 72 | $views[$class] = "\t<li class='$class'>$view"; |
71 | 73 | } |