@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct() { |
24 | 24 | $this->name = 'newsletter'; |
25 | - $this->description = __( 'Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like Mailchimp, because sending non-related mailouts to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso' ); |
|
25 | + $this->description = __('Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like Mailchimp, because sending non-related mailouts to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso'); |
|
26 | 26 | $this->label = array( |
27 | - 'singular' => __( 'batch', 'event_espresso' ), |
|
28 | - 'plural' => __( 'batches', 'event_espresso' ) |
|
27 | + 'singular' => __('batch', 'event_espresso'), |
|
28 | + 'plural' => __('batches', 'event_espresso') |
|
29 | 29 | ); |
30 | 30 | $this->_master_templates = array( |
31 | 31 | 'email' => 'registration', |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | - protected function _get_data_for_context( $context, EE_Registration $registration, $id ) { |
|
52 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) { |
|
53 | 53 | //newsletter message type data handler is 'Registrations' and it expects an array of EE_Registration objects. |
54 | - return array( $registration ); |
|
54 | + return array($registration); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | |
65 | 65 | protected function _set_contexts() { |
66 | 66 | $this->_context_label = array( |
67 | - 'label' => __( 'recipient', 'event_espresso' ), |
|
68 | - 'plural' => __( 'recipients', 'event_espresso' ), |
|
69 | - 'description' => __( 'Recipient\'s are who will receive the message.', 'event_espresso' ) |
|
67 | + 'label' => __('recipient', 'event_espresso'), |
|
68 | + 'plural' => __('recipients', 'event_espresso'), |
|
69 | + 'description' => __('Recipient\'s are who will receive the message.', 'event_espresso') |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | $this->_contexts = array( |
73 | 73 | 'attendee' => array( |
74 | - 'label' => __( 'Registrant', 'event_espresso' ), |
|
75 | - 'description' => __( 'This template goes to selected registrants.', 'event_espresso' ) |
|
74 | + 'label' => __('Registrant', 'event_espresso'), |
|
75 | + 'description' => __('This template goes to selected registrants.', 'event_espresso') |
|
76 | 76 | ) |
77 | 77 | ); |
78 | 78 | } |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | 'newsletter', |
99 | 99 | ); |
100 | 100 | |
101 | - foreach ( $this->_valid_shortcodes as $context => $shortcodes ) { |
|
102 | - foreach ( $shortcodes as $key => $shortcode ) { |
|
103 | - if ( ! in_array( $shortcode, $included_shortcodes ) ) { |
|
104 | - unset( $this->_valid_shortcodes[ $context ][ $key ] ); |
|
101 | + foreach ($this->_valid_shortcodes as $context => $shortcodes) { |
|
102 | + foreach ($shortcodes as $key => $shortcode) { |
|
103 | + if ( ! in_array($shortcode, $included_shortcodes)) { |
|
104 | + unset($this->_valid_shortcodes[$context][$key]); |
|
105 | 105 | } |
106 | 106 | } |
107 | - $this->_valid_shortcodes[ $context ][] = 'newsletter'; |
|
107 | + $this->_valid_shortcodes[$context][] = 'newsletter'; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | } |
@@ -118,44 +118,44 @@ discard block |
||
118 | 118 | $addressee = array(); |
119 | 119 | |
120 | 120 | //looping through registrations |
121 | - foreach ( $this->_data->registrations as $reg_id => $details ) { |
|
121 | + foreach ($this->_data->registrations as $reg_id => $details) { |
|
122 | 122 | //set $attendee array to blank on each loop |
123 | 123 | $aee = array(); |
124 | 124 | |
125 | 125 | //need to get the attendee from this registration. |
126 | - $attendee = isset( $details['att_obj'] ) && $details['att_obj'] instanceof EE_Attendee |
|
126 | + $attendee = isset($details['att_obj']) && $details['att_obj'] instanceof EE_Attendee |
|
127 | 127 | ? $details['att_obj'] |
128 | 128 | : null; |
129 | 129 | |
130 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
130 | + if ( ! $attendee instanceof EE_Attendee) { |
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | |
134 | 134 | //set $aee from attendee object |
135 | 135 | $aee['att_obj'] = $attendee; |
136 | - $aee['reg_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['reg_objs'] ) |
|
137 | - ? $this->_data->attendees[ $attendee->ID() ]['reg_objs'] |
|
136 | + $aee['reg_objs'] = isset($this->_data->attendees[$attendee->ID()]['reg_objs']) |
|
137 | + ? $this->_data->attendees[$attendee->ID()]['reg_objs'] |
|
138 | 138 | : array(); |
139 | 139 | $aee['attendee_email'] = $attendee->email(); |
140 | - $aee['tkt_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['tkt_objs'] ) |
|
141 | - ? $this->_data->attendees[ $attendee->ID() ]['tkt_objs'] |
|
140 | + $aee['tkt_objs'] = isset($this->_data->attendees[$attendee->ID()]['tkt_objs']) |
|
141 | + ? $this->_data->attendees[$attendee->ID()]['tkt_objs'] |
|
142 | 142 | : array(); |
143 | 143 | |
144 | - if ( isset( $this->_data->attendees[ $attendee->ID() ]['evt_objs'] ) ) { |
|
145 | - $aee['evt_objs'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs']; |
|
146 | - $aee['events'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs']; |
|
144 | + if (isset($this->_data->attendees[$attendee->ID()]['evt_objs'])) { |
|
145 | + $aee['evt_objs'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
146 | + $aee['events'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
147 | 147 | } else { |
148 | 148 | $aee['evt_objs'] = $aee['events'] = array(); |
149 | 149 | } |
150 | 150 | |
151 | - $aee['reg_obj'] = isset( $details['reg_obj'] ) |
|
151 | + $aee['reg_obj'] = isset($details['reg_obj']) |
|
152 | 152 | ? $details['reg_obj'] |
153 | 153 | : null; |
154 | 154 | $aee['attendees'] = $this->_data->attendees; |
155 | 155 | |
156 | 156 | //merge in the primary attendee data |
157 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
158 | - $addressee[] = new EE_Messages_Addressee( $aee ); |
|
157 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
158 | + $addressee[] = new EE_Messages_Addressee($aee); |
|
159 | 159 | } |
160 | 160 | return $addressee; |
161 | 161 | } |
@@ -20,81 +20,81 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_Newsletter_Shortcodes extends EE_Shortcodes { |
22 | 22 | |
23 | - protected function _init_props() { |
|
24 | - $this->label = __("Batch Messages Shortcodes", 'event_espresso'); |
|
25 | - $this->description = __('All shortcodes used for the batch message type', 'event_espresso'); |
|
26 | - $this->_shortcodes = array( |
|
27 | - '[NEWSLETTER_CONTENT]' => __('This will parse to whatever is found in the related [newsletter_content] field. Note that when triggering a batch message, whatever is added for the custom message will be inserted where this shortcode is placed.', 'event_espresso') |
|
28 | - ); |
|
29 | - } |
|
23 | + protected function _init_props() { |
|
24 | + $this->label = __("Batch Messages Shortcodes", 'event_espresso'); |
|
25 | + $this->description = __('All shortcodes used for the batch message type', 'event_espresso'); |
|
26 | + $this->_shortcodes = array( |
|
27 | + '[NEWSLETTER_CONTENT]' => __('This will parse to whatever is found in the related [newsletter_content] field. Note that when triggering a batch message, whatever is added for the custom message will be inserted where this shortcode is placed.', 'event_espresso') |
|
28 | + ); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - protected function _parser( $shortcode ) { |
|
34 | - if ( $shortcode == '[NEWSLETTER_CONTENT]' ) { |
|
35 | - $this->_validate_list_requirements(); |
|
36 | - $valid_shortcodes = array('recipient_details', 'organization'); |
|
37 | - $template = $this->_data['template']['newsletter_content']; |
|
38 | - $data = $this->_data; |
|
39 | - return $this->_shortcode_helper->parse_message_template( $template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
40 | - } |
|
41 | - } |
|
33 | + protected function _parser( $shortcode ) { |
|
34 | + if ( $shortcode == '[NEWSLETTER_CONTENT]' ) { |
|
35 | + $this->_validate_list_requirements(); |
|
36 | + $valid_shortcodes = array('recipient_details', 'organization'); |
|
37 | + $template = $this->_data['template']['newsletter_content']; |
|
38 | + $data = $this->_data; |
|
39 | + return $this->_shortcode_helper->parse_message_template( $template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Callback set in args for EE_Register_Messages_Shortcode_Library::register for 'msgr_validator_callback'. |
|
46 | - * |
|
47 | - * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
48 | - * 'FHEE__EE_messenger__get_validator_config' filter. |
|
49 | - * |
|
50 | - * @since 4.3.0 |
|
51 | - * @param array $validator_config current validator configuration array |
|
52 | - * @param EE_messenger $messenger |
|
53 | - * @return array new validator config. |
|
54 | - */ |
|
55 | - public static function messenger_validator_config( $validator_config, EE_messenger $messenger ) { |
|
56 | - if ( $messenger->name !== 'email' ) |
|
57 | - return $validator_config; |
|
44 | + /** |
|
45 | + * Callback set in args for EE_Register_Messages_Shortcode_Library::register for 'msgr_validator_callback'. |
|
46 | + * |
|
47 | + * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
48 | + * 'FHEE__EE_messenger__get_validator_config' filter. |
|
49 | + * |
|
50 | + * @since 4.3.0 |
|
51 | + * @param array $validator_config current validator configuration array |
|
52 | + * @param EE_messenger $messenger |
|
53 | + * @return array new validator config. |
|
54 | + */ |
|
55 | + public static function messenger_validator_config( $validator_config, EE_messenger $messenger ) { |
|
56 | + if ( $messenger->name !== 'email' ) |
|
57 | + return $validator_config; |
|
58 | 58 | |
59 | - $validator_config['content']['shortcodes'][] = 'newsletter'; |
|
60 | - $validator_config['newsletter_content'] = array( |
|
61 | - 'shortcodes' => array('recipient_details', 'organization'), |
|
62 | - 'required' => array('[NEWSLETTER_CONTENT]') |
|
63 | - ); |
|
64 | - return $validator_config; |
|
65 | - } |
|
59 | + $validator_config['content']['shortcodes'][] = 'newsletter'; |
|
60 | + $validator_config['newsletter_content'] = array( |
|
61 | + 'shortcodes' => array('recipient_details', 'organization'), |
|
62 | + 'required' => array('[NEWSLETTER_CONTENT]') |
|
63 | + ); |
|
64 | + return $validator_config; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Callback set in args for EE_Register_Messages_Shortcode_Library::register for |
|
72 | - * 'msgr_template_fields_callback'. |
|
73 | - * |
|
74 | - * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
75 | - * FHEE__EE_messenger__get_template_fields filter. |
|
76 | - * |
|
77 | - * @since 4.3.0 |
|
78 | - * |
|
79 | - * @param array $template_fields current template fields setup array. |
|
80 | - * @param EE_messenger $messenger |
|
81 | - * @return array new/modified template fields array. |
|
82 | - */ |
|
83 | - public static function messenger_template_fields( $template_fields, EE_messenger $messenger ) { |
|
84 | - if ( $messenger->name !== 'email' ) |
|
85 | - return $template_fields; |
|
70 | + /** |
|
71 | + * Callback set in args for EE_Register_Messages_Shortcode_Library::register for |
|
72 | + * 'msgr_template_fields_callback'. |
|
73 | + * |
|
74 | + * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
75 | + * FHEE__EE_messenger__get_template_fields filter. |
|
76 | + * |
|
77 | + * @since 4.3.0 |
|
78 | + * |
|
79 | + * @param array $template_fields current template fields setup array. |
|
80 | + * @param EE_messenger $messenger |
|
81 | + * @return array new/modified template fields array. |
|
82 | + */ |
|
83 | + public static function messenger_template_fields( $template_fields, EE_messenger $messenger ) { |
|
84 | + if ( $messenger->name !== 'email' ) |
|
85 | + return $template_fields; |
|
86 | 86 | |
87 | - $template_fields['extra']['content']['newsletter_content'] = array( |
|
88 | - 'input' => 'wp_editor', |
|
89 | - 'label' => '[NEWSLETTER_CONTENT]', |
|
90 | - 'type' => 'string', |
|
91 | - 'required' => TRUE, |
|
92 | - 'validation' => TRUE, |
|
93 | - 'format' => '%s', |
|
94 | - 'rows' => '15', |
|
95 | - 'shortcodes_required' => array('[NEWSLETTER_CONTENT]') |
|
96 | - ); |
|
97 | - return $template_fields; |
|
98 | - } |
|
87 | + $template_fields['extra']['content']['newsletter_content'] = array( |
|
88 | + 'input' => 'wp_editor', |
|
89 | + 'label' => '[NEWSLETTER_CONTENT]', |
|
90 | + 'type' => 'string', |
|
91 | + 'required' => TRUE, |
|
92 | + 'validation' => TRUE, |
|
93 | + 'format' => '%s', |
|
94 | + 'rows' => '15', |
|
95 | + 'shortcodes_required' => array('[NEWSLETTER_CONTENT]') |
|
96 | + ); |
|
97 | + return $template_fields; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | } //end class EE_Newsletter_Shortcodes |