@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function __construct() |
| 34 | 34 | { |
| 35 | 35 | $types = glsr( OptionManager::class )->get( 'settings.general.notification', [] ); |
| 36 | - $this->email = count( array_intersect( ['admin', 'author', 'custom'], $types )) > 0; |
|
| 36 | + $this->email = count( array_intersect( ['admin', 'author', '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(), |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | protected function buildEmail( array $args ) |
| 64 | 64 | { |
| 65 | - return glsr( Email::class )->compose([ |
|
| 65 | + return glsr( Email::class )->compose( [ |
|
| 66 | 66 | 'to' => $this->getEmailAddresses(), |
| 67 | 67 | 'subject' => $args['title'], |
| 68 | 68 | 'template' => 'email-notification', |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | 'review_rating' => $this->review->rating, |
| 76 | 76 | 'review_title' => $this->review->title, |
| 77 | 77 | ], |
| 78 | - ]); |
|
| 78 | + ] ); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | return glsr( Slack::class )->compose( $this->review, [ |
| 87 | 87 | 'fallback' => $this->buildEmail( $args )->read( 'plaintext' ), |
| 88 | - 'link' => sprintf( '<%s|%s>', $args['link'], __( 'View Review', 'site-reviews' )), |
|
| 88 | + 'link' => sprintf( '<%s|%s>', $args['link'], __( 'View Review', 'site-reviews' ) ), |
|
| 89 | 89 | 'pretext' => $args['title'], |
| 90 | - ]); |
|
| 90 | + ] ); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -96,22 +96,22 @@ discard block |
||
| 96 | 96 | protected function getEmailAddresses() |
| 97 | 97 | { |
| 98 | 98 | $emails = []; |
| 99 | - if( in_array( 'admin', $this->types )) { |
|
| 99 | + if( in_array( 'admin', $this->types ) ) { |
|
| 100 | 100 | $emails[] = get_option( 'admin_email' ); |
| 101 | 101 | } |
| 102 | - if( in_array( 'author', $this->types )) { |
|
| 103 | - $assignedPost = get_post( intval( $this->review->assigned_to )); |
|
| 102 | + if( in_array( 'author', $this->types ) ) { |
|
| 103 | + $assignedPost = get_post( intval( $this->review->assigned_to ) ); |
|
| 104 | 104 | if( $assignedPost instanceof WP_Post ) { |
| 105 | 105 | $emails[] = get_the_author_meta( 'user_email', $assignedPost->ID ); |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | - if( in_array( 'custom', $this->types )) { |
|
| 108 | + if( in_array( 'custom', $this->types ) ) { |
|
| 109 | 109 | $customEmails = glsr( OptionManager::class )->get( 'settings.general.notification_email' ); |
| 110 | 110 | $customEmails = str_replace( [' ', ',', ';'], ',', $customEmails ); |
| 111 | 111 | $customEmails = explode( ',', $customEmails ); |
| 112 | 112 | $emails = array_merge( $emails, $customEmails ); |
| 113 | 113 | } |
| 114 | - $emails = array_filter( array_keys( array_flip( $emails ))); |
|
| 114 | + $emails = array_filter( array_keys( array_flip( $emails ) ) ); |
|
| 115 | 115 | return apply_filters( 'site-reviews/notification/emails', $emails, $this->review ); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -128,16 +128,16 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function getTitle() |
| 130 | 130 | { |
| 131 | - $assignedTitle = get_the_title( intval( $this->review->assigned_to )); |
|
| 131 | + $assignedTitle = get_the_title( intval( $this->review->assigned_to ) ); |
|
| 132 | 132 | $title = _nx( |
| 133 | 133 | 'New %s-star review', |
| 134 | 134 | 'New %s-star review of: %s', |
| 135 | - intval( empty( $assignedTitle )), |
|
| 135 | + intval( empty($assignedTitle) ), |
|
| 136 | 136 | 'This string differs depending on whether or not the review has been assigned to a post.', |
| 137 | 137 | 'site-reviews' |
| 138 | 138 | ); |
| 139 | 139 | $title = sprintf( '[%s] %s', |
| 140 | - wp_specialchars_decode( strval( get_option( 'blogname' )), ENT_QUOTES ), |
|
| 140 | + wp_specialchars_decode( strval( get_option( 'blogname' ) ), ENT_QUOTES ), |
|
| 141 | 141 | sprintf( $title, $this->review->rating, $assignedTitle ) |
| 142 | 142 | ); |
| 143 | 143 | return apply_filters( 'site-reviews/notification/title', $title, $this->review ); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | protected function sendToEmail( array $args ) |
| 150 | 150 | { |
| 151 | 151 | $email = $this->buildEmail( $args ); |
| 152 | - if( empty( $email->to )) { |
|
| 152 | + if( empty($email->to) ) { |
|
| 153 | 153 | glsr_log()->error( 'Email notification was not sent: missing email address' ); |
| 154 | 154 | return; |
| 155 | 155 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | { |
| 166 | 166 | $notification = $this->buildSlackNotification( $args ); |
| 167 | 167 | $result = $notification->send(); |
| 168 | - if( is_wp_error( $result )) { |
|
| 168 | + if( is_wp_error( $result ) ) { |
|
| 169 | 169 | $notification->review = null; |
| 170 | 170 | glsr_log()->error( $result->get_error_message() )->debug( $notification ); |
| 171 | 171 | } |