PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / trunk
GiveWP – Donation Plugin and Fundraising Platform vtrunk
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / emails / class-email-notification-table.php
give / includes / admin / emails Last commit date
abstract-email-notification.php 4 years ago ajax-handler.php 2 weeks ago backward-compatibility.php 6 years ago class-donation-receipt-email.php 4 years ago class-donor-note-email.php 6 years ago class-donor-register-email.php 3 years ago class-email-access-email.php 4 days ago class-email-notification-table.php 3 years ago class-email-notification-util.php 6 years ago class-email-notifications.php 5 months ago class-email-setting-field.php 3 years ago class-failed-donation-email.php 5 months ago class-new-donation-email.php 6 years ago class-new-donor-register-email.php 3 years ago class-new-offline-donation-email.php 9 months ago class-offline-donation-instruction-email.php 6 years ago filters.php 3 years ago
class-email-notification-table.php
321 lines
1 <?php
2
3 /**
4 * Email Notification
5 *
6 * This class handles table html for email notifications listing.
7 *
8 * @package Give
9 * @subpackage Classes/Emails
10 * @copyright Copyright (c) 2016, GiveWP
11 * @license https://opensource.org/licenses/gpl-license GNU Public License
12 * @since 2.0
13 */
14 class Give_Email_Notification_Table extends WP_List_Table {
15 /**
16 * @var Give_Email_Notifications $email_notifications
17 * @since 2.0
18 * @access private
19 */
20 private $email_notifications;
21
22
23 /**
24 * Number of email notifications per page
25 *
26 * @since 2.0
27 * @access private
28 * @var int
29 */
30 private $per_page = - 1;
31
32 /**
33 * Give_Email_Notification_Table constructor.
34 *
35 * @since 2.0
36 * @access public
37 */
38 public function __construct() {
39 parent::__construct(
40 array(
41 'singular' => 'giveemailnotification',
42 'plural' => 'giveemailnotifications',
43 )
44 );
45
46 $this->email_notifications = Give_Email_Notifications::get_instance();
47 }
48
49
50 /**
51 * Get table columns.
52 *
53 * @since 2.0
54 * @access public
55 *
56 * @return array
57 */
58 public function get_columns() {
59 /**
60 * Filter the table columns
61 *
62 * @since 2.0
63 */
64 return apply_filters(
65 'give_email_notification_setting_columns',
66 array(
67 'cb' => __( 'Email Status', 'give' ),
68 'name' => __( 'Email', 'give' ),
69 'email_type' => __( 'Content Type', 'give' ),
70 'recipient' => __( 'Recipient(s)', 'give' ),
71 'setting' => __( 'Edit Email', 'give' ),
72 )
73 );
74 }
75
76 /**
77 * Get name column.
78 *
79 * @since 2.0
80 * @access public
81 *
82 * @param Give_Email_Notification $email
83 *
84 * @return string
85 */
86 public function column_name( $email ) {
87 $edit_url = esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails&section=' . $email->config['id'] ) );
88 $actions = $this->get_row_actions( $email );
89
90 ob_start();
91 ?>
92 <a class="row-title" href="<?php echo $edit_url; ?>"><?php echo $email->config['label']; ?></a>
93
94 <?php if ( $desc = $email->config['description'] ) : ?>
95 <?php echo Give()->tooltips->render_help( esc_attr( $desc ) ); ?>
96 <?php endif; ?>
97
98 <?php echo $this->row_actions( $actions ); ?>
99 <?php
100 return ob_get_clean();
101 }
102
103 /**
104 * Get recipient column.
105 *
106 * @since 2.0
107 * @access public
108 *
109 * @param Give_Email_Notification $email
110 *
111 * @return string
112 */
113 public function column_recipient( $email ) {
114 ob_start();
115
116 if ( Give_Email_Notification_Util::has_recipient_field( $email ) ) {
117 $recipients = $email->get_recipient();
118 if ( is_array( $recipients ) ) {
119 $recipients = implode( '<br>', $recipients );
120 }
121
122 echo $recipients;
123
124 } elseif ( ! empty( $email->config['recipient_group_name'] ) ) {
125 echo $email->config['recipient_group_name'];
126 }
127
128 return ob_get_clean();
129 }
130
131 /**
132 * Get status column.
133 *
134 * @since 2.0
135 * @access public
136 *
137 * @param Give_Email_Notification $email
138 *
139 * @return string
140 */
141 public function column_cb( $email ) {
142 $notification_status = $email->get_notification_status();
143 $user_can_edit_status = (int) Give_Email_Notification_Util::is_notification_status_editable( $email );
144 $icon_classes = Give_Email_Notification_Util::is_email_notification_active( $email )
145 ? 'dashicons dashicons-yes'
146 : 'dashicons dashicons-no-alt';
147 $attributes = array(
148 'class' => "give-email-notification-status give-email-notification-{$notification_status}",
149 'data-id' => $email->config['id'],
150 'data-status' => $email->get_notification_status(),
151 'data-edit' => $user_can_edit_status,
152 );
153
154 if ( ! $user_can_edit_status ) {
155 $icon_classes = 'dashicons dashicons-lock';
156
157 $attributes['data-notice'] = esc_attr( $email->config['notices']['non-notification-status-editable'] );
158 }
159
160 $html = sprintf(
161 '<span %1$s><i class="%2$s"></i></span></span><span class="spinner"></span>',
162 give_get_attribute_str( $attributes ),
163 $icon_classes
164 );
165
166 return $html;
167 }
168
169
170 /**
171 * Get email_type column.
172 *
173 * @since 2.0
174 * @access public
175 *
176 * @param Give_Email_Notification $email
177 *
178 * @return string
179 */
180 public function column_email_type( Give_Email_Notification $email ) {
181 $email_content_type_label = apply_filters(
182 "give_email_list_render_{$email->config['id']}_email_content_type",
183 Give_Email_Notification_Util::get_formatted_email_type( $email->config['content_type'] ),
184 $email
185 );
186
187 return $email_content_type_label;
188 }
189
190 /**
191 * Get setting column.
192 *
193 * @since 2.0
194 * @access public
195 *
196 * @param Give_Email_Notification $email
197 *
198 * @return string
199 */
200 public function column_setting( Give_Email_Notification $email ) {
201 return Give()->tooltips->render_link(
202 array(
203 'label' => __( 'Edit', 'give' ) . " {$email->config['label']}",
204 'tag_content' => '<span class="dashicons dashicons-admin-generic"></span>',
205 'link' => esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails&section=' . $email->config['id'] ) ),
206 'attributes' => array(
207 'class' => 'button button-small',
208 ),
209 )
210 );
211 }
212
213
214 /**
215 * Print row actions.
216 *
217 * @since 2.0
218 * @access private
219 *
220 * @param Give_Email_Notification $email
221 *
222 * @return array
223 */
224 private function get_row_actions( $email ) {
225 $edit_url = esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails&section=' . $email->config['id'] ) );
226
227 /**
228 * Filter the row actions
229 *
230 * @since 2.0
231 *
232 * @param array $row_actions
233 */
234 $row_actions = apply_filters(
235 'give_email_notification_row_actions',
236 array(
237 'edit' => "<a href=\"{$edit_url}\">" . __( 'Edit', 'give' ) . '</a>',
238 ),
239 $email
240 );
241
242 return $row_actions;
243 }
244
245
246 /**
247 * Prepare email notifications
248 *
249 * @since 2.0
250 * @access public
251 */
252 public function prepare_items() {
253 // Set columns.
254 $columns = $this->get_columns();
255 $hidden = array();
256 $email_notifications = array();
257 $sortable = $this->get_sortable_columns();
258 $this->_column_headers = array( $columns, $hidden, $sortable, $this->get_primary_column_name() );
259
260 // Get email section
261 $current_section = give_get_current_setting_section();
262
263 // Set email notifications.
264 /* @var Give_Email_Notification $email_notification */
265 foreach ( $this->email_notifications->get_email_notifications() as $email_notification ) {
266 if ( ! Give_Email_Notification_Util::is_show_on_emails_setting_page($email_notification)) {
267 continue;
268 }
269
270 if ('donor-email' === $current_section) {
271 // Add donor emails to email array list.
272 if (empty($email_notification->config['has_recipient_field'])) {
273 $email_notifications[] = $email_notification;
274 }
275 } elseif ('admin-email' === $current_section) {
276 // Add admin emails to email array list.
277 if ( ! empty($email_notification->config['has_recipient_field'])) {
278 $email_notifications[] = $email_notification;
279 }
280 }
281
282 /**
283 * @since 2.23.0
284 */
285 $email_notifications = apply_filters('give_email_notification_table_items', $email_notifications,
286 $email_notification, $current_section);
287 }
288
289 $total_items = count( $email_notifications );
290 $this->items = $email_notifications;
291 $this->set_pagination_args(
292 array(
293 'total_items' => $total_items,
294 'per_page' => $this->per_page,
295 )
296 );
297 }
298
299 /**
300 * Message to be displayed when there are no items
301 *
302 * @since 2.0
303 * @access public
304 */
305 public function no_items() {
306 _e( 'No give email notification found.', 'give' );
307 }
308
309 /**
310 * Get primary column.
311 *
312 * @since 2,0
313 * @access public
314 *
315 * @return string Name of the default primary column.
316 */
317 public function get_primary_column_name() {
318 return 'name';
319 }
320 }
321