@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | // Database/ReviewManager.php |
| 6 | 6 | add_action( 'site-reviews/review/created', function( $review, $command ) { |
| 7 | - if( has_action( 'site-reviews/local/review/create' )) { |
|
| 7 | + if( has_action( 'site-reviews/local/review/create' ) ) { |
|
| 8 | 8 | glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/create/review" hook instead.'; |
| 9 | 9 | do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID ); |
| 10 | 10 | } |
@@ -12,18 +12,18 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // Handlers/CreateReview.php |
| 14 | 14 | add_action( 'site-reviews/review/submitted', function( $review ) { |
| 15 | - if( has_action( 'site-reviews/local/review/submitted' )) { |
|
| 15 | + if( has_action( 'site-reviews/local/review/submitted' ) ) { |
|
| 16 | 16 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
| 17 | 17 | do_action( 'site-reviews/local/review/submitted', null, $review ); |
| 18 | 18 | } |
| 19 | - if( has_filter( 'site-reviews/local/review/submitted/message' )) { |
|
| 19 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
| 20 | 20 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
| 21 | 21 | } |
| 22 | 22 | }); |
| 23 | 23 | |
| 24 | 24 | // Database/ReviewManager.php |
| 25 | 25 | add_filter( 'site-reviews/create/review-values', function( $values, $command ) { |
| 26 | - if( has_filter( 'site-reviews/local/review' )) { |
|
| 26 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
| 27 | 27 | glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
| 28 | 28 | return apply_filters( 'site-reviews/local/review', $values, $command ); |
| 29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // Handlers/EnqueuePublicAssets.php |
| 34 | 34 | add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
| 35 | - if( has_filter( 'site-reviews/enqueue/localize' )) { |
|
| 35 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
| 36 | 36 | glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
| 37 | 37 | return apply_filters( 'site-reviews/enqueue/localize', $variables ); |
| 38 | 38 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | // Modules/Rating.php |
| 43 | 43 | add_filter( 'site-reviews/rating/average', function( $average ) { |
| 44 | - if( has_filter( 'site-reviews/average/rating' )) { |
|
| 44 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
| 45 | 45 | glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
| 46 | 46 | } |
| 47 | 47 | return $average; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // Modules/Rating.php |
| 51 | 51 | add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
| 52 | - if( has_filter( 'site-reviews/bayesian/ranking' )) { |
|
| 52 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
| 53 | 53 | glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
| 54 | 54 | } |
| 55 | 55 | return $ranking; |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // Modules/Html/Partials/SiteReviews.php |
| 59 | 59 | add_filter( 'site-reviews/review/build/after', function( $renderedFields ) { |
| 60 | - if( has_filter( 'site-reviews/rendered/field' )) { |
|
| 60 | + if( has_filter( 'site-reviews/rendered/field' ) ) { |
|
| 61 | 61 | glsr()->deprecated[] = 'The "site-reviews/rendered/field" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 62 | 62 | } |
| 63 | - if( has_filter( 'site-reviews/reviews/review/text' )) { |
|
| 63 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
| 64 | 64 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 65 | 65 | } |
| 66 | - if( has_filter( 'site-reviews/reviews/review/title' )) { |
|
| 66 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
| 67 | 67 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 68 | 68 | } |
| 69 | 69 | return $renderedFields; |
@@ -71,26 +71,26 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // Modules/Html/Partials/SiteReviews.php |
| 73 | 73 | add_filter( 'site-reviews/review/build/before', function( $review ) { |
| 74 | - if( has_filter( 'site-reviews/rendered/review' )) { |
|
| 74 | + if( has_filter( 'site-reviews/rendered/review' ) ) { |
|
| 75 | 75 | glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
| 76 | 76 | } |
| 77 | - if( has_filter( 'site-reviews/rendered/review/meta/order' )) { |
|
| 77 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
| 78 | 78 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
| 79 | 79 | } |
| 80 | - if( has_filter( 'site-reviews/rendered/review/order' )) { |
|
| 80 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
| 81 | 81 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
| 82 | 82 | } |
| 83 | - if( has_filter( 'site-reviews/rendered/review-form/login-register' )) { |
|
| 83 | + if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) { |
|
| 84 | 84 | glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
| 85 | 85 | } |
| 86 | - if( has_filter( 'site-reviews/reviews/navigation_links' )) { |
|
| 86 | + if( has_filter( 'site-reviews/reviews/navigation_links' ) ) { |
|
| 87 | 87 | glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
| 88 | 88 | } |
| 89 | 89 | return $review; |
| 90 | 90 | }); |
| 91 | 91 | |
| 92 | 92 | add_action( 'wp_footer', function() { |
| 93 | - $notices = array_keys( array_flip( glsr()->deprecated )); |
|
| 93 | + $notices = array_keys( array_flip( glsr()->deprecated ) ); |
|
| 94 | 94 | foreach( $notices as $notice ) { |
| 95 | 95 | glsr_log()->notice( $notice ); |
| 96 | 96 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | 'setting' => 'Plugin Settings', |
| 39 | 39 | 'reviews' => 'Review Counts', |
| 40 | 40 | ]; |
| 41 | - $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) { |
|
| 41 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) { |
|
| 42 | 42 | $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' ); |
| 43 | 43 | if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
| 44 | 44 | return $carry.$this->implode( strtoupper( $details[$key] ), $systemDetails ); |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $plugins = get_plugins(); |
| 57 | 57 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 58 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
| 59 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 58 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
| 59 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | public function getInactivePluginDetails() |
| 81 | 81 | { |
| 82 | 82 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 83 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
| 83 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $plugins = array_merge( |
| 92 | 92 | get_mu_plugins(), |
| 93 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
| 93 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
| 94 | 94 | ); |
| 95 | - if( empty( $plugins ))return; |
|
| 95 | + if( empty($plugins) )return; |
|
| 96 | 96 | return $this->normalizePluginList( $plugins ); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function getMultisitePluginDetails() |
| 103 | 103 | { |
| 104 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
| 104 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
| 105 | 105 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | 'Max Input Vars' => ini_get( 'max_input_vars' ), |
| 128 | 128 | 'Memory Limit' => ini_get( 'memory_limit' ), |
| 129 | 129 | 'Post Max Size' => ini_get( 'post_max_size' ), |
| 130 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
| 131 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
| 132 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
| 133 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
| 134 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
| 130 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
| 131 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
| 132 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
| 133 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
| 134 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
| 135 | 135 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
| 136 | 136 | ]; |
| 137 | 137 | } |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | ksort( $settings ); |
| 177 | 177 | $details = []; |
| 178 | 178 | foreach( $settings as $key => $value ) { |
| 179 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
| 180 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
| 179 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
| 180 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
| 181 | 181 | $details[$key] = $value; |
| 182 | 182 | } |
| 183 | 183 | return $details; |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | 'WPE_APIKEY' => 'WP Engine', |
| 250 | 250 | ]; |
| 251 | 251 | foreach( $checks as $key => $value ) { |
| 252 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
| 252 | + if( !$this->isWebhostCheckValid( $key ) )continue; |
|
| 253 | 253 | return $value; |
| 254 | 254 | } |
| 255 | - return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
|
| 255 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $plugins = get_plugins(); |
| 275 | 275 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 276 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
| 277 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 276 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
| 277 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 278 | 278 | return $active + $inactive; |
| 279 | 279 | } |
| 280 | 280 | |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | protected function implode( $title, array $details ) |
| 286 | 286 | { |
| 287 | 287 | $strings = ['['.$title.']']; |
| 288 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
| 288 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
| 289 | 289 | $padding = max( [$padding, static::PAD] ); |
| 290 | 290 | foreach( $details as $key => $value ) { |
| 291 | 291 | $strings[] = is_string( $key ) |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | $keys = [ |
| 329 | 329 | 'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret', |
| 330 | 330 | ]; |
| 331 | - array_walk( $settings, function( &$value, $setting ) use( $keys ) { |
|
| 331 | + array_walk( $settings, function( &$value, $setting ) use($keys) { |
|
| 332 | 332 | foreach( $keys as $key ) { |
| 333 | - if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue; |
|
| 333 | + if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue; |
|
| 334 | 334 | $value = str_repeat( '•', 13 ); |
| 335 | 335 | return; |
| 336 | 336 | } |
@@ -4,7 +4,8 @@ discard block |
||
| 4 | 4 | /** |
| 5 | 5 | * @return mixed |
| 6 | 6 | */ |
| 7 | -function glsr( $alias = null ) { |
|
| 7 | +function glsr( $alias = null ) |
|
| 8 | +{ |
|
| 8 | 9 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 9 | 10 | return !empty( $alias ) |
| 10 | 11 | ? $app->make( $alias ) |
@@ -14,7 +15,8 @@ discard block |
||
| 14 | 15 | /** |
| 15 | 16 | * @return \WP_Screen|object |
| 16 | 17 | */ |
| 17 | -function glsr_current_screen() { |
|
| 18 | +function glsr_current_screen() |
|
| 19 | +{ |
|
| 18 | 20 | if( function_exists( 'get_current_screen' )) { |
| 19 | 21 | $screen = get_current_screen(); |
| 20 | 22 | } |
@@ -27,7 +29,8 @@ discard block |
||
| 27 | 29 | * @param mixed ...$vars |
| 28 | 30 | * @return void |
| 29 | 31 | */ |
| 30 | -function glsr_debug( ...$vars ) { |
|
| 32 | +function glsr_debug( ...$vars ) |
|
| 33 | +{ |
|
| 31 | 34 | if( count( $vars ) == 1 ) { |
| 32 | 35 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
| 33 | 36 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -46,14 +49,16 @@ discard block |
||
| 46 | 49 | * @param mixed $fallback |
| 47 | 50 | * @return string|array |
| 48 | 51 | */ |
| 49 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
| 52 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
| 53 | +{ |
|
| 50 | 54 | return glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ); |
| 51 | 55 | } |
| 52 | 56 | |
| 53 | 57 | /** |
| 54 | 58 | * @return array |
| 55 | 59 | */ |
| 56 | -function glsr_get_options() { |
|
| 60 | +function glsr_get_options() |
|
| 61 | +{ |
|
| 57 | 62 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
| 58 | 63 | } |
| 59 | 64 | |
@@ -61,7 +66,8 @@ discard block |
||
| 61 | 66 | * @param int $post_id |
| 62 | 67 | * @return void|\GeminiLabs\SiteReviews\Review |
| 63 | 68 | */ |
| 64 | -function glsr_get_review( $post_id ) { |
|
| 69 | +function glsr_get_review( $post_id ) |
|
| 70 | +{ |
|
| 65 | 71 | $post = get_post( $post_id ); |
| 66 | 72 | if( $post instanceof WP_Post ) { |
| 67 | 73 | return glsr( 'Database\ReviewManager' )->single( $post ); |
@@ -72,14 +78,16 @@ discard block |
||
| 72 | 78 | * @return array |
| 73 | 79 | * @todo document change of $reviews->reviews to $reviews->results |
| 74 | 80 | */ |
| 75 | -function glsr_get_reviews( array $args = array() ) { |
|
| 81 | +function glsr_get_reviews( array $args = array() ) |
|
| 82 | +{ |
|
| 76 | 83 | return glsr( 'Database\ReviewManager' )->get( $args ); |
| 77 | 84 | } |
| 78 | 85 | |
| 79 | 86 | /** |
| 80 | 87 | * @return \GeminiLabs\SiteReviews\Modules\Console |
| 81 | 88 | */ |
| 82 | -function glsr_log() { |
|
| 89 | +function glsr_log() |
|
| 90 | +{ |
|
| 83 | 91 | $args = func_get_args(); |
| 84 | 92 | $context = isset( $args[1] ) |
| 85 | 93 | ? $args[1] |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | add_filter( 'sbp_exclude_defer_scripts', function( $scriptHandles ) { |
| 20 | 20 | $scriptHandles[] = 'site-reviews/google-recaptcha'; |
| 21 | - return array_keys( array_flip( $scriptHandles )); |
|
| 21 | + return array_keys( array_flip( $scriptHandles ) ); |
|
| 22 | 22 | }); |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | * @see ?? |
| 29 | 29 | */ |
| 30 | 30 | add_filter( 'sf_edit_query_args', function( $query ) { |
| 31 | - if( !empty( $query['meta_key'] ) && $query['meta_key'] == '_glsr_ranking' ) { |
|
| 32 | - unset( $query['meta_key'] ); |
|
| 31 | + if( !empty($query['meta_key']) && $query['meta_key'] == '_glsr_ranking' ) { |
|
| 32 | + unset($query['meta_key']); |
|
| 33 | 33 | $query['meta_query'] = [ |
| 34 | 34 | 'relation' => 'OR', |
| 35 | 35 | ['key' => '_glsr_ranking', 'compare' => 'EXISTS'], |