@@ -42,47 +42,47 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public function run() |
| 44 | 44 | { |
| 45 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
| 46 | - add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] ); |
|
| 47 | - add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] ); |
|
| 48 | - add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] ); |
|
| 49 | - add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
| 50 | - add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
| 51 | - add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
| 52 | - add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
| 53 | - add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
| 54 | - add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
| 55 | - add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
| 56 | - add_action( 'site-reviews/create/review', [$this->editor, 'onCreateReview'], 10, 3 ); |
|
| 57 | - add_action( 'before_delete_post', [$this->editor, 'onDeleteReview'] ); |
|
| 58 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'onSaveReview'], 20, 2 ); |
|
| 59 | - add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'] ); |
|
| 60 | - add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
| 61 | - add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
| 62 | - add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
| 63 | - add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
| 64 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
| 65 | - add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
| 66 | - add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
| 67 | - add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
| 68 | - add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
| 69 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
| 70 | - add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
| 71 | - add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
| 72 | - add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
| 73 | - add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
| 74 | - add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
| 75 | - add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
| 76 | - add_action( 'wp_footer', [$this->main, 'renderSchema'] ); |
|
| 77 | - add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
| 78 | - add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
| 79 | - add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
| 80 | - add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
| 81 | - add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
| 82 | - add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
| 45 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
| 46 | + add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] ); |
|
| 47 | + add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] ); |
|
| 48 | + add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] ); |
|
| 49 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
| 50 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
| 51 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
| 52 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
| 53 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
| 54 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
| 55 | + add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
| 56 | + add_action( 'site-reviews/create/review', [$this->editor, 'onCreateReview'], 10, 3 ); |
|
| 57 | + add_action( 'before_delete_post', [$this->editor, 'onDeleteReview'] ); |
|
| 58 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'onSaveReview'], 20, 2 ); |
|
| 59 | + add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'] ); |
|
| 60 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
| 61 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
| 62 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
| 63 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
| 64 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
| 65 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
| 66 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
| 67 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
| 68 | + add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
| 69 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
| 70 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
| 71 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
| 72 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
| 73 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
| 74 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
| 75 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
| 76 | + add_action( 'wp_footer', [$this->main, 'renderSchema'] ); |
|
| 77 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
| 78 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
| 79 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
| 80 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
| 81 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
| 82 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
| 83 | 83 | add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
| 84 | - add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
| 85 | - add_action( 'admin_init', [$this->router, 'routeWebhookRequest'] ); |
|
| 86 | - add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
| 84 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
| 85 | + add_action( 'admin_init', [$this->router, 'routeWebhookRequest'] ); |
|
| 86 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
| 87 | 87 | } |
| 88 | 88 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | glsr()->version, |
| 45 | 45 | true |
| 46 | 46 | ); |
| 47 | - if( !empty( $this->pointers )) { |
|
| 47 | + if( !empty($this->pointers) ) { |
|
| 48 | 48 | wp_enqueue_style( 'wp-pointer' ); |
| 49 | 49 | wp_enqueue_script( 'wp-pointer' ); |
| 50 | 50 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $dependencies = apply_filters( 'site-reviews/enqueue/admin/dependencies', [] ); |
| 85 | 85 | $dependencies = array_merge( $dependencies, [ |
| 86 | 86 | 'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util', |
| 87 | - ]); |
|
| 87 | + ] ); |
|
| 88 | 88 | return $dependencies; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $generatedPointers = []; |
| 115 | 115 | foreach( $pointers as $pointer ) { |
| 116 | 116 | if( $pointer['screen'] != glsr_current_screen()->id )continue; |
| 117 | - if( in_array( $pointer['id'], $dismissedPointers ))continue; |
|
| 117 | + if( in_array( $pointer['id'], $dismissedPointers ) )continue; |
|
| 118 | 118 | $generatedPointers[] = $this->generatePointer( $pointer ); |
| 119 | 119 | } |
| 120 | 120 | $this->pointers = $generatedPointers; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | protected function isCurrentScreen() |
| 127 | 127 | { |
| 128 | 128 | $screen = glsr_current_screen(); |
| 129 | - return $screen && ( $screen->post_type == Application::POST_TYPE |
|
| 129 | + return $screen && ($screen->post_type == Application::POST_TYPE |
|
| 130 | 130 | || $screen->base == 'post' |
| 131 | 131 | || $screen->id == 'dashboard' |
| 132 | 132 | || $screen->id == 'widgets' |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | $variables = []; |
| 142 | 142 | foreach( glsr()->mceShortcodes as $tag => $args ) { |
| 143 | - if( empty( $args['required'] ))continue; |
|
| 143 | + if( empty($args['required']) )continue; |
|
| 144 | 144 | $variables[$tag] = $args['required']; |
| 145 | 145 | } |
| 146 | 146 | return $variables; |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | [], |
| 37 | 37 | glsr()->version |
| 38 | 38 | ); |
| 39 | - if( !$this->isCurrentScreen() )return; |
|
| 39 | + if( !$this->isCurrentScreen() ) { |
|
| 40 | + return; |
|
| 41 | + } |
|
| 40 | 42 | wp_enqueue_script( |
| 41 | 43 | Application::ID, |
| 42 | 44 | glsr()->url( 'assets/scripts/'.Application::ID.'-admin.js' ), |
@@ -113,8 +115,12 @@ discard block |
||
| 113 | 115 | $dismissedPointers = explode( ',', (string)$dismissedPointers ); |
| 114 | 116 | $generatedPointers = []; |
| 115 | 117 | foreach( $pointers as $pointer ) { |
| 116 | - if( $pointer['screen'] != glsr_current_screen()->id )continue; |
|
| 117 | - if( in_array( $pointer['id'], $dismissedPointers ))continue; |
|
| 118 | + if( $pointer['screen'] != glsr_current_screen()->id ) { |
|
| 119 | + continue; |
|
| 120 | + } |
|
| 121 | + if( in_array( $pointer['id'], $dismissedPointers )) { |
|
| 122 | + continue; |
|
| 123 | + } |
|
| 118 | 124 | $generatedPointers[] = $this->generatePointer( $pointer ); |
| 119 | 125 | } |
| 120 | 126 | $this->pointers = $generatedPointers; |
@@ -140,7 +146,9 @@ discard block |
||
| 140 | 146 | { |
| 141 | 147 | $variables = []; |
| 142 | 148 | foreach( glsr()->mceShortcodes as $tag => $args ) { |
| 143 | - if( empty( $args['required'] ))continue; |
|
| 149 | + if( empty( $args['required'] )) { |
|
| 150 | + continue; |
|
| 151 | + } |
|
| 144 | 152 | $variables[$tag] = $args['required']; |
| 145 | 153 | } |
| 146 | 154 | return $variables; |
@@ -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[] = 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 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | public function filterTinymcePlugins( array $plugins ) |
| 82 | 82 | { |
| 83 | 83 | if( user_can_richedit() |
| 84 | - && ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ))) { |
|
| 84 | + && (current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) ) { |
|
| 85 | 85 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
| 86 | 86 | } |
| 87 | 87 | return $plugins; |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function registerShortcodeButtons() |
| 95 | 95 | { |
| 96 | - $command = new RegisterShortcodeButtons([ |
|
| 96 | + $command = new RegisterShortcodeButtons( [ |
|
| 97 | 97 | 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
| 98 | 98 | 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
| 99 | 99 | 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
| 100 | - ]); |
|
| 100 | + ] ); |
|
| 101 | 101 | $this->execute( $command ); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
| 111 | 111 | glsr()->render( 'partials/editor/review', [ |
| 112 | 112 | 'post' => $post, |
| 113 | - ]); |
|
| 113 | + ] ); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function renderReviewNotice( WP_Post $post ) |
| 121 | 121 | { |
| 122 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 123 | - glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' )); |
|
| 122 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 123 | + glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ) ); |
|
| 124 | 124 | glsr( Html::class )->renderTemplate( 'partials/editor/notice', [ |
| 125 | 125 | 'context' => [ |
| 126 | 126 | 'notices' => glsr( Notice::class )->get(), |
| 127 | 127 | ], |
| 128 | - ]); |
|
| 128 | + ] ); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | if( glsr_current_screen()->base != 'post' )return; |
| 138 | 138 | $shortcodes = []; |
| 139 | 139 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 140 | - if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ))continue; |
|
| 140 | + if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ) )continue; |
|
| 141 | 141 | $shortcodes[$shortcode] = $values; |
| 142 | 142 | } |
| 143 | - if( empty( $shortcodes ))return; |
|
| 143 | + if( empty($shortcodes) )return; |
|
| 144 | 144 | glsr()->render( 'partials/editor/tinymce', [ |
| 145 | 145 | 'shortcodes' => $shortcodes, |
| 146 | - ]); |
|
| 146 | + ] ); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | public function routerClearLog() |
| 153 | 153 | { |
| 154 | 154 | glsr( Logger::class )->clear(); |
| 155 | - glsr( Notice::class )->addSuccess( __( 'Log cleared.', 'site-reviews' )); |
|
| 155 | + glsr( Notice::class )->addSuccess( __( 'Log cleared.', 'site-reviews' ) ); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -186,17 +186,17 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | $file = $_FILES['import-file']; |
| 188 | 188 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
| 189 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
| 189 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
| 190 | 190 | } |
| 191 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
| 192 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
| 191 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
| 192 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
| 193 | 193 | } |
| 194 | 194 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
| 195 | - if( empty( $settings )) { |
|
| 196 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
| 195 | + if( empty($settings) ) { |
|
| 196 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
| 197 | 197 | } |
| 198 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
| 199 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
| 198 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
| 199 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
| 215 | 215 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
| 216 | 216 | ]; |
| 217 | - return !isset( $errors[$errorCode] ) |
|
| 217 | + return !isset($errors[$errorCode]) |
|
| 218 | 218 | ? __( 'Unknown upload error.', 'site-reviews' ) |
| 219 | 219 | : $errors[$errorCode]; |
| 220 | 220 | } |