@@ -57,60 +57,60 @@ |
||
57 | 57 | */ |
58 | 58 | public function run() |
59 | 59 | { |
60 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
61 | - add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
62 | - add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
63 | - add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
64 | - add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
65 | - add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
66 | - add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
67 | - add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
68 | - add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
69 | - add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
70 | - add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
71 | - add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
72 | - add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
73 | - add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
74 | - add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
75 | - add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
76 | - add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
77 | - add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
78 | - add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
79 | - add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
80 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
81 | - add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
82 | - add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
83 | - add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
60 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
61 | + add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
62 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
63 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
64 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
65 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
66 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
67 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
68 | + add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
69 | + add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
70 | + add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
71 | + add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
72 | + add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
73 | + add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
74 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
75 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
76 | + add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
77 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
78 | + add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
79 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
80 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
81 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
82 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
83 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
84 | 84 | add_action( 'manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
85 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
86 | - add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
87 | - add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
88 | - add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
89 | - add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
90 | - add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
91 | - add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
92 | - add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
93 | - add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
94 | - add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
95 | - add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
96 | - add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
97 | - add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
98 | - add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
99 | - add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
100 | - add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
101 | - add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
102 | - add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
103 | - add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
104 | - add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
85 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
86 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
87 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
88 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
89 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
90 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
91 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
92 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
93 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
94 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
95 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
96 | + add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
97 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
98 | + add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
99 | + add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
100 | + add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
101 | + add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
102 | + add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
103 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
104 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
105 | 105 | add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
106 | - add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
107 | - add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
108 | - add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
109 | - add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
110 | - add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
111 | - add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
112 | - add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
113 | - add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
114 | - add_action( 'set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6 ); |
|
106 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
107 | + add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
108 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
109 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
110 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
111 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
112 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
113 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
114 | + add_action( 'set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6 ); |
|
115 | 115 | } |
116 | 116 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function send() |
74 | 74 | { |
75 | 75 | if( !$this->message || !$this->subject || !$this->to )return; |
76 | - add_action( 'wp_mail_failed', [$this, 'logMailError']); |
|
76 | + add_action( 'wp_mail_failed', [$this, 'logMailError'] ); |
|
77 | 77 | $sent = wp_mail( |
78 | 78 | $this->to, |
79 | 79 | $this->subject, |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $this->headers, |
82 | 82 | $this->attachments |
83 | 83 | ); |
84 | - remove_action( 'wp_mail_failed', [$this, 'logMailError']); |
|
84 | + remove_action( 'wp_mail_failed', [$this, 'logMailError'] ); |
|
85 | 85 | $this->reset(); |
86 | 86 | return $sent; |
87 | 87 | } |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function buildPlainTextMessage( PHPMailer $phpmailer ) |
94 | 94 | { |
95 | - if( empty( $this->email ))return; |
|
96 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
95 | + if( empty($this->email) )return; |
|
96 | + if( $phpmailer->ContentType === 'text/plain' || !empty($phpmailer->AltBody) )return; |
|
97 | 97 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
98 | 98 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
99 | 99 | } |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | $allowed = [ |
107 | 107 | 'bcc', 'cc', 'from', 'reply-to', |
108 | 108 | ]; |
109 | - $headers = array_intersect_key( $this->email, array_flip( $allowed )); |
|
109 | + $headers = array_intersect_key( $this->email, array_flip( $allowed ) ); |
|
110 | 110 | $headers = array_filter( $headers ); |
111 | 111 | foreach( $headers as $key => $value ) { |
112 | - unset( $headers[$key] ); |
|
112 | + unset($headers[$key]); |
|
113 | 113 | $headers[] = $key.': '.$value; |
114 | 114 | } |
115 | 115 | $headers[] = 'Content-Type: text/html'; |
@@ -121,16 +121,16 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function buildHtmlMessage() |
123 | 123 | { |
124 | - $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' )); |
|
125 | - if( !empty( $template )) { |
|
124 | + $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) ); |
|
125 | + if( !empty($template) ) { |
|
126 | 126 | $message = glsr( Template::class )->interpolate( $template, $this->email['template-tags'], $this->email['template'] ); |
127 | 127 | } |
128 | 128 | else if( $this->email['template'] ) { |
129 | 129 | $message = glsr( Template::class )->build( 'templates/'.$this->email['template'], [ |
130 | 130 | 'context' => $this->email['template-tags'], |
131 | - ]); |
|
131 | + ] ); |
|
132 | 132 | } |
133 | - if( !isset( $message )) { |
|
133 | + if( !isset($message) ) { |
|
134 | 134 | $message = $this->email['message']; |
135 | 135 | } |
136 | 136 | $message = $this->email['before'].$message.$this->email['after']; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $message = str_replace( ']]>', ']]>', $message ); |
142 | 142 | $message = glsr( Template::class )->build( 'partials/email/index', [ |
143 | 143 | 'context' => ['message' => $message], |
144 | - ]); |
|
144 | + ] ); |
|
145 | 145 | return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this ); |
146 | 146 | } |
147 | 147 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | protected function normalize( array $email = [] ) |
163 | 163 | { |
164 | 164 | $email = shortcode_atts( glsr( EmailDefaults::class )->defaults(), $email ); |
165 | - if( empty( $email['reply-to'] )) { |
|
165 | + if( empty($email['reply-to']) ) { |
|
166 | 166 | $email['reply-to'] = $email['from']; |
167 | 167 | } |
168 | 168 | $this->email = apply_filters( 'site-reviews/email/compose', $email, $this ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function __construct() |
34 | 34 | { |
35 | 35 | $types = glsr( OptionManager::class )->get( 'settings.general.notifications', [] ); |
36 | - $this->email = count( array_intersect( ['admin', 'custom'], $types )) > 0; |
|
36 | + $this->email = count( array_intersect( ['admin', 'custom'], $types ) ) > 0; |
|
37 | 37 | $this->slack = in_array( 'slack', $types ); |
38 | 38 | $this->types = $types; |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function send( Review $review ) |
45 | 45 | { |
46 | - if( empty( $this->types ))return; |
|
46 | + if( empty($this->types) )return; |
|
47 | 47 | $this->review = $review; |
48 | 48 | $args = [ |
49 | 49 | 'link' => $this->getLink(), |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function buildEmail( array $args ) |
60 | 60 | { |
61 | - return glsr( Email::class )->compose([ |
|
61 | + return glsr( Email::class )->compose( [ |
|
62 | 62 | 'to' => $this->getEmailAddresses(), |
63 | 63 | 'subject' => $args['title'], |
64 | 64 | 'template' => 'email-notification', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'review_rating' => $this->review->rating, |
72 | 72 | 'review_title' => $this->review->title, |
73 | 73 | ], |
74 | - ]); |
|
74 | + ] ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'button_url' => $args['link'], |
84 | 84 | 'fallback' => $this->buildEmail( $args )->read( 'plaintext' ), |
85 | 85 | 'pretext' => $args['title'], |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | protected function getEmailAddresses() |
93 | 93 | { |
94 | 94 | $emails = []; |
95 | - if( in_array( 'admin', $this->types )) { |
|
95 | + if( in_array( 'admin', $this->types ) ) { |
|
96 | 96 | $emails[] = get_option( 'admin_email' ); |
97 | 97 | } |
98 | - if( in_array( 'author', $this->types )) { |
|
99 | - $assignedPost = get_post( intval( $this->review->assigned_to )); |
|
98 | + if( in_array( 'author', $this->types ) ) { |
|
99 | + $assignedPost = get_post( intval( $this->review->assigned_to ) ); |
|
100 | 100 | if( $assignedPost instanceof WP_Post ) { |
101 | 101 | $this->email = true; |
102 | - $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author )); |
|
102 | + $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author ) ); |
|
103 | 103 | } |
104 | 104 | } |
105 | - if( in_array( 'custom', $this->types )) { |
|
105 | + if( in_array( 'custom', $this->types ) ) { |
|
106 | 106 | $customEmails = glsr( OptionManager::class )->get( 'settings.general.notification_email' ); |
107 | 107 | $customEmails = str_replace( [' ', ',', ';'], ',', $customEmails ); |
108 | 108 | $customEmails = explode( ',', $customEmails ); |
109 | 109 | $emails = array_merge( $emails, $customEmails ); |
110 | 110 | } |
111 | - $emails = array_filter( array_keys( array_flip( $emails ))); |
|
111 | + $emails = array_filter( array_keys( array_flip( $emails ) ) ); |
|
112 | 112 | return apply_filters( 'site-reviews/notification/emails', $emails, $this->review ); |
113 | 113 | } |
114 | 114 | |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function getTitle() |
127 | 127 | { |
128 | - $assignedTitle = get_the_title( intval( $this->review->assigned_to )); |
|
128 | + $assignedTitle = get_the_title( intval( $this->review->assigned_to ) ); |
|
129 | 129 | $title = _nx( |
130 | 130 | 'New %s-star review', |
131 | 131 | 'New %s-star review of: %s', |
132 | - intval( empty( $assignedTitle )), |
|
132 | + intval( empty($assignedTitle) ), |
|
133 | 133 | 'This string differs depending on whether or not the review has been assigned to a post.', |
134 | 134 | 'site-reviews' |
135 | 135 | ); |
136 | 136 | $title = sprintf( '[%s] %s', |
137 | - wp_specialchars_decode( strval( get_option( 'blogname' )), ENT_QUOTES ), |
|
137 | + wp_specialchars_decode( strval( get_option( 'blogname' ) ), ENT_QUOTES ), |
|
138 | 138 | sprintf( $title, $this->review->rating, $assignedTitle ) |
139 | 139 | ); |
140 | 140 | return apply_filters( 'site-reviews/notification/title', $title, $this->review ); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | protected function sendToEmail( array $args ) |
147 | 147 | { |
148 | 148 | $email = $this->buildEmail( $args ); |
149 | - if( empty( $email->to )) { |
|
149 | + if( empty($email->to) ) { |
|
150 | 150 | glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
151 | 151 | return; |
152 | 152 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if( !$this->slack )return; |
162 | 162 | $notification = $this->buildSlackNotification( $args ); |
163 | 163 | $result = $notification->send(); |
164 | - if( is_wp_error( $result )) { |
|
164 | + if( is_wp_error( $result ) ) { |
|
165 | 165 | $notification->review = null; |
166 | 166 | glsr_log()->error( $result->get_error_message() )->debug( $notification ); |
167 | 167 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function getSettingFields( $path ) |
56 | 56 | { |
57 | - return array_filter( $this->settings, function( $key ) use( $path ) { |
|
57 | + return array_filter( $this->settings, function( $key ) use($path) { |
|
58 | 58 | return glsr( Helper::class )->startsWith( $path, $key ); |
59 | 59 | }, ARRAY_FILTER_USE_KEY ); |
60 | 60 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | $field = wp_parse_args( $field, [ |
70 | 70 | 'is_setting' => true, |
71 | 71 | 'name' => $name, |
72 | - ]); |
|
73 | - $rows.= new Field( $this->normalize( $field )); |
|
72 | + ] ); |
|
73 | + $rows .= new Field( $this->normalize( $field ) ); |
|
74 | 74 | } |
75 | 75 | return $rows; |
76 | 76 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function getTemplateData( $id ) |
83 | 83 | { |
84 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
84 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
85 | 85 | return [ |
86 | 86 | 'context' => [ |
87 | 87 | 'rows' => $this->getSettingRows( $fields ), |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function getTemplateDataForAddons( $id ) |
97 | 97 | { |
98 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
98 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
99 | 99 | $settings = glsr( Helper::class )->convertDotNotationArray( $fields ); |
100 | 100 | $settingKeys = array_keys( $settings['settings']['addons'] ); |
101 | 101 | $results = []; |
102 | 102 | foreach( $settingKeys as $key ) { |
103 | - $addonFields = array_filter( $fields, function( $path ) use( $key ) { |
|
103 | + $addonFields = array_filter( $fields, function( $path ) use($key) { |
|
104 | 104 | return glsr( Helper::class )->startsWith( 'settings.addons.'.$key, $path ); |
105 | 105 | }, ARRAY_FILTER_USE_KEY ); |
106 | 106 | $results[$key] = $this->getSettingRows( $addonFields ); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function getTemplateDataForLicenses( $id ) |
119 | 119 | { |
120 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
120 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
121 | 121 | ksort( $fields ); |
122 | 122 | return [ |
123 | 123 | 'context' => [ |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | protected function getTemplateDataForTranslations() |
133 | 133 | { |
134 | 134 | $translations = glsr( Translation::class )->renderAll(); |
135 | - $class = empty( $translations ) |
|
135 | + $class = empty($translations) |
|
136 | 136 | ? 'glsr-hidden' |
137 | 137 | : ''; |
138 | 138 | return [ |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | $path, |
156 | 156 | glsr( Helper::class )->dataGet( glsr()->defaults, $path ) |
157 | 157 | ); |
158 | - if( is_array( $expectedValue )) { |
|
158 | + if( is_array( $expectedValue ) ) { |
|
159 | 159 | return is_array( $optionValue ) |
160 | - ? count( array_intersect( $optionValue, $expectedValue )) === 0 |
|
160 | + ? count( array_intersect( $optionValue, $expectedValue ) ) === 0 |
|
161 | 161 | : !in_array( $optionValue, $expectedValue ); |
162 | 162 | } |
163 | 163 | return $optionValue != $expectedValue; |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | */ |
169 | 169 | protected function isMultiDependency( $path ) |
170 | 170 | { |
171 | - if( isset( $this->settings[$path] )) { |
|
171 | + if( isset($this->settings[$path]) ) { |
|
172 | 172 | $field = $this->settings[$path]; |
173 | - return ( $field['type'] == 'checkbox' && !empty( $field['options'] )) |
|
174 | - || !empty( $field['multiple'] ); |
|
173 | + return ($field['type'] == 'checkbox' && !empty($field['options'])) |
|
174 | + || !empty($field['multiple']); |
|
175 | 175 | } |
176 | 176 | return false; |
177 | 177 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function normalizeDependsOn( array $field ) |
194 | 194 | { |
195 | - if( !empty( $field['depends_on'] ) && is_array( $field['depends_on'] )) { |
|
195 | + if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) { |
|
196 | 196 | $isFieldHidden = false; |
197 | 197 | $conditions = []; |
198 | 198 | foreach( $field['depends_on'] as $path => $value ) { |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | 'name' => $this->getFieldNameForDependsOn( $path ), |
201 | 201 | 'value' => $value, |
202 | 202 | ]; |
203 | - if( $this->isFieldHidden( $path, $value )) { |
|
203 | + if( $this->isFieldHidden( $path, $value ) ) { |
|
204 | 204 | $isFieldHidden = true; |
205 | 205 | } |
206 | 206 | } |
207 | - $field['data-depends'] = json_encode( $conditions, JSON_HEX_APOS|JSON_HEX_QUOT ); |
|
207 | + $field['data-depends'] = json_encode( $conditions, JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
208 | 208 | $field['is_hidden'] = $isFieldHidden; |
209 | 209 | } |
210 | 210 | return $field; |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | */ |
216 | 216 | protected function normalizeLabelAndLegend( array $field ) |
217 | 217 | { |
218 | - if( !empty( $field['label'] )) { |
|
218 | + if( !empty($field['label']) ) { |
|
219 | 219 | $field['legend'] = $field['label']; |
220 | - unset( $field['label'] ); |
|
220 | + unset($field['label']); |
|
221 | 221 | } |
222 | 222 | else { |
223 | 223 | $field['is_valid'] = false; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | protected function normalizeValue( array $field ) |
233 | 233 | { |
234 | - if( !isset( $field['value'] )) { |
|
234 | + if( !isset($field['value']) ) { |
|
235 | 235 | $field['value'] = glsr( OptionManager::class )->get( |
236 | 236 | $field['name'], |
237 | 237 | $this->getFieldDefault( $field ) |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | 'after_widget' => '</div>', |
24 | 24 | 'before_title' => '<h3 class="glsr-'.$type.'-title">', |
25 | 25 | 'after_title' => '</h3>', |
26 | - ]); |
|
26 | + ] ); |
|
27 | 27 | $args = apply_filters( 'site-reviews/shortcode/args', $args, $type, $shortcodePartial ); |
28 | 28 | $instance = $this->normalize( $instance ); |
29 | 29 | $partial = glsr( Partial::class )->build( $shortcodePartial, $instance ); |
30 | - if( !empty( $instance['title'] )) { |
|
30 | + if( !empty($instance['title']) ) { |
|
31 | 31 | $instance['title'] = $args['before_title'].$instance['title'].$args['after_title']; |
32 | 32 | } |
33 | 33 | return $args['before_widget'].$instance['title'].$partial.$args['after_widget']; |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function normalize( $args ) |
92 | 92 | { |
93 | - $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args )); |
|
93 | + $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args ) ); |
|
94 | 94 | array_walk( $args, function( &$value, $key ) { |
95 | 95 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
96 | - if( !method_exists( $this, $methodName ))return; |
|
96 | + if( !method_exists( $this, $methodName ) )return; |
|
97 | 97 | $value = $this->$methodName( $value ); |
98 | 98 | }); |
99 | 99 | return $this->sanitize( $args ); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | protected function normalizeAssignedTo( $postId ) |
112 | 112 | { |
113 | 113 | if( $postId == 'parent_id' ) { |
114 | - $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ))); |
|
114 | + $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ) ) ); |
|
115 | 115 | } |
116 | 116 | else if( $postId == 'post_id' ) { |
117 | 117 | $postId = intval( get_the_ID() ); |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function normalizeHide( $hide ) |
136 | 136 | { |
137 | - if( is_string( $hide )) { |
|
137 | + if( is_string( $hide ) ) { |
|
138 | 138 | $hide = explode( ',', $hide ); |
139 | 139 | } |
140 | 140 | $hideKeys = array_keys( $this->getHideOptions() ); |
141 | - return array_filter( array_map( 'trim', $hide ), function( $value ) use( $hideKeys ) { |
|
141 | + return array_filter( array_map( 'trim', $hide ), function( $value ) use($hideKeys) { |
|
142 | 142 | return in_array( $value, $hideKeys ); |
143 | 143 | }); |
144 | 144 | } |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | __( 'Terrible', 'site-reviews' ), |
167 | 167 | ]; |
168 | 168 | $defaults = array_pad( $defaults, glsr()->constant( 'MAX_RATING', Rating::class ), '' ); |
169 | - $labels = array_map( 'trim', explode( ',', $labels )); |
|
169 | + $labels = array_map( 'trim', explode( ',', $labels ) ); |
|
170 | 170 | foreach( $defaults as $i => $label ) { |
171 | - if( empty( $labels[$i] ))continue; |
|
171 | + if( empty($labels[$i]) )continue; |
|
172 | 172 | $defaults[$i] = $labels[$i]; |
173 | 173 | } |
174 | 174 | return array_combine( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), $defaults ); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $this->args = $args; |
36 | 36 | $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $args ); |
37 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
37 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) )return; |
|
38 | 38 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
39 | 39 | $this->generateSchema(); |
40 | 40 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'stars' => $this->buildStars(), |
49 | 49 | 'text' => $this->buildText(), |
50 | 50 | ], |
51 | - ]); |
|
51 | + ] ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | */ |
57 | 57 | protected function buildPercentage() |
58 | 58 | { |
59 | - if( $this->isHidden( 'bars' ))return; |
|
60 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
|
61 | - $bars = array_reduce( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), function( $carry, $level ) use( $percentages ) { |
|
59 | + if( $this->isHidden( 'bars' ) )return; |
|
60 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) ); |
|
61 | + $bars = array_reduce( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), function( $carry, $level ) use($percentages) { |
|
62 | 62 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
63 | 63 | $background = $this->buildPercentageBackground( $percentages[$level] ); |
64 | 64 | $count = apply_filters( 'site-reviews/summary/counts', |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $percent = $this->buildPercentageCount( $count ); |
69 | 69 | return $carry.glsr( Builder::class )->div( $label.$background.$percent, [ |
70 | 70 | 'class' => 'glsr-bar', |
71 | - ]); |
|
71 | + ] ); |
|
72 | 72 | }); |
73 | 73 | return $this->wrap( 'percentage', $bars ); |
74 | 74 | } |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | */ |
80 | 80 | protected function buildPercentageBackground( $percent ) |
81 | 81 | { |
82 | - $backgroundPercent = glsr( Builder::class )->span([ |
|
82 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
83 | 83 | 'class' => 'glsr-bar-background-percent', |
84 | 84 | 'style' => 'width:'.$percent, |
85 | - ]); |
|
85 | + ] ); |
|
86 | 86 | return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
87 | 87 | } |
88 | 88 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | protected function buildRating() |
111 | 111 | { |
112 | - if( $this->isHidden( 'rating' ))return; |
|
112 | + if( $this->isHidden( 'rating' ) )return; |
|
113 | 113 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
114 | 114 | } |
115 | 115 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function buildStars() |
120 | 120 | { |
121 | - if( $this->isHidden( 'stars' ))return; |
|
121 | + if( $this->isHidden( 'stars' ) )return; |
|
122 | 122 | $stars = glsr_star_rating( $this->averageRating ); |
123 | 123 | return $this->wrap( 'stars', $stars ); |
124 | 124 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function buildText() |
130 | 130 | { |
131 | - if( $this->isHidden( 'summary' ))return; |
|
132 | - $count = intval( array_sum( $this->ratingCounts )); |
|
133 | - if( empty( $this->args['text'] )) { |
|
131 | + if( $this->isHidden( 'summary' ) )return; |
|
132 | + $count = intval( array_sum( $this->ratingCounts ) ); |
|
133 | + if( empty($this->args['text']) ) { |
|
134 | 134 | // @todo document this change |
135 | 135 | $this->args['text'] = _nx( |
136 | 136 | '{rating} out of {max} stars (based on {num} review)', |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | ); |
142 | 142 | } |
143 | 143 | $summary = str_replace( |
144 | - ['{rating}','{max}', '{num}'], |
|
144 | + ['{rating}', '{max}', '{num}'], |
|
145 | 145 | [$this->averageRating, glsr()->constant( 'MAX_RATING', Rating::class ), $count], |
146 | 146 | $this->args['text'] |
147 | 147 | ); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | protected function generateSchema() |
155 | 155 | { |
156 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
156 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
157 | 157 | glsr( Schema::class )->store( |
158 | 158 | glsr( Schema::class )->buildSummary( $this->args ) |
159 | 159 | ); |
@@ -185,6 +185,6 @@ discard block |
||
185 | 185 | { |
186 | 186 | return glsr( Builder::class )->div( $value, [ |
187 | 187 | 'class' => 'glsr-summary-'.$key, |
188 | - ]); |
|
188 | + ] ); |
|
189 | 189 | } |
190 | 190 | } |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | if( $review->review_type != 'local' )continue; |
39 | 39 | $reviews[] = $this->buildReview( $review ); |
40 | 40 | } |
41 | - if( !empty( $reviews )) { |
|
41 | + if( !empty($reviews) ) { |
|
42 | 42 | array_walk( $reviews, function( &$review ) { |
43 | - unset( $review['@context'] ); |
|
44 | - unset( $review['itemReviewed'] ); |
|
43 | + unset($review['@context']); |
|
44 | + unset($review['itemReviewed']); |
|
45 | 45 | }); |
46 | 46 | $schema['review'] = $reviews; |
47 | 47 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function buildSummary( $args = null ) |
56 | 56 | { |
57 | - if( is_array( $args )) { |
|
57 | + if( is_array( $args ) ) { |
|
58 | 58 | $this->args = $args; |
59 | 59 | } |
60 | 60 | $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' ); |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | $schema = method_exists( $this, $buildSummary ) |
63 | 63 | ? $this->$buildSummary() |
64 | 64 | : $this->buildSummaryForCustom(); |
65 | - if( !empty( $count )) { |
|
65 | + if( !empty($count) ) { |
|
66 | 66 | $schema->aggregateRating( |
67 | 67 | $this->getSchemaType( 'AggregateRating' ) |
68 | 68 | ->ratingValue( $this->getRatingValue() ) |
69 | 69 | ->reviewCount( $count ) |
70 | - ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class )) |
|
71 | - ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class )) |
|
70 | + ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) ) |
|
71 | + ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) ) |
|
72 | 72 | ); |
73 | 73 | } |
74 | 74 | $schema = $schema->toArray(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function render() |
82 | 82 | { |
83 | - if( empty( glsr()->schemas ))return; |
|
83 | + if( empty(glsr()->schemas) )return; |
|
84 | 84 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
85 | 85 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
86 | 86 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
87 | - )); |
|
87 | + ) ); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | $schemas = glsr()->schemas; |
96 | 96 | $schemas[] = $schema; |
97 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
97 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | protected function buildReview( $review ) |
105 | 105 | { |
106 | 106 | $schema = $this->getSchemaType( 'Review' ) |
107 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
107 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) { |
|
108 | 108 | $schema->name( $review->title ); |
109 | 109 | }) |
110 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
110 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) { |
|
111 | 111 | $schema->reviewBody( $review->content ); |
112 | 112 | }) |
113 | - ->datePublished(( new DateTime( $review->date ))) |
|
114 | - ->author( $this->getSchemaType( 'Person' )->name( $review->author )) |
|
115 | - ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ))); |
|
116 | - if( !empty( $review->rating )) { |
|
113 | + ->datePublished( (new DateTime( $review->date )) ) |
|
114 | + ->author( $this->getSchemaType( 'Person' )->name( $review->author ) ) |
|
115 | + ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) ); |
|
116 | + if( !empty($review->rating) ) { |
|
117 | 117 | $schema->reviewRating( |
118 | 118 | $this->getSchemaType( 'Rating' ) |
119 | 119 | ->ratingValue( $review->rating ) |
120 | - ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class )) |
|
121 | - ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class )) |
|
120 | + ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) ) |
|
121 | + ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) ) |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | return apply_filters( 'site-reviews/schema/review', $schema->toArray(), $review, $this->args ); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | foreach( $values as $value ) { |
134 | 134 | $option = $this->getSchemaOptionValue( $value ); |
135 | - if( empty( $option ))continue; |
|
135 | + if( empty($option) )continue; |
|
136 | 136 | $schema->$value( $option ); |
137 | 137 | } |
138 | 138 | return $schema; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | return $this->buildSchemaValues( $this->getSchemaType(), [ |
147 | 147 | 'description', 'image', 'name', 'url', |
148 | - ]); |
|
148 | + ] ); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | { |
156 | 156 | return $this->buildSchemaValues( $this->buildSummaryForCustom(), [ |
157 | 157 | 'address', 'priceRange', 'telephone', |
158 | - ]); |
|
158 | + ] ); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | $offerType = $this->getSchemaOption( 'offerType', 'AggregateOffer' ); |
167 | 167 | $offers = $this->buildSchemaValues( $this->getSchemaType( $offerType ), [ |
168 | 168 | 'highPrice', 'lowPrice', 'price', 'priceCurrency', |
169 | - ]); |
|
169 | + ] ); |
|
170 | 170 | return $this->buildSummaryForCustom() |
171 | - ->doIf( !empty( $offers->getProperties() ), function( $schema ) use( $offers ) { |
|
171 | + ->doIf( !empty($offers->getProperties()), function( $schema ) use($offers) { |
|
172 | 172 | $schema->offers( $offers ); |
173 | 173 | }) |
174 | 174 | ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' ); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function getRatingCounts() |
181 | 181 | { |
182 | - if( !isset( $this->ratingCounts )) { |
|
182 | + if( !isset($this->ratingCounts) ) { |
|
183 | 183 | $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args ); |
184 | 184 | } |
185 | 185 | return $this->ratingCounts; |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | protected function getSchemaOption( $option, $fallback ) |
202 | 202 | { |
203 | 203 | $option = strtolower( $option ); |
204 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
204 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
205 | 205 | return $schemaOption; |
206 | 206 | } |
207 | 207 | $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option ); |
208 | - if( is_array( $setting )) { |
|
208 | + if( is_array( $setting ) ) { |
|
209 | 209 | return $this->getSchemaOptionDefault( $setting, $fallback ); |
210 | 210 | } |
211 | - return !empty( $setting ) |
|
211 | + return !empty($setting) |
|
212 | 212 | ? $setting |
213 | 213 | : $fallback; |
214 | 214 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $setting = wp_parse_args( $setting, [ |
223 | 223 | 'custom' => '', |
224 | 224 | 'default' => $fallback, |
225 | - ]); |
|
225 | + ] ); |
|
226 | 226 | return $setting['default'] != 'custom' |
227 | 227 | ? $setting['default'] |
228 | 228 | : $setting['custom']; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | } |
242 | 242 | if( !is_single() && !is_page() )return; |
243 | 243 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
244 | - if( method_exists( $this, $method )) { |
|
244 | + if( method_exists( $this, $method ) ) { |
|
245 | 245 | return $this->$method(); |
246 | 246 | } |
247 | 247 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function getSchemaType( $type = null ) |
254 | 254 | { |
255 | - if( !is_string( $type )) { |
|
255 | + if( !is_string( $type ) ) { |
|
256 | 256 | $type = $this->getSchemaOption( 'type', 'LocalBusiness' ); |
257 | 257 | } |
258 | 258 | $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' ); |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | protected function getThingDescription() |
268 | 268 | { |
269 | 269 | $post = get_post(); |
270 | - if( !( $post instanceof WP_Post )) { |
|
270 | + if( !($post instanceof WP_Post) ) { |
|
271 | 271 | return ''; |
272 | 272 | } |
273 | - $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt )); |
|
274 | - return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 )); |
|
273 | + $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) ); |
|
274 | + return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) ); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -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 | - $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
98 | + $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
99 | 99 | $multisitePlugins = $this->getMultisitePluginDetails(); |
100 | 100 | return is_array( $multisitePlugins ) |
101 | 101 | ? array_diff( $inactivePlugins, $multisitePlugins ) |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function getMuPluginDetails() |
109 | 109 | { |
110 | - if( empty( $plugins = get_mu_plugins() ))return; |
|
110 | + if( empty($plugins = get_mu_plugins()) )return; |
|
111 | 111 | return $this->normalizePluginList( $plugins ); |
112 | 112 | } |
113 | 113 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | public function getMultisitePluginDetails() |
118 | 118 | { |
119 | 119 | $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] ); |
120 | - if( !is_multisite() || empty( $activePlugins ))return; |
|
121 | - return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins )); |
|
120 | + if( !is_multisite() || empty($activePlugins) )return; |
|
121 | + return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | 'Memory Limit' => ini_get( 'memory_limit' ), |
146 | 146 | 'Post Max Size' => ini_get( 'post_max_size' ), |
147 | 147 | 'Sendmail Path' => ini_get( 'sendmail_path' ), |
148 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
149 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
150 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
151 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
152 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
148 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
149 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
150 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
151 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
152 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
153 | 153 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
154 | 154 | ]; |
155 | 155 | } |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | { |
162 | 162 | $counts = glsr( CountsManager::class )->getCounts(); |
163 | 163 | $counts = glsr( Helper::class )->flattenArray( $counts ); |
164 | - array_walk( $counts, function( &$ratings ) use( $counts ) { |
|
165 | - if( !is_array( $ratings )) { |
|
164 | + array_walk( $counts, function( &$ratings ) use($counts) { |
|
165 | + if( !is_array( $ratings ) ) { |
|
166 | 166 | glsr_log() |
167 | 167 | ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
168 | 168 | ->debug( $ratings ) |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | ksort( $settings ); |
202 | 202 | $details = []; |
203 | 203 | foreach( $settings as $key => $value ) { |
204 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
205 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
204 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
205 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
206 | 206 | $details[$key] = $value; |
207 | 207 | } |
208 | 208 | return $details; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | return [ |
217 | 217 | 'Console level' => glsr( Console::class )->humanLevel(), |
218 | 218 | 'Console size' => glsr( Console::class )->humanSize( '0' ), |
219 | - 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' )), |
|
219 | + 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ), |
|
220 | 220 | 'Version (current)' => glsr()->version, |
221 | 221 | 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
222 | 222 | ]; |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | 'WPE_APIKEY' => 'WP Engine', |
278 | 278 | ]; |
279 | 279 | foreach( $checks as $key => $value ) { |
280 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
280 | + if( !$this->isWebhostCheckValid( $key ) )continue; |
|
281 | 281 | return $value; |
282 | 282 | } |
283 | - return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
|
283 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | { |
302 | 302 | $plugins = get_plugins(); |
303 | 303 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
304 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
305 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
304 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
305 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
306 | 306 | return $active + $inactive; |
307 | 307 | } |
308 | 308 | |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | protected function implode( $title, array $details ) |
314 | 314 | { |
315 | 315 | $strings = ['['.$title.']']; |
316 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
316 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
317 | 317 | $padding = max( [$padding, static::PAD] ); |
318 | 318 | foreach( $details as $key => $value ) { |
319 | 319 | $strings[] = is_string( $key ) |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | protected function normalizePluginList( array $plugins ) |
343 | 343 | { |
344 | 344 | $plugins = array_map( function( $plugin ) { |
345 | - return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' )); |
|
345 | + return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' ) ); |
|
346 | 346 | }, $plugins ); |
347 | 347 | natcasesort( $plugins ); |
348 | 348 | return array_flip( $plugins ); |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | $keys = [ |
357 | 357 | 'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret', |
358 | 358 | ]; |
359 | - array_walk( $settings, function( &$value, $setting ) use( $keys ) { |
|
359 | + array_walk( $settings, function( &$value, $setting ) use($keys) { |
|
360 | 360 | foreach( $keys as $key ) { |
361 | - if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue; |
|
361 | + if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue; |
|
362 | 362 | $value = str_repeat( '•', 13 ); |
363 | 363 | return; |
364 | 364 | } |
@@ -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 ) * glsr()->constant( 'MAX_RATING' ); // prior, 70% = 3.5 |
|
126 | + $bayesMean = ($confidencePercentage / 100) * glsr()->constant( '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 | } |