Test Failed
Push — tmp ( 15f615...89cc97 )
by Paul
10:31 queued 04:40
created
plugin/Hooks.php 1 patch
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -38,21 +38,21 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function __construct()
40 40
     {
41
-        $this->admin = glsr(AdminController::class);
42
-        $this->basename = plugin_basename(glsr()->file);
43
-        $this->blocks = glsr(BlocksController::class);
44
-        $this->editor = glsr(EditorController::class);
45
-        $this->listtable = glsr(ListTableController::class);
46
-        $this->main = glsr(MainController::class);
47
-        $this->menu = glsr(MenuController::class);
48
-        $this->notices = glsr(NoticeController::class);
49
-        $this->public = glsr(PublicController::class);
50
-        $this->review = glsr(ReviewController::class);
51
-        $this->router = glsr(Router::class);
52
-        $this->settings = glsr(SettingsController::class);
53
-        $this->translator = glsr(TranslationController::class);
54
-        $this->trustalyze = glsr(TrustalyzeController::class);
55
-        $this->welcome = glsr(WelcomeController::class);
41
+        $this->admin = glsr( AdminController::class );
42
+        $this->basename = plugin_basename( glsr()->file );
43
+        $this->blocks = glsr( BlocksController::class );
44
+        $this->editor = glsr( EditorController::class );
45
+        $this->listtable = glsr( ListTableController::class );
46
+        $this->main = glsr( MainController::class );
47
+        $this->menu = glsr( MenuController::class );
48
+        $this->notices = glsr( NoticeController::class );
49
+        $this->public = glsr( PublicController::class );
50
+        $this->review = glsr( ReviewController::class );
51
+        $this->router = glsr( Router::class );
52
+        $this->settings = glsr( SettingsController::class );
53
+        $this->translator = glsr( TranslationController::class );
54
+        $this->trustalyze = glsr( TrustalyzeController::class );
55
+        $this->welcome = glsr( WelcomeController::class );
56 56
     }
57 57
 
