@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | public function fields() |
| 13 | 13 | { |
| 14 | 14 | return [[ |
| 15 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
| 15 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
| 16 | 16 | 'minWidth' => 320, |
| 17 | 17 | 'type' => 'container', |
| 18 | - ],[ |
|
| 18 | + ], [ |
|
| 19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 20 | 20 | 'name' => 'title', |
| 21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | 'name' => 'assigned_to', |
| 29 | 29 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ), |
| 30 | 30 | 'type' => 'textbox', |
| 31 | - ],[ |
|
| 31 | + ], [ |
|
| 32 | 32 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
| 33 | 33 | 'name' => 'schema', |
| 34 | 34 | 'options' => [ |
@@ -37,34 +37,34 @@ discard block |
||
| 37 | 37 | ], |
| 38 | 38 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
| 39 | 39 | 'type' => 'listbox', |
| 40 | - ],[ |
|
| 40 | + ], [ |
|
| 41 | 41 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 42 | 42 | 'name' => 'class', |
| 43 | 43 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 44 | 44 | 'type' => 'textbox', |
| 45 | - ],[ |
|
| 45 | + ], [ |
|
| 46 | 46 | 'columns' => 2, |
| 47 | 47 | 'items' => [[ |
| 48 | 48 | 'type' => 'checkbox', |
| 49 | 49 | 'name' => 'hide_bars', |
| 50 | 50 | 'text' => esc_html__( 'Bars', 'site-reviews' ), |
| 51 | 51 | 'tooltip' => esc_attr__( 'Hide the percentage bars?', 'site-reviews' ), |
| 52 | - ],[ |
|
| 52 | + ], [ |
|
| 53 | 53 | 'type' => 'checkbox', |
| 54 | 54 | 'name' => 'hide_if_empty', |
| 55 | 55 | 'text' => esc_html__( 'If Empty', 'site-reviews' ), |
| 56 | 56 | 'tooltip' => esc_attr__( 'Hide the summary if no reviews are found?', 'site-reviews' ), |
| 57 | - ],[ |
|
| 57 | + ], [ |
|
| 58 | 58 | 'type' => 'checkbox', |
| 59 | 59 | 'name' => 'hide_rating', |
| 60 | 60 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
| 61 | 61 | 'tooltip' => esc_attr__( 'Hide the rating?', 'site-reviews' ), |
| 62 | - ],[ |
|
| 62 | + ], [ |
|
| 63 | 63 | 'type' => 'checkbox', |
| 64 | 64 | 'name' => 'hide_stars', |
| 65 | 65 | 'text' => esc_html__( 'Stars', 'site-reviews' ), |
| 66 | 66 | 'tooltip' => esc_attr__( 'Hide the stars?', 'site-reviews' ), |
| 67 | - ],[ |
|
| 67 | + ], [ |
|
| 68 | 68 | 'type' => 'checkbox', |
| 69 | 69 | 'name' => 'hide_summary', |
| 70 | 70 | 'text' => esc_html__( 'Summary', 'site-reviews' ), |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | { |
| 15 | 15 | foreach( $command->shortcodes as $slug => $label ) { |
| 16 | 16 | $buttonClass = glsr( Helper::class )->buildClassName( $slug.'-button', 'Shortcodes' ); |
| 17 | - if( !class_exists( $buttonClass )) { |
|
| 18 | - glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass )); |
|
| 17 | + if( !class_exists( $buttonClass ) ) { |
|
| 18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) ); |
|
| 19 | 19 | continue; |
| 20 | 20 | } |
| 21 | 21 | $shortcode = glsr( $buttonClass )->register( $slug, [ |
| 22 | 22 | 'label' => $label, |
| 23 | 23 | 'title' => $label, |
| 24 | - ]); |
|
| 24 | + ] ); |
|
| 25 | 25 | glsr()->mceShortcodes[$slug] = $shortcode->properties; |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | { |
| 15 | 15 | foreach( $command->shortcodes as $shortcode ) { |
| 16 | 16 | $shortcodeClass = glsr( Helper::class )->buildClassName( $shortcode.'-shortcode', 'Shortcodes' ); |
| 17 | - if( !class_exists( $shortcodeClass )) { |
|
| 18 | - glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass )); |
|
| 17 | + if( !class_exists( $shortcodeClass ) ) { |
|
| 18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ) ); |
|
| 19 | 19 | continue; |
| 20 | 20 | } |
| 21 | 21 | add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] ); |
@@ -16,8 +16,8 @@ |
||
| 16 | 16 | global $wp_widget_factory; |
| 17 | 17 | foreach( $command->widgets as $key => $values ) { |
| 18 | 18 | $widgetClass = glsr( Helper::class )->buildClassName( $key.'-widget', 'Widgets' ); |
| 19 | - if( !class_exists( $widgetClass )) { |
|
| 20 | - glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass )); |
|
| 19 | + if( !class_exists( $widgetClass ) ) { |
|
| 20 | + glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ) ); |
|
| 21 | 21 | continue; |
| 22 | 22 | } |
| 23 | 23 | // Here we bypass register_widget() in order to pass our custom values to the widget |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function handle( Command $command ) |
| 14 | 14 | { |
| 15 | - if( !get_post( $command->id )) { |
|
| 15 | + if( !get_post( $command->id ) ) { |
|
| 16 | 16 | return false; |
| 17 | 17 | } |
| 18 | - if( is_null( $command->pinned )) { |
|
| 18 | + if( is_null( $command->pinned ) ) { |
|
| 19 | 19 | $meta = get_post_meta( $command->id, 'pinned', true ); |
| 20 | 20 | $command->pinned = !wp_validate_boolean( $meta ); |
| 21 | 21 | } |
@@ -15,7 +15,9 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function download( $filename, $content ) |
| 17 | 17 | { |
| 18 | - if( !current_user_can( Application::CAPABILITY ))return; |
|
| 18 | + if( !current_user_can( Application::CAPABILITY )) { |
|
| 19 | + return; |
|
| 20 | + } |
|
| 19 | 21 | nocache_headers(); |
| 20 | 22 | header( 'Content-Type: text/plain' ); |
| 21 | 23 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function download( $filename, $content ) |
| 17 | 17 | { |
| 18 | - if( !current_user_can( Application::CAPABILITY ))return; |
|
| 18 | + if( !current_user_can( Application::CAPABILITY ) )return; |
|
| 19 | 19 | nocache_headers(); |
| 20 | 20 | header( 'Content-Type: text/plain' ); |
| 21 | 21 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function execute( $command ) |
| 32 | 32 | { |
| 33 | - $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command )); |
|
| 34 | - if( !class_exists( $handlerClass )) { |
|
| 33 | + $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) ); |
|
| 34 | + if( !class_exists( $handlerClass ) ) { |
|
| 35 | 35 | throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' ); |
| 36 | 36 | } |
| 37 | 37 | try { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | catch( Exception $e ) { |
| 41 | 41 | status_header( 400 ); |
| 42 | - glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() )); |
|
| 42 | + glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) ); |
|
| 43 | 43 | glsr_log()->error( $e->getMessage() ); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -49,6 +49,6 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | protected function getPostId() |
| 51 | 51 | { |
| 52 | - return intval( filter_input( INPUT_GET, 'post' )); |
|
| 52 | + return intval( filter_input( INPUT_GET, 'post' ) ); |
|
| 53 | 53 | } |
| 54 | 54 | } |
@@ -82,7 +82,7 @@ |
||
| 82 | 82 | { |
| 83 | 83 | $this->render()->div( glsr( Notice::class )->get(), [ |
| 84 | 84 | 'id' => 'glsr-notices', |
| 85 | - ]); |
|
| 85 | + ] ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -130,8 +130,8 @@ |
||
| 130 | 130 | public function validateRequired( $attribute, $value ) |
| 131 | 131 | { |
| 132 | 132 | return is_null( $value ) |
| 133 | - || ( is_string( $value ) && trim( $value ) === '' ) |
|
| 134 | - || ( is_array( $value ) && count( $value ) < 1 ) |
|
| 133 | + || (is_string( $value ) && trim( $value ) === '') |
|
| 134 | + || (is_array( $value ) && count( $value ) < 1) |
|
| 135 | 135 | ? false |
| 136 | 136 | : true; |
| 137 | 137 | } |
@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function send() |
| 66 | 66 | { |
| 67 | - if( !$this->message || !$this->subject || !$this->to )return; |
|
| 67 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 68 | 70 | $sent = wp_mail( |
| 69 | 71 | $this->to, |
| 70 | 72 | $this->subject, |
@@ -83,7 +85,9 @@ discard block |
||
| 83 | 85 | */ |
| 84 | 86 | public function buildPlainTextMessage( $phpmailer ) |
| 85 | 87 | { |
| 86 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 88 | + if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody )) { |
|
| 89 | + return; |
|
| 90 | + } |
|
| 87 | 91 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 88 | 92 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 89 | 93 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $this->message = $this->buildHtmlMessage( $email ); |
| 44 | 44 | $this->subject = $email['subject']; |
| 45 | 45 | $this->to = $email['to']; |
| 46 | - add_action( 'phpmailer_init', [ $this, 'buildPlainTextMessage'] ); |
|
| 46 | + add_action( 'phpmailer_init', [$this, 'buildPlainTextMessage'] ); |
|
| 47 | 47 | return $this; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function buildPlainTextMessage( $phpmailer ) |
| 85 | 85 | { |
| 86 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 86 | + if( $phpmailer->ContentType === 'text/plain' || !empty($phpmailer->AltBody) )return; |
|
| 87 | 87 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 88 | 88 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 89 | 89 | } |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | 'from', |
| 100 | 100 | 'reply-to', |
| 101 | 101 | ]; |
| 102 | - $headers = array_intersect_key( $email, array_flip( $allowed )); |
|
| 102 | + $headers = array_intersect_key( $email, array_flip( $allowed ) ); |
|
| 103 | 103 | $headers = array_filter( $headers ); |
| 104 | 104 | foreach( $headers as $key => $value ) { |
| 105 | - unset( $headers[ $key ] ); |
|
| 105 | + unset($headers[$key]); |
|
| 106 | 106 | $headers[] = "{$key}: {$value}"; |
| 107 | 107 | } |
| 108 | 108 | $headers[] = 'Content-Type: text/html'; |
@@ -114,16 +114,16 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | protected function buildHtmlMessage( $email ) |
| 116 | 116 | { |
| 117 | - $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' )); |
|
| 118 | - if( !empty( $template )) { |
|
| 117 | + $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) ); |
|
| 118 | + if( !empty($template) ) { |
|
| 119 | 119 | $message = glsr( Template::class )->interpolate( $template, $email['template-tags'] ); |
| 120 | 120 | } |
| 121 | 121 | else if( $email['template'] ) { |
| 122 | 122 | $message = glsr( Template::class )->build( 'templates/'.$email['template'], [ |
| 123 | 123 | 'context' => $email['template-tags'], |
| 124 | - ]); |
|
| 124 | + ] ); |
|
| 125 | 125 | } |
| 126 | - if( !isset( $message )) { |
|
| 126 | + if( !isset($message) ) { |
|
| 127 | 127 | $message = $email['message']; |
| 128 | 128 | } |
| 129 | 129 | $message = $email['before'].$message.$email['after']; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $message = str_replace( ']]>', ']]>', $message ); |
| 135 | 135 | $message = glsr( Template::class )->build( 'partials/email/index', [ |
| 136 | 136 | 'context' => ['message' => $message], |
| 137 | - ]); |
|
| 137 | + ] ); |
|
| 138 | 138 | return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this ); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | 'to' => '', |
| 161 | 161 | ]; |
| 162 | 162 | $email = shortcode_atts( $defaults, $email ); |
| 163 | - if( empty( $email['reply-to'] )) { |
|
| 163 | + if( empty($email['reply-to']) ) { |
|
| 164 | 164 | $email['reply-to'] = $email['from']; |
| 165 | 165 | } |
| 166 | 166 | return apply_filters( 'site-reviews/email/compose', $email, $this ); |