@@ -54,57 +54,57 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | public function run() |
| 56 | 56 | { |
| 57 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
| 58 | - add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
| 59 | - add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
| 60 | - add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
| 61 | - add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
| 62 | - add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
| 63 | - add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
| 64 | - add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
| 65 | - add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
| 66 | - add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
| 67 | - add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
| 68 | - add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'], 10, 2 ); |
|
| 69 | - add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
| 70 | - add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
| 71 | - add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
| 72 | - add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
| 73 | - add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
| 74 | - add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
| 75 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
| 76 | - add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
| 77 | - add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
| 78 | - add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
| 79 | - add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
| 80 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
| 81 | - add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
| 82 | - add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
| 83 | - add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
| 84 | - add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
| 85 | - add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
| 86 | - add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
| 87 | - add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
| 88 | - add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
| 89 | - add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
| 90 | - add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
| 91 | - add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
| 92 | - add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
| 93 | - add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
| 94 | - add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
| 95 | - add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
| 96 | - add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
| 97 | - add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
| 98 | - add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
| 99 | - add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
| 57 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
| 58 | + add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
| 59 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
| 60 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
| 61 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
| 62 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
| 63 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
| 64 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
| 65 | + add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
| 66 | + add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
| 67 | + add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
| 68 | + add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'], 10, 2 ); |
|
| 69 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
| 70 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
| 71 | + add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
| 72 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
| 73 | + add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
| 74 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
| 75 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
| 76 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
| 77 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
| 78 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
| 79 | + add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
| 80 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
| 81 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
| 82 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
| 83 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
| 84 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
| 85 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
| 86 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
| 87 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
| 88 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
| 89 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
| 90 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
| 91 | + add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
| 92 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
| 93 | + add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
| 94 | + add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
| 95 | + add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
| 96 | + add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
| 97 | + add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
| 98 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
| 99 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
| 100 | 100 | add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
| 101 | - add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
| 102 | - add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
| 103 | - add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
| 104 | - add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
| 105 | - add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
| 106 | - add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
| 107 | - add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
| 108 | - add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
| 101 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
| 102 | + add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
| 103 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
| 104 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
| 105 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
| 106 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
| 107 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
| 108 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
| 109 | 109 | } |
| 110 | 110 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'setting' => 'Plugin Settings', |
| 41 | 41 | 'reviews' => 'Review Counts', |
| 42 | 42 | ]; |
| 43 | - $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) { |
|
| 43 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) { |
|
| 44 | 44 | $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' ); |
| 45 | 45 | if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
| 46 | 46 | return $carry.$this->implode( |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $plugins = get_plugins(); |
| 62 | 62 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 63 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
| 64 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 63 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
| 64 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function getInactivePluginDetails() |
| 96 | 96 | { |
| 97 | 97 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 98 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
| 98 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $plugins = array_merge( |
| 107 | 107 | get_mu_plugins(), |
| 108 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
| 108 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
| 109 | 109 | ); |
| 110 | - if( empty( $plugins ))return; |
|
| 110 | + if( empty($plugins) )return; |
|
| 111 | 111 | return $this->normalizePluginList( $plugins ); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function getMultisitePluginDetails() |
| 118 | 118 | { |
| 119 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
| 119 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
| 120 | 120 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | 'Max Input Vars' => ini_get( 'max_input_vars' ), |
| 144 | 144 | 'Memory Limit' => ini_get( 'memory_limit' ), |
| 145 | 145 | 'Post Max Size' => ini_get( 'post_max_size' ), |
| 146 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
| 147 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
| 148 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
| 149 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
| 150 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
| 146 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
| 147 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
| 148 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
| 149 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
| 150 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
| 151 | 151 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
| 152 | 152 | ]; |
| 153 | 153 | } |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $counts = glsr( CountsManager::class )->getCounts(); |
| 161 | 161 | $counts = glsr( Helper::class )->flattenArray( $counts ); |
| 162 | - array_walk( $counts, function( &$ratings ) use( $counts ) { |
|
| 163 | - if( !is_array( $ratings )) { |
|
| 162 | + array_walk( $counts, function( &$ratings ) use($counts) { |
|
| 163 | + if( !is_array( $ratings ) ) { |
|
| 164 | 164 | glsr_log() |
| 165 | 165 | ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
| 166 | 166 | ->debug( $ratings ) |
@@ -199,8 +199,8 @@ discard block |
||
| 199 | 199 | ksort( $settings ); |
| 200 | 200 | $details = []; |
| 201 | 201 | foreach( $settings as $key => $value ) { |
| 202 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
| 203 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
| 202 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
| 203 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
| 204 | 204 | $details[$key] = $value; |
| 205 | 205 | } |
| 206 | 206 | return $details; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | { |
| 214 | 214 | return [ |
| 215 | 215 | 'Console size' => glsr( Console::class )->humanSize( '0' ), |
| 216 | - 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' )), |
|
| 216 | + 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ), |
|
| 217 | 217 | 'Version (current)' => glsr()->version, |
| 218 | 218 | 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
| 219 | 219 | ]; |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | 'WPE_APIKEY' => 'WP Engine', |
| 274 | 274 | ]; |
| 275 | 275 | foreach( $checks as $key => $value ) { |
| 276 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
| 276 | + if( !$this->isWebhostCheckValid( $key ) )continue; |
|
| 277 | 277 | return $value; |
| 278 | 278 | } |
| 279 | - return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
|
| 279 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | { |
| 298 | 298 | $plugins = get_plugins(); |
| 299 | 299 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 300 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
| 301 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 300 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
| 301 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 302 | 302 | return $active + $inactive; |
| 303 | 303 | } |
| 304 | 304 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | protected function implode( $title, array $details ) |
| 310 | 310 | { |
| 311 | 311 | $strings = ['['.$title.']']; |
| 312 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
| 312 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
| 313 | 313 | $padding = max( [$padding, static::PAD] ); |
| 314 | 314 | foreach( $details as $key => $value ) { |
| 315 | 315 | $strings[] = is_string( $key ) |
@@ -352,9 +352,9 @@ discard block |
||
| 352 | 352 | $keys = [ |
| 353 | 353 | 'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret', |
| 354 | 354 | ]; |
| 355 | - array_walk( $settings, function( &$value, $setting ) use( $keys ) { |
|
| 355 | + array_walk( $settings, function( &$value, $setting ) use($keys) { |
|
| 356 | 356 | foreach( $keys as $key ) { |
| 357 | - if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue; |
|
| 357 | + if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue; |
|
| 358 | 358 | $value = str_repeat( '•', 13 ); |
| 359 | 359 | return; |
| 360 | 360 | } |
@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | * @see https://wordpress.org/plugins/wp-super-cache/ |
| 21 | 21 | */ |
| 22 | 22 | add_action( 'site-reviews/review/created', function( $review, $request ) { |
| 23 | - if( !function_exists( 'wp_cache_post_change' ))return; |
|
| 23 | + if( !function_exists( 'wp_cache_post_change' ) )return; |
|
| 24 | 24 | wp_cache_post_change( $request->post_id ); |
| 25 | - if( empty( $review->assigned_to ) || $review->assigned_to == $request->post_id )return; |
|
| 25 | + if( empty($review->assigned_to) || $review->assigned_to == $request->post_id )return; |
|
| 26 | 26 | wp_cache_post_change( $review->assigned_to ); |
| 27 | 27 | }, 10, 2 ); |
| 28 | 28 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | add_filter( 'sbp_exclude_defer_scripts', function( $scriptHandles ) { |
| 35 | 35 | $scriptHandles[] = 'site-reviews/google-recaptcha'; |
| 36 | - return array_keys( array_flip( $scriptHandles )); |
|
| 36 | + return array_keys( array_flip( $scriptHandles ) ); |
|
| 37 | 37 | }); |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | * @see https://searchandfilter.com/ |
| 44 | 44 | */ |
| 45 | 45 | add_filter( 'sf_edit_query_args', function( $query ) { |
| 46 | - if( !empty( $query['meta_key'] ) && $query['meta_key'] == '_glsr_ranking' ) { |
|
| 47 | - unset( $query['meta_key'] ); |
|
| 46 | + if( !empty($query['meta_key']) && $query['meta_key'] == '_glsr_ranking' ) { |
|
| 47 | + unset($query['meta_key']); |
|
| 48 | 48 | $query['meta_query'] = [ |
| 49 | 49 | 'relation' => 'OR', |
| 50 | 50 | ['key' => '_glsr_ranking', 'compare' => 'EXISTS'], |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $className = str_replace( '.php', '', $file ); |
| 25 | 25 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
| 26 | 26 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
| 27 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
| 27 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ) )return; |
|
| 28 | 28 | glsr( 'Modules\\Upgrader\\'.$className ); |
| 29 | 29 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
| 30 | 30 | }); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $this->setReviewCounts(); |
| 42 | 42 | $this->updateVersionFrom( $version ); |
| 43 | 43 | } |
| 44 | - else if( !glsr( OptionManager::class )->get( 'last_review_count', false )) { |
|
| 44 | + else if( !glsr( OptionManager::class )->get( 'last_review_count', false ) ) { |
|
| 45 | 45 | $this->setReviewCounts(); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | foreach( $this->rules as $attribute => $rules ) { |
| 75 | 75 | foreach( $rules as $rule ) { |
| 76 | 76 | $this->validateAttribute( $attribute, $rule ); |
| 77 | - if( $this->shouldStopValidating( $attribute ))break; |
|
| 77 | + if( $this->shouldStopValidating( $attribute ) )break; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | return $this->errors; |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function validateAttribute( $attribute, $rule ) |
| 91 | 91 | { |
| 92 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
| 92 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
| 93 | 93 | if( $rule == '' )return; |
| 94 | 94 | $value = $this->getValue( $attribute ); |
| 95 | - if( !method_exists( $this, $method = 'validate'.$rule )) { |
|
| 95 | + if( !method_exists( $this, $method = 'validate'.$rule ) ) { |
|
| 96 | 96 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
| 97 | 97 | } |
| 98 | - if( !$this->$method( $value, $attribute, $parameters )) { |
|
| 98 | + if( !$this->$method( $value, $attribute, $parameters ) ) { |
|
| 99 | 99 | $this->addFailure( $attribute, $rule, $parameters ); |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | protected function getMessage( $attribute, $rule, array $parameters ) |
| 146 | 146 | { |
| 147 | - if( in_array( $rule, $this->sizeRules )) { |
|
| 147 | + if( in_array( $rule, $this->sizeRules ) ) { |
|
| 148 | 148 | return $this->getSizeMessage( $attribute, $rule, $parameters ); |
| 149 | 149 | } |
| 150 | 150 | $lowerRule = glsr( Helper::class )->snakeCase( $rule ); |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | protected function getRule( $attribute, $rules ) |
| 161 | 161 | { |
| 162 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
| 162 | + if( !array_key_exists( $attribute, $this->rules ) )return; |
|
| 163 | 163 | $rules = (array)$rules; |
| 164 | 164 | foreach( $this->rules[$attribute] as $rule ) { |
| 165 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
| 166 | - if( in_array( $rule, $rules )) { |
|
| 165 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
| 166 | + if( in_array( $rule, $rules ) ) { |
|
| 167 | 167 | return [$rule, $parameters]; |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | if( is_numeric( $value ) && $hasNumeric ) { |
| 182 | 182 | return $value; |
| 183 | 183 | } |
| 184 | - else if( is_array( $value )) { |
|
| 184 | + else if( is_array( $value ) ) { |
|
| 185 | 185 | return count( $value ); |
| 186 | 186 | } |
| 187 | 187 | return function_exists( 'mb_strlen' ) |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | protected function getValue( $attribute ) |
| 211 | 211 | { |
| 212 | - if( isset( $this->data[$attribute] )) { |
|
| 212 | + if( isset($this->data[$attribute]) ) { |
|
| 213 | 213 | return $this->data[$attribute]; |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | protected function hasRule( $attribute, $rules ) |
| 224 | 224 | { |
| 225 | - return !is_null( $this->getRule( $attribute, $rules )); |
|
| 225 | + return !is_null( $this->getRule( $attribute, $rules ) ); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | { |
| 261 | 261 | $parameters = []; |
| 262 | 262 | if( strpos( $rule, ':' ) !== false ) { |
| 263 | - list( $rule, $parameter ) = explode( ':', $rule, 2 ); |
|
| 263 | + list($rule, $parameter) = explode( ':', $rule, 2 ); |
|
| 264 | 264 | $parameters = $this->parseParameters( $rule, $parameter ); |
| 265 | 265 | } |
| 266 | 266 | $rule = glsr( Helper::class )->camelCase( $rule ); |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | protected function shouldStopValidating( $attribute ) |
| 290 | 290 | { |
| 291 | 291 | return $this->hasRule( $attribute, $this->implicitRules ) |
| 292 | - && isset( $this->failedRules[$attribute] ) |
|
| 292 | + && isset($this->failedRules[$attribute]) |
|
| 293 | 293 | && array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules ); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | protected function translator( $key, array $parameters ) |
| 303 | 303 | { |
| 304 | 304 | $strings = glsr( ValidationStringsDefaults::class )->defaults(); |
| 305 | - if( isset( $strings[$key] )) { |
|
| 305 | + if( isset($strings[$key]) ) { |
|
| 306 | 306 | return $this->replace( $strings[$key], $parameters ); |
| 307 | 307 | } |
| 308 | 308 | return "error"; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function __construct() |
| 34 | 34 | { |
| 35 | 35 | static::$instance = $this; |
| 36 | - $this->file = realpath( trailingslashit( dirname( __DIR__ )).static::ID.'.php' ); |
|
| 36 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
| 37 | 37 | $plugin = get_file_data( $this->file, [ |
| 38 | 38 | 'languages' => 'Domain Path', |
| 39 | 39 | 'name' => 'Plugin Name', |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $constant = 'static::'.$property; |
| 87 | 87 | return defined( $constant ) |
| 88 | - ? apply_filters( 'site-reviews/const/'.$property, constant( $constant )) |
|
| 88 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
| 89 | 89 | : ''; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | public function file( $view ) |
| 105 | 105 | { |
| 106 | 106 | $file = ''; |
| 107 | - $view.= '.php'; |
|
| 108 | - if( glsr( Helper::class )->startsWith( 'templates/', $view )) { |
|
| 109 | - $file = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view )); |
|
| 110 | - if( !file_exists( $file )) { |
|
| 107 | + $view .= '.php'; |
|
| 108 | + if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) { |
|
| 109 | + $file = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) ); |
|
| 110 | + if( !file_exists( $file ) ) { |
|
| 111 | 111 | $file = $this->path( $view ); |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | - if( !file_exists( $file )) { |
|
| 114 | + if( !file_exists( $file ) ) { |
|
| 115 | 115 | $file = $this->path( 'views/'.$view ); |
| 116 | 116 | } |
| 117 | 117 | return $file; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function getDefaults() |
| 124 | 124 | { |
| 125 | - if( empty( $this->defaults )) { |
|
| 125 | + if( empty($this->defaults) ) { |
|
| 126 | 126 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
| 127 | 127 | $this->upgrade(); |
| 128 | 128 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | public function hasPermission() |
| 136 | 136 | { |
| 137 | 137 | $isAdmin = $this->isAdmin(); |
| 138 | - return !$isAdmin || ( $isAdmin && current_user_can( $this->constant( 'CAPABILITY' ))); |
|
| 138 | + return !$isAdmin || ($isAdmin && current_user_can( $this->constant( 'CAPABILITY' ) )); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
| 192 | 192 | $this->reviewTypes = wp_parse_args( $types, [ |
| 193 | 193 | 'local' => __( 'Local', 'site-reviews' ), |
| 194 | - ]); |
|
| 194 | + ] ); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
| 204 | 204 | $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
| 205 | - if( !file_exists( $file )) { |
|
| 205 | + if( !file_exists( $file ) ) { |
|
| 206 | 206 | glsr_log()->error( 'File not found: '.$file ); |
| 207 | 207 | return; |
| 208 | 208 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function scheduleCronJob() |
| 218 | 218 | { |
| 219 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 219 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
| 220 | 220 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public function unscheduleCronJob() |
| 236 | 236 | { |
| 237 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
| 237 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public function url( $path = '' ) |
| 268 | 268 | { |
| 269 | - $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 269 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
| 270 | 270 | return apply_filters( 'site-reviews/url', $url, $path ); |
| 271 | 271 | } |
| 272 | 272 | } |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | $ipAddresses = array_fill_keys( ['v4', 'v6'], [] ); |
| 20 | 20 | foreach( array_keys( $ipAddresses ) as $version ) { |
| 21 | 21 | $response = wp_remote_get( 'https://www.cloudflare.com/ips-'.$version ); |
| 22 | - if( is_wp_error( $response )) { |
|
| 22 | + if( is_wp_error( $response ) ) { |
|
| 23 | 23 | glsr_log()->error( $response->get_error_message() ); |
| 24 | 24 | continue; |
| 25 | 25 | } |
| 26 | 26 | $ipAddresses[$version] = array_filter( |
| 27 | - (array)preg_split( '/\R/', wp_remote_retrieve_body( $response )) |
|
| 27 | + (array)preg_split( '/\R/', wp_remote_retrieve_body( $response ) ) |
|
| 28 | 28 | ); |
| 29 | 29 | } |
| 30 | 30 | set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, static::EXPIRY_TIME ); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if( $test === false ) { |
| 60 | 60 | $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' ); |
| 61 | 61 | $test = !is_wp_error( $response ) |
| 62 | - && in_array( $response['response']['code'], range( 200, 299 )) |
|
| 62 | + && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
| 63 | 63 | ? 'Works' |
| 64 | 64 | : 'Does not work'; |
| 65 | 65 | set_transient( Application::ID.'_remote_post_test', $test, static::EXPIRY_TIME ); |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | public function defaults() |
| 14 | 14 | { |
| 15 | 15 | $settings = $this->settings(); |
| 16 | - $defaults = array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' )); |
|
| 16 | + $defaults = array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ) ); |
|
| 17 | 17 | return wp_parse_args( $defaults, [ |
| 18 | 18 | 'version' => '', |
| 19 | 19 | 'version_upgraded_from' => '', |
| 20 | - ]); |
|
| 20 | + ] ); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function settings() |
| 48 | 48 | { |
| 49 | - $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' )); |
|
| 49 | + $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ) ); |
|
| 50 | 50 | return $this->normalize( $settings ); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | protected function normalize( array $settings ) |
| 57 | 57 | { |
| 58 | 58 | array_walk( $settings, function( &$setting ) { |
| 59 | - if( isset( $setting['default'] ))return; |
|
| 59 | + if( isset($setting['default']) )return; |
|
| 60 | 60 | $setting['default'] = ''; |
| 61 | 61 | }); |
| 62 | 62 | return $settings; |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $average = array_sum( $ratingCounts ); |
| 51 | 51 | if( $average > 0 ) { |
| 52 | - $average = round( $this->getTotalSum( $ratingCounts ) / $average, intval( $roundBy )); |
|
| 52 | + $average = round( $this->getTotalSum( $ratingCounts ) / $average, intval( $roundBy ) ); |
|
| 53 | 53 | } |
| 54 | - return floatval( apply_filters( 'site-reviews/rating/average', $average, $ratingCounts )); |
|
| 54 | + return floatval( apply_filters( 'site-reviews/rating/average', $average, $ratingCounts ) ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | $z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
| 74 | 74 | $phat = 1 * $upDownCounts[1] / $numRatings; |
| 75 | - return ( $phat + $z * $z / ( 2 * $numRatings ) - $z * sqrt(( $phat * ( 1 - $phat ) + $z * $z / ( 4 * $numRatings )) / $numRatings )) / ( 1 + $z * $z / $numRatings ); |
|
| 75 | + return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $total = array_sum( $ratingCounts ); |
| 92 | 92 | foreach( $ratingCounts as $index => $count ) { |
| 93 | - if( empty( $count ))continue; |
|
| 93 | + if( empty($count) )continue; |
|
| 94 | 94 | $ratingCounts[$index] = $count / $total * 100; |
| 95 | 95 | } |
| 96 | 96 | return $this->getRoundedPercentages( $ratingCounts ); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $this->getRankingUsingImdb( $ratingCounts ), |
| 106 | 106 | $ratingCounts, |
| 107 | 107 | $this |
| 108 | - )); |
|
| 108 | + ) ); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -123,12 +123,12 @@ discard block |
||
| 123 | 123 | $avgRating = $this->getAverage( $ratingCounts ); |
| 124 | 124 | // Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error. |
| 125 | 125 | // This could also be the average score of all items instead of a fixed value. |
| 126 | - $bayesMean = ( $confidencePercentage / 100 ) * static::MAX_RATING; // prior, 70% = 3.5 |
|
| 126 | + $bayesMean = ($confidencePercentage / 100) * static::MAX_RATING; // prior, 70% = 3.5 |
|
| 127 | 127 | // Represents the number of ratings expected to begin observing a pattern that would put confidence in the prior. |
| 128 | 128 | $bayesMinimal = 10; // confidence |
| 129 | 129 | $numOfReviews = array_sum( $ratingCounts ); |
| 130 | 130 | return $avgRating > 0 |
| 131 | - ? (( $bayesMinimal * $bayesMean ) + ( $avgRating * $numOfReviews )) / ( $bayesMinimal + $numOfReviews ) |
|
| 131 | + ? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews) |
|
| 132 | 132 | : 0; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $weight = $this->getWeight( $ratingCounts, $ratingCountsSum ); |
| 149 | 149 | $weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true ); |
| 150 | 150 | $zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
| 151 | - return $weight - $zScore * sqrt(( $weightPow2 - pow( $weight, 2 )) / ( $ratingCountsSum + 1 )); |
|
| 151 | + return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -168,14 +168,14 @@ discard block |
||
| 168 | 168 | $remainders = glsr_array_column( $percentages, 'remainder' ); |
| 169 | 169 | array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages ); |
| 170 | 170 | $i = 0; |
| 171 | - if( array_sum( glsr_array_column( $percentages, 'percent' )) > 0 ) { |
|
| 172 | - while( array_sum( glsr_array_column( $percentages, 'percent' )) < $totalPercent ) { |
|
| 171 | + if( array_sum( glsr_array_column( $percentages, 'percent' ) ) > 0 ) { |
|
| 172 | + while( array_sum( glsr_array_column( $percentages, 'percent' ) ) < $totalPercent ) { |
|
| 173 | 173 | $percentages[$i]['percent']++; |
| 174 | 174 | $i++; |
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | array_multisort( $indexes, SORT_DESC, $percentages ); |
| 178 | - return array_combine( $indexes, glsr_array_column( $percentages, 'percent' )); |
|
| 178 | + return array_combine( $indexes, glsr_array_column( $percentages, 'percent' ) ); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | protected function getTotalSum( array $ratingCounts ) |
| 185 | 185 | { |
| 186 | - return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use( $ratingCounts ) { |
|
| 187 | - return $carry + ( $index * $ratingCounts[$index] ); |
|
| 186 | + return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use($ratingCounts) { |
|
| 187 | + return $carry + ($index * $ratingCounts[$index]); |
|
| 188 | 188 | }); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -196,11 +196,11 @@ discard block |
||
| 196 | 196 | protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false ) |
| 197 | 197 | { |
| 198 | 198 | return array_reduce( array_keys( $ratingCounts ), |
| 199 | - function( $count, $rating ) use( $ratingCounts, $ratingCountsSum, $powerOf2 ) { |
|
| 199 | + function( $count, $rating ) use($ratingCounts, $ratingCountsSum, $powerOf2) { |
|
| 200 | 200 | $ratingLevel = $powerOf2 |
| 201 | 201 | ? pow( $rating, 2 ) |
| 202 | 202 | : $rating; |
| 203 | - return $count + ( $ratingLevel * ( $ratingCounts[$rating] + 1 )) / $ratingCountsSum; |
|
| 203 | + return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum; |
|
| 204 | 204 | } |
| 205 | 205 | ); |
| 206 | 206 | } |