58 58
     /**
@@ -60,66 +60,66 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function addActions()
62 62
     {
63
-        add_action('plugins_loaded', [glsr(), 'getDefaultSettings'], 11);
64
-        add_action('plugins_loaded', [glsr(), 'registerAddons']);
65
-        add_action('plugins_loaded', [glsr(), 'registerLanguages']);
66
-        add_action('plugins_loaded', [glsr(), 'registerReviewTypes']);
67
-        add_action('admin_init', [glsr(), 'setDefaultSettings']);
68
-        add_action('load-edit.php', [$this, 'translateAdminEditPage']);
69
-        add_action('load-post.php', [$this, 'translateAdminPostPage']);
70
-        add_action('plugins_loaded', [$this, 'translatePlugin']);
71
-        add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']);
72
-        add_action('admin_init', [$this->admin, 'registerTinymcePopups']);
73
-        add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11);
74
-        add_action('init', [$this->blocks, 'registerAssets'], 9);
75
-        add_action('init', [$this->blocks, 'registerBlocks']);
76
-        add_action('add_meta_boxes_'.glsr()->post_type, [$this->editor, 'registerMetaBoxes']);
77
-        add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999);
78
-        add_action('admin_menu', [$this->editor, 'removeMetaBoxes']);
79
-        add_action('current_screen', [$this->editor, 'removePostTypeSupport']);
80
-        add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']);
81
-        add_action('admin_head', [$this->editor, 'renderReviewFields']);
82
-        add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']);
83
-        add_action('save_post_'.glsr()->post_type, [$this->editor, 'saveMetaboxes'], 10, 3);
84
-        add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2);
85
-        add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']);
86
-        add_action('manage_'.glsr()->post_type.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2);
87
-        add_action('save_post_'.glsr()->post_type, [$this->listtable, 'saveBulkEditFields']);
88
-        add_action('admin_footer', [$this->main, 'logOnce']);
89
-        add_action('wp_footer', [$this->main, 'logOnce']);
90
-        add_action('init', [$this->main, 'registerPostType'], 8);
91
-        add_action('init', [$this->main, 'registerShortcodes']);
92
-        add_action('init', [$this->main, 'registerTaxonomy']);
93
-        add_action('widgets_init', [$this->main, 'registerWidgets']);
94
-        add_action('admin_menu', [$this->menu, 'registerMenuCount']);
95
-        add_action('admin_menu', [$this->menu, 'registerSubMenus']);
96
-        add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999);
97
-        add_action('admin_notices', [$this->notices, 'filterAdminNotices']);
98
-        add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999);
99
-        add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']);
100
-        add_action('wp_footer', [$this->public, 'renderSchema']);
101
-        add_action('admin_action_approve', [$this->review, 'approve']);
102
-        add_action('the_posts', [$this->review, 'filterPostsToCacheReviews']);
103
-        add_action('set_object_terms', [$this->review, 'onAfterChangeAssignedTerms'], 10, 6);
104
-        add_action('site-reviews/review/updated/post_ids', [$this->review, 'onChangeAssignedPosts'], 10, 2);
105
-        add_action('site-reviews/review/updated/user_ids', [$this->review, 'onChangeAssignedUsers'], 10, 2);
63
+        add_action( 'plugins_loaded', [glsr(), 'getDefaultSettings'], 11 );
64
+        add_action( 'plugins_loaded', [glsr(), 'registerAddons'] );
65
+        add_action( 'plugins_loaded', [glsr(), 'registerLanguages'] );
66
+        add_action( 'plugins_loaded', [glsr(), 'registerReviewTypes'] );
67
+        add_action( 'admin_init', [glsr(), 'setDefaultSettings'] );
68
+        add_action( 'load-edit.php', [$this, 'translateAdminEditPage'] );
69
+        add_action( 'load-post.php', [$this, 'translateAdminPostPage'] );
70
+        add_action( 'plugins_loaded', [$this, 'translatePlugin'] );
71
+        add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] );
72
+        add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] );
73
+        add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 );
74
+        add_action( 'init', [$this->blocks, 'registerAssets'], 9 );
75
+        add_action( 'init', [$this->blocks, 'registerBlocks'] );
76
+        add_action( 'add_meta_boxes_'.glsr()->post_type, [$this->editor, 'registerMetaBoxes'] );
77
+        add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 );
78
+        add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] );
79
+        add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] );
80
+        add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] );
81
+        add_action( 'admin_head', [$this->editor, 'renderReviewFields'] );
82
+        add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] );
83
+        add_action( 'save_post_'.glsr()->post_type, [$this->editor, 'saveMetaboxes'], 10, 3 );
84
+        add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 );
85
+        add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] );
86
+        add_action( 'manage_'.glsr()->post_type.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 );
87
+        add_action( 'save_post_'.glsr()->post_type, [$this->listtable, 'saveBulkEditFields'] );
88
+        add_action( 'admin_footer', [$this->main, 'logOnce'] );
89
+        add_action( 'wp_footer', [$this->main, 'logOnce'] );
90
+        add_action( 'init', [$this->main, 'registerPostType'], 8 );
91
+        add_action( 'init', [$this->main, 'registerShortcodes'] );
92
+        add_action( 'init', [$this->main, 'registerTaxonomy'] );
93
+        add_action( 'widgets_init', [$this->main, 'registerWidgets'] );
94
+        add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] );
95
+        add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] );
96
+        add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 );
97
+        add_action( 'admin_notices', [$this->notices, 'filterAdminNotices'] );
98
+        add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 );
99
+        add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] );
100
+        add_action( 'wp_footer', [$this->public, 'renderSchema'] );
101
+        add_action( 'admin_action_approve', [$this->review, 'approve'] );
102
+        add_action( 'the_posts', [$this->review, 'filterPostsToCacheReviews'] );
103
+        add_action( 'set_object_terms', [$this->review, 'onAfterChangeAssignedTerms'], 10, 6 );
104
+        add_action( 'site-reviews/review/updated/post_ids', [$this->review, 'onChangeAssignedPosts'], 10, 2 );
105
+        add_action( 'site-reviews/review/updated/user_ids', [$this->review, 'onChangeAssignedUsers'], 10, 2 );
106 106
         // add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3);
107 107
         // add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']);
108 108
         // add_action('delete_'.glsr()->taxonomy, [$this->review, 'onAfterDeleteCategory']);
109 109
         // add_action('before_delete_post', [$this->review, 'onBeforeDelete']);
110 110
         // add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4);
111
-        add_action('admin_action_unapprove', [$this->review, 'unapprove']);
112
-        add_action('admin_init', [$this->router, 'routeAdminPostRequest']);
113
-        add_action('wp_ajax_'.glsr()->prefix.'action', [$this->router, 'routeAjaxRequest']);
114
-        add_action('wp_ajax_nopriv_'.glsr()->prefix.'action', [$this->router, 'routeAjaxRequest']);
115
-        add_action('init', [$this->router, 'routePublicPostRequest']);
116
-        add_action('admin_init', [$this->settings, 'registerSettings']);
117
-        add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']);
118
-        add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']);
119
-        add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']);
120
-        add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3);
121
-        add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2);
122
-        add_action('admin_menu', [$this->welcome, 'registerPage']);
111
+        add_action( 'admin_action_unapprove', [$this->review, 'unapprove'] );
112
+        add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] );
113
+        add_action( 'wp_ajax_'.glsr()->prefix.'action', [$this->router, 'routeAjaxRequest'] );
114
+        add_action( 'wp_ajax_nopriv_'.glsr()->prefix.'action', [$this->router, 'routeAjaxRequest'] );
115
+        add_action( 'init', [$this->router, 'routePublicPostRequest'] );
116
+        add_action( 'admin_init', [$this->settings, 'registerSettings'] );
117
+        add_action( 'site-reviews/review/created', [$this->trustalyze, 'onCreated'] );
118
+        add_action( 'site-reviews/review/reverted', [$this->trustalyze, 'onReverted'] );
119
+        add_action( 'site-reviews/review/saved', [$this->trustalyze, 'onSaved'] );
120
+        add_action( 'updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3 );
121
+        add_action( 'activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2 );
122
+        add_action( 'admin_menu', [$this->welcome, 'registerPage'] );
123 123
     }
124 124
 
125 125
     /**
@@ -127,32 +127,32 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function addFilters()
129 129
     {
130
-        add_filter('map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2);
131
-        add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15);
132
-        add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']);
133
-        add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']);
134
-        add_filter('allowed_block_types', [$this->blocks, 'filterAllowedBlockTypes'], 10, 2);
135
-        add_filter('block_categories', [$this->blocks, 'filterBlockCategories']);
136
-        add_filter('classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2);
137
-        add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2);
138
-        add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']);
139
-        add_filter('the_editor', [$this->editor, 'filterEditorTextarea']);
140
-        add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3);
141
-        add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']);
142
-        add_filter('manage_'.glsr()->post_type.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']);
143
-        add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2);
144
-        add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2);
145
-        add_filter('posts_clauses', [$this->listtable, 'filterPostClauses'], 10, 2);
146
-        add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2);
147
-        add_filter('manage_edit-'.glsr()->post_type.'_sortable_columns', [$this->listtable, 'filterSortableColumns']);
148
-        add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScriptTags'], 10, 2);
149
-        add_filter('site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11);
150
-        add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']);
151
-        add_filter('site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback']);
152
-        add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3);
153
-        add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9);
154
-        add_filter('admin_title', [$this->welcome, 'filterAdminTitle']);
155
-        add_filter('admin_footer_text', [$this->welcome, 'filterFooterText']);
130
+        add_filter( 'map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2 );
131
+        add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 );
132
+        add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] );
133
+        add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] );
134
+        add_filter( 'allowed_block_types', [$this->blocks, 'filterAllowedBlockTypes'], 10, 2 );
135
+        add_filter( 'block_categories', [$this->blocks, 'filterBlockCategories'] );
136
+        add_filter( 'classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2 );
137
+        add_filter( 'use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2 );
138
+        add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] );
139
+        add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] );
140
+        add_filter( 'is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3 );
141
+        add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] );
142
+        add_filter( 'manage_'.glsr()->post_type.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] );
143
+        add_filter( 'post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2 );
144
+        add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 );
145
+        add_filter( 'posts_clauses', [$this->listtable, 'filterPostClauses'], 10, 2 );
146
+        add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 );
147
+        add_filter( 'manage_edit-'.glsr()->post_type.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] );
148
+        add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScriptTags'], 10, 2 );
149
+        add_filter( 'site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11 );
150
+        add_filter( 'site-reviews/render/view', [$this->public, 'filterRenderView'] );
151
+        add_filter( 'site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback'] );
152
+        add_filter( 'site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3 );
153
+        add_filter( 'plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9 );
154
+        add_filter( 'admin_title', [$this->welcome, 'filterAdminTitle'] );
155
+        add_filter( 'admin_footer_text', [$this->welcome, 'filterFooterText'] );
156 156
     }
157 157
 
158 158
     /**
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function translateAdminEditPage()
172 172
     {
173
-        if (glsr()->post_type === glsr_current_screen()->post_type) {
174
-            add_filter('bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2);
175
-            add_filter('display_post_states', [$this->translator, 'filterPostStates'], 10, 2);
176
-            add_filter('gettext', [$this->translator, 'filterPostStatusLabels'], 10, 3);
177
-            add_filter('ngettext', [$this->translator, 'filterPostStatusText'], 10, 5);
173
+        if( glsr()->post_type === glsr_current_screen()->post_type ) {
174
+            add_filter( 'bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2 );
175
+            add_filter( 'display_post_states', [$this->translator, 'filterPostStates'], 10, 2 );
176
+            add_filter( 'gettext', [$this->translator, 'filterPostStatusLabels'], 10, 3 );
177
+            add_filter( 'ngettext', [$this->translator, 'filterPostStatusText'], 10, 5 );
178 178
         }
179 179
     }
180 180
 
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function translateAdminPostPage()
186 186
     {
187
-        if (glsr()->post_type === glsr_current_screen()->post_type) {
188
-            add_filter('gettext', [$this->translator, 'filterPostStatusLabels'], 10, 3);
189
-            add_action('admin_print_scripts-post.php', [$this->translator, 'translatePostStatusLabels']);
187
+        if( glsr()->post_type === glsr_current_screen()->post_type ) {
188
+            add_filter( 'gettext', [$this->translator, 'filterPostStatusLabels'], 10, 3 );
189
+            add_action( 'admin_print_scripts-post.php', [$this->translator, 'translatePostStatusLabels'] );
190 190
         }
191 191
     }
192 192
 
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
      */
