| @@ -42,9 +42,9 @@ | ||
| 42 | 42 | $recipient_id = trim( (string) ( $data['id'] ?? '' ) ); |
| 43 | 43 | $raw_pending = $data['pending'] ?? null; |
| 44 | 44 | $statuses = array_map( 'sanitize_key', is_array( $raw_pending ) ? $raw_pending : array() ); |
| 45 | 45 | |
| 46 | - if ( '' === $recipient_id || empty( $statuses ) ) { | |
| 46 | + if ( '' === $recipient_id || array() === $statuses ) { | |
| 47 | 47 | return $this->response_data( false, esc_html__( 'Invalid request.', 'defender-security' ) ); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $in_house = is_numeric( $recipient_id ); |
| @@ -58,9 +58,9 @@ | ||
| 58 | 58 | if ( null === $subscriber ) { |
| 59 | 59 | return $this->response_data( false, esc_html__( 'Recipient not found.', 'defender-security' ) ); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if ( empty( $modules ) ) { | |
| 62 | + if ( ! is_array( $modules ) || array() === $modules ) { | |
| 63 | 63 | return $this->response_data( false, esc_html__( 'Module not found.', 'defender-security' ) ); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | return $this->send_verification_email( $subscriber, $modules ); |
| @@ -74,9 +74,9 @@ | ||
| 74 | 74 | * @return array Sanitized slug list. |
| 75 | 75 | */ |
| 76 | 76 | public function parse_subscription_slugs( $slug, $uids ): array { |
| 77 | 77 | if ( is_string( $uids ) && '' !== trim( $uids ) ) { |
| 78 | - return array_filter( array_map( 'sanitize_key', explode( ',', $uids ) ) ); | |
| 78 | + return array_filter( array_map( 'sanitize_key', explode( ',', $uids ) ), fn( string $v ): bool => '' !== $v ); | |
| 79 | 79 | } |
| 80 | 80 | if ( is_string( $slug ) && '' !== trim( $slug ) ) { |
| 81 | 81 | return array( sanitize_key( $slug ) ); |
| 82 | 82 | } |
| @@ -103,14 +103,19 @@ | ||
| 103 | 103 | continue; |
| 104 | 104 | } |
| 105 | 105 | $result['found_module'] = true; |
| 106 | 106 | |
| 107 | - $match = $this->confirm_recipients_in_group( $model->$group, $hash, $group ); | |
| 107 | + $recipients = 'in_house_recipients' === $group ? $model->in_house_recipients : $model->out_house_recipients; | |
| 108 | + $match = $this->confirm_recipients_in_group( $recipients, $hash, $group ); | |
| 108 | 109 | if ( null === $match ) { |
| 109 | 110 | continue; |
| 110 | 111 | } |
| 111 | 112 | |
| 112 | - $model->$group = $match['recipients']; | |
| 113 | + if ( 'in_house_recipients' === $group ) { | |
| 114 | + $model->in_house_recipients = $match['recipients']; | |
| 115 | + } else { | |
| 116 | + $model->out_house_recipients = $match['recipients']; | |
| 117 | + } | |
| 113 | 118 | $model->save(); |
| 114 | 119 | |
| 115 | 120 | $result['processed'] = true; |
| 116 | 121 | $result['redirect_slug'] = '' === $result['redirect_slug'] ? $model->slug : $result['redirect_slug']; |