@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | $filenames = []; |
| 21 | 21 | $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' ); |
| 22 | 22 | foreach( $iterator as $fileinfo ) { |
| 23 | - if( !$fileinfo->isFile() )continue; |
|
| 23 | + if( !$fileinfo->isFile() ) { |
|
| 24 | + continue; |
|
| 25 | + } |
|
| 24 | 26 | $filenames[] = $fileinfo->getFilename(); |
| 25 | 27 | } |
| 26 | 28 | natsort( $filenames ); |
@@ -28,7 +30,9 @@ discard block |
||
| 28 | 30 | $className = str_replace( '.php', '', $file ); |
| 29 | 31 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
| 30 | 32 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
| 31 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
| 33 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' )) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 32 | 36 | glsr( 'Modules\\Upgrader\\'.$className ); |
| 33 | 37 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
| 34 | 38 | }); |
@@ -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 | }); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | add_action( 'admin_init', function() { |
| 60 | 60 | glsr( AdminController::class )->routerCountReviews( false ); |
| 61 | - glsr_log()->info( __( 'Calculated rating counts.', 'site-reviews' )); |
|
| 61 | + glsr_log()->info( __( 'Calculated rating counts.', 'site-reviews' ) ); |
|
| 62 | 62 | }); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | 'glsr_get_review', 'glsr_get_reviews', |
| 19 | 19 | 'glsr_log', |
| 20 | 20 | ); |
| 21 | - if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return; |
|
| 22 | - add_filter( $hook, function() use( $hook, $args ) { |
|
| 21 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook ) )return; |
|
| 22 | + add_filter( $hook, function() use($hook, $args) { |
|
| 23 | 23 | array_shift( $args ); // remove the fallback value |
| 24 | 24 | return call_user_func_array( $hook, $args ); |
| 25 | 25 | }); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | function glsr( $alias = null ) { |
| 32 | 32 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 33 | - return !empty( $alias ) |
|
| 33 | + return !empty($alias) |
|
| 34 | 34 | ? $app->make( $alias ) |
| 35 | 35 | : $app; |
| 36 | 36 | } |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | * @return null|\GeminiLabs\SiteReviews\Review |
| 40 | 40 | */ |
| 41 | 41 | function glsr_create_review( $reviewValues = array() ) { |
| 42 | - if( !is_array( $reviewValues )) { |
|
| 42 | + if( !is_array( $reviewValues ) ) { |
|
| 43 | 43 | $reviewValues = array(); |
| 44 | 44 | } |
| 45 | 45 | $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( $reviewValues ); |
| 46 | 46 | $result = glsr( 'Database\ReviewManager' )->create( $review ); |
| 47 | - return !empty( $result ) |
|
| 47 | + return !empty($result) |
|
| 48 | 48 | ? $result |
| 49 | 49 | : null; |
| 50 | 50 | } |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | * @return \WP_Screen|object |
| 54 | 54 | */ |
| 55 | 55 | function glsr_current_screen() { |
| 56 | - if( function_exists( 'get_current_screen' )) { |
|
| 56 | + if( function_exists( 'get_current_screen' ) ) { |
|
| 57 | 57 | $screen = get_current_screen(); |
| 58 | 58 | } |
| 59 | - return empty( $screen ) |
|
| 59 | + return empty($screen) |
|
| 60 | 60 | ? (object)array_fill_keys( ['base', 'id', 'post_type'], null ) |
| 61 | 61 | : $screen; |
| 62 | 62 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @return \GeminiLabs\SiteReviews\Review|void |
| 103 | 103 | */ |
| 104 | 104 | function glsr_get_review( $post_id ) { |
| 105 | - if( !is_numeric( $post_id ))return; |
|
| 105 | + if( !is_numeric( $post_id ) )return; |
|
| 106 | 106 | $post = get_post( $post_id ); |
| 107 | 107 | if( $post instanceof WP_Post ) { |
| 108 | 108 | return glsr( 'Database\ReviewManager' )->single( $post ); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @todo document change of $reviews->reviews to $reviews->results |
| 115 | 115 | */ |
| 116 | 116 | function glsr_get_reviews( $args = array() ) { |
| 117 | - if( !is_array( $args )) { |
|
| 117 | + if( !is_array( $args ) ) { |
|
| 118 | 118 | $args = []; |
| 119 | 119 | } |
| 120 | 120 | return glsr( 'Database\ReviewManager' )->get( $args ); |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | function glsr_log() { |
| 127 | 127 | $args = func_get_args(); |
| 128 | - $context = isset( $args[1] ) |
|
| 128 | + $context = isset($args[1]) |
|
| 129 | 129 | ? $args[1] |
| 130 | 130 | : []; |
| 131 | 131 | $console = glsr( 'Modules\Console' ); |
| 132 | - return !empty( $args ) |
|
| 132 | + return !empty($args) |
|
| 133 | 133 | ? $console->log( 'debug', $args[0], $context ) |
| 134 | 134 | : $console; |
| 135 | 135 | } |
@@ -18,7 +18,9 @@ discard block |
||
| 18 | 18 | 'glsr_get_review', 'glsr_get_reviews', |
| 19 | 19 | 'glsr_log', |
| 20 | 20 | ); |
| 21 | - if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return; |
|
| 21 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook )) { |
|
| 22 | + return; |
|
| 23 | + } |
|
| 22 | 24 | add_filter( $hook, function() use( $hook, $args ) { |
| 23 | 25 | array_shift( $args ); // remove the fallback value |
| 24 | 26 | return call_user_func_array( $hook, $args ); |
@@ -28,7 +30,8 @@ discard block |
||
| 28 | 30 | /** |
| 29 | 31 | * @return mixed |
| 30 | 32 | */ |
| 31 | -function glsr( $alias = null ) { |
|
| 33 | +function glsr( $alias = null ) |
|
| 34 | +{ |
|
| 32 | 35 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 33 | 36 | return !empty( $alias ) |
| 34 | 37 | ? $app->make( $alias ) |
@@ -38,7 +41,8 @@ discard block |
||
| 38 | 41 | /** |
| 39 | 42 | * @return null|\GeminiLabs\SiteReviews\Review |
| 40 | 43 | */ |
| 41 | -function glsr_create_review( $reviewValues = array() ) { |
|
| 44 | +function glsr_create_review( $reviewValues = array() ) |
|
| 45 | +{ |
|
| 42 | 46 | if( !is_array( $reviewValues )) { |
| 43 | 47 | $reviewValues = array(); |
| 44 | 48 | } |
@@ -52,7 +56,8 @@ discard block |
||
| 52 | 56 | /** |
| 53 | 57 | * @return \WP_Screen|object |
| 54 | 58 | */ |
| 55 | -function glsr_current_screen() { |
|
| 59 | +function glsr_current_screen() |
|
| 60 | +{ |
|
| 56 | 61 | if( function_exists( 'get_current_screen' )) { |
| 57 | 62 | $screen = get_current_screen(); |
| 58 | 63 | } |
@@ -65,7 +70,8 @@ discard block |
||
| 65 | 70 | * @param mixed ...$vars |
| 66 | 71 | * @return void |
| 67 | 72 | */ |
| 68 | -function glsr_debug( ...$vars ) { |
|
| 73 | +function glsr_debug( ...$vars ) |
|
| 74 | +{ |
|
| 69 | 75 | if( count( $vars ) == 1 ) { |
| 70 | 76 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
| 71 | 77 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -84,7 +90,8 @@ discard block |
||
| 84 | 90 | * @param mixed $fallback |
| 85 | 91 | * @return string|array |
| 86 | 92 | */ |
| 87 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
| 93 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
| 94 | +{ |
|
| 88 | 95 | return is_string( $path ) |
| 89 | 96 | ? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ) |
| 90 | 97 | : $fallback; |
@@ -93,7 +100,8 @@ discard block |
||
| 93 | 100 | /** |
| 94 | 101 | * @return array |
| 95 | 102 | */ |
| 96 | -function glsr_get_options() { |
|
| 103 | +function glsr_get_options() |
|
| 104 | +{ |
|
| 97 | 105 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
| 98 | 106 | } |
| 99 | 107 | |
@@ -101,8 +109,11 @@ discard block |
||
| 101 | 109 | * @param int $post_id |
| 102 | 110 | * @return \GeminiLabs\SiteReviews\Review|void |
| 103 | 111 | */ |
| 104 | -function glsr_get_review( $post_id ) { |
|
| 105 | - if( !is_numeric( $post_id ))return; |
|
| 112 | +function glsr_get_review( $post_id ) |
|
| 113 | +{ |
|
| 114 | + if( !is_numeric( $post_id )) { |
|
| 115 | + return; |
|
| 116 | + } |
|
| 106 | 117 | $post = get_post( $post_id ); |
| 107 | 118 | if( $post instanceof WP_Post ) { |
| 108 | 119 | return glsr( 'Database\ReviewManager' )->single( $post ); |
@@ -113,7 +124,8 @@ discard block |
||
| 113 | 124 | * @return array |
| 114 | 125 | * @todo document change of $reviews->reviews to $reviews->results |
| 115 | 126 | */ |
| 116 | -function glsr_get_reviews( $args = array() ) { |
|
| 127 | +function glsr_get_reviews( $args = array() ) |
|
| 128 | +{ |
|
| 117 | 129 | if( !is_array( $args )) { |
| 118 | 130 | $args = []; |
| 119 | 131 | } |
@@ -123,7 +135,8 @@ discard block |
||
| 123 | 135 | /** |
| 124 | 136 | * @return \GeminiLabs\SiteReviews\Modules\Console |
| 125 | 137 | */ |
| 126 | -function glsr_log() { |
|
| 138 | +function glsr_log() |
|
| 139 | +{ |
|
| 127 | 140 | $args = func_get_args(); |
| 128 | 141 | $context = isset( $args[1] ) |
| 129 | 142 | ? $args[1] |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | global $menu, $typenow; |
| 24 | 24 | foreach( $menu as $key => $value ) { |
| 25 | - if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
| 25 | + if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
| 26 | 26 | $postCount = wp_count_posts( Application::POST_TYPE ); |
| 27 | 27 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
| 28 | 28 | 'class' => 'pending-count', |
| 29 | - ]); |
|
| 29 | + ] ); |
|
| 30 | 30 | $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [ |
| 31 | 31 | 'class' => 'awaiting-mod count-'.$postCount->pending, |
| 32 | - ]); |
|
| 32 | + ] ); |
|
| 33 | 33 | $menu[$key][0] .= ' '.$awaitingModeration; |
| 34 | 34 | if( $typenow === Application::POST_TYPE ) { |
| 35 | - $menu[$key][4].= ' current'; |
|
| 35 | + $menu[$key][4] .= ' current'; |
|
| 36 | 36 | } |
| 37 | 37 | break; |
| 38 | 38 | } |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | 'tools' => __( 'Tools', 'site-reviews' ), |
| 50 | 50 | 'addons' => __( 'Add-ons', 'site-reviews' ), |
| 51 | 51 | 'documentation' => __( 'Documentation', 'site-reviews' ), |
| 52 | - ]); |
|
| 52 | + ] ); |
|
| 53 | 53 | foreach( $pages as $slug => $title ) { |
| 54 | 54 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
| 55 | 55 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
| 56 | - if( !is_callable( $callback ))continue; |
|
| 56 | + if( !is_callable( $callback ) )continue; |
|
| 57 | 57 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->constant( 'CAPABILITY' ), $slug, $callback ); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $this->renderPage( 'addons', [ |
| 69 | 69 | 'template' => glsr( Template::class ), |
| 70 | - ]); |
|
| 70 | + ] ); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -84,16 +84,16 @@ discard block |
||
| 84 | 84 | 'hooks' => __( 'Hooks', 'site-reviews' ), |
| 85 | 85 | 'functions' => __( 'Functions', 'site-reviews' ), |
| 86 | 86 | 'addons' => __( 'Addons', 'site-reviews' ), |
| 87 | - ]); |
|
| 87 | + ] ); |
|
| 88 | 88 | $addons = apply_filters( 'site-reviews/addon/documentation', [] ); |
| 89 | 89 | ksort( $addons ); |
| 90 | - if( empty( $addons )) { |
|
| 91 | - unset( $tabs['addons'] ); |
|
| 90 | + if( empty($addons) ) { |
|
| 91 | + unset($tabs['addons']); |
|
| 92 | 92 | } |
| 93 | 93 | $this->renderPage( 'documentation', [ |
| 94 | 94 | 'addons' => $addons, |
| 95 | 95 | 'tabs' => $tabs, |
| 96 | - ]); |
|
| 96 | + ] ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -111,18 +111,18 @@ discard block |
||
| 111 | 111 | 'translations' => __( 'Translations', 'site-reviews' ), |
| 112 | 112 | 'addons' => __( 'Addons', 'site-reviews' ), |
| 113 | 113 | 'licenses' => __( 'Licenses', 'site-reviews' ), |
| 114 | - ]); |
|
| 115 | - if( empty( glsr( Helper::class )->getPathValue( 'settings.addons', glsr()->defaults ))) { |
|
| 116 | - unset( $tabs['addons'] ); |
|
| 114 | + ] ); |
|
| 115 | + if( empty(glsr( Helper::class )->getPathValue( 'settings.addons', glsr()->defaults )) ) { |
|
| 116 | + unset($tabs['addons']); |
|
| 117 | 117 | } |
| 118 | - if( empty( glsr( Helper::class )->getPathValue( 'settings.licenses', glsr()->defaults ))) { |
|
| 119 | - unset( $tabs['licenses'] ); |
|
| 118 | + if( empty(glsr( Helper::class )->getPathValue( 'settings.licenses', glsr()->defaults )) ) { |
|
| 119 | + unset($tabs['licenses']); |
|
| 120 | 120 | } |
| 121 | 121 | $this->renderPage( 'settings', [ |
| 122 | 122 | 'notices' => $this->getNotices(), |
| 123 | 123 | 'settings' => glsr( Settings::class ), |
| 124 | 124 | 'tabs' => $tabs, |
| 125 | - ]); |
|
| 125 | + ] ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -137,24 +137,24 @@ discard block |
||
| 137 | 137 | 'sync' => __( 'Sync Reviews', 'site-reviews' ), |
| 138 | 138 | 'console' => __( 'Console', 'site-reviews' ), |
| 139 | 139 | 'system-info' => __( 'System Info', 'site-reviews' ), |
| 140 | - ]); |
|
| 141 | - if( !apply_filters( 'site-reviews/addon/sync/enable', false )) { |
|
| 142 | - unset( $tabs['sync'] ); |
|
| 140 | + ] ); |
|
| 141 | + if( !apply_filters( 'site-reviews/addon/sync/enable', false ) ) { |
|
| 142 | + unset($tabs['sync']); |
|
| 143 | 143 | } |
| 144 | 144 | $this->renderPage( 'tools', [ |
| 145 | 145 | 'data' => [ |
| 146 | 146 | 'context' => [ |
| 147 | 147 | 'base_url' => admin_url( 'edit.php?post_type='.Application::POST_TYPE ), |
| 148 | - 'console' => strval( glsr( Console::class )), |
|
| 148 | + 'console' => strval( glsr( Console::class ) ), |
|
| 149 | 149 | 'id' => Application::ID, |
| 150 | - 'system' => strval( glsr( System::class )), |
|
| 150 | + 'system' => strval( glsr( System::class ) ), |
|
| 151 | 151 | ], |
| 152 | 152 | 'services' => apply_filters( 'site-reviews/addon/sync/services', [] ), |
| 153 | 153 | ], |
| 154 | 154 | 'notices' => $this->getNotices(), |
| 155 | 155 | 'tabs' => $tabs, |
| 156 | 156 | 'template' => glsr( Template::class ), |
| 157 | - ]); |
|
| 157 | + ] ); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | { |
| 176 | 176 | return glsr( Builder::class )->div( glsr( Notice::class )->get(), [ |
| 177 | 177 | 'id' => 'glsr-notices', |
| 178 | - ]); |
|
| 178 | + ] ); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function enqueueAssets() |
| 25 | 25 | { |
| 26 | - $command = new EnqueueAdminAssets([ |
|
| 26 | + $command = new EnqueueAdminAssets( [ |
|
| 27 | 27 | 'pointers' => [[ |
| 28 | 28 | 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
| 29 | 29 | 'id' => 'glsr-pointer-pinned', |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | 'target' => '#misc-pub-pinned', |
| 36 | 36 | 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
| 37 | 37 | ]], |
| 38 | - ]); |
|
| 38 | + ] ); |
|
| 39 | 39 | $this->execute( $command ); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
| 49 | 49 | 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
| 50 | - ]); |
|
| 50 | + ] ); |
|
| 51 | 51 | return $links; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -58,19 +58,19 @@ discard block |
||
| 58 | 58 | public function filterDashboardGlanceItems( array $items ) |
| 59 | 59 | { |
| 60 | 60 | $postCount = wp_count_posts( Application::POST_TYPE ); |
| 61 | - if( empty( $postCount->publish )) { |
|
| 61 | + if( empty($postCount->publish) ) { |
|
| 62 | 62 | return $items; |
| 63 | 63 | } |
| 64 | 64 | $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
| 65 | - $text = sprintf( $text, number_format_i18n( $postCount->publish )); |
|
| 65 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
| 66 | 66 | $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
| 67 | 67 | ? glsr( Builder::class )->a( $text, [ |
| 68 | 68 | 'class' => 'glsr-review-count', |
| 69 | 69 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
| 70 | - ]) |
|
| 70 | + ] ) |
|
| 71 | 71 | : glsr( Builder::class )->span( $text, [ |
| 72 | 72 | 'class' => 'glsr-review-count', |
| 73 | - ]); |
|
| 73 | + ] ); |
|
| 74 | 74 | return $items; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function filterTinymcePlugins( array $plugins ) |
| 82 | 82 | { |
| 83 | - if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) { |
|
| 83 | + if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) { |
|
| 84 | 84 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
| 85 | 85 | } |
| 86 | 86 | return $plugins; |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function registerTinymcePopups() |
| 94 | 94 | { |
| 95 | - $command = new RegisterTinymcePopups([ |
|
| 95 | + $command = new RegisterTinymcePopups( [ |
|
| 96 | 96 | 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
| 97 | 97 | 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
| 98 | 98 | 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
| 99 | - ]); |
|
| 99 | + ] ); |
|
| 100 | 100 | $this->execute( $command ); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -108,15 +108,15 @@ discard block |
||
| 108 | 108 | public function renderTinymceButton( $editorId ) |
| 109 | 109 | { |
| 110 | 110 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId ); |
| 111 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
| 111 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ) )return; |
|
| 112 | 112 | $shortcodes = []; |
| 113 | 113 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 114 | 114 | $shortcodes[$shortcode] = $values; |
| 115 | 115 | } |
| 116 | - if( empty( $shortcodes ))return; |
|
| 116 | + if( empty($shortcodes) )return; |
|
| 117 | 117 | glsr()->render( 'partials/editor/tinymce', [ |
| 118 | 118 | 'shortcodes' => $shortcodes, |
| 119 | - ]); |
|
| 119 | + ] ); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | public function routerClearConsole() |
| 126 | 126 | { |
| 127 | 127 | glsr( Console::class )->clear(); |
| 128 | - glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' )); |
|
| 128 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function routerFetchConsole() |
| 135 | 135 | { |
| 136 | - glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' )); |
|
| 136 | + glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -143,22 +143,22 @@ discard block |
||
| 143 | 143 | public function routerCountReviews( $showNotice = true ) |
| 144 | 144 | { |
| 145 | 145 | $countManager = glsr( CountsManager::class ); |
| 146 | - $terms = get_terms([ |
|
| 146 | + $terms = get_terms( [ |
|
| 147 | 147 | 'hide_empty' => true, |
| 148 | 148 | 'taxonomy' => Application::TAXONOMY, |
| 149 | - ]); |
|
| 149 | + ] ); |
|
| 150 | 150 | foreach( $terms as $term ) { |
| 151 | - $countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id )); |
|
| 151 | + $countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ) ); |
|
| 152 | 152 | } |
| 153 | 153 | $postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' ); |
| 154 | 154 | foreach( $postIds as $postId ) { |
| 155 | - $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId )); |
|
| 155 | + $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) ); |
|
| 156 | 156 | } |
| 157 | 157 | $countManager->setCounts( $countManager->buildCounts() ); |
| 158 | 158 | if( $showNotice ) { |
| 159 | - glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' )); |
|
| 159 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
| 160 | 160 | } |
| 161 | - glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' )); |
|
| 161 | + glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -192,17 +192,17 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | $file = $_FILES['import-file']; |
| 194 | 194 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
| 195 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
| 195 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
| 196 | 196 | } |
| 197 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
| 198 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
| 197 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
| 198 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
| 199 | 199 | } |
| 200 | 200 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
| 201 | - if( empty( $settings )) { |
|
| 202 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
| 201 | + if( empty($settings) ) { |
|
| 202 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
| 203 | 203 | } |
| 204 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
| 205 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
| 204 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
| 205 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
| 221 | 221 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
| 222 | 222 | ]; |
| 223 | - return !isset( $errors[$errorCode] ) |
|
| 223 | + return !isset($errors[$errorCode]) |
|
| 224 | 224 | ? __( 'Unknown upload error.', 'site-reviews' ) |
| 225 | 225 | : $errors[$errorCode]; |
| 226 | 226 | } |
@@ -108,12 +108,16 @@ |
||
| 108 | 108 | public function renderTinymceButton( $editorId ) |
| 109 | 109 | { |
| 110 | 110 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId ); |
| 111 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
| 111 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors )) { |
|
| 112 | + return; |
|
| 113 | + } |
|
| 112 | 114 | $shortcodes = []; |
| 113 | 115 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 114 | 116 | $shortcodes[$shortcode] = $values; |
| 115 | 117 | } |
| 116 | - if( empty( $shortcodes ))return; |
|
| 118 | + if( empty( $shortcodes )) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 117 | 121 | glsr()->render( 'partials/editor/tinymce', [ |
| 118 | 122 | 'shortcodes' => $shortcodes, |
| 119 | 123 | ]); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function callbackRegisterSettings( $input ) |
| 19 | 19 | { |
| 20 | - if( !is_array( $input )) { |
|
| 20 | + if( !is_array( $input ) ) { |
|
| 21 | 21 | $input = ['settings' => []]; |
| 22 | 22 | } |
| 23 | 23 | if( key( $input ) == 'settings' ) { |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $options = $this->sanitizeSubmissions( $input, $options ); |
| 27 | 27 | $options = $this->sanitizeTranslations( $input, $options ); |
| 28 | 28 | if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
| 29 | - glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' )); |
|
| 29 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
| 30 | 30 | } |
| 31 | 31 | return $options; |
| 32 | 32 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
| 43 | 43 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
| 44 | - ]); |
|
| 44 | + ] ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | if( $inputForm['support']['polylang'] == 'yes' ) { |
| 54 | 54 | if( !glsr( Polylang::class )->isActive() ) { |
| 55 | 55 | $options['settings']['general']['support']['polylang'] = 'no'; |
| 56 | - glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' )); |
|
| 56 | + glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' ) ); |
|
| 57 | 57 | } |
| 58 | 58 | else if( !glsr( Polylang::class )->isSupported() ) { |
| 59 | 59 | $options['settings']['general']['support']['polylang'] = 'no'; |
| 60 | - glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' )); |
|
| 60 | + glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' ) ); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | - if( !isset( $inputForm['notifications'] )) { |
|
| 63 | + if( !isset($inputForm['notifications']) ) { |
|
| 64 | 64 | $options['settings']['general']['notifications'] = []; |
| 65 | 65 | } |
| 66 | 66 | if( trim( $inputForm['notification_message'] ) == '' ) { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | protected function sanitizeSubmissions( array $input, array $options ) |
| 76 | 76 | { |
| 77 | 77 | $inputForm = $input['settings']['submissions']; |
| 78 | - if( !isset( $inputForm['required'] )) { |
|
| 78 | + if( !isset($inputForm['required']) ) { |
|
| 79 | 79 | $options['settings']['submissions']['required'] = []; |
| 80 | 80 | } |
| 81 | 81 | return $options; |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | protected function sanitizeTranslations( array $input, array $options ) |
| 88 | 88 | { |
| 89 | - if( isset( $input['settings']['strings'] )) { |
|
| 90 | - $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] )); |
|
| 89 | + if( isset($input['settings']['strings']) ) { |
|
| 90 | + $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) ); |
|
| 91 | 91 | $allowedTags = ['a' => ['class' => [], 'href' => [], 'target' => []]]; |
| 92 | - array_walk( $options['settings']['strings'], function( &$string ) use( $allowedTags ) { |
|
| 93 | - if( isset( $string['s2'] )) { |
|
| 92 | + array_walk( $options['settings']['strings'], function( &$string ) use($allowedTags) { |
|
| 93 | + if( isset($string['s2']) ) { |
|
| 94 | 94 | $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
| 95 | 95 | } |
| 96 | - if( isset( $string['p2'] )) { |
|
| 96 | + if( isset($string['p2']) ) { |
|
| 97 | 97 | $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
| 98 | 98 | } |
| 99 | 99 | }); |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | sort( $termIds ); |
| 27 | 27 | sort( $oldTermIds ); |
| 28 | - if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ))return; |
|
| 29 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
| 28 | + if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ) )return; |
|
| 29 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
| 30 | 30 | $ignoredTerms = array_intersect( $oldTermIds, $termIds ); |
| 31 | - if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms )) { |
|
| 31 | + if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms ) ) { |
|
| 32 | 32 | glsr( CountsManager::class )->decreaseTermCounts( $review ); |
| 33 | 33 | } |
| 34 | - if( $review->term_ids = array_diff( $termIds, $ignoredTerms )) { |
|
| 34 | + if( $review->term_ids = array_diff( $termIds, $ignoredTerms ) ) { |
|
| 35 | 35 | glsr( CountsManager::class )->increaseTermCounts( $review ); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function onAfterChangeStatus( $newStatus, $oldStatus, WP_Post $post ) |
| 46 | 46 | { |
| 47 | - if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 48 | - $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
|
| 47 | + if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ) )return; |
|
| 48 | + $review = glsr( ReviewManager::class )->single( get_post( $post->ID ) ); |
|
| 49 | 49 | if( $post->post_status == 'publish' ) { |
| 50 | 50 | glsr( CountsManager::class )->increase( $review ); |
| 51 | 51 | } |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function onBeforeDelete( $postId ) |
| 73 | 73 | { |
| 74 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 75 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
| 74 | + if( !$this->isReviewPostId( $postId ) )return; |
|
| 75 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
| 76 | 76 | glsr( CountsManager::class )->decrease( $review ); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | if( !$this->isReviewPostId( $postId ) |
| 90 | 90 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 91 | 91 | )return; |
| 92 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
| 92 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
| 93 | 93 | if( $review->$metaKey == $metaValue )return; |
| 94 | 94 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 95 | 95 | call_user_func( [$this, $method], $review, $metaValue ); |
@@ -25,7 +25,9 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | sort( $termIds ); |
| 27 | 27 | sort( $oldTermIds ); |
| 28 | - if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ))return; |
|
| 28 | + if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId )) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 29 | 31 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 30 | 32 | $ignoredTerms = array_intersect( $oldTermIds, $termIds ); |
| 31 | 33 | if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms )) { |
@@ -44,7 +46,9 @@ discard block |
||
| 44 | 46 | */ |
| 45 | 47 | public function onAfterChangeStatus( $newStatus, $oldStatus, WP_Post $post ) |
| 46 | 48 | { |
| 47 | - if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 49 | + if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 48 | 52 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
| 49 | 53 | if( $post->post_status == 'publish' ) { |
| 50 | 54 | glsr( CountsManager::class )->increase( $review ); |
@@ -60,7 +64,9 @@ discard block |
||
| 60 | 64 | */ |
| 61 | 65 | public function onAfterCreate( Review $review ) |
| 62 | 66 | { |
| 63 | - if( $review->status !== 'publish' )return; |
|
| 67 | + if( $review->status !== 'publish' ) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 64 | 70 | glsr( CountsManager::class )->increase( $review ); |
| 65 | 71 | } |
| 66 | 72 | |
@@ -71,7 +77,9 @@ discard block |
||
| 71 | 77 | */ |
| 72 | 78 | public function onBeforeDelete( $postId ) |
| 73 | 79 | { |
| 74 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 80 | + if( !$this->isReviewPostId( $postId )) { |
|
| 81 | + return; |
|
| 82 | + } |
|
| 75 | 83 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 76 | 84 | glsr( CountsManager::class )->decrease( $review ); |
| 77 | 85 | } |
@@ -88,9 +96,13 @@ discard block |
||
| 88 | 96 | { |
| 89 | 97 | if( !$this->isReviewPostId( $postId ) |
| 90 | 98 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 91 | - )return; |
|
| 99 | + ) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 92 | 102 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 93 | - if( $review->$metaKey == $metaValue )return; |
|
| 103 | + if( $review->$metaKey == $metaValue ) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 94 | 106 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 95 | 107 | call_user_func( [$this, $method], $review, $metaValue ); |
| 96 | 108 | } |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function handle( Command $command ) |
| 15 | 15 | { |
| 16 | - $postId = wp_update_post([ |
|
| 16 | + $postId = wp_update_post( [ |
|
| 17 | 17 | 'ID' => $command->id, |
| 18 | 18 | 'post_status' => $command->status, |
| 19 | - ]); |
|
| 20 | - if( is_wp_error( $postId )) { |
|
| 19 | + ] ); |
|
| 20 | + if( is_wp_error( $postId ) ) { |
|
| 21 | 21 | glsr_log()->error( $postId->get_error_message() ); |
| 22 | 22 | return []; |
| 23 | 23 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | 'aria-label' => '“'.esc_attr( $title ).'” ('.__( 'Edit', 'site-reviews' ).')', |
| 40 | 40 | 'class' => 'row-title', |
| 41 | 41 | 'href' => get_edit_post_link( $postId ), |
| 42 | - ]); |
|
| 42 | + ] ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | protected function getPostState( $postId ) |
| 50 | 50 | { |
| 51 | 51 | ob_start(); |
| 52 | - _post_states( get_post( $postId )); |
|
| 52 | + _post_states( get_post( $postId ) ); |
|
| 53 | 53 | return ob_get_clean(); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | protected function getStatusLinks() |
| 60 | 60 | { |
| 61 | 61 | global $avail_post_stati; |
| 62 | - require_once( ABSPATH.'wp-admin/includes/class-wp-posts-list-table.php' ); |
|
| 62 | + require_once(ABSPATH.'wp-admin/includes/class-wp-posts-list-table.php'); |
|
| 63 | 63 | $hookName = 'edit-'.Application::POST_TYPE; |
| 64 | 64 | set_current_screen( $hookName ); |
| 65 | 65 | $avail_post_stati = get_available_post_statuses( Application::POST_TYPE ); |
| 66 | 66 | $table = new \WP_Posts_List_Table( ['screen' => $hookName] ); |
| 67 | 67 | $views = apply_filters( 'views_'.$hookName, $table->get_views() ); // uses compat get_views() |
| 68 | - if( empty( $views ))return; |
|
| 68 | + if( empty($views) )return; |
|
| 69 | 69 | foreach( $views as $class => $view ) { |
| 70 | 70 | $views[$class] = "\t<li class='$class'>$view"; |
| 71 | 71 | } |
@@ -65,7 +65,9 @@ |
||
| 65 | 65 | $avail_post_stati = get_available_post_statuses( Application::POST_TYPE ); |
| 66 | 66 | $table = new \WP_Posts_List_Table( ['screen' => $hookName] ); |
| 67 | 67 | $views = apply_filters( 'views_'.$hookName, $table->get_views() ); // uses compat get_views() |
| 68 | - if( empty( $views ))return; |
|
| 68 | + if( empty( $views )) { |
|
| 69 | + return; |
|
| 70 | + } |
|
| 69 | 71 | foreach( $views as $class => $view ) { |
| 70 | 72 | $views[$class] = "\t<li class='$class'>$view"; |
| 71 | 73 | } |
@@ -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 | } |