197 197
     public function translatePlugin()
198 198
     {
199
-        if (!empty(glsr(Translation::class)->translations())) {
200
-            add_filter('gettext', [$this->translator, 'filterGettext'], 9, 3);
201
-            add_filter('site-reviews/gettext/site-reviews', [$this->translator, 'filterGettextSiteReviews'], 10, 2);
202
-            add_filter('gettext_with_context', [$this->translator, 'filterGettextWithContext'], 9, 4);
203
-            add_filter('site-reviews/gettext_with_context/site-reviews', [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3);
204
-            add_filter('ngettext', [$this->translator, 'filterNgettext'], 9, 5);
205
-            add_filter('site-reviews/ngettext/site-reviews', [$this->translator, 'filterNgettextSiteReviews'], 10, 4);
206
-            add_filter('ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 9, 6);
207
-            add_filter('site-reviews/ngettext_with_context/site-reviews', [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5);
199
+        if( !empty(glsr( Translation::class )->translations()) ) {
200
+            add_filter( 'gettext', [$this->translator, 'filterGettext'], 9, 3 );
201
+            add_filter( 'site-reviews/gettext/site-reviews', [$this->translator, 'filterGettextSiteReviews'], 10, 2 );
202
+            add_filter( 'gettext_with_context', [$this->translator, 'filterGettextWithContext'], 9, 4 );
203
+            add_filter( 'site-reviews/gettext_with_context/site-reviews', [$this->translator, 'filterGettextWithContextSiteReviews'], 10, 3 );
204
+            add_filter( 'ngettext', [$this->translator, 'filterNgettext'], 9, 5 );
205
+            add_filter( 'site-reviews/ngettext/site-reviews', [$this->translator, 'filterNgettextSiteReviews'], 10, 4 );
206
+            add_filter( 'ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 9, 6 );
207
+            add_filter( 'site-reviews/ngettext_with_context/site-reviews', [$this->translator, 'filterNgettextWithContextSiteReviews'], 10, 5 );
208 208
         }
209 209
     }
210 210
 }
Please login to merge, or discard this patch.
plugin/Database.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function createTables()
27 27
     {
28
-        glsr(SqlSchema::class)->createTables();
29
-        glsr(SqlSchema::class)->addTableConstraints();
28
+        glsr( SqlSchema::class )->createTables();
29
+        glsr( SqlSchema::class )->addTableConstraints();
30 30
     }
31 31
 
32 32
     /**
33 33
      * @param int $reviewId
34 34
      * @return int|false
35 35
      */
36
-    public function delete($reviewId)
36
+    public function delete( $reviewId )
37 37
     {
38
-        return $this->db->delete(glsr(Query::class)->table('ratings'), [
38
+        return $this->db->delete( glsr( Query::class )->table( 'ratings' ), [
39 39
             'review_id' => $reviewId,
40
-        ]);
40
+        ] );
41 41
     }
42 42
 
43 43
     /**
@@ -47,36 +47,36 @@  discard block
 block discarded – undo
47 47
      * @return string
48 48
      * @filter posts_search
49 49
      */
50
-    public function filterSearchByTitle($search, WP_Query $query)
50
+    public function filterSearchByTitle( $search, WP_Query $query )
51 51
     {
52
-        if (empty($search) || empty($query->get('search_terms'))) {
52
+        if( empty($search) || empty($query->get( 'search_terms' )) ) {
53 53
             return $search;
54 54
         }
55 55
         global $wpdb;
56
-        $n = empty($query->get('exact'))
56
+        $n = empty($query->get( 'exact' ))
57 57
             ? '%'
58 58
             : '';
59 59
         $search = [];
60
-        foreach ((array) $query->get('search_terms') as $term) {
61
-            $search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n);
60
+        foreach( (array)$query->get( 'search_terms' ) as $term ) {
61
+            $search[] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like( $term ).$n );
62 62
         }
63
-        if (!is_user_logged_in()) {
63
+        if( !is_user_logged_in() ) {
64 64
             $search[] = "{$wpdb->posts}.post_password = ''";
65 65
         }
66
-        return ' AND '.implode(' AND ', $search);
66
+        return ' AND '.implode( ' AND ', $search );
67 67
     }
68 68
 
69 69
     /**
70 70
      * @param int $reviewId
71 71
      * @return \GeminiLabs\SiteReviews\Review|false
72 72
      */
73
-    public function insert($reviewId, array $data = [])
73
+    public function insert( $reviewId, array $data = [] )
74 74
     {
75
-        $defaults = glsr(RatingDefaults::class)->restrict($data);
76
-        $data = Arr::set($defaults, 'review_id', $reviewId);
77
-        $result = $this->insertRaw(glsr(Query::class)->table('ratings'), $data);
75
+        $defaults = glsr( RatingDefaults::class )->restrict( $data );
76
+        $data = Arr::set( $defaults, 'review_id', $reviewId );
77
+        $result = $this->insertRaw( glsr( Query::class )->table( 'ratings' ), $data );
78 78
         return (false !== $result)
79
-            ? glsr(ReviewManager::class)->get($reviewId)
79
+            ? glsr( ReviewManager::class )->get( $reviewId )
80 80
             : false;
81 81
     }
82 82
 
@@ -84,50 +84,50 @@  discard block
 block discarded – undo
84 84
      * @param string $table
85 85
      * @return int|false
86 86
      */
87
-    public function insertBulk($table, array $values, array $fields)
87
+    public function insertBulk( $table, array $values, array $fields )
88 88
     {
89 89
         $this->db->insert_id = 0;
90 90
         $data = [];
91
-        foreach ($values as $value) {
92
-            $value = array_intersect_key($value, array_flip($fields)); // only keep field values
93
-            if (count($value) === count($fields)) {
94
-                $value = array_merge(array_flip($fields), $value); // make sure the order is correct
95
-                $data[] = glsr(QuerySql::class)->escValuesForInsert($value);
91
+        foreach( $values as $value ) {
92
+            $value = array_intersect_key( $value, array_flip( $fields ) ); // only keep field values
93
+            if( count( $value ) === count( $fields ) ) {
94
+                $value = array_merge( array_flip( $fields ), $value ); // make sure the order is correct
95
+                $data[] = glsr( QuerySql::class )->escValuesForInsert( $value );
96 96
             }
97 97
         }
98
-        $table = glsr(Query::class)->table($table);
99
-        $fields = glsr(QuerySql::class)->escFieldsForInsert(array_keys($data));
100
-        $values = implode(',', array_values($data));
101
-        return $this->db->query("INSERT IGNORE INTO {$table} {$fields} VALUES {$values}");
98
+        $table = glsr( Query::class )->table( $table );
99
+        $fields = glsr( QuerySql::class )->escFieldsForInsert( array_keys( $data ) );
100
+        $values = implode( ',', array_values( $data ) );
101
+        return $this->db->query( "INSERT IGNORE INTO {$table} {$fields} VALUES {$values}" );
102 102
     }
103 103
 
104 104
     /**
105 105
      * @param string $table
106 106
      * @return int|false
107 107
      */
108
-    public function insertRaw($table, array $data)
108
+    public function insertRaw( $table, array $data )
109 109
     {
110 110
         $this->db->insert_id = 0;
111
-        $fields = glsr(QuerySql::class)->escFieldsForInsert(array_keys($data));
112
-        $values = glsr(QuerySql::class)->escValuesForInsert($data);
113
-        return $this->db->query("INSERT IGNORE INTO {$table} {$fields} VALUES {$values}");
111
+        $fields = glsr( QuerySql::class )->escFieldsForInsert( array_keys( $data ) );
112
+        $values = glsr( QuerySql::class )->escValuesForInsert( $data );
113
+        return $this->db->query( "INSERT IGNORE INTO {$table} {$fields} VALUES {$values}" );
114 114
     }
115 115
 
116 116
     /**
117 117
      * Do not remove this as it has been given in code snippets.
118 118
      * @return array
119 119
      */
120
-    public function getTerms(array $args = [])
120
+    public function getTerms( array $args = [] )
121 121
     {
122
-        $args = wp_parse_args($args, [
122
+        $args = wp_parse_args( $args, [
123 123
             'count' => false,
124 124
             'fields' => 'id=>name',
125 125
             'hide_empty' => false,
126 126
             'taxonomy' => glsr()->taxonomy,
127
-        ]);
128
-        $terms = get_terms($args);
129
-        if (is_wp_error($terms)) {
130
-            glsr_log()->error($terms->get_error_message());
127
+        ] );
128
+        $terms = get_terms( $args );
129
+        if( is_wp_error( $terms ) ) {
130
+            glsr_log()->error( $terms->get_error_message() );
131 131
             return [];
132 132
         }
133 133
         return $terms;
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
     public function isMigrationNeeded()
140 140
     {
141 141
         global $wpdb;
142
-        $table = glsr(Query::class)->table('ratings');
143
-        $postCount = wp_count_posts(glsr()->post_type)->publish;
144
-        if (empty($postCount)) {
142
+        $table = glsr( Query::class )->table( 'ratings' );
143
+        $postCount = wp_count_posts( glsr()->post_type )->publish;
144
+        if( empty($postCount) ) {
145 145
             return false;
146 146
         }
147
-        if (!empty($wpdb->get_var("SELECT COUNT(*) FROM {$table} WHERE is_approved = 1"))) {
147
+        if( !empty($wpdb->get_var( "SELECT COUNT(*) FROM {$table} WHERE is_approved = 1" )) ) {
148 148
             return false;
149 149
         }
150 150
         return true;
@@ -156,42 +156,42 @@  discard block
 block discarded – undo
156 156
      * @param bool $single
157 157
      * @return mixed
158 158
      */
159
-    public function meta($postId, $key, $single = true)
159
+    public function meta( $postId, $key, $single = true )
160 160
     {
161
-        $key = Str::prefix('_', $key);
162
-        return get_post_meta(Helper::castToInt($postId), $key, $single);
161
+        $key = Str::prefix( '_', $key );
162
+        return get_post_meta( Helper::castToInt( $postId ), $key, $single );
163 163
     }
164 164
 
165 165
     /**
166 166
      * @param string $searchTerm
167 167
      * @return void|string
168 168
      */
169
-    public function searchPosts($searchTerm)
169
+    public function searchPosts( $searchTerm )
170 170
     {
171 171
         $args = [
172 172
             'post_status' => 'publish',
173 173
             'post_type' => 'any',
174 174
         ];
175
-        if (is_numeric($searchTerm)) {
175
+        if( is_numeric( $searchTerm ) ) {
176 176
             $args['post__in'] = [$searchTerm];
177 177
         } else {
178 178
             $args['orderby'] = 'relevance';
179 179
             $args['posts_per_page'] = 10;
180 180
             $args['s'] = $searchTerm;
181 181
         }
182
-        add_filter('posts_search', [$this, 'filterSearchByTitle'], 500, 2);
183
-        $search = new WP_Query($args);
184
-        remove_filter('posts_search', [$this, 'filterSearchByTitle'], 500);
185
-        if ($search->have_posts()) {
182
+        add_filter( 'posts_search', [$this, 'filterSearchByTitle'], 500, 2 );
183
+        $search = new WP_Query( $args );
184
+        remove_filter( 'posts_search', [$this, 'filterSearchByTitle'], 500 );
185
+        if( $search->have_posts() ) {
186 186
             $results = '';
187
-            while ($search->have_posts()) {
187
+            while( $search->have_posts() ) {
188 188
                 $search->the_post();
189 189
                 ob_start();
190
-                glsr()->render('partials/editor/search-result', [
190
+                glsr()->render( 'partials/editor/search-result', [
191 191
                     'ID' => get_the_ID(),
192
-                    'permalink' => esc_url((string) get_permalink()),
193
-                    'title' => esc_attr(get_the_title()),
194
-                ]);
192
+                    'permalink' => esc_url( (string)get_permalink() ),
193
+                    'title' => esc_attr( get_the_title() ),
194
+                ] );
195 195
                 $results .= ob_get_clean();
196 196
             }
197 197
             wp_reset_postdata();
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
      * @param int $reviewId
204 204
      * @return int|bool
205 205
      */
206
-    public function update($reviewId, array $data = [])
206
+    public function update( $reviewId, array $data = [] )
207 207
     {
208
-        $defaults = glsr(RatingDefaults::class)->restrict($data);
209
-        $data = array_intersect_key($data, $defaults);
210
-        return $this->db->update(glsr(Query::class)->table('ratings'), $data, [
208
+        $defaults = glsr( RatingDefaults::class )->restrict( $data );
209
+        $data = array_intersect_key( $data, $defaults );
210
+        return $this->db->update( glsr( Query::class )->table( 'ratings' ), $data, [
211 211
             'review_id' => $reviewId,
212
-        ]);
212
+        ] );
213 213
     }
214 214
 }
Please login to merge, or discard this patch.
plugin/Helper.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
      * @param string $path
15 15
      * @return string
16 16
      */
17
-    public static function buildClassName($name, $path = '')
17
+    public static function buildClassName( $name, $path = '' )
18 18
     {
19
-        $className = Str::camelCase($name);
20
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
19
+        $className = Str::camelCase( $name );
20
+        $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' );
21 21
         return !empty($path)
22 22
             ? __NAMESPACE__.'\\'.$path.'\\'.$className
23 23
             : $className;
@@ -28,18 +28,18 @@  discard block
 block discarded – undo
28 28
      * @param string $prefix
29 29
      * @return string
30 30
      */
31
-    public static function buildMethodName($name, $prefix = '')
31
+    public static function buildMethodName( $name, $prefix = '' )
32 32
     {
33
-        return lcfirst(Str::camelCase($prefix.'-'.$name));
33
+        return lcfirst( Str::camelCase( $prefix.'-'.$name ) );
34 34
     }
35 35
 
36 36
     /**
37 37
      * @param string $name
38 38
      * @return string
39 39
      */
40
-    public static function buildPropertyName($name)
40
+    public static function buildPropertyName( $name )
41 41
     {
42
-        return static::buildMethodName($name);
42
+        return static::buildMethodName( $name );
43 43
     }
44 44
 
45 45
     /**
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
      * @param mixed $value
48 48
      * @return mixed
49 49
      */
50
-    public static function castTo($cast = '', $value)
50
+    public static function castTo( $cast = '', $value )
51 51
     {
52
-        $method = static::buildMethodName($cast, 'castTo');
53
-        return !empty($cast) && method_exists(__CLASS__, $method)
54
-            ? static::$method($value)
52
+        $method = static::buildMethodName( $cast, 'castTo' );
53
+        return !empty($cast) && method_exists( __CLASS__, $method )
54
+            ? static::$method( $value )
55 55
             : $value;
56 56
     }
57 57
 
@@ -59,73 +59,73 @@  discard block
 block discarded – undo
59 59
      * @param mixed $value
60 60
      * @return array
61 61
      */
62
-    public static function castToArray($value)
62
+    public static function castToArray( $value )
63 63
     {
64
-        return (array) $value;
64
+        return (array)$value;
65 65
     }
66 66
 
67 67
     /**
68 68
      * @param mixed $value
69 69
      * @return bool
70 70
      */
71
-    public static function castToBool($value)
71
+    public static function castToBool( $value )
72 72
     {
73
-        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
73
+        return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
74 74
     }
75 75
 
76 76
     /**
77 77
      * @param mixed $value
78 78
      * @return float
79 79
      */
80
-    public static function castToFloat($value)
80
+    public static function castToFloat( $value )
81 81
     {
82
-        return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
82
+        return (float)filter_var( $value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND );
83 83
     }
84 84
 
85 85
     /**
86 86
      * @param mixed $value
87 87
      * @return int
88 88
      */
89
-    public static function castToInt($value)
89
+    public static function castToInt( $value )
90 90
     {
91
-        return (int) filter_var($value, FILTER_VALIDATE_INT);
91
+        return (int)filter_var( $value, FILTER_VALIDATE_INT );
92 92
     }
93 93
 
94 94
     /**
95 95
      * @param mixed $value
96 96
      * @return object
97 97
      */
98
-    public static function castToObject($value)
98
+    public static function castToObject( $value )
99 99
     {
100
-        return (object) (array) $value;
100
+        return (object)(array)$value;
101 101
     }
102 102
 
103 103
     /**
104 104
      * @param mixed $value
105 105
      * @return string
106 106
      */
107
-    public static function castToString($value)
107
+    public static function castToString( $value )
108 108
     {
109
-        if (is_object($value) && in_array('__toString', get_class_methods($value))) {
110
-            return (string) $value->__toString();
109
+        if( is_object( $value ) && in_array( '__toString', get_class_methods( $value ) ) ) {
110
+            return (string)$value->__toString();
111 111
         }
112
-        if (is_array($value) || is_object($value)) {
113
-            return serialize($value);
112
+        if( is_array( $value ) || is_object( $value ) ) {
113
+            return serialize( $value );
114 114
         }
115
-        return (string) $value;
115
+        return (string)$value;
116 116
     }
117 117
 
118 118
     /**
119 119
      * @param string $key
120 120
      * @return mixed
121 121
      */
122
-    public static function filterInput($key, array $request = [])
122
+    public static function filterInput( $key, array $request = [] )
123 123
     {
124
-        if (isset($request[$key])) {
124
+        if( isset($request[$key]) ) {
125 125
             return $request[$key];
126 126
         }
127
-        $variable = filter_input(INPUT_POST, $key);
128
-        if (is_null($variable) && isset($_POST[$key])) {
127
+        $variable = filter_input( INPUT_POST, $key );
128
+        if( is_null( $variable ) && isset($_POST[$key]) ) {
129 129
             $variable = $_POST[$key];
130 130
         }
131 131
         return $variable;
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
      * @param string $key
136 136
      * @return array
137 137
      */
138
-    public static function filterInputArray($key)
138
+    public static function filterInputArray( $key )
139 139
     {
140
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
141
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
140
+        $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
141
+        if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
142 142
             $variable = $_POST[$key];
143 143
         }
144
-        return (array) $variable;
144
+        return (array)$variable;
145 145
     }
146 146
 
147 147
     /**
@@ -150,22 +150,22 @@  discard block
 block discarded – undo
150 150
     public static function getIpAddress()
151 151
     {
152 152
         $whitelist = [];
153
-        $isUsingCloudflare = !empty(filter_input(INPUT_SERVER, 'CF-Connecting-IP'));
154
-        if (glsr()->filterBool('whip/whitelist/cloudflare', $isUsingCloudflare)) {
155
-            $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
153
+        $isUsingCloudflare = !empty(filter_input( INPUT_SERVER, 'CF-Connecting-IP' ));
154
+        if( glsr()->filterBool( 'whip/whitelist/cloudflare', $isUsingCloudflare ) ) {
155
+            $cloudflareIps = glsr( Cache::class )->getCloudflareIps();
156 156
             $whitelist[Whip::CLOUDFLARE_HEADERS] = [Whip::IPV4 => $cloudflareIps['v4']];
157
-            if (defined('AF_INET6')) {
157
+            if( defined( 'AF_INET6' ) ) {
158 158
                 $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6'];
159 159
             }
160 160
         }
161
-        $whitelist = glsr()->filterArray('whip/whitelist', $whitelist);
162
-        $methods = glsr()->filterInt('whip/methods', Whip::ALL_METHODS);
163
-        $whip = new Whip($methods, $whitelist);
164
-        glsr()->action('whip', $whip);
165
-        if (false !== ($clientAddress = $whip->getValidIpAddress())) {
166
-            return (string) $clientAddress;
161
+        $whitelist = glsr()->filterArray( 'whip/whitelist', $whitelist );
162
+        $methods = glsr()->filterInt( 'whip/methods', Whip::ALL_METHODS );
163
+        $whip = new Whip( $methods, $whitelist );
164
+        glsr()->action( 'whip', $whip );
165
+        if( false !== ($clientAddress = $whip->getValidIpAddress()) ) {
166
+            return (string)$clientAddress;
167 167
         }
168
-        glsr_log()->error('Unable to detect IP address, please see the FAQ page for a possible solution.');
168
+        glsr_log()->error( 'Unable to detect IP address, please see the FAQ page for a possible solution.' );
169 169
         return 'unknown';
170 170
     }
171 171
 
@@ -174,16 +174,16 @@  discard block
 block discarded – undo
174 174
      * @param int $fallback
175 175
      * @return int
176 176
      */
177
-    public function getPageNumber($fromUrl = null, $fallback = 1)
177
+    public function getPageNumber( $fromUrl = null, $fallback = 1 )
178 178
     {
179
-        $pagedQueryVar = glsr()->constant('PAGED_QUERY_VAR');
179
+        $pagedQueryVar = glsr()->constant( 'PAGED_QUERY_VAR' );
180 180
         $pageNum = empty($fromUrl)
181
-            ? filter_input(INPUT_GET, $pagedQueryVar, FILTER_VALIDATE_INT)
182
-            : filter_var(Url::query($fromUrl, $pagedQueryVar), FILTER_VALIDATE_INT);
183
-        if (empty($pageNum)) {
184
-            $pageNum = (int) $fallback;
181
+            ? filter_input( INPUT_GET, $pagedQueryVar, FILTER_VALIDATE_INT )
182
+            : filter_var( Url::query( $fromUrl, $pagedQueryVar ), FILTER_VALIDATE_INT );
183
+        if( empty($pageNum) ) {
184
+            $pageNum = (int)$fallback;
185 185
         }
186
-        return max(1, $pageNum);
186
+        return max( 1, $pageNum );
187 187
     }
188 188
 
189 189
     /**
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
      * @param mixed $fallback
192 192
      * @return bool
193 193
      */
194
-    public static function ifEmpty($value, $fallback)
194
+    public static function ifEmpty( $value, $fallback )
195 195
     {
196
-        return static::isEmpty($value) ? $fallback : $value;
196
+        return static::isEmpty( $value ) ? $fallback : $value;
197 197
     }
198 198
 
199 199
     /**
@@ -202,12 +202,12 @@  discard block
 block discarded – undo
202 202
      * @param string|int $max
203 203
      * @return bool
204 204
      */
205
-    public static function inRange($value, $min, $max)
205
+    public static function inRange( $value, $min, $max )
206 206
     {
207
-        $inRange = filter_var($value, FILTER_VALIDATE_INT, ['options' => [
208
-            'min_range' => intval($min),
209
-            'max_range' => intval($max),
210
-        ]]);
207
+        $inRange = filter_var( $value, FILTER_VALIDATE_INT, ['options' => [
208
+            'min_range' => intval( $min ),
209
+            'max_range' => intval( $max ),
210
+        ]] );
211 211
         return false !== $inRange;
212 212
     }
213 213
 
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
      * @param mixed $value
216 216
      * @return bool
217 217
      */
218
-    public static function isEmpty($value)
218
+    public static function isEmpty( $value )
219 219
     {
220
-        return !is_numeric($value) && !is_bool($value) && empty($value);
220
+        return !is_numeric( $value ) && !is_bool( $value ) && empty($value);
221 221
     }
222 222
 
223 223
     /**
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
      * @param int|string $compareWithValue
226 226
      * @return bool
227 227
      */
228
-    public static function isGreaterThan($value, $compareWithValue)
228
+    public static function isGreaterThan( $value, $compareWithValue )
229 229
     {
230
-        return version_compare($value, $compareWithValue, '>');
230
+        return version_compare( $value, $compareWithValue, '>' );
231 231
     }
232 232
 
233 233
     /**
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
      * @param int|string $compareWithValue
236 236
      * @return bool
237 237
      */
238
-    public static function isGreaterThanOrEqual($value, $compareWithValue)
238
+    public static function isGreaterThanOrEqual( $value, $compareWithValue )
239 239
     {
240
-        return version_compare($value, $compareWithValue, '>=');
240
+        return version_compare( $value, $compareWithValue, '>=' );
241 241
     }
242 242
 
243 243
     /**
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
      * @param int|string $compareWithValue
246 246
      * @return bool
247 247
      */
248
-    public static function isLessThan($value, $compareWithValue)
248
+    public static function isLessThan( $value, $compareWithValue )
249 249
     {
250
-        return version_compare($value, $compareWithValue, '<');
250
+        return version_compare( $value, $compareWithValue, '<' );
251 251
     }
252 252
 
253 253
     /**
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
      * @param int|string $compareWithValue
256 256
      * @return bool
257 257
      */
258
-    public static function isLessThanOrEqual($value, $compareWithValue)
258
+    public static function isLessThanOrEqual( $value, $compareWithValue )
259 259
     {
260
-        return version_compare($value, $compareWithValue, '<=');
260
+        return version_compare( $value, $compareWithValue, '<=' );
261 261
     }
262 262
 }
Please login to merge, or discard this patch.
plugin/Commands/TogglePinned.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
     public $isPinned;
13 13
     public $review;
14 14
 
15
-    public function __construct($input)
15
+    public function __construct( $input )
16 16
     {
17
-        $this->review = glsr(Query::class)->review($input['id']);
17
+        $this->review = glsr( Query::class )->review( $input['id'] );
18 18
         $this->isPinned = isset($input['pinned'])
19
-            ? wp_validate_boolean($input['pinned'])
19
+            ? wp_validate_boolean( $input['pinned'] )
20 20
             : !$this->review->is_pinned;
21 21
     }
22 22
 
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function handle()
27 27
     {
28
-        if (!glsr()->can('edit_others_posts')) {
29
-            return wp_validate_boolean($this->review->is_pinned);
28
+        if( !glsr()->can( 'edit_others_posts' ) ) {
29
+            return wp_validate_boolean( $this->review->is_pinned );
30 30
         }
31
-        if ($this->isPinned !== $this->review->is_pinned) {
32
-            glsr(Database::class)->update($this->review->ID, [
31
+        if( $this->isPinned !== $this->review->is_pinned ) {
32
+            glsr( Database::class )->update( $this->review->ID, [
33 33
                 'is_pinned' => $this->isPinned,
34
-            ]);
34
+            ] );
35 35
             $notice = $this->isPinned
36
-                ? _x('Review pinned.', 'admin-text', 'site-reviews')
37
-                : _x('Review unpinned.', 'admin-text', 'site-reviews');
38
-            glsr(Notice::class)->addSuccess($notice);
36
+                ? _x( 'Review pinned.', 'admin-text', 'site-reviews' )
37
+                : _x( 'Review unpinned.', 'admin-text', 'site-reviews' );
38
+            glsr( Notice::class )->addSuccess( $notice );
39 39
         }
40 40
         return $this->isPinned;
41 41
     }
Please login to merge, or discard this patch.
plugin/Commands/AssignPosts.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     public $ratingId;
11 11
     public $postIds;
12 12
 
13
-    public function __construct($ratingId, array $postIds)
13
+    public function __construct( $ratingId, array $postIds )
14 14
     {
15 15
         $this->ratingId = $ratingId;
16 16
         $this->postIds = $postIds;
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function handle()
23 23
     {
24
-        foreach ($this->postIds as $postId) {
25
-            glsr(ReviewManager::class)->assignPost($this->ratingId, $postId);
24
+        foreach( $this->postIds as $postId ) {
25
+            glsr( ReviewManager::class )->assignPost( $this->ratingId, $postId );
26 26
         }
27 27
     }
28 28
 }
Please login to merge, or discard this patch.
plugin/Defaults/DefaultsAbstract.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
      * @param string $name
44 44
      * @return void|array
45 45
      */
46
-    public function __call($name, array $args = [])
46
+    public function __call( $name, array $args = [] )
47 47
     {
48
-        if (!method_exists($this, $name) || !in_array($name, $this->callable)) {
49
-            glsr_log()->error("Invalid method [$name].");
48
+        if( !method_exists( $this, $name ) || !in_array( $name, $this->callable ) ) {
49
+            glsr_log()->error( "Invalid method [$name]." );
50 50
             return;
51 51
         }
52
-        $args[0] = $this->mapKeys(Arr::get($args, 0, []));
53
-        $defaults = $this->sanitize(call_user_func_array([$this, $name], $args));
54
-        $hookName = (new ReflectionClass($this))->getShortName();
55
-        $hookName = str_replace('Defaults', '', $hookName);
56
-        $hookName = Str::dashCase($hookName);
57
-        return glsr()->filterArray('defaults/'.$hookName, $defaults, $name);
52
+        $args[0] = $this->mapKeys( Arr::get( $args, 0, [] ) );
53
+        $defaults = $this->sanitize( call_user_func_array( [$this, $name], $args ) );
54
+        $hookName = (new ReflectionClass( $this ))->getShortName();
55
+        $hookName = str_replace( 'Defaults', '', $hookName );
56
+        $hookName = Str::dashCase( $hookName );
57
+        return glsr()->filterArray( 'defaults/'.$hookName, $defaults, $name );
58 58
     }
59 59
 
60 60
     /**
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
     /**
66 66
      * @return array
67 67
      */
68
-    protected function filter(array $values = [])
68
+    protected function filter( array $values = [] )
69 69
     {
70
-        return $this->merge(array_filter($values));
70
+        return $this->merge( array_filter( $values ) );
71 71
     }
72 72
 
73 73
     /**
74 74
      * @return array
75 75
      */
76
-    protected function filteredData(array $values = [])
76
+    protected function filteredData( array $values = [] )
77 77
     {
78
-        $defaults = $this->flattenArrayValues($this->unguarded());
79
-        $values = $this->flattenArrayValues(shortcode_atts($defaults, $values));
80
-        $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) {
81
-            return !$this->isEmpty($value);
78
+        $defaults = $this->flattenArrayValues( $this->unguarded() );
79
+        $values = $this->flattenArrayValues( shortcode_atts( $defaults, $values ) );
80
+        $filtered = array_filter( array_diff_assoc( $values, $defaults ), function( $value ) {
81
+            return !$this->isEmpty( $value );
82 82
         });
83 83
         $filteredJson = [];
84
-        foreach ($filtered as $key => $value) {
85
-            $filteredJson['data-'.$key] = is_array($value)
86
-                ? json_encode($value, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
84
+        foreach( $filtered as $key => $value ) {
85
+            $filteredJson['data-'.$key] = is_array( $value )
86
+                ? json_encode( $value, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )
87 87
                 : $value;
88 88
         }
89 89
         return $filteredJson;
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
     /**
93 93
      * @return array
94 94
      */
95
-    protected function flattenArrayValues(array $values)
95
+    protected function flattenArrayValues( array $values )
96 96
     {
97
-        array_walk($values, function (&$value) {
98
-            if (is_array($value)) {
99
-                $value = implode(',', $value);
97
+        array_walk( $values, function( &$value ) {
98
+            if( is_array( $value ) ) {
99
+                $value = implode( ',', $value );
100 100
             }
101 101
         });
102 102
         return $values;
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
      * @param mixed $var
107 107
      * @return bool
108 108
      */
109
-    protected function isEmpty($var)
109
+    protected function isEmpty( $var )
110 110
     {
111
-        return !is_numeric($var) && !is_bool($var) && empty($var);
111
+        return !is_numeric( $var ) && !is_bool( $var ) && empty($var);
112 112
     }
113 113
 
114 114
     /**
115 115
      * @return array
116 116
      */
117
-    protected function mapKeys(array $args)
117
+    protected function mapKeys( array $args )
118 118
     {
119
-        foreach ($this->mapped as $old => $new) {
120
-            if (array_key_exists($old, $args)) {
119
+        foreach( $this->mapped as $old => $new ) {
120
+            if( array_key_exists( $old, $args ) ) {
121 121
                 $args[$new] = $args[$old];
122 122
                 unset($args[$old]);
123 123
             }
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
     /**
129 129
      * @return array
130 130
      */
131
-    protected function merge(array $values = [])
131
+    protected function merge( array $values = [] )
132 132
     {
133
-        return $this->parse($values, $this->defaults());
133
+        return $this->parse( $values, $this->defaults() );
134 134
     }
135 135
 
136 136
     /**
137 137
      * @param mixed $values
138 138
      * @return array
139 139
      */
140
-    protected function normalize($values)
140
+    protected function normalize( $values )
141 141
     {
142
-        if (!is_string($values)) {
143
-            return Arr::consolidate($values);
142
+        if( !is_string( $values ) ) {
143
+            return Arr::consolidate( $values );
144 144
         }
145 145
         $normalized = [];
146
-        wp_parse_str($values, $normalized);
146
+        wp_parse_str( $values, $normalized );
147 147
         return $normalized;
148 148
     }
149 149
 
@@ -152,16 +152,16 @@  discard block
 block discarded – undo
152 152
      * @param mixed $defaults
153 153
      * @return array
154 154
      */
155
-    protected function parse($values, $defaults)
155
+    protected function parse( $values, $defaults )
156 156
     {
157
-        $values = $this->normalize($values);
158
-        if (!is_array($defaults)) {
157
+        $values = $this->normalize( $values );
158
+        if( !is_array( $defaults ) ) {
159 159
             return $values;
160 160
         }
161 161
         $parsed = $defaults;
162
-        foreach ($values as $key => $value) {
163
-            if (is_array($value) && isset($parsed[$key])) {
164
-                $parsed[$key] = Arr::unique($this->parse($value, $parsed[$key]));
162
+        foreach( $values as $key => $value ) {
163
+            if( is_array( $value ) && isset($parsed[$key]) ) {
164
+                $parsed[$key] = Arr::unique( $this->parse( $value, $parsed[$key] ) );
165 165
                 continue;
166 166
             }
167 167
             $parsed[$key] = $value;
@@ -173,17 +173,17 @@  discard block
 block discarded – undo
173 173
      * @param mixed $values
174 174
      * @return array
175 175
      */
176
-    protected function parseRestricted($values, array $pairs)
176
+    protected function parseRestricted( $values, array $pairs )
177 177
     {
178
-        $values = $this->normalize($values);
178
+        $values = $this->normalize( $values );
179 179
         $parsed = [];
180
-        foreach ($pairs as $key => $default) {
181
-          if (!array_key_exists($key, $values)) {
180
+        foreach( $pairs as $key => $default ) {
181
+          if( !array_key_exists( $key, $values ) ) {
182 182
               $parsed[$key] = $default;
183 183
               continue;
184 184
           }
185
-          if (is_array($default)) {
186
-              $parsed[$key] = $this->parse($values[$key], $default);
185
+          if( is_array( $default ) ) {
186
+              $parsed[$key] = $this->parse( $values[$key], $default );
187 187
               continue;
188 188
           }
189 189
           $parsed[$key] = $values[$key];
@@ -194,23 +194,23 @@  discard block
 block discarded – undo
194 194
     /**
195 195
      * @return array
196 196
      */
197
-    protected function restrict(array $values = [])
197
+    protected function restrict( array $values = [] )
198 198
     {
199
-        return $this->parseRestricted($values, $this->defaults());
199
+        return $this->parseRestricted( $values, $this->defaults() );
200 200
     }
201 201
 
202 202
     /**
203 203
      * @return array
204 204
      */
205
-    protected function sanitize(array $values = [])
205
+    protected function sanitize( array $values = [] )
206 206
     {
207
-        foreach ($this->casts as $key => $cast) {
208
-            if (!array_key_exists($key, $values)) {
207
+        foreach( $this->casts as $key => $cast ) {
208
+            if( !array_key_exists( $key, $values ) ) {
209 209
                 continue;
210 210
             }
211
-            $values[$key] = Helper::castTo($cast, $values[$key]);
212
-            if ('string' === $cast) {
213
-                $values[$key] = sanitize_key($values[$key]);
211
+            $values[$key] = Helper::castTo( $cast, $values[$key] );
212
+            if( 'string' === $cast ) {
213
+                $values[$key] = sanitize_key( $values[$key] );
214 214
             }
215 215
         }
216 216
         return $values;
@@ -221,6 +221,6 @@  discard block
 block discarded – undo
221 221
      */
222 222
     protected function unguarded()
223 223
     {
224
-        return array_diff_key($this->defaults(), array_flip($this->guarded));
224
+        return array_diff_key( $this->defaults(), array_flip( $this->guarded ) );
225 225
     }
226 226
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableColumns/ColumnValueResponse.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
     /**
11 11
      * {@inheritdoc}
12 12
      */
13
-    public function handle(Review $review)
13
+    public function handle( Review $review )
14 14
     {
15
-        return glsr(Database::class)->meta($review->ID, 'response')
16
-            ? _x('Yes', 'admin-text', 'site-reviews')
17
-            : _x('No', 'admin-text', 'site-reviews');
15
+        return glsr( Database::class )->meta( $review->ID, 'response' )
16
+            ? _x( 'Yes', 'admin-text', 'site-reviews' )
17
+            : _x( 'No', 'admin-text', 'site-reviews' );
18 18
     }
19 19
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableColumns/ColumnValuePinned.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
     /**
11 11
      * {@inheritdoc}
12 12
      */
13
-    public function handle(Review $review)
13
+    public function handle( Review $review )
14 14
     {
15 15
         $pinned = $review->is_pinned ? 'pinned ' : '';
16
-        if (glsr()->can('edit_others_posts')) {
16
+        if( glsr()->can( 'edit_others_posts' ) ) {
17 17
             $pinned .= 'pin-review ';
18 18
         }
19
-        return glsr(Builder::class)->i([
19
+        return glsr( Builder::class )->i( [
20 20
             'class' => $pinned.'dashicons dashicons-sticky',
21 21
             'data-id' => $review->ID,
22
-        ]);
22
+        ] );
23 23
     }
24 24
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableColumns/ColumnValueAssignedTo.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * @return array
15 15
      */
16
-    public function assignedLinks(array $postIds)
16
+    public function assignedLinks( array $postIds )
17 17
     {
18 18
         $links = [];
19 19
         $usedIds = [];
20
-        foreach ($postIds as $postId) {
21
-            $post = get_post(glsr(Multilingual::class)->getPostId($postId));
22
-            if (!empty($post->ID) && !in_array($post->ID, $usedIds)) {
23
-                $links[] = glsr(Builder::class)->a([
24
-                    'href' => get_the_permalink($post->ID),
25
-                    'text' => get_the_title($post->ID),
26
-                ]);
20
+        foreach( $postIds as $postId ) {
21
+            $post = get_post( glsr( Multilingual::class )->getPostId( $postId ) );
22
+            if( !empty($post->ID) && !in_array( $post->ID, $usedIds ) ) {
23
+                $links[] = glsr( Builder::class )->a( [
24
+                    'href' => get_the_permalink( $post->ID ),
25
+                    'text' => get_the_title( $post->ID ),
26
+                ] );
27 27
                 $usedIds[] = $post->ID;
28
-                $usedIds = Arr::unique($usedIds);
28
+                $usedIds = Arr::unique( $usedIds );
29 29
             }
30 30
         }
31 31
         return $links;
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
     /**
35 35
      * {@inheritdoc}
36 36
      */
37
-    public function handle(Review $review)
37
+    public function handle( Review $review )
38 38
     {
39
-        return Str::naturalJoin($this->assignedLinks($review->assigned_post_ids));
39
+        return Str::naturalJoin( $this->assignedLinks( $review->assigned_post_ids ) );
40 40
     }
41 41
 }
Please login to merge, or discard this patch.