PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.2.0
GiveWP – Donation Plugin and Fundraising Platform v2.2.0
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 7 years ago ajax-handler.php 8 years ago backward-compatibility.php 8 years ago class-donation-receipt-email.php 8 years ago class-donor-register-email.php 7 years ago class-email-access-email.php 7 years ago class-email-notification-table.php 8 years ago class-email-notification-util.php 8 years ago class-email-notifications.php 8 years ago class-email-setting-field.php 8 years ago class-new-donation-email.php 8 years ago class-new-donor-register-email.php 8 years ago class-new-offline-donation-email.php 7 years ago class-offline-donation-instruction-email.php 7 years ago filters.php 8 years ago
class-email-notification-table.php
291 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, WordImpress
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( array(
40 'singular' => __( 'Give Email Notification', 'give' ),
41 'plural' => __( 'Give Email Notifications', 'give' ),
42 ) );
43
44 $this->email_notifications = Give_Email_Notifications::get_instance();
45 }
46
47
48 /**
49 * Get table columns.
50 *
51 * @since 2.0
52 * @access public
53 *
54 * @return array
55 */
56 public function get_columns() {
57 /**
58 * Filter the table columns
59 *
60 * @since 2.0
61 */
62 return apply_filters( 'give_email_notification_setting_columns', array(
63 'cb' => __( 'Email Status', 'give' ),
64 'name' => __( 'Email', 'give' ),
65 'email_type' => __( 'Content Type', 'give' ),
66 'recipient' => __( 'Recipient(s)', 'give' ),
67 'setting' => __( 'Edit Email', 'give' ),
68 ) );
69 }
70
71 /**
72 * Get name column.
73 *
74 * @since 2.0
75 * @access public
76 *
77 * @param Give_Email_Notification $email
78 *
79 * @return string
80 */
81 public function column_name( $email ) {
82 $edit_url = esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails&section=' . $email->config['id'] ) );
83 $actions = $this->get_row_actions( $email );
84
85 ob_start();
86 ?>
87 <a class="row-title" href="<?php echo $edit_url; ?>"><?php echo $email->config['label']; ?></a>
88
89 <?php if ( $desc = $email->config['description'] ) : ?>
90 <?php echo Give()->tooltips->render_help( esc_attr( $desc ) ); ?>
91 <?php endif; ?>
92
93 <?php echo $this->row_actions( $actions ); ?>
94 <?php
95 return ob_get_clean();
96 }
97
98 /**
99 * Get recipient column.
100 *
101 * @since 2.0
102 * @access public
103 *
104 * @param Give_Email_Notification $email
105 *
106 * @return string
107 */
108 public function column_recipient( $email ) {
109 ob_start();
110
111 if( Give_Email_Notification_Util::has_recipient_field( $email ) ) {
112 $recipients = $email->get_recipient();
113 if ( is_array( $recipients ) ) {
114 $recipients = implode( '<br>', $recipients );
115 }
116
117 echo $recipients;
118
119 } elseif ( ! empty( $email->config['recipient_group_name'] ) ) {
120 echo $email->config['recipient_group_name'];
121 }
122
123 return ob_get_clean();
124 }
125
126 /**
127 * Get status column.
128 *
129 * @since 2.0
130 * @access public
131 *
132 * @param Give_Email_Notification $email
133 *
134 * @return string
135 */
136 public function column_cb( $email ) {
137 $notification_status = $email->get_notification_status();
138 $user_can_edit_status = (int) Give_Email_Notification_Util::is_notification_status_editable( $email );
139 $icon_classes = Give_Email_Notification_Util::is_email_notification_active( $email )
140 ? 'dashicons dashicons-yes'
141 : 'dashicons dashicons-no-alt';
142 $attributes = array(
143 'class' => "give-email-notification-status give-email-notification-{$notification_status}",
144 'data-id' => $email->config['id'],
145 'data-status' => $email->get_notification_status(),
146 'data-edit' => $user_can_edit_status,
147 );
148
149 if ( ! $user_can_edit_status ) {
150 $icon_classes = 'dashicons dashicons-lock';
151
152 $attributes['data-notice'] = esc_attr( $email->config['notices']['non-notification-status-editable'] );
153 }
154
155 $html = sprintf(
156 '<span %1$s><i class="%2$s"></i></span></span><span class="spinner"></span>',
157 give_get_attribute_str( $attributes ),
158 $icon_classes
159 );
160
161 return $html;
162 }
163
164
165 /**
166 * Get email_type column.
167 *
168 * @since 2.0
169 * @access public
170 *
171 * @param Give_Email_Notification $email
172 *
173 * @return string
174 */
175 public function column_email_type( Give_Email_Notification $email ) {
176 $email_content_type_label = apply_filters(
177 "give_email_list_render_{$email->config['id']}_email_content_type",
178 Give_Email_Notification_Util::get_formatted_email_type( $email->config['content_type'] ),
179 $email
180 );
181
182 return $email_content_type_label;
183 }
184
185 /**
186 * Get setting column.
187 *
188 * @since 2.0
189 * @access public
190 *
191 * @param Give_Email_Notification $email
192 *
193 * @return string
194 */
195 public function column_setting( Give_Email_Notification $email ) {
196 return Give()->tooltips->render_link( array(
197 'label' => __( 'Edit', 'give' ) . " {$email->config['label']}",
198 'tag_content' => '<span class="dashicons dashicons-admin-generic"></span>',
199 'link' => esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails&section=' . $email->config['id'] ) ),
200 'attributes' => array(
201 'class' => 'button button-small',
202 ),
203 ) );
204 }
205
206
207 /**
208 * Print row actions.
209 *
210 * @since 2.0
211 * @access private
212 *
213 * @param Give_Email_Notification $email
214 *
215 * @return array
216 */
217 private function get_row_actions( $email ) {
218 $edit_url = esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails&section=' . $email->config['id'] ) );
219
220 /**
221 * Filter the row actions
222 *
223 * @since 2.0
224 *
225 * @param array $row_actions
226 */
227 $row_actions = apply_filters(
228 'give_email_notification_row_actions',
229 array(
230 'edit' => "<a href=\"{$edit_url}\">" . __( 'Edit', 'give' ) . '</a>',
231 ),
232 $email
233 );
234
235 return $row_actions;
236 }
237
238
239 /**
240 * Prepare email notifications
241 *
242 * @since 2.0
243 * @access public
244 */
245 public function prepare_items() {
246 // Set columns.
247 $columns = $this->get_columns();
248 $hidden = array();
249 $email_notifications = array();
250 $sortable = $this->get_sortable_columns();
251 $this->_column_headers = array( $columns, $hidden, $sortable, $this->get_primary_column_name() );
252
253 // Set email notifications.
254 /* @var Give_Email_Notification $email_notification */
255 foreach ( $this->email_notifications->get_email_notifications() as $email_notification ) {
256 if ( Give_Email_Notification_Util::is_show_on_emails_setting_page( $email_notification ) ) {
257 $email_notifications[] = $email_notification;
258 }
259 }
260
261 $totalItems = count( $email_notifications );
262 $this->items = $email_notifications;
263 $this->set_pagination_args( array(
264 'total_items' => $totalItems,
265 'per_page' => $this->per_page,
266 ) );
267 }
268
269 /**
270 * Message to be displayed when there are no items
271 *
272 * @since 2.0
273 * @access public
274 */
275 public function no_items() {
276 _e( 'No give email notification found.', 'give' );
277 }
278
279 /**
280 * Get primary column.
281 *
282 * @since 2,0
283 * @access public
284 *
285 * @return string Name of the default primary column.
286 */
287 public function get_primary_column_name() {
288 return 'name';
289 }
290 }
291