Completed
Branch Gutenberg/espresso-cpt-editor (d57906)
by
unknown
78:21 queued 69:49
created
admin_pages/messages/EE_Message_List_Table.class.php 2 patches
Indentation   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -15,430 +15,430 @@  discard block
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * @return Messages_Admin_Page
20
-     */
21
-    public function get_admin_page()
22
-    {
23
-        return $this->_admin_page;
24
-    }
25
-
26
-
27
-    protected function _setup_data()
28
-    {
29
-        $this->_data           = $this->_get_messages($this->_per_page, $this->_view);
30
-        $this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true);
31
-    }
32
-
33
-
34
-    protected function _set_properties()
35
-    {
36
-        $this->_wp_list_args = array(
37
-            'singular' => __('Message', 'event_espresso'),
38
-            'plural'   => __('Messages', 'event_espresso'),
39
-            'ajax'     => true,
40
-            'screen'   => $this->get_admin_page()->get_current_screen()->id,
41
-        );
42
-
43
-        $this->_columns = array(
44
-            'cb'           => '<input type="checkbox" />',
45
-            'to'           => __('To', 'event_espresso'),
46
-            'from'         => __('From', 'event_espresso'),
47
-            'messenger'    => __('Messenger', 'event_espresso'),
48
-            'message_type' => __('Message Type', 'event_espresso'),
49
-            'context'      => __('Context', 'event_espresso'),
50
-            'modified'     => __('Modified', 'event_espresso'),
51
-            'action'       => __('Actions', 'event_espresso'),
52
-            'msg_id'       => __('ID', 'event_espresso'),
53
-        );
54
-
55
-        $this->_sortable_columns = array(
56
-            'modified'     => array('MSG_modified' => true),
57
-            'message_type' => array('MSG_message_type' => false),
58
-            'messenger'    => array('MSG_messenger' => false),
59
-            'to'           => array('MSG_to' => false),
60
-            'from'         => array('MSG_from' => false),
61
-            'context'      => array('MSG_context' => false),
62
-            'msg_id'       => array('MSG_ID', false),
63
-        );
64
-
65
-        $this->_primary_column = 'to';
66
-
67
-        $this->_hidden_columns = array(
68
-            'msg_id',
69
-        );
70
-    }
71
-
72
-
73
-    /**
74
-     * This simply sets up the row class for the table rows.
75
-     * Allows for easier overriding of child methods for setting up sorting.
76
-     *
77
-     * @param  object $item the current item
78
-     * @return string
79
-     */
80
-    protected function _get_row_class($item)
81
-    {
82
-        $class = parent::_get_row_class($item);
83
-        //add status class
84
-        $class .= ' ee-status-strip msg-status-' . $item->STS_ID();
85
-        if ($this->_has_checkbox_column) {
86
-            $class .= ' has-checkbox-column';
87
-        }
88
-        return $class;
89
-    }
90
-
91
-
92
-    /**
93
-     * _get_table_filters
94
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
95
-     * get's shown in the table.
96
-     *
97
-     * @abstract
98
-     * @access protected
99
-     * @return string
100
-     * @throws \EE_Error
101
-     */
102
-    protected function _get_table_filters()
103
-    {
104
-        $filters = array();
105
-
106
-        //get select_inputs
107
-        $select_inputs = array(
108
-            $this->_get_messengers_dropdown_filter(),
109
-            $this->_get_message_types_dropdown_filter(),
110
-            $this->_get_contexts_for_message_types_dropdown_filter(),
111
-        );
112
-
113
-        //set filters to select inputs if they aren't empty
114
-        foreach ($select_inputs as $select_input) {
115
-            if ($select_input) {
116
-                $filters[] = $select_input;
117
-            }
118
-        }
119
-        return $filters;
120
-    }
121
-
122
-
123
-    protected function _add_view_counts()
124
-    {
125
-        foreach ($this->_views as $view => $args) {
126
-            $this->_views[$view]['count'] = $this->_get_messages($this->_per_page, $view, true, true);
127
-        }
128
-    }
129
-
130
-
131
-    /**
132
-     * @param EE_Message $message
133
-     * @return string   checkbox
134
-     * @throws \EE_Error
135
-     */
136
-    public function column_cb($message)
137
-    {
138
-        return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID());
139
-    }
140
-
141
-
142
-    /**
143
-     * @param EE_Message $message
144
-     * @return string
145
-     * @throws \EE_Error
146
-     */
147
-    public function column_msg_id(EE_Message $message)
148
-    {
149
-        return $message->ID();
150
-    }
151
-
152
-
153
-    /**
154
-     * @param EE_Message $message
155
-     * @return string    The recipient of the message
156
-     * @throws \EE_Error
157
-     */
158
-    public function column_to(EE_Message $message)
159
-    {
160
-        EE_Registry::instance()->load_helper('URL');
161
-        $actions           = array();
162
-        $actions['delete'] = '<a href="'
163
-                             . EEH_URL::add_query_args_and_nonce(
164
-                array(
165
-                    'page'   => 'espresso_messages',
166
-                    'action' => 'delete_ee_message',
167
-                    'MSG_ID' => $message->ID(),
168
-                ),
169
-                admin_url('admin.php')
170
-            )
171
-                             . '">' . __('Delete', 'event_espresso') . '</a>';
172
-        return esc_html($message->to()) . $this->row_actions($actions);
173
-    }
174
-
175
-
176
-    /**
177
-     * @param EE_Message $message
178
-     * @return string   The sender of the message
179
-     */
180
-    public function column_from(EE_Message $message)
181
-    {
182
-        return esc_html($message->from());
183
-    }
184
-
185
-
186
-    /**
187
-     * @param EE_Message $message
188
-     * @return string  The messenger used to send the message.
189
-     */
190
-    public function column_messenger(EE_Message $message)
191
-    {
192
-        return ucwords($message->messenger_label());
193
-    }
194
-
195
-
196
-    /**
197
-     * @param EE_Message $message
198
-     * @return string  The message type used to generate the message.
199
-     */
200
-    public function column_message_type(EE_Message $message)
201
-    {
202
-        return ucwords($message->message_type_label());
203
-    }
204
-
205
-
206
-    /**
207
-     * @param EE_Message $message
208
-     * @return string  The context the message was generated for.
209
-     */
210
-    public function column_context(EE_Message $message)
211
-    {
212
-        return $message->context_label();
213
-    }
214
-
215
-
216
-    /**
217
-     * @param EE_Message $message
218
-     * @return string    The timestamp when this message was last modified.
219
-     */
220
-    public function column_modified(EE_Message $message)
221
-    {
222
-        return $message->modified();
223
-    }
224
-
225
-
226
-    /**
227
-     * @param EE_Message $message
228
-     * @return string   Actions that can be done on the current message.
229
-     */
230
-    public function column_action(EE_Message $message)
231
-    {
232
-        EE_Registry::instance()->load_helper('MSG_Template');
233
-        $action_links = array(
234
-            'view'                => EEH_MSG_Template::get_message_action_link('view', $message),
235
-            'error'               => EEH_MSG_Template::get_message_action_link('error', $message),
236
-            'generate_now'        => EEH_MSG_Template::get_message_action_link('generate_now', $message),
237
-            'send_now'            => EEH_MSG_Template::get_message_action_link('send_now', $message),
238
-            'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message),
239
-            'view_transaction'    => EEH_MSG_Template::get_message_action_link('view_transaction', $message),
240
-        );
241
-        $content      = '';
242
-        switch ($message->STS_ID()) {
243
-            case EEM_Message::status_sent :
244
-                $content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction'];
245
-                break;
246
-            case EEM_Message::status_resend :
247
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
248
-                break;
249
-            case EEM_Message::status_retry :
250
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction'];
251
-                break;
252
-            case EEM_Message::status_failed :
253
-            case EEM_Message::status_debug_only :
254
-                $content = $action_links['error'] . $action_links['view_transaction'];
255
-                break;
256
-            case EEM_Message::status_idle :
257
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
258
-                break;
259
-            case EEM_Message::status_incomplete;
260
-                $content = $action_links['generate_now'] . $action_links['view_transaction'];
261
-                break;
262
-        }
263
-        return $content;
264
-    }
265
-
266
-
267
-    /**
268
-     * Retrieve the EE_Message objects for the list table.
269
-     *
270
-     * @param int    $perpage The number of items per page
271
-     * @param string $view    The view items are being retrieved for
272
-     * @param bool   $count   Whether to just return a count or not.
273
-     * @param bool   $all     Disregard any paging info (no limit on data returned).
274
-     * @return int|EE_Message[]
275
-     * @throws \EE_Error
276
-     */
277
-    protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false)
278
-    {
279
-
280
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
281
-            ? $this->_req_data['paged']
282
-            : 1;
283
-
284
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
285
-            ? $this->_req_data['perpage']
286
-            : $perpage;
287
-
288
-        $offset       = ($current_page - 1) * $per_page;
289
-        $limit        = $all || $count ? null : array($offset, $per_page);
290
-        $query_params = array(
291
-            'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'],
292
-            'order'    => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'],
293
-            'limit'    => $limit,
294
-        );
295
-
296
-        /**
297
-         * Any filters coming in from other routes?
298
-         */
299
-        if (isset($this->_req_data['filterby'])) {
300
-            $query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params());
301
-            if ( ! $count) {
302
-                $query_params['group_by'] = 'MSG_ID';
303
-            }
304
-        }
305
-
306
-        //view conditionals
307
-        if ($view !== 'all' && $count && $all) {
308
-            $query_params[0]['AND*view_conditional'] = array(
309
-                'STS_ID' => strtoupper($view),
310
-            );
311
-        }
312
-
313
-        if (! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') {
314
-            $query_params[0]['AND*view_conditional'] = $this->_req_data === EEM_Message::status_failed
315
-                ? array(
316
-                    'STS_ID' => array(
317
-                        'IN',
318
-                        array(EEM_Message::status_failed, EEM_Message::status_messenger_executing)
319
-                    )
320
-                )
321
-                : array( 'STS_ID' => strtoupper($this->_req_data['status']) );
322
-        }
323
-
324
-        if (! $all && ! empty($this->_req_data['s'])) {
325
-            $search_string         = '%' . $this->_req_data['s'] . '%';
326
-            $query_params[0]['OR'] = array(
327
-                'MSG_to'      => array('LIKE', $search_string),
328
-                'MSG_from'    => array('LIKE', $search_string),
329
-                'MSG_subject' => array('LIKE', $search_string),
330
-                'MSG_content' => array('LIKE', $search_string),
331
-            );
332
-        }
333
-
334
-        //account for debug only status.  We don't show Messages with the EEM_Message::status_debug_only to clients when
335
-        //the messages system is in debug mode.
336
-        //Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only
337
-        //messages in the database.
338
-        if (! EEM_Message::debug()) {
339
-            $query_params[0]['AND*debug_only_conditional'] = array(
340
-                'STS_ID' => array('!=', EEM_Message::status_debug_only),
341
-            );
342
-        }
343
-
344
-        //account for filters
345
-        if (! $all
346
-            && isset($this->_req_data['ee_messenger_filter_by'])
347
-            && $this->_req_data['ee_messenger_filter_by'] !== 'none_selected'
348
-        ) {
349
-            $query_params[0]['AND*messenger_filter'] = array(
350
-                'MSG_messenger' => $this->_req_data['ee_messenger_filter_by'],
351
-            );
352
-        }
353
-        if (! $all
354
-            && ! empty($this->_req_data['ee_message_type_filter_by'])
355
-            && $this->_req_data['ee_message_type_filter_by'] !== 'none_selected'
356
-        ) {
357
-            $query_params[0]['AND*message_type_filter'] = array(
358
-                'MSG_message_type' => $this->_req_data['ee_message_type_filter_by'],
359
-            );
360
-        }
361
-
362
-        if (! $all
363
-            && ! empty($this->_req_data['ee_context_filter_by'])
364
-            && $this->_req_data['ee_context_filter_by'] !== 'none_selected'
365
-        ) {
366
-            $query_params[0]['AND*context_filter'] = array(
367
-                'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by'])),
368
-            );
369
-        }
370
-
371
-        return $count
372
-            /** @type int */
373
-            ? EEM_Message::instance()->count($query_params, null, true)
374
-            /** @type EE_Message[] */
375
-            : EEM_Message::instance()->get_all($query_params);
376
-    }
377
-
378
-
379
-    /**
380
-     * Generate dropdown filter select input for messengers.
381
-     *
382
-     * @return string
383
-     */
384
-    protected function _get_messengers_dropdown_filter()
385
-    {
386
-        $messenger_options                    = array();
387
-        $active_messages_grouped_by_messenger = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
388
-
389
-        //setup array of messenger options
390
-        foreach ($active_messages_grouped_by_messenger as $active_message) {
391
-            if ($active_message instanceof EE_Message) {
392
-                $messenger_options[$active_message->messenger()] = ucwords($active_message->messenger_label());
393
-            }
394
-        }
395
-        return $this->get_admin_page()->get_messengers_select_input($messenger_options);
396
-    }
397
-
398
-
399
-    /**
400
-     * Generate dropdown filter select input for message types
401
-     *
402
-     * @return string
403
-     */
404
-    protected function _get_message_types_dropdown_filter()
405
-    {
406
-        $message_type_options                    = array();
407
-        $active_messages_grouped_by_message_type = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type'));
408
-
409
-        //setup array of message type options
410
-        foreach ($active_messages_grouped_by_message_type as $active_message) {
411
-            if ($active_message instanceof EE_Message) {
412
-                $message_type_options[$active_message->message_type()] = ucwords($active_message->message_type_label());
413
-            }
414
-        }
415
-        return $this->get_admin_page()->get_message_types_select_input($message_type_options);
416
-    }
417
-
418
-
419
-    /**
420
-     * Generate dropdown filter select input for message type contexts
421
-     *
422
-     * @return string
423
-     */
424
-    protected function _get_contexts_for_message_types_dropdown_filter()
425
-    {
426
-        $context_options                    = array();
427
-        $active_messages_grouped_by_context = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
428
-
429
-        //setup array of context options
430
-        foreach ($active_messages_grouped_by_context as $active_message) {
431
-            if ($active_message instanceof EE_Message) {
432
-                $message_type = $active_message->message_type_object();
433
-                if ($message_type instanceof EE_message_type) {
434
-                    foreach ($message_type->get_contexts() as $context => $context_details) {
435
-                        if (isset($context_details['label'])) {
436
-                            $context_options[$context] = $context_details['label'];
437
-                        }
438
-                    }
439
-                }
440
-            }
441
-        }
442
-        return $this->get_admin_page()->get_contexts_for_message_types_select_input($context_options);
443
-    }
18
+	/**
19
+	 * @return Messages_Admin_Page
20
+	 */
21
+	public function get_admin_page()
22
+	{
23
+		return $this->_admin_page;
24
+	}
25
+
26
+
27
+	protected function _setup_data()
28
+	{
29
+		$this->_data           = $this->_get_messages($this->_per_page, $this->_view);
30
+		$this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true);
31
+	}
32
+
33
+
34
+	protected function _set_properties()
35
+	{
36
+		$this->_wp_list_args = array(
37
+			'singular' => __('Message', 'event_espresso'),
38
+			'plural'   => __('Messages', 'event_espresso'),
39
+			'ajax'     => true,
40
+			'screen'   => $this->get_admin_page()->get_current_screen()->id,
41
+		);
42
+
43
+		$this->_columns = array(
44
+			'cb'           => '<input type="checkbox" />',
45
+			'to'           => __('To', 'event_espresso'),
46
+			'from'         => __('From', 'event_espresso'),
47
+			'messenger'    => __('Messenger', 'event_espresso'),
48
+			'message_type' => __('Message Type', 'event_espresso'),
49
+			'context'      => __('Context', 'event_espresso'),
50
+			'modified'     => __('Modified', 'event_espresso'),
51
+			'action'       => __('Actions', 'event_espresso'),
52
+			'msg_id'       => __('ID', 'event_espresso'),
53
+		);
54
+
55
+		$this->_sortable_columns = array(
56
+			'modified'     => array('MSG_modified' => true),
57
+			'message_type' => array('MSG_message_type' => false),
58
+			'messenger'    => array('MSG_messenger' => false),
59
+			'to'           => array('MSG_to' => false),
60
+			'from'         => array('MSG_from' => false),
61
+			'context'      => array('MSG_context' => false),
62
+			'msg_id'       => array('MSG_ID', false),
63
+		);
64
+
65
+		$this->_primary_column = 'to';
66
+
67
+		$this->_hidden_columns = array(
68
+			'msg_id',
69
+		);
70
+	}
71
+
72
+
73
+	/**
74
+	 * This simply sets up the row class for the table rows.
75
+	 * Allows for easier overriding of child methods for setting up sorting.
76
+	 *
77
+	 * @param  object $item the current item
78
+	 * @return string
79
+	 */
80
+	protected function _get_row_class($item)
81
+	{
82
+		$class = parent::_get_row_class($item);
83
+		//add status class
84
+		$class .= ' ee-status-strip msg-status-' . $item->STS_ID();
85
+		if ($this->_has_checkbox_column) {
86
+			$class .= ' has-checkbox-column';
87
+		}
88
+		return $class;
89
+	}
90
+
91
+
92
+	/**
93
+	 * _get_table_filters
94
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
95
+	 * get's shown in the table.
96
+	 *
97
+	 * @abstract
98
+	 * @access protected
99
+	 * @return string
100
+	 * @throws \EE_Error
101
+	 */
102
+	protected function _get_table_filters()
103
+	{
104
+		$filters = array();
105
+
106
+		//get select_inputs
107
+		$select_inputs = array(
108
+			$this->_get_messengers_dropdown_filter(),
109
+			$this->_get_message_types_dropdown_filter(),
110
+			$this->_get_contexts_for_message_types_dropdown_filter(),
111
+		);
112
+
113
+		//set filters to select inputs if they aren't empty
114
+		foreach ($select_inputs as $select_input) {
115
+			if ($select_input) {
116
+				$filters[] = $select_input;
117
+			}
118
+		}
119
+		return $filters;
120
+	}
121
+
122
+
123
+	protected function _add_view_counts()
124
+	{
125
+		foreach ($this->_views as $view => $args) {
126
+			$this->_views[$view]['count'] = $this->_get_messages($this->_per_page, $view, true, true);
127
+		}
128
+	}
129
+
130
+
131
+	/**
132
+	 * @param EE_Message $message
133
+	 * @return string   checkbox
134
+	 * @throws \EE_Error
135
+	 */
136
+	public function column_cb($message)
137
+	{
138
+		return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID());
139
+	}
140
+
141
+
142
+	/**
143
+	 * @param EE_Message $message
144
+	 * @return string
145
+	 * @throws \EE_Error
146
+	 */
147
+	public function column_msg_id(EE_Message $message)
148
+	{
149
+		return $message->ID();
150
+	}
151
+
152
+
153
+	/**
154
+	 * @param EE_Message $message
155
+	 * @return string    The recipient of the message
156
+	 * @throws \EE_Error
157
+	 */
158
+	public function column_to(EE_Message $message)
159
+	{
160
+		EE_Registry::instance()->load_helper('URL');
161
+		$actions           = array();
162
+		$actions['delete'] = '<a href="'
163
+							 . EEH_URL::add_query_args_and_nonce(
164
+				array(
165
+					'page'   => 'espresso_messages',
166
+					'action' => 'delete_ee_message',
167
+					'MSG_ID' => $message->ID(),
168
+				),
169
+				admin_url('admin.php')
170
+			)
171
+							 . '">' . __('Delete', 'event_espresso') . '</a>';
172
+		return esc_html($message->to()) . $this->row_actions($actions);
173
+	}
174
+
175
+
176
+	/**
177
+	 * @param EE_Message $message
178
+	 * @return string   The sender of the message
179
+	 */
180
+	public function column_from(EE_Message $message)
181
+	{
182
+		return esc_html($message->from());
183
+	}
184
+
185
+
186
+	/**
187
+	 * @param EE_Message $message
188
+	 * @return string  The messenger used to send the message.
189
+	 */
190
+	public function column_messenger(EE_Message $message)
191
+	{
192
+		return ucwords($message->messenger_label());
193
+	}
194
+
195
+
196
+	/**
197
+	 * @param EE_Message $message
198
+	 * @return string  The message type used to generate the message.
199
+	 */
200
+	public function column_message_type(EE_Message $message)
201
+	{
202
+		return ucwords($message->message_type_label());
203
+	}
204
+
205
+
206
+	/**
207
+	 * @param EE_Message $message
208
+	 * @return string  The context the message was generated for.
209
+	 */
210
+	public function column_context(EE_Message $message)
211
+	{
212
+		return $message->context_label();
213
+	}
214
+
215
+
216
+	/**
217
+	 * @param EE_Message $message
218
+	 * @return string    The timestamp when this message was last modified.
219
+	 */
220
+	public function column_modified(EE_Message $message)
221
+	{
222
+		return $message->modified();
223
+	}
224
+
225
+
226
+	/**
227
+	 * @param EE_Message $message
228
+	 * @return string   Actions that can be done on the current message.
229
+	 */
230
+	public function column_action(EE_Message $message)
231
+	{
232
+		EE_Registry::instance()->load_helper('MSG_Template');
233
+		$action_links = array(
234
+			'view'                => EEH_MSG_Template::get_message_action_link('view', $message),
235
+			'error'               => EEH_MSG_Template::get_message_action_link('error', $message),
236
+			'generate_now'        => EEH_MSG_Template::get_message_action_link('generate_now', $message),
237
+			'send_now'            => EEH_MSG_Template::get_message_action_link('send_now', $message),
238
+			'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message),
239
+			'view_transaction'    => EEH_MSG_Template::get_message_action_link('view_transaction', $message),
240
+		);
241
+		$content      = '';
242
+		switch ($message->STS_ID()) {
243
+			case EEM_Message::status_sent :
244
+				$content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction'];
245
+				break;
246
+			case EEM_Message::status_resend :
247
+				$content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
248
+				break;
249
+			case EEM_Message::status_retry :
250
+				$content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction'];
251
+				break;
252
+			case EEM_Message::status_failed :
253
+			case EEM_Message::status_debug_only :
254
+				$content = $action_links['error'] . $action_links['view_transaction'];
255
+				break;
256
+			case EEM_Message::status_idle :
257
+				$content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
258
+				break;
259
+			case EEM_Message::status_incomplete;
260
+				$content = $action_links['generate_now'] . $action_links['view_transaction'];
261
+				break;
262
+		}
263
+		return $content;
264
+	}
265
+
266
+
267
+	/**
268
+	 * Retrieve the EE_Message objects for the list table.
269
+	 *
270
+	 * @param int    $perpage The number of items per page
271
+	 * @param string $view    The view items are being retrieved for
272
+	 * @param bool   $count   Whether to just return a count or not.
273
+	 * @param bool   $all     Disregard any paging info (no limit on data returned).
274
+	 * @return int|EE_Message[]
275
+	 * @throws \EE_Error
276
+	 */
277
+	protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false)
278
+	{
279
+
280
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
281
+			? $this->_req_data['paged']
282
+			: 1;
283
+
284
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
285
+			? $this->_req_data['perpage']
286
+			: $perpage;
287
+
288
+		$offset       = ($current_page - 1) * $per_page;
289
+		$limit        = $all || $count ? null : array($offset, $per_page);
290
+		$query_params = array(
291
+			'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'],
292
+			'order'    => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'],
293
+			'limit'    => $limit,
294
+		);
295
+
296
+		/**
297
+		 * Any filters coming in from other routes?
298
+		 */
299
+		if (isset($this->_req_data['filterby'])) {
300
+			$query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params());
301
+			if ( ! $count) {
302
+				$query_params['group_by'] = 'MSG_ID';
303
+			}
304
+		}
305
+
306
+		//view conditionals
307
+		if ($view !== 'all' && $count && $all) {
308
+			$query_params[0]['AND*view_conditional'] = array(
309
+				'STS_ID' => strtoupper($view),
310
+			);
311
+		}
312
+
313
+		if (! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') {
314
+			$query_params[0]['AND*view_conditional'] = $this->_req_data === EEM_Message::status_failed
315
+				? array(
316
+					'STS_ID' => array(
317
+						'IN',
318
+						array(EEM_Message::status_failed, EEM_Message::status_messenger_executing)
319
+					)
320
+				)
321
+				: array( 'STS_ID' => strtoupper($this->_req_data['status']) );
322
+		}
323
+
324
+		if (! $all && ! empty($this->_req_data['s'])) {
325
+			$search_string         = '%' . $this->_req_data['s'] . '%';
326
+			$query_params[0]['OR'] = array(
327
+				'MSG_to'      => array('LIKE', $search_string),
328
+				'MSG_from'    => array('LIKE', $search_string),
329
+				'MSG_subject' => array('LIKE', $search_string),
330
+				'MSG_content' => array('LIKE', $search_string),
331
+			);
332
+		}
333
+
334
+		//account for debug only status.  We don't show Messages with the EEM_Message::status_debug_only to clients when
335
+		//the messages system is in debug mode.
336
+		//Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only
337
+		//messages in the database.
338
+		if (! EEM_Message::debug()) {
339
+			$query_params[0]['AND*debug_only_conditional'] = array(
340
+				'STS_ID' => array('!=', EEM_Message::status_debug_only),
341
+			);
342
+		}
343
+
344
+		//account for filters
345
+		if (! $all
346
+			&& isset($this->_req_data['ee_messenger_filter_by'])
347
+			&& $this->_req_data['ee_messenger_filter_by'] !== 'none_selected'
348
+		) {
349
+			$query_params[0]['AND*messenger_filter'] = array(
350
+				'MSG_messenger' => $this->_req_data['ee_messenger_filter_by'],
351
+			);
352
+		}
353
+		if (! $all
354
+			&& ! empty($this->_req_data['ee_message_type_filter_by'])
355
+			&& $this->_req_data['ee_message_type_filter_by'] !== 'none_selected'
356
+		) {
357
+			$query_params[0]['AND*message_type_filter'] = array(
358
+				'MSG_message_type' => $this->_req_data['ee_message_type_filter_by'],
359
+			);
360
+		}
361
+
362
+		if (! $all
363
+			&& ! empty($this->_req_data['ee_context_filter_by'])
364
+			&& $this->_req_data['ee_context_filter_by'] !== 'none_selected'
365
+		) {
366
+			$query_params[0]['AND*context_filter'] = array(
367
+				'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by'])),
368
+			);
369
+		}
370
+
371
+		return $count
372
+			/** @type int */
373
+			? EEM_Message::instance()->count($query_params, null, true)
374
+			/** @type EE_Message[] */
375
+			: EEM_Message::instance()->get_all($query_params);
376
+	}
377
+
378
+
379
+	/**
380
+	 * Generate dropdown filter select input for messengers.
381
+	 *
382
+	 * @return string
383
+	 */
384
+	protected function _get_messengers_dropdown_filter()
385
+	{
386
+		$messenger_options                    = array();
387
+		$active_messages_grouped_by_messenger = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
388
+
389
+		//setup array of messenger options
390
+		foreach ($active_messages_grouped_by_messenger as $active_message) {
391
+			if ($active_message instanceof EE_Message) {
392
+				$messenger_options[$active_message->messenger()] = ucwords($active_message->messenger_label());
393
+			}
394
+		}
395
+		return $this->get_admin_page()->get_messengers_select_input($messenger_options);
396
+	}
397
+
398
+
399
+	/**
400
+	 * Generate dropdown filter select input for message types
401
+	 *
402
+	 * @return string
403
+	 */
404
+	protected function _get_message_types_dropdown_filter()
405
+	{
406
+		$message_type_options                    = array();
407
+		$active_messages_grouped_by_message_type = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type'));
408
+
409
+		//setup array of message type options
410
+		foreach ($active_messages_grouped_by_message_type as $active_message) {
411
+			if ($active_message instanceof EE_Message) {
412
+				$message_type_options[$active_message->message_type()] = ucwords($active_message->message_type_label());
413
+			}
414
+		}
415
+		return $this->get_admin_page()->get_message_types_select_input($message_type_options);
416
+	}
417
+
418
+
419
+	/**
420
+	 * Generate dropdown filter select input for message type contexts
421
+	 *
422
+	 * @return string
423
+	 */
424
+	protected function _get_contexts_for_message_types_dropdown_filter()
425
+	{
426
+		$context_options                    = array();
427
+		$active_messages_grouped_by_context = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
428
+
429
+		//setup array of context options
430
+		foreach ($active_messages_grouped_by_context as $active_message) {
431
+			if ($active_message instanceof EE_Message) {
432
+				$message_type = $active_message->message_type_object();
433
+				if ($message_type instanceof EE_message_type) {
434
+					foreach ($message_type->get_contexts() as $context => $context_details) {
435
+						if (isset($context_details['label'])) {
436
+							$context_options[$context] = $context_details['label'];
437
+						}
438
+					}
439
+				}
440
+			}
441
+		}
442
+		return $this->get_admin_page()->get_contexts_for_message_types_select_input($context_options);
443
+	}
444 444
 } //end EE_Message_List_Table class
445 445
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     {
82 82
         $class = parent::_get_row_class($item);
83 83
         //add status class
84
-        $class .= ' ee-status-strip msg-status-' . $item->STS_ID();
84
+        $class .= ' ee-status-strip msg-status-'.$item->STS_ID();
85 85
         if ($this->_has_checkbox_column) {
86 86
             $class .= ' has-checkbox-column';
87 87
         }
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
                 ),
169 169
                 admin_url('admin.php')
170 170
             )
171
-                             . '">' . __('Delete', 'event_espresso') . '</a>';
172
-        return esc_html($message->to()) . $this->row_actions($actions);
171
+                             . '">'.__('Delete', 'event_espresso').'</a>';
172
+        return esc_html($message->to()).$this->row_actions($actions);
173 173
     }
174 174
 
175 175
 
@@ -238,26 +238,26 @@  discard block
 block discarded – undo
238 238
             'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message),
239 239
             'view_transaction'    => EEH_MSG_Template::get_message_action_link('view_transaction', $message),
240 240
         );
241
-        $content      = '';
241
+        $content = '';
242 242
         switch ($message->STS_ID()) {
243 243
             case EEM_Message::status_sent :
244
-                $content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction'];
244
+                $content = $action_links['view'].$action_links['queue_for_resending'].$action_links['view_transaction'];
245 245
                 break;
246 246
             case EEM_Message::status_resend :
247
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
247
+                $content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction'];
248 248
                 break;
249 249
             case EEM_Message::status_retry :
250
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction'];
250
+                $content = $action_links['view'].$action_links['send_now'].$action_links['error'].$action_links['view_transaction'];
251 251
                 break;
252 252
             case EEM_Message::status_failed :
253 253
             case EEM_Message::status_debug_only :
254
-                $content = $action_links['error'] . $action_links['view_transaction'];
254
+                $content = $action_links['error'].$action_links['view_transaction'];
255 255
                 break;
256 256
             case EEM_Message::status_idle :
257
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
257
+                $content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction'];
258 258
                 break;
259 259
             case EEM_Message::status_incomplete;
260
-                $content = $action_links['generate_now'] . $action_links['view_transaction'];
260
+                $content = $action_links['generate_now'].$action_links['view_transaction'];
261 261
                 break;
262 262
         }
263 263
         return $content;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             );
311 311
         }
312 312
 
313
-        if (! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') {
313
+        if ( ! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') {
314 314
             $query_params[0]['AND*view_conditional'] = $this->_req_data === EEM_Message::status_failed
315 315
                 ? array(
316 316
                     'STS_ID' => array(
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
                         array(EEM_Message::status_failed, EEM_Message::status_messenger_executing)
319 319
                     )
320 320
                 )
321
-                : array( 'STS_ID' => strtoupper($this->_req_data['status']) );
321
+                : array('STS_ID' => strtoupper($this->_req_data['status']));
322 322
         }
323 323
 
324
-        if (! $all && ! empty($this->_req_data['s'])) {
325
-            $search_string         = '%' . $this->_req_data['s'] . '%';
324
+        if ( ! $all && ! empty($this->_req_data['s'])) {
325
+            $search_string         = '%'.$this->_req_data['s'].'%';
326 326
             $query_params[0]['OR'] = array(
327 327
                 'MSG_to'      => array('LIKE', $search_string),
328 328
                 'MSG_from'    => array('LIKE', $search_string),
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
         //the messages system is in debug mode.
336 336
         //Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only
337 337
         //messages in the database.
338
-        if (! EEM_Message::debug()) {
338
+        if ( ! EEM_Message::debug()) {
339 339
             $query_params[0]['AND*debug_only_conditional'] = array(
340 340
                 'STS_ID' => array('!=', EEM_Message::status_debug_only),
341 341
             );
342 342
         }
343 343
 
344 344
         //account for filters
345
-        if (! $all
345
+        if ( ! $all
346 346
             && isset($this->_req_data['ee_messenger_filter_by'])
347 347
             && $this->_req_data['ee_messenger_filter_by'] !== 'none_selected'
348 348
         ) {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
                 'MSG_messenger' => $this->_req_data['ee_messenger_filter_by'],
351 351
             );
352 352
         }
353
-        if (! $all
353
+        if ( ! $all
354 354
             && ! empty($this->_req_data['ee_message_type_filter_by'])
355 355
             && $this->_req_data['ee_message_type_filter_by'] !== 'none_selected'
356 356
         ) {
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             );
360 360
         }
361 361
 
362
-        if (! $all
362
+        if ( ! $all
363 363
             && ! empty($this->_req_data['ee_context_filter_by'])
364 364
             && $this->_req_data['ee_context_filter_by'] !== 'none_selected'
365 365
         ) {
Please login to merge, or discard this patch.
admin/extend/registration_form/Extend_Registration_Form_Admin_Page.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -504,7 +504,7 @@
 block discarded – undo
504 504
      *
505 505
      * @param int                  $id
506 506
      * @param EEM_Soft_Delete_Base $model
507
-     * @return boolean
507
+     * @return integer
508 508
      */
509 509
     protected function _delete_item($id, $model)
510 510
     {
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function __construct($routing = true)
34 34
     {
35
-        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS);
36
-        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS);
37
-        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
38
-        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS);
39
-        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
35
+        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS);
36
+        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS);
37
+        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/');
38
+        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS);
39
+        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/');
40 40
         parent::__construct($routing);
41 41
     }
42 42
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
48 48
         $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0;
49 49
 
50
-        $new_page_routes    = array(
50
+        $new_page_routes = array(
51 51
             'question_groups'    => array(
52 52
                 'func'       => '_question_groups_overview_list_table',
53 53
                 'capability' => 'ee_read_question_groups',
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 
312 312
         //additional labels
313
-        $new_labels               = array(
313
+        $new_labels = array(
314 314
             'add_question'          => esc_html__('Add New Question', 'event_espresso'),
315 315
             'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
316 316
             'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
      */
355 355
     public function load_sortable_question_script()
356 356
     {
357
-        wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
357
+        wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js',
358 358
             array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
359 359
         wp_enqueue_script('ee-question-sortable');
360 360
     }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 
421 421
     protected function _questions_overview_list_table()
422 422
     {
423
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
423
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
424 424
                 'add_question',
425 425
                 'add_question',
426 426
                 array(),
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
     protected function _question_groups_overview_list_table()
434 434
     {
435 435
         $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
436
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
436
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
437 437
                 'add_question_group',
438 438
                 'add_question_group',
439 439
                 array(),
@@ -477,20 +477,20 @@  discard block
 block discarded – undo
477 477
     {
478 478
         $success = 0;
479 479
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
480
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
480
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
481 481
             // if array has more than one element than success message should be plural
482 482
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
483 483
             // cycle thru bulk action checkboxes
484 484
             while (list($ID, $value) = each($this->_req_data['checkbox'])) {
485
-                if (! $this->_delete_item($ID, $model)) {
485
+                if ( ! $this->_delete_item($ID, $model)) {
486 486
                     $success = 0;
487 487
                 }
488 488
             }
489 489
 
490
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
490
+        } elseif ( ! empty($this->_req_data['QSG_ID'])) {
491 491
             $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
492 492
 
493
-        } elseif (! empty($this->_req_data['QST_ID'])) {
493
+        } elseif ( ! empty($this->_req_data['QST_ID'])) {
494 494
             $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
495 495
         } else {
496 496
             EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
535 535
         }
536 536
         // add ID to title if editing
537
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
537
+        $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
538 538
         if ($ID) {
539 539
             /** @var EE_Question_Group $questionGroup */
540 540
             $questionGroup            = $this->_question_group_model->get_one_by_ID($ID);
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 
554 554
         $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
555 555
         $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
556
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
556
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php',
557 557
             $this->_template_args, true);
558 558
 
559 559
         // the details template wrapper
@@ -600,13 +600,13 @@  discard block
 block discarded – undo
600 600
         $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
601 601
         $questions      = $question_group->questions();
602 602
         // make sure system phone question is added to list of questions for this group
603
-        if (! isset($questions[$phone_question_id])) {
603
+        if ( ! isset($questions[$phone_question_id])) {
604 604
             $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
605 605
         }
606 606
 
607 607
         foreach ($questions as $question_ID => $question) {
608 608
             // first we always check for order.
609
-            if (! empty($this->_req_data['question_orders'][$question_ID])) {
609
+            if ( ! empty($this->_req_data['question_orders'][$question_ID])) {
610 610
                 //update question order
611 611
                 $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]);
612 612
             }
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
      */
655 655
     public function _duplicate_question()
656 656
     {
657
-        $question_ID = (int)$this->_req_data['QST_ID'];
657
+        $question_ID = (int) $this->_req_data['QST_ID'];
658 658
         $question    = EEM_Question::instance()->get_one_by_ID($question_ID);
659 659
         if ($question instanceof EE_Question) {
660 660
             $new_question = $question->duplicate();
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
      */
691 691
     protected function _trash_question()
692 692
     {
693
-        $success    = $this->_question_model->delete_by_ID((int)$this->_req_data['QST_ID']);
693
+        $success    = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
694 694
         $query_args = array('action' => 'default', 'status' => 'all');
695 695
         $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
696 696
     }
@@ -722,12 +722,12 @@  discard block
 block discarded – undo
722 722
         //echo "trash $trash";
723 723
         //var_dump($this->_req_data['checkbox']);die;
724 724
         if (isset($this->_req_data['checkbox'])) {
725
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
725
+            if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
726 726
                 // if array has more than one element than success message should be plural
727 727
                 $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
728 728
                 // cycle thru bulk action checkboxes
729 729
                 while (list($ID, $value) = each($this->_req_data['checkbox'])) {
730
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
730
+                    if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) {
731 731
                         $success = 0;
732 732
                     }
733 733
                 }
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
             } else {
736 736
                 // grab single id and delete
737 737
                 $ID = absint($this->_req_data['checkbox']);
738
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
738
+                if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
739 739
                     $success = 0;
740 740
                 }
741 741
             }
@@ -744,14 +744,14 @@  discard block
 block discarded – undo
744 744
             // delete via trash link
745 745
             // grab single id and delete
746 746
             $ID = absint($this->_req_data[$model->primary_key_name()]);
747
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
747
+            if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
748 748
                 $success = 0;
749 749
             }
750 750
 
751 751
         }
752 752
 
753 753
 
754
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) );
754
+        $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) );
755 755
         //echo "action :$action";
756 756
         //$action = 'questions' ? 'default' : $action;
757 757
         if ($trash) {
@@ -845,13 +845,13 @@  discard block
 block discarded – undo
845 845
             : array();
846 846
 
847 847
         $perpage = ! empty($this->_req_data['perpage'])
848
-            ? (int)$this->_req_data['perpage']
848
+            ? (int) $this->_req_data['perpage']
849 849
             : null;
850 850
         $curpage = ! empty($this->_req_data['curpage'])
851
-            ? (int)$this->_req_data['curpage']
851
+            ? (int) $this->_req_data['curpage']
852 852
             : null;
853 853
 
854
-        if (! empty($row_ids)) {
854
+        if ( ! empty($row_ids)) {
855 855
             //figure out where we start the row_id count at for the current page.
856 856
             $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
857 857
 
@@ -898,14 +898,14 @@  discard block
 block discarded – undo
898 898
             array($this, 'email_validation_settings_form'),
899 899
             2
900 900
         );
901
-        $this->_template_args = (array)apply_filters(
901
+        $this->_template_args = (array) apply_filters(
902 902
             'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
903 903
             $this->_template_args
904 904
         );
905 905
         $this->_set_add_edit_form_tags('update_reg_form_settings');
906 906
         $this->_set_publish_post_box_vars(null, false, false, null, false);
907 907
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
908
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
908
+            REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php',
909 909
             $this->_template_args,
910 910
             true
911 911
         );
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
             'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
926 926
             EE_Registry::instance()->CFG->registration
927 927
         );
928
-        $success                                   = $this->_update_espresso_configuration(
928
+        $success = $this->_update_espresso_configuration(
929 929
             esc_html__('Registration Form Options', 'event_espresso'),
930 930
             EE_Registry::instance()->CFG,
931 931
             __FILE__, __FUNCTION__, __LINE__
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
                                 $prev_email_validation_level = 'basic';
1023 1023
                             }
1024 1024
                             // confirm our i18n email validation will work on the server
1025
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1025
+                            if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1026 1026
                                 // or reset email validation level to previous value
1027 1027
                                 $email_validation_level = $prev_email_validation_level;
1028 1028
                             }
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
     private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1065 1065
     {
1066 1066
         // first check that PCRE is enabled
1067
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1067
+        if ( ! defined('PREG_BAD_UTF8_ERROR')) {
1068 1068
             EE_Error::add_error(
1069 1069
                 sprintf(
1070 1070
                     esc_html__(
Please login to merge, or discard this patch.
Indentation   +1088 added lines, -1088 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -25,1093 +25,1093 @@  discard block
 block discarded – undo
25 25
 {
26 26
 
27 27
 
28
-    /**
29
-     * @Constructor
30
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
31
-     * @access public
32
-     */
33
-    public function __construct($routing = true)
34
-    {
35
-        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS);
36
-        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS);
37
-        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
38
-        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS);
39
-        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
40
-        parent::__construct($routing);
41
-    }
42
-
43
-
44
-    protected function _extend_page_config()
45
-    {
46
-        $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
47
-        $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
48
-        $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0;
49
-
50
-        $new_page_routes    = array(
51
-            'question_groups'    => array(
52
-                'func'       => '_question_groups_overview_list_table',
53
-                'capability' => 'ee_read_question_groups',
54
-            ),
55
-            'add_question'       => array(
56
-                'func'       => '_edit_question',
57
-                'capability' => 'ee_edit_questions',
58
-            ),
59
-            'insert_question'    => array(
60
-                'func'       => '_insert_or_update_question',
61
-                'args'       => array('new_question' => true),
62
-                'capability' => 'ee_edit_questions',
63
-                'noheader'   => true,
64
-            ),
65
-            'duplicate_question' => array(
66
-                'func'       => '_duplicate_question',
67
-                'capability' => 'ee_edit_questions',
68
-                'noheader'   => true,
69
-            ),
70
-            'trash_question'     => array(
71
-                'func'       => '_trash_question',
72
-                'capability' => 'ee_delete_question',
73
-                'obj_id'     => $qst_id,
74
-                'noheader'   => true,
75
-            ),
76
-
77
-            'restore_question' => array(
78
-                'func'       => '_trash_or_restore_questions',
79
-                'capability' => 'ee_delete_question',
80
-                'obj_id'     => $qst_id,
81
-                'args'       => array('trash' => false),
82
-                'noheader'   => true,
83
-            ),
84
-
85
-            'delete_question' => array(
86
-                'func'       => '_delete_question',
87
-                'capability' => 'ee_delete_question',
88
-                'obj_id'     => $qst_id,
89
-                'noheader'   => true,
90
-            ),
91
-
92
-            'trash_questions' => array(
93
-                'func'       => '_trash_or_restore_questions',
94
-                'capability' => 'ee_delete_questions',
95
-                'args'       => array('trash' => true),
96
-                'noheader'   => true,
97
-            ),
98
-
99
-            'restore_questions' => array(
100
-                'func'       => '_trash_or_restore_questions',
101
-                'capability' => 'ee_delete_questions',
102
-                'args'       => array('trash' => false),
103
-                'noheader'   => true,
104
-            ),
105
-
106
-            'delete_questions' => array(
107
-                'func'       => '_delete_questions',
108
-                'args'       => array(),
109
-                'capability' => 'ee_delete_questions',
110
-                'noheader'   => true,
111
-            ),
112
-
113
-            'add_question_group' => array(
114
-                'func'       => '_edit_question_group',
115
-                'capability' => 'ee_edit_question_groups',
116
-            ),
117
-
118
-            'edit_question_group' => array(
119
-                'func'       => '_edit_question_group',
120
-                'capability' => 'ee_edit_question_group',
121
-                'obj_id'     => $qsg_id,
122
-                'args'       => array('edit'),
123
-            ),
124
-
125
-            'delete_question_groups' => array(
126
-                'func'       => '_delete_question_groups',
127
-                'capability' => 'ee_delete_question_groups',
128
-                'noheader'   => true,
129
-            ),
130
-
131
-            'delete_question_group' => array(
132
-                'func'       => '_delete_question_groups',
133
-                'capability' => 'ee_delete_question_group',
134
-                'obj_id'     => $qsg_id,
135
-                'noheader'   => true,
136
-            ),
137
-
138
-            'trash_question_group' => array(
139
-                'func'       => '_trash_or_restore_question_groups',
140
-                'args'       => array('trash' => true),
141
-                'capability' => 'ee_delete_question_group',
142
-                'obj_id'     => $qsg_id,
143
-                'noheader'   => true,
144
-            ),
145
-
146
-            'restore_question_group' => array(
147
-                'func'       => '_trash_or_restore_question_groups',
148
-                'args'       => array('trash' => false),
149
-                'capability' => 'ee_delete_question_group',
150
-                'obj_id'     => $qsg_id,
151
-                'noheader'   => true,
152
-            ),
153
-
154
-            'insert_question_group' => array(
155
-                'func'       => '_insert_or_update_question_group',
156
-                'args'       => array('new_question_group' => true),
157
-                'capability' => 'ee_edit_question_groups',
158
-                'noheader'   => true,
159
-            ),
160
-
161
-            'update_question_group' => array(
162
-                'func'       => '_insert_or_update_question_group',
163
-                'args'       => array('new_question_group' => false),
164
-                'capability' => 'ee_edit_question_group',
165
-                'obj_id'     => $qsg_id,
166
-                'noheader'   => true,
167
-            ),
168
-
169
-            'trash_question_groups' => array(
170
-                'func'       => '_trash_or_restore_question_groups',
171
-                'args'       => array('trash' => true),
172
-                'capability' => 'ee_delete_question_groups',
173
-                'noheader'   => array('trash' => false),
174
-            ),
175
-
176
-            'restore_question_groups' => array(
177
-                'func'       => '_trash_or_restore_question_groups',
178
-                'args'       => array('trash' => false),
179
-                'capability' => 'ee_delete_question_groups',
180
-                'noheader'   => true,
181
-            ),
182
-
183
-
184
-            'espresso_update_question_group_order' => array(
185
-                'func'       => 'update_question_group_order',
186
-                'capability' => 'ee_edit_question_groups',
187
-                'noheader'   => true,
188
-            ),
189
-
190
-            'view_reg_form_settings' => array(
191
-                'func'       => '_reg_form_settings',
192
-                'capability' => 'manage_options',
193
-            ),
194
-
195
-            'update_reg_form_settings' => array(
196
-                'func'       => '_update_reg_form_settings',
197
-                'capability' => 'manage_options',
198
-                'noheader'   => true,
199
-            ),
200
-        );
201
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
202
-
203
-        $new_page_config    = array(
204
-
205
-            'question_groups' => array(
206
-                'nav'           => array(
207
-                    'label' => esc_html__('Question Groups', 'event_espresso'),
208
-                    'order' => 20,
209
-                ),
210
-                'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
211
-                'help_tabs'     => array(
212
-                    'registration_form_question_groups_help_tab'                           => array(
213
-                        'title'    => esc_html__('Question Groups', 'event_espresso'),
214
-                        'filename' => 'registration_form_question_groups',
215
-                    ),
216
-                    'registration_form_question_groups_table_column_headings_help_tab'     => array(
217
-                        'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
218
-                        'filename' => 'registration_form_question_groups_table_column_headings',
219
-                    ),
220
-                    'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
221
-                        'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
222
-                        'filename' => 'registration_form_question_groups_views_bulk_actions_search',
223
-                    ),
224
-                ),
225
-                'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
226
-                'metaboxes'     => $this->_default_espresso_metaboxes,
227
-                'require_nonce' => false,
228
-                'qtips'         => array(
229
-                    'EE_Registration_Form_Tips',
230
-                ),
231
-            ),
232
-
233
-            'add_question' => array(
234
-                'nav'           => array(
235
-                    'label'      => esc_html__('Add Question', 'event_espresso'),
236
-                    'order'      => 5,
237
-                    'persistent' => false,
238
-                ),
239
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
240
-                'help_tabs'     => array(
241
-                    'registration_form_add_question_help_tab' => array(
242
-                        'title'    => esc_html__('Add Question', 'event_espresso'),
243
-                        'filename' => 'registration_form_add_question',
244
-                    ),
245
-                ),
246
-                'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
247
-                'require_nonce' => false,
248
-            ),
249
-
250
-            'add_question_group' => array(
251
-                'nav'           => array(
252
-                    'label'      => esc_html__('Add Question Group', 'event_espresso'),
253
-                    'order'      => 5,
254
-                    'persistent' => false,
255
-                ),
256
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
257
-                'help_tabs'     => array(
258
-                    'registration_form_add_question_group_help_tab' => array(
259
-                        'title'    => esc_html__('Add Question Group', 'event_espresso'),
260
-                        'filename' => 'registration_form_add_question_group',
261
-                    ),
262
-                ),
263
-                'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
264
-                'require_nonce' => false,
265
-            ),
266
-
267
-            'edit_question_group' => array(
268
-                'nav'           => array(
269
-                    'label'      => esc_html__('Edit Question Group', 'event_espresso'),
270
-                    'order'      => 5,
271
-                    'persistent' => false,
272
-                    'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']),
273
-                        $this->_current_page_view_url) : $this->_admin_base_url,
274
-                ),
275
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
276
-                'help_tabs'     => array(
277
-                    'registration_form_edit_question_group_help_tab' => array(
278
-                        'title'    => esc_html__('Edit Question Group', 'event_espresso'),
279
-                        'filename' => 'registration_form_edit_question_group',
280
-                    ),
281
-                ),
282
-                'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
283
-                'require_nonce' => false,
284
-            ),
285
-
286
-            'view_reg_form_settings' => array(
287
-                'nav'           => array(
288
-                    'label' => esc_html__('Reg Form Settings', 'event_espresso'),
289
-                    'order' => 40,
290
-                ),
291
-                'labels'        => array(
292
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
293
-                ),
294
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
295
-                'help_tabs'     => array(
296
-                    'registration_form_reg_form_settings_help_tab' => array(
297
-                        'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
298
-                        'filename' => 'registration_form_reg_form_settings',
299
-                    ),
300
-                ),
301
-                'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
302
-                'require_nonce' => false,
303
-            ),
304
-
305
-        );
306
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
307
-
308
-        //change the list table we're going to use so it's the NEW list table!
309
-        $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
310
-
311
-
312
-        //additional labels
313
-        $new_labels               = array(
314
-            'add_question'          => esc_html__('Add New Question', 'event_espresso'),
315
-            'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
316
-            'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
317
-            'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
318
-            'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
319
-        );
320
-        $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
321
-
322
-    }
323
-
324
-
325
-    protected function _ajax_hooks()
326
-    {
327
-        add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
328
-    }
329
-
330
-
331
-    public function load_scripts_styles_question_groups()
332
-    {
333
-        wp_enqueue_script('espresso_ajax_table_sorting');
334
-    }
335
-
336
-
337
-    public function load_scripts_styles_add_question_group()
338
-    {
339
-        $this->load_scripts_styles_forms();
340
-        $this->load_sortable_question_script();
341
-    }
342
-
343
-    public function load_scripts_styles_edit_question_group()
344
-    {
345
-        $this->load_scripts_styles_forms();
346
-        $this->load_sortable_question_script();
347
-    }
348
-
349
-
350
-    /**
351
-     * registers and enqueues script for questions
352
-     *
353
-     * @return void
354
-     */
355
-    public function load_sortable_question_script()
356
-    {
357
-        wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
358
-            array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
359
-        wp_enqueue_script('ee-question-sortable');
360
-    }
361
-
362
-
363
-    protected function _set_list_table_views_default()
364
-    {
365
-        $this->_views = array(
366
-            'all' => array(
367
-                'slug'        => 'all',
368
-                'label'       => esc_html__('View All Questions', 'event_espresso'),
369
-                'count'       => 0,
370
-                'bulk_action' => array(
371
-                    'trash_questions' => esc_html__('Trash', 'event_espresso'),
372
-                ),
373
-            ),
374
-        );
375
-
376
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions',
377
-            'espresso_registration_form_trash_questions')
378
-        ) {
379
-            $this->_views['trash'] = array(
380
-                'slug'        => 'trash',
381
-                'label'       => esc_html__('Trash', 'event_espresso'),
382
-                'count'       => 0,
383
-                'bulk_action' => array(
384
-                    'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
385
-                    'restore_questions' => esc_html__('Restore', 'event_espresso'),
386
-                ),
387
-            );
388
-        }
389
-    }
390
-
391
-
392
-    protected function _set_list_table_views_question_groups()
393
-    {
394
-        $this->_views = array(
395
-            'all' => array(
396
-                'slug'        => 'all',
397
-                'label'       => esc_html__('All', 'event_espresso'),
398
-                'count'       => 0,
399
-                'bulk_action' => array(
400
-                    'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
401
-                ),
402
-            ),
403
-        );
404
-
405
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups',
406
-            'espresso_registration_form_trash_question_groups')
407
-        ) {
408
-            $this->_views['trash'] = array(
409
-                'slug'        => 'trash',
410
-                'label'       => esc_html__('Trash', 'event_espresso'),
411
-                'count'       => 0,
412
-                'bulk_action' => array(
413
-                    'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
414
-                    'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
415
-                ),
416
-            );
417
-        }
418
-    }
419
-
420
-
421
-    protected function _questions_overview_list_table()
422
-    {
423
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
424
-                'add_question',
425
-                'add_question',
426
-                array(),
427
-                'add-new-h2'
428
-            );
429
-        parent::_questions_overview_list_table();
430
-    }
431
-
432
-
433
-    protected function _question_groups_overview_list_table()
434
-    {
435
-        $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
436
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
437
-                'add_question_group',
438
-                'add_question_group',
439
-                array(),
440
-                'add-new-h2'
441
-            );
442
-        $this->display_admin_list_table_page_with_sidebar();
443
-    }
444
-
445
-
446
-    protected function _delete_question()
447
-    {
448
-        $success = $this->_delete_items($this->_question_model);
449
-        $this->_redirect_after_action(
450
-            $success,
451
-            $this->_question_model->item_name($success),
452
-            'deleted',
453
-            array('action' => 'default', 'status' => 'all')
454
-        );
455
-    }
456
-
457
-
458
-    protected function _delete_questions()
459
-    {
460
-        $success = $this->_delete_items($this->_question_model);
461
-        $this->_redirect_after_action(
462
-            $success,
463
-            $this->_question_model->item_name($success),
464
-            'deleted permanently',
465
-            array('action' => 'default', 'status' => 'trash')
466
-        );
467
-    }
468
-
469
-
470
-    /**
471
-     * Performs the deletion of a single or multiple questions or question groups.
472
-     *
473
-     * @param EEM_Soft_Delete_Base $model
474
-     * @return int number of items deleted permanently
475
-     */
476
-    private function _delete_items(EEM_Soft_Delete_Base $model)
477
-    {
478
-        $success = 0;
479
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
480
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
481
-            // if array has more than one element than success message should be plural
482
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
483
-            // cycle thru bulk action checkboxes
484
-            while (list($ID, $value) = each($this->_req_data['checkbox'])) {
485
-                if (! $this->_delete_item($ID, $model)) {
486
-                    $success = 0;
487
-                }
488
-            }
489
-
490
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
491
-            $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
492
-
493
-        } elseif (! empty($this->_req_data['QST_ID'])) {
494
-            $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
495
-        } else {
496
-            EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
497
-                "event_espresso")), __FILE__, __FUNCTION__, __LINE__);
498
-        }
499
-        return $success;
500
-    }
501
-
502
-    /**
503
-     * Deletes the specified question (and its associated question options) or question group
504
-     *
505
-     * @param int                  $id
506
-     * @param EEM_Soft_Delete_Base $model
507
-     * @return boolean
508
-     */
509
-    protected function _delete_item($id, $model)
510
-    {
511
-        if ($model instanceof EEM_Question) {
512
-            EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
513
-        }
514
-        return $model->delete_permanently_by_ID(absint($id));
515
-    }
516
-
517
-
518
-    /******************************    QUESTION GROUPS    ******************************/
519
-
520
-
521
-    protected function _edit_question_group($type = 'add')
522
-    {
523
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
524
-        $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : false;
525
-
526
-        switch ($this->_req_action) {
527
-            case 'add_question_group' :
528
-                $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
529
-                break;
530
-            case 'edit_question_group' :
531
-                $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
532
-                break;
533
-            default :
534
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
535
-        }
536
-        // add ID to title if editing
537
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
538
-        if ($ID) {
539
-            /** @var EE_Question_Group $questionGroup */
540
-            $questionGroup            = $this->_question_group_model->get_one_by_ID($ID);
541
-            $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
542
-            $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
543
-        } else {
544
-            /** @var EE_Question_Group $questionGroup */
545
-            $questionGroup = EEM_Question_Group::instance()->create_default_object();
546
-            $questionGroup->set_order_to_latest();
547
-            $this->_set_add_edit_form_tags('insert_question_group');
548
-        }
549
-        $this->_template_args['values']         = $this->_yes_no_values;
550
-        $this->_template_args['all_questions']  = $questionGroup->questions_in_and_not_in_group();
551
-        $this->_template_args['QSG_ID']         = $ID ? $ID : true;
552
-        $this->_template_args['question_group'] = $questionGroup;
553
-
554
-        $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
555
-        $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
556
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
557
-            $this->_template_args, true);
558
-
559
-        // the details template wrapper
560
-        $this->display_admin_page_with_sidebar();
561
-    }
562
-
563
-
564
-    protected function _delete_question_groups()
565
-    {
566
-        $success = $this->_delete_items($this->_question_group_model);
567
-        $this->_redirect_after_action($success, $this->_question_group_model->item_name($success),
568
-            'deleted permanently', array('action' => 'question_groups', 'status' => 'trash'));
569
-    }
570
-
571
-
572
-    /**
573
-     * @param bool $new_question_group
574
-     */
575
-    protected function _insert_or_update_question_group($new_question_group = true)
576
-    {
577
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
578
-        $set_column_values = $this->_set_column_values_for($this->_question_group_model);
579
-        if ($new_question_group) {
580
-            $QSG_ID  = $this->_question_group_model->insert($set_column_values);
581
-            $success = $QSG_ID ? 1 : 0;
582
-        } else {
583
-            $QSG_ID = absint($this->_req_data['QSG_ID']);
584
-            unset($set_column_values['QSG_ID']);
585
-            $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
586
-        }
587
-        $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone);
588
-        // update the existing related questions
589
-        // BUT FIRST...  delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group)
590
-        if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) {
591
-            // delete where QST ID = system phone question ID and Question Group ID is NOT this group
592
-            EEM_Question_Group_Question::instance()->delete(array(
593
-                array(
594
-                    'QST_ID' => $phone_question_id,
595
-                    'QSG_ID' => array('!=', $QSG_ID),
596
-                ),
597
-            ));
598
-        }
599
-        /** @type EE_Question_Group $question_group */
600
-        $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
601
-        $questions      = $question_group->questions();
602
-        // make sure system phone question is added to list of questions for this group
603
-        if (! isset($questions[$phone_question_id])) {
604
-            $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
605
-        }
606
-
607
-        foreach ($questions as $question_ID => $question) {
608
-            // first we always check for order.
609
-            if (! empty($this->_req_data['question_orders'][$question_ID])) {
610
-                //update question order
611
-                $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]);
612
-            }
613
-
614
-            // then we always check if adding or removing.
615
-            if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) {
616
-                $question_group->add_question($question_ID);
617
-            } else {
618
-                // not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it)
619
-                if (
620
-                in_array(
621
-                    $question->system_ID(),
622
-                    EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group())
623
-                )
624
-                ) {
625
-                    continue;
626
-                } else {
627
-                    $question_group->remove_question($question_ID);
628
-                }
629
-            }
630
-        }
631
-        // save new related questions
632
-        if (isset($this->_req_data['questions'])) {
633
-            foreach ($this->_req_data['questions'] as $QST_ID) {
634
-                $question_group->add_question($QST_ID);
635
-                if (isset($this->_req_data['question_orders'][$QST_ID])) {
636
-                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]);
637
-                }
638
-            }
639
-        }
640
-
641
-        if ($success !== false) {
642
-            $msg = $new_question_group ? sprintf(esc_html__('The %s has been created', 'event_espresso'),
643
-                $this->_question_group_model->item_name()) : sprintf(esc_html__('The %s has been updated',
644
-                'event_espresso'), $this->_question_group_model->item_name());
645
-            EE_Error::add_success($msg);
646
-        }
647
-        $this->_redirect_after_action(false, '', '', array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
648
-            true);
649
-
650
-    }
651
-
652
-    /**
653
-     * duplicates a question and all its question options and redirects to the new question.
654
-     */
655
-    public function _duplicate_question()
656
-    {
657
-        $question_ID = (int)$this->_req_data['QST_ID'];
658
-        $question    = EEM_Question::instance()->get_one_by_ID($question_ID);
659
-        if ($question instanceof EE_Question) {
660
-            $new_question = $question->duplicate();
661
-            if ($new_question instanceof EE_Question) {
662
-                $this->_redirect_after_action(true, esc_html__('Question', 'event_espresso'),
663
-                    esc_html__('Duplicated', 'event_espresso'),
664
-                    array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), true);
665
-            } else {
666
-                global $wpdb;
667
-                EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %1$d because: %2$s',
668
-                    'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__);
669
-                $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
670
-            }
671
-        } else {
672
-            EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %d because it didn\'t exist!',
673
-                'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__);
674
-            $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
675
-        }
676
-    }
677
-
678
-
679
-    /**
680
-     * @param bool $trash
681
-     */
682
-    protected function _trash_or_restore_question_groups($trash = true)
683
-    {
684
-        $this->_trash_or_restore_items($this->_question_group_model, $trash);
685
-    }
686
-
687
-
688
-    /**
689
-     *_trash_question
690
-     */
691
-    protected function _trash_question()
692
-    {
693
-        $success    = $this->_question_model->delete_by_ID((int)$this->_req_data['QST_ID']);
694
-        $query_args = array('action' => 'default', 'status' => 'all');
695
-        $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
696
-    }
697
-
698
-
699
-    /**
700
-     * @param bool $trash
701
-     */
702
-    protected function _trash_or_restore_questions($trash = true)
703
-    {
704
-        $this->_trash_or_restore_items($this->_question_model, $trash);
705
-    }
706
-
707
-
708
-    /**
709
-     * Internally used to delete or restore items, using the request data. Meant to be
710
-     * flexible between question or question groups
711
-     *
712
-     * @param EEM_Soft_Delete_Base $model
713
-     * @param boolean              $trash whether to trash or restore
714
-     */
715
-    private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
716
-    {
717
-
718
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
719
-
720
-        $success = 1;
721
-        //Checkboxes
722
-        //echo "trash $trash";
723
-        //var_dump($this->_req_data['checkbox']);die;
724
-        if (isset($this->_req_data['checkbox'])) {
725
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
726
-                // if array has more than one element than success message should be plural
727
-                $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
728
-                // cycle thru bulk action checkboxes
729
-                while (list($ID, $value) = each($this->_req_data['checkbox'])) {
730
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
731
-                        $success = 0;
732
-                    }
733
-                }
734
-
735
-            } else {
736
-                // grab single id and delete
737
-                $ID = absint($this->_req_data['checkbox']);
738
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
739
-                    $success = 0;
740
-                }
741
-            }
742
-
743
-        } else {
744
-            // delete via trash link
745
-            // grab single id and delete
746
-            $ID = absint($this->_req_data[$model->primary_key_name()]);
747
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
748
-                $success = 0;
749
-            }
750
-
751
-        }
752
-
753
-
754
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) );
755
-        //echo "action :$action";
756
-        //$action = 'questions' ? 'default' : $action;
757
-        if ($trash) {
758
-            $action_desc = 'trashed';
759
-            $status      = 'trash';
760
-        } else {
761
-            $action_desc = 'restored';
762
-            $status      = 'all';
763
-        }
764
-        $this->_redirect_after_action($success, $model->item_name($success), $action_desc,
765
-            array('action' => $action, 'status' => $status));
766
-    }
767
-
768
-
769
-    /**
770
-     * @param            $per_page
771
-     * @param int        $current_page
772
-     * @param bool|false $count
773
-     * @return \EE_Soft_Delete_Base_Class[]|int
774
-     */
775
-    public function get_trashed_questions($per_page, $current_page = 1, $count = false)
776
-    {
777
-        $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
778
-
779
-        if ($count) {
780
-            //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
781
-            $where   = isset($query_params[0]) ? array($query_params[0]) : array();
782
-            $results = $this->_question_model->count_deleted($where);
783
-        } else {
784
-            //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
785
-            $results = $this->_question_model->get_all_deleted($query_params);
786
-        }
787
-        return $results;
788
-    }
789
-
790
-
791
-    /**
792
-     * @param            $per_page
793
-     * @param int        $current_page
794
-     * @param bool|false $count
795
-     * @return \EE_Soft_Delete_Base_Class[]
796
-     */
797
-    public function get_question_groups($per_page, $current_page = 1, $count = false)
798
-    {
799
-        $questionGroupModel = EEM_Question_Group::instance();
800
-        $query_params       = $this->get_query_params($questionGroupModel, $per_page, $current_page);
801
-        if ($count) {
802
-            $where   = isset($query_params[0]) ? array($query_params[0]) : array();
803
-            $results = $questionGroupModel->count($where);
804
-        } else {
805
-            $results = $questionGroupModel->get_all($query_params);
806
-        }
807
-        return $results;
808
-    }
809
-
810
-
811
-    /**
812
-     * @param      $per_page
813
-     * @param int  $current_page
814
-     * @param bool $count
815
-     * @return \EE_Soft_Delete_Base_Class[]|int
816
-     */
817
-    public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
818
-    {
819
-        $questionGroupModel = EEM_Question_Group::instance();
820
-        $query_params       = $this->get_query_params($questionGroupModel, $per_page, $current_page);
821
-        if ($count) {
822
-            $where                 = isset($query_params[0]) ? array($query_params[0]) : array();
823
-            $query_params['limit'] = null;
824
-            $results               = $questionGroupModel->count_deleted($where);
825
-        } else {
826
-            $results = $questionGroupModel->get_all_deleted($query_params);
827
-        }
828
-        return $results;
829
-    }
830
-
831
-
832
-    /**
833
-     * method for performing updates to question order
834
-     *
835
-     * @return array results array
836
-     */
837
-    public function update_question_group_order()
838
-    {
839
-
840
-        $success = esc_html__('Question group order was updated successfully.', 'event_espresso');
841
-
842
-        // grab our row IDs
843
-        $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
844
-            ? explode(',', rtrim($this->_req_data['row_ids'], ','))
845
-            : array();
846
-
847
-        $perpage = ! empty($this->_req_data['perpage'])
848
-            ? (int)$this->_req_data['perpage']
849
-            : null;
850
-        $curpage = ! empty($this->_req_data['curpage'])
851
-            ? (int)$this->_req_data['curpage']
852
-            : null;
853
-
854
-        if (! empty($row_ids)) {
855
-            //figure out where we start the row_id count at for the current page.
856
-            $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
857
-
858
-            $row_count = count($row_ids);
859
-            for ($i = 0; $i < $row_count; $i++) {
860
-                //Update the questions when re-ordering
861
-                $updated = EEM_Question_Group::instance()->update(
862
-                    array('QSG_order' => $qsgcount),
863
-                    array(array('QSG_ID' => $row_ids[$i]))
864
-                );
865
-                if ($updated === false) {
866
-                    $success = false;
867
-                }
868
-                $qsgcount++;
869
-            }
870
-        } else {
871
-            $success = false;
872
-        }
873
-
874
-        $errors = ! $success
875
-            ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
876
-            : false;
877
-
878
-        echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
879
-        die();
880
-
881
-    }
882
-
883
-
884
-
885
-    /***************************************        REGISTRATION SETTINGS        ***************************************/
886
-
887
-
888
-    /**
889
-     * _reg_form_settings
890
-     *
891
-     * @throws \EE_Error
892
-     */
893
-    protected function _reg_form_settings()
894
-    {
895
-        $this->_template_args['values'] = $this->_yes_no_values;
896
-        add_action(
897
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
898
-            array($this, 'email_validation_settings_form'),
899
-            2
900
-        );
901
-        $this->_template_args = (array)apply_filters(
902
-            'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
903
-            $this->_template_args
904
-        );
905
-        $this->_set_add_edit_form_tags('update_reg_form_settings');
906
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
907
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
908
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
909
-            $this->_template_args,
910
-            true
911
-        );
912
-        $this->display_admin_page_with_sidebar();
913
-    }
914
-
915
-
916
-    /**
917
-     * _update_reg_form_settings
918
-     */
919
-    protected function _update_reg_form_settings()
920
-    {
921
-        EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
922
-            EE_Registry::instance()->CFG->registration
923
-        );
924
-        EE_Registry::instance()->CFG->registration = apply_filters(
925
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
926
-            EE_Registry::instance()->CFG->registration
927
-        );
928
-        $success                                   = $this->_update_espresso_configuration(
929
-            esc_html__('Registration Form Options', 'event_espresso'),
930
-            EE_Registry::instance()->CFG,
931
-            __FILE__, __FUNCTION__, __LINE__
932
-        );
933
-        $this->_redirect_after_action($success, esc_html__('Registration Form Options', 'event_espresso'), 'updated',
934
-            array('action' => 'view_reg_form_settings'));
935
-    }
936
-
937
-
938
-    /**
939
-     * email_validation_settings_form
940
-     *
941
-     * @access    public
942
-     * @return    void
943
-     * @throws \EE_Error
944
-     */
945
-    public function email_validation_settings_form()
946
-    {
947
-        echo $this->_email_validation_settings_form()->get_html();
948
-    }
949
-
950
-
951
-    /**
952
-     * _email_validation_settings_form
953
-     *
954
-     * @access protected
955
-     * @return EE_Form_Section_Proper
956
-     * @throws \EE_Error
957
-     */
958
-    protected function _email_validation_settings_form()
959
-    {
960
-        return new EE_Form_Section_Proper(
961
-            array(
962
-                'name'            => 'email_validation_settings',
963
-                'html_id'         => 'email_validation_settings',
964
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
965
-                'subsections'     => apply_filters(
966
-                    'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
967
-                    array(
968
-                        'email_validation_hdr'   => new EE_Form_Section_HTML(
969
-                            EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
970
-                        ),
971
-                        'email_validation_level' => new EE_Select_Input(
972
-                            array(
973
-                                'basic'      => esc_html__('Basic', 'event_espresso'),
974
-                                'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
975
-                                'i18n'       => esc_html__('International', 'event_espresso'),
976
-                                'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
977
-                            ),
978
-                            array(
979
-                                'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
980
-                                                     . EEH_Template::get_help_tab_link('email_validation_info'),
981
-                                'html_help_text'  => esc_html__('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
982
-                                    'event_espresso'),
983
-                                'default'         => isset(EE_Registry::instance()->CFG->registration->email_validation_level)
984
-                                    ? EE_Registry::instance()->CFG->registration->email_validation_level
985
-                                    : 'wp_default',
986
-                                'required'        => false,
987
-                            )
988
-                        ),
989
-                    )
990
-                ),
991
-            )
992
-        );
993
-    }
994
-
995
-
996
-    /**
997
-     * update_email_validation_settings_form
998
-     *
999
-     * @access    public
1000
-     * @param \EE_Registration_Config $EE_Registration_Config
1001
-     * @return \EE_Registration_Config
1002
-     */
1003
-    public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1004
-    {
1005
-        $prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1006
-        try {
1007
-            $email_validation_settings_form = $this->_email_validation_settings_form();
1008
-            // if not displaying a form, then check for form submission
1009
-            if ($email_validation_settings_form->was_submitted()) {
1010
-                // capture form data
1011
-                $email_validation_settings_form->receive_form_submission();
1012
-                // validate form data
1013
-                if ($email_validation_settings_form->is_valid()) {
1014
-                    // grab validated data from form
1015
-                    $valid_data = $email_validation_settings_form->valid_data();
1016
-                    if (isset($valid_data['email_validation_level'])) {
1017
-                        $email_validation_level = $valid_data['email_validation_level'];
1018
-                        // now if they want to use international email addresses
1019
-                        if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1020
-                            // in case we need to reset their email validation level,
1021
-                            // make sure that the previous value wasn't already set to one of the i18n options.
1022
-                            if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1023
-                                // if so, then reset it back to "basic" since that is the only other option that,
1024
-                                // despite offering poor validation, supports i18n email addresses
1025
-                                $prev_email_validation_level = 'basic';
1026
-                            }
1027
-                            // confirm our i18n email validation will work on the server
1028
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1029
-                                // or reset email validation level to previous value
1030
-                                $email_validation_level = $prev_email_validation_level;
1031
-                            }
1032
-                        }
1033
-                        $EE_Registration_Config->email_validation_level = $email_validation_level;
1034
-                    } else {
1035
-                        EE_Error::add_error(
1036
-                            esc_html__(
1037
-                                'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1038
-                                'event_espresso'
1039
-                            ),
1040
-                            __FILE__, __FUNCTION__, __LINE__
1041
-                        );
1042
-                    }
1043
-                } else {
1044
-                    if ($email_validation_settings_form->submission_error_message() !== '') {
1045
-                        EE_Error::add_error(
1046
-                            $email_validation_settings_form->submission_error_message(),
1047
-                            __FILE__, __FUNCTION__, __LINE__
1048
-                        );
1049
-                    }
1050
-                }
1051
-            }
1052
-        } catch (EE_Error $e) {
1053
-            $e->get_error();
1054
-        }
1055
-        return $EE_Registration_Config;
1056
-    }
1057
-
1058
-
1059
-    /**
1060
-     * confirms that the server's PHP version has the PCRE module enabled,
1061
-     * and that the PCRE version works with our i18n email validation
1062
-     *
1063
-     * @param \EE_Registration_Config $EE_Registration_Config
1064
-     * @param string                  $email_validation_level
1065
-     * @return bool
1066
-     */
1067
-    private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1068
-    {
1069
-        // first check that PCRE is enabled
1070
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1071
-            EE_Error::add_error(
1072
-                sprintf(
1073
-                    esc_html__(
1074
-                        'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1075
-                        'event_espresso'
1076
-                    ),
1077
-                    '<br />'
1078
-                ),
1079
-                __FILE__,
1080
-                __FUNCTION__,
1081
-                __LINE__
1082
-            );
1083
-            return false;
1084
-        } else {
1085
-            // PCRE support is enabled, but let's still
1086
-            // perform a test to see if the server will support it.
1087
-            // but first, save the updated validation level to the config,
1088
-            // so that the validation strategy picks it up.
1089
-            // this will get bumped back down if it doesn't work
1090
-            $EE_Registration_Config->email_validation_level = $email_validation_level;
1091
-            try {
1092
-                $email_validator    = new EE_Email_Validation_Strategy();
1093
-                $i18n_email_address = apply_filters(
1094
-                    'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1095
-                    'jägerjü[email protected]'
1096
-                );
1097
-                $email_validator->validate($i18n_email_address);
1098
-            } catch (Exception $e) {
1099
-                EE_Error::add_error(
1100
-                    sprintf(
1101
-                        esc_html__(
1102
-                            'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1103
-                            'event_espresso'
1104
-                        ),
1105
-                        '<br />',
1106
-                        '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>'
1107
-                    ),
1108
-                    __FILE__, __FUNCTION__, __LINE__
1109
-                );
1110
-                return false;
1111
-            }
1112
-        }
1113
-        return true;
1114
-    }
28
+	/**
29
+	 * @Constructor
30
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
31
+	 * @access public
32
+	 */
33
+	public function __construct($routing = true)
34
+	{
35
+		define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS);
36
+		define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS);
37
+		define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
38
+		define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS);
39
+		define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
40
+		parent::__construct($routing);
41
+	}
42
+
43
+
44
+	protected function _extend_page_config()
45
+	{
46
+		$this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
47
+		$qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
48
+		$qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0;
49
+
50
+		$new_page_routes    = array(
51
+			'question_groups'    => array(
52
+				'func'       => '_question_groups_overview_list_table',
53
+				'capability' => 'ee_read_question_groups',
54
+			),
55
+			'add_question'       => array(
56
+				'func'       => '_edit_question',
57
+				'capability' => 'ee_edit_questions',
58
+			),
59
+			'insert_question'    => array(
60
+				'func'       => '_insert_or_update_question',
61
+				'args'       => array('new_question' => true),
62
+				'capability' => 'ee_edit_questions',
63
+				'noheader'   => true,
64
+			),
65
+			'duplicate_question' => array(
66
+				'func'       => '_duplicate_question',
67
+				'capability' => 'ee_edit_questions',
68
+				'noheader'   => true,
69
+			),
70
+			'trash_question'     => array(
71
+				'func'       => '_trash_question',
72
+				'capability' => 'ee_delete_question',
73
+				'obj_id'     => $qst_id,
74
+				'noheader'   => true,
75
+			),
76
+
77
+			'restore_question' => array(
78
+				'func'       => '_trash_or_restore_questions',
79
+				'capability' => 'ee_delete_question',
80
+				'obj_id'     => $qst_id,
81
+				'args'       => array('trash' => false),
82
+				'noheader'   => true,
83
+			),
84
+
85
+			'delete_question' => array(
86
+				'func'       => '_delete_question',
87
+				'capability' => 'ee_delete_question',
88
+				'obj_id'     => $qst_id,
89
+				'noheader'   => true,
90
+			),
91
+
92
+			'trash_questions' => array(
93
+				'func'       => '_trash_or_restore_questions',
94
+				'capability' => 'ee_delete_questions',
95
+				'args'       => array('trash' => true),
96
+				'noheader'   => true,
97
+			),
98
+
99
+			'restore_questions' => array(
100
+				'func'       => '_trash_or_restore_questions',
101
+				'capability' => 'ee_delete_questions',
102
+				'args'       => array('trash' => false),
103
+				'noheader'   => true,
104
+			),
105
+
106
+			'delete_questions' => array(
107
+				'func'       => '_delete_questions',
108
+				'args'       => array(),
109
+				'capability' => 'ee_delete_questions',
110
+				'noheader'   => true,
111
+			),
112
+
113
+			'add_question_group' => array(
114
+				'func'       => '_edit_question_group',
115
+				'capability' => 'ee_edit_question_groups',
116
+			),
117
+
118
+			'edit_question_group' => array(
119
+				'func'       => '_edit_question_group',
120
+				'capability' => 'ee_edit_question_group',
121
+				'obj_id'     => $qsg_id,
122
+				'args'       => array('edit'),
123
+			),
124
+
125
+			'delete_question_groups' => array(
126
+				'func'       => '_delete_question_groups',
127
+				'capability' => 'ee_delete_question_groups',
128
+				'noheader'   => true,
129
+			),
130
+
131
+			'delete_question_group' => array(
132
+				'func'       => '_delete_question_groups',
133
+				'capability' => 'ee_delete_question_group',
134
+				'obj_id'     => $qsg_id,
135
+				'noheader'   => true,
136
+			),
137
+
138
+			'trash_question_group' => array(
139
+				'func'       => '_trash_or_restore_question_groups',
140
+				'args'       => array('trash' => true),
141
+				'capability' => 'ee_delete_question_group',
142
+				'obj_id'     => $qsg_id,
143
+				'noheader'   => true,
144
+			),
145
+
146
+			'restore_question_group' => array(
147
+				'func'       => '_trash_or_restore_question_groups',
148
+				'args'       => array('trash' => false),
149
+				'capability' => 'ee_delete_question_group',
150
+				'obj_id'     => $qsg_id,
151
+				'noheader'   => true,
152
+			),
153
+
154
+			'insert_question_group' => array(
155
+				'func'       => '_insert_or_update_question_group',
156
+				'args'       => array('new_question_group' => true),
157
+				'capability' => 'ee_edit_question_groups',
158
+				'noheader'   => true,
159
+			),
160
+
161
+			'update_question_group' => array(
162
+				'func'       => '_insert_or_update_question_group',
163
+				'args'       => array('new_question_group' => false),
164
+				'capability' => 'ee_edit_question_group',
165
+				'obj_id'     => $qsg_id,
166
+				'noheader'   => true,
167
+			),
168
+
169
+			'trash_question_groups' => array(
170
+				'func'       => '_trash_or_restore_question_groups',
171
+				'args'       => array('trash' => true),
172
+				'capability' => 'ee_delete_question_groups',
173
+				'noheader'   => array('trash' => false),
174
+			),
175
+
176
+			'restore_question_groups' => array(
177
+				'func'       => '_trash_or_restore_question_groups',
178
+				'args'       => array('trash' => false),
179
+				'capability' => 'ee_delete_question_groups',
180
+				'noheader'   => true,
181
+			),
182
+
183
+
184
+			'espresso_update_question_group_order' => array(
185
+				'func'       => 'update_question_group_order',
186
+				'capability' => 'ee_edit_question_groups',
187
+				'noheader'   => true,
188
+			),
189
+
190
+			'view_reg_form_settings' => array(
191
+				'func'       => '_reg_form_settings',
192
+				'capability' => 'manage_options',
193
+			),
194
+
195
+			'update_reg_form_settings' => array(
196
+				'func'       => '_update_reg_form_settings',
197
+				'capability' => 'manage_options',
198
+				'noheader'   => true,
199
+			),
200
+		);
201
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
202
+
203
+		$new_page_config    = array(
204
+
205
+			'question_groups' => array(
206
+				'nav'           => array(
207
+					'label' => esc_html__('Question Groups', 'event_espresso'),
208
+					'order' => 20,
209
+				),
210
+				'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
211
+				'help_tabs'     => array(
212
+					'registration_form_question_groups_help_tab'                           => array(
213
+						'title'    => esc_html__('Question Groups', 'event_espresso'),
214
+						'filename' => 'registration_form_question_groups',
215
+					),
216
+					'registration_form_question_groups_table_column_headings_help_tab'     => array(
217
+						'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
218
+						'filename' => 'registration_form_question_groups_table_column_headings',
219
+					),
220
+					'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
221
+						'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
222
+						'filename' => 'registration_form_question_groups_views_bulk_actions_search',
223
+					),
224
+				),
225
+				'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
226
+				'metaboxes'     => $this->_default_espresso_metaboxes,
227
+				'require_nonce' => false,
228
+				'qtips'         => array(
229
+					'EE_Registration_Form_Tips',
230
+				),
231
+			),
232
+
233
+			'add_question' => array(
234
+				'nav'           => array(
235
+					'label'      => esc_html__('Add Question', 'event_espresso'),
236
+					'order'      => 5,
237
+					'persistent' => false,
238
+				),
239
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
240
+				'help_tabs'     => array(
241
+					'registration_form_add_question_help_tab' => array(
242
+						'title'    => esc_html__('Add Question', 'event_espresso'),
243
+						'filename' => 'registration_form_add_question',
244
+					),
245
+				),
246
+				'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
247
+				'require_nonce' => false,
248
+			),
249
+
250
+			'add_question_group' => array(
251
+				'nav'           => array(
252
+					'label'      => esc_html__('Add Question Group', 'event_espresso'),
253
+					'order'      => 5,
254
+					'persistent' => false,
255
+				),
256
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
257
+				'help_tabs'     => array(
258
+					'registration_form_add_question_group_help_tab' => array(
259
+						'title'    => esc_html__('Add Question Group', 'event_espresso'),
260
+						'filename' => 'registration_form_add_question_group',
261
+					),
262
+				),
263
+				'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
264
+				'require_nonce' => false,
265
+			),
266
+
267
+			'edit_question_group' => array(
268
+				'nav'           => array(
269
+					'label'      => esc_html__('Edit Question Group', 'event_espresso'),
270
+					'order'      => 5,
271
+					'persistent' => false,
272
+					'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']),
273
+						$this->_current_page_view_url) : $this->_admin_base_url,
274
+				),
275
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
276
+				'help_tabs'     => array(
277
+					'registration_form_edit_question_group_help_tab' => array(
278
+						'title'    => esc_html__('Edit Question Group', 'event_espresso'),
279
+						'filename' => 'registration_form_edit_question_group',
280
+					),
281
+				),
282
+				'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
283
+				'require_nonce' => false,
284
+			),
285
+
286
+			'view_reg_form_settings' => array(
287
+				'nav'           => array(
288
+					'label' => esc_html__('Reg Form Settings', 'event_espresso'),
289
+					'order' => 40,
290
+				),
291
+				'labels'        => array(
292
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
293
+				),
294
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
295
+				'help_tabs'     => array(
296
+					'registration_form_reg_form_settings_help_tab' => array(
297
+						'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
298
+						'filename' => 'registration_form_reg_form_settings',
299
+					),
300
+				),
301
+				'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
302
+				'require_nonce' => false,
303
+			),
304
+
305
+		);
306
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
307
+
308
+		//change the list table we're going to use so it's the NEW list table!
309
+		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
310
+
311
+
312
+		//additional labels
313
+		$new_labels               = array(
314
+			'add_question'          => esc_html__('Add New Question', 'event_espresso'),
315
+			'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
316
+			'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
317
+			'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
318
+			'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
319
+		);
320
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
321
+
322
+	}
323
+
324
+
325
+	protected function _ajax_hooks()
326
+	{
327
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
328
+	}
329
+
330
+
331
+	public function load_scripts_styles_question_groups()
332
+	{
333
+		wp_enqueue_script('espresso_ajax_table_sorting');
334
+	}
335
+
336
+
337
+	public function load_scripts_styles_add_question_group()
338
+	{
339
+		$this->load_scripts_styles_forms();
340
+		$this->load_sortable_question_script();
341
+	}
342
+
343
+	public function load_scripts_styles_edit_question_group()
344
+	{
345
+		$this->load_scripts_styles_forms();
346
+		$this->load_sortable_question_script();
347
+	}
348
+
349
+
350
+	/**
351
+	 * registers and enqueues script for questions
352
+	 *
353
+	 * @return void
354
+	 */
355
+	public function load_sortable_question_script()
356
+	{
357
+		wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
358
+			array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
359
+		wp_enqueue_script('ee-question-sortable');
360
+	}
361
+
362
+
363
+	protected function _set_list_table_views_default()
364
+	{
365
+		$this->_views = array(
366
+			'all' => array(
367
+				'slug'        => 'all',
368
+				'label'       => esc_html__('View All Questions', 'event_espresso'),
369
+				'count'       => 0,
370
+				'bulk_action' => array(
371
+					'trash_questions' => esc_html__('Trash', 'event_espresso'),
372
+				),
373
+			),
374
+		);
375
+
376
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions',
377
+			'espresso_registration_form_trash_questions')
378
+		) {
379
+			$this->_views['trash'] = array(
380
+				'slug'        => 'trash',
381
+				'label'       => esc_html__('Trash', 'event_espresso'),
382
+				'count'       => 0,
383
+				'bulk_action' => array(
384
+					'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
385
+					'restore_questions' => esc_html__('Restore', 'event_espresso'),
386
+				),
387
+			);
388
+		}
389
+	}
390
+
391
+
392
+	protected function _set_list_table_views_question_groups()
393
+	{
394
+		$this->_views = array(
395
+			'all' => array(
396
+				'slug'        => 'all',
397
+				'label'       => esc_html__('All', 'event_espresso'),
398
+				'count'       => 0,
399
+				'bulk_action' => array(
400
+					'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
401
+				),
402
+			),
403
+		);
404
+
405
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups',
406
+			'espresso_registration_form_trash_question_groups')
407
+		) {
408
+			$this->_views['trash'] = array(
409
+				'slug'        => 'trash',
410
+				'label'       => esc_html__('Trash', 'event_espresso'),
411
+				'count'       => 0,
412
+				'bulk_action' => array(
413
+					'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
414
+					'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
415
+				),
416
+			);
417
+		}
418
+	}
419
+
420
+
421
+	protected function _questions_overview_list_table()
422
+	{
423
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
424
+				'add_question',
425
+				'add_question',
426
+				array(),
427
+				'add-new-h2'
428
+			);
429
+		parent::_questions_overview_list_table();
430
+	}
431
+
432
+
433
+	protected function _question_groups_overview_list_table()
434
+	{
435
+		$this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
436
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
437
+				'add_question_group',
438
+				'add_question_group',
439
+				array(),
440
+				'add-new-h2'
441
+			);
442
+		$this->display_admin_list_table_page_with_sidebar();
443
+	}
444
+
445
+
446
+	protected function _delete_question()
447
+	{
448
+		$success = $this->_delete_items($this->_question_model);
449
+		$this->_redirect_after_action(
450
+			$success,
451
+			$this->_question_model->item_name($success),
452
+			'deleted',
453
+			array('action' => 'default', 'status' => 'all')
454
+		);
455
+	}
456
+
457
+
458
+	protected function _delete_questions()
459
+	{
460
+		$success = $this->_delete_items($this->_question_model);
461
+		$this->_redirect_after_action(
462
+			$success,
463
+			$this->_question_model->item_name($success),
464
+			'deleted permanently',
465
+			array('action' => 'default', 'status' => 'trash')
466
+		);
467
+	}
468
+
469
+
470
+	/**
471
+	 * Performs the deletion of a single or multiple questions or question groups.
472
+	 *
473
+	 * @param EEM_Soft_Delete_Base $model
474
+	 * @return int number of items deleted permanently
475
+	 */
476
+	private function _delete_items(EEM_Soft_Delete_Base $model)
477
+	{
478
+		$success = 0;
479
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
480
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
481
+			// if array has more than one element than success message should be plural
482
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
483
+			// cycle thru bulk action checkboxes
484
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
485
+				if (! $this->_delete_item($ID, $model)) {
486
+					$success = 0;
487
+				}
488
+			}
489
+
490
+		} elseif (! empty($this->_req_data['QSG_ID'])) {
491
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
492
+
493
+		} elseif (! empty($this->_req_data['QST_ID'])) {
494
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
495
+		} else {
496
+			EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
497
+				"event_espresso")), __FILE__, __FUNCTION__, __LINE__);
498
+		}
499
+		return $success;
500
+	}
501
+
502
+	/**
503
+	 * Deletes the specified question (and its associated question options) or question group
504
+	 *
505
+	 * @param int                  $id
506
+	 * @param EEM_Soft_Delete_Base $model
507
+	 * @return boolean
508
+	 */
509
+	protected function _delete_item($id, $model)
510
+	{
511
+		if ($model instanceof EEM_Question) {
512
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
513
+		}
514
+		return $model->delete_permanently_by_ID(absint($id));
515
+	}
516
+
517
+
518
+	/******************************    QUESTION GROUPS    ******************************/
519
+
520
+
521
+	protected function _edit_question_group($type = 'add')
522
+	{
523
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
524
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : false;
525
+
526
+		switch ($this->_req_action) {
527
+			case 'add_question_group' :
528
+				$this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
529
+				break;
530
+			case 'edit_question_group' :
531
+				$this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
532
+				break;
533
+			default :
534
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
535
+		}
536
+		// add ID to title if editing
537
+		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
538
+		if ($ID) {
539
+			/** @var EE_Question_Group $questionGroup */
540
+			$questionGroup            = $this->_question_group_model->get_one_by_ID($ID);
541
+			$additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
542
+			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
543
+		} else {
544
+			/** @var EE_Question_Group $questionGroup */
545
+			$questionGroup = EEM_Question_Group::instance()->create_default_object();
546
+			$questionGroup->set_order_to_latest();
547
+			$this->_set_add_edit_form_tags('insert_question_group');
548
+		}
549
+		$this->_template_args['values']         = $this->_yes_no_values;
550
+		$this->_template_args['all_questions']  = $questionGroup->questions_in_and_not_in_group();
551
+		$this->_template_args['QSG_ID']         = $ID ? $ID : true;
552
+		$this->_template_args['question_group'] = $questionGroup;
553
+
554
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
555
+		$this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
556
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
557
+			$this->_template_args, true);
558
+
559
+		// the details template wrapper
560
+		$this->display_admin_page_with_sidebar();
561
+	}
562
+
563
+
564
+	protected function _delete_question_groups()
565
+	{
566
+		$success = $this->_delete_items($this->_question_group_model);
567
+		$this->_redirect_after_action($success, $this->_question_group_model->item_name($success),
568
+			'deleted permanently', array('action' => 'question_groups', 'status' => 'trash'));
569
+	}
570
+
571
+
572
+	/**
573
+	 * @param bool $new_question_group
574
+	 */
575
+	protected function _insert_or_update_question_group($new_question_group = true)
576
+	{
577
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
578
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
579
+		if ($new_question_group) {
580
+			$QSG_ID  = $this->_question_group_model->insert($set_column_values);
581
+			$success = $QSG_ID ? 1 : 0;
582
+		} else {
583
+			$QSG_ID = absint($this->_req_data['QSG_ID']);
584
+			unset($set_column_values['QSG_ID']);
585
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
586
+		}
587
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone);
588
+		// update the existing related questions
589
+		// BUT FIRST...  delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group)
590
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) {
591
+			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
592
+			EEM_Question_Group_Question::instance()->delete(array(
593
+				array(
594
+					'QST_ID' => $phone_question_id,
595
+					'QSG_ID' => array('!=', $QSG_ID),
596
+				),
597
+			));
598
+		}
599
+		/** @type EE_Question_Group $question_group */
600
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
601
+		$questions      = $question_group->questions();
602
+		// make sure system phone question is added to list of questions for this group
603
+		if (! isset($questions[$phone_question_id])) {
604
+			$questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
605
+		}
606
+
607
+		foreach ($questions as $question_ID => $question) {
608
+			// first we always check for order.
609
+			if (! empty($this->_req_data['question_orders'][$question_ID])) {
610
+				//update question order
611
+				$question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]);
612
+			}
613
+
614
+			// then we always check if adding or removing.
615
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) {
616
+				$question_group->add_question($question_ID);
617
+			} else {
618
+				// not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it)
619
+				if (
620
+				in_array(
621
+					$question->system_ID(),
622
+					EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group())
623
+				)
624
+				) {
625
+					continue;
626
+				} else {
627
+					$question_group->remove_question($question_ID);
628
+				}
629
+			}
630
+		}
631
+		// save new related questions
632
+		if (isset($this->_req_data['questions'])) {
633
+			foreach ($this->_req_data['questions'] as $QST_ID) {
634
+				$question_group->add_question($QST_ID);
635
+				if (isset($this->_req_data['question_orders'][$QST_ID])) {
636
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]);
637
+				}
638
+			}
639
+		}
640
+
641
+		if ($success !== false) {
642
+			$msg = $new_question_group ? sprintf(esc_html__('The %s has been created', 'event_espresso'),
643
+				$this->_question_group_model->item_name()) : sprintf(esc_html__('The %s has been updated',
644
+				'event_espresso'), $this->_question_group_model->item_name());
645
+			EE_Error::add_success($msg);
646
+		}
647
+		$this->_redirect_after_action(false, '', '', array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
648
+			true);
649
+
650
+	}
651
+
652
+	/**
653
+	 * duplicates a question and all its question options and redirects to the new question.
654
+	 */
655
+	public function _duplicate_question()
656
+	{
657
+		$question_ID = (int)$this->_req_data['QST_ID'];
658
+		$question    = EEM_Question::instance()->get_one_by_ID($question_ID);
659
+		if ($question instanceof EE_Question) {
660
+			$new_question = $question->duplicate();
661
+			if ($new_question instanceof EE_Question) {
662
+				$this->_redirect_after_action(true, esc_html__('Question', 'event_espresso'),
663
+					esc_html__('Duplicated', 'event_espresso'),
664
+					array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), true);
665
+			} else {
666
+				global $wpdb;
667
+				EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %1$d because: %2$s',
668
+					'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__);
669
+				$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
670
+			}
671
+		} else {
672
+			EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %d because it didn\'t exist!',
673
+				'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__);
674
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
675
+		}
676
+	}
677
+
678
+
679
+	/**
680
+	 * @param bool $trash
681
+	 */
682
+	protected function _trash_or_restore_question_groups($trash = true)
683
+	{
684
+		$this->_trash_or_restore_items($this->_question_group_model, $trash);
685
+	}
686
+
687
+
688
+	/**
689
+	 *_trash_question
690
+	 */
691
+	protected function _trash_question()
692
+	{
693
+		$success    = $this->_question_model->delete_by_ID((int)$this->_req_data['QST_ID']);
694
+		$query_args = array('action' => 'default', 'status' => 'all');
695
+		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
696
+	}
697
+
698
+
699
+	/**
700
+	 * @param bool $trash
701
+	 */
702
+	protected function _trash_or_restore_questions($trash = true)
703
+	{
704
+		$this->_trash_or_restore_items($this->_question_model, $trash);
705
+	}
706
+
707
+
708
+	/**
709
+	 * Internally used to delete or restore items, using the request data. Meant to be
710
+	 * flexible between question or question groups
711
+	 *
712
+	 * @param EEM_Soft_Delete_Base $model
713
+	 * @param boolean              $trash whether to trash or restore
714
+	 */
715
+	private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
716
+	{
717
+
718
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
719
+
720
+		$success = 1;
721
+		//Checkboxes
722
+		//echo "trash $trash";
723
+		//var_dump($this->_req_data['checkbox']);die;
724
+		if (isset($this->_req_data['checkbox'])) {
725
+			if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
726
+				// if array has more than one element than success message should be plural
727
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
728
+				// cycle thru bulk action checkboxes
729
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
730
+					if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
731
+						$success = 0;
732
+					}
733
+				}
734
+
735
+			} else {
736
+				// grab single id and delete
737
+				$ID = absint($this->_req_data['checkbox']);
738
+				if (! $model->delete_or_restore_by_ID($trash, $ID)) {
739
+					$success = 0;
740
+				}
741
+			}
742
+
743
+		} else {
744
+			// delete via trash link
745
+			// grab single id and delete
746
+			$ID = absint($this->_req_data[$model->primary_key_name()]);
747
+			if (! $model->delete_or_restore_by_ID($trash, $ID)) {
748
+				$success = 0;
749
+			}
750
+
751
+		}
752
+
753
+
754
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) );
755
+		//echo "action :$action";
756
+		//$action = 'questions' ? 'default' : $action;
757
+		if ($trash) {
758
+			$action_desc = 'trashed';
759
+			$status      = 'trash';
760
+		} else {
761
+			$action_desc = 'restored';
762
+			$status      = 'all';
763
+		}
764
+		$this->_redirect_after_action($success, $model->item_name($success), $action_desc,
765
+			array('action' => $action, 'status' => $status));
766
+	}
767
+
768
+
769
+	/**
770
+	 * @param            $per_page
771
+	 * @param int        $current_page
772
+	 * @param bool|false $count
773
+	 * @return \EE_Soft_Delete_Base_Class[]|int
774
+	 */
775
+	public function get_trashed_questions($per_page, $current_page = 1, $count = false)
776
+	{
777
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
778
+
779
+		if ($count) {
780
+			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
781
+			$where   = isset($query_params[0]) ? array($query_params[0]) : array();
782
+			$results = $this->_question_model->count_deleted($where);
783
+		} else {
784
+			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
785
+			$results = $this->_question_model->get_all_deleted($query_params);
786
+		}
787
+		return $results;
788
+	}
789
+
790
+
791
+	/**
792
+	 * @param            $per_page
793
+	 * @param int        $current_page
794
+	 * @param bool|false $count
795
+	 * @return \EE_Soft_Delete_Base_Class[]
796
+	 */
797
+	public function get_question_groups($per_page, $current_page = 1, $count = false)
798
+	{
799
+		$questionGroupModel = EEM_Question_Group::instance();
800
+		$query_params       = $this->get_query_params($questionGroupModel, $per_page, $current_page);
801
+		if ($count) {
802
+			$where   = isset($query_params[0]) ? array($query_params[0]) : array();
803
+			$results = $questionGroupModel->count($where);
804
+		} else {
805
+			$results = $questionGroupModel->get_all($query_params);
806
+		}
807
+		return $results;
808
+	}
809
+
810
+
811
+	/**
812
+	 * @param      $per_page
813
+	 * @param int  $current_page
814
+	 * @param bool $count
815
+	 * @return \EE_Soft_Delete_Base_Class[]|int
816
+	 */
817
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
818
+	{
819
+		$questionGroupModel = EEM_Question_Group::instance();
820
+		$query_params       = $this->get_query_params($questionGroupModel, $per_page, $current_page);
821
+		if ($count) {
822
+			$where                 = isset($query_params[0]) ? array($query_params[0]) : array();
823
+			$query_params['limit'] = null;
824
+			$results               = $questionGroupModel->count_deleted($where);
825
+		} else {
826
+			$results = $questionGroupModel->get_all_deleted($query_params);
827
+		}
828
+		return $results;
829
+	}
830
+
831
+
832
+	/**
833
+	 * method for performing updates to question order
834
+	 *
835
+	 * @return array results array
836
+	 */
837
+	public function update_question_group_order()
838
+	{
839
+
840
+		$success = esc_html__('Question group order was updated successfully.', 'event_espresso');
841
+
842
+		// grab our row IDs
843
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
844
+			? explode(',', rtrim($this->_req_data['row_ids'], ','))
845
+			: array();
846
+
847
+		$perpage = ! empty($this->_req_data['perpage'])
848
+			? (int)$this->_req_data['perpage']
849
+			: null;
850
+		$curpage = ! empty($this->_req_data['curpage'])
851
+			? (int)$this->_req_data['curpage']
852
+			: null;
853
+
854
+		if (! empty($row_ids)) {
855
+			//figure out where we start the row_id count at for the current page.
856
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
857
+
858
+			$row_count = count($row_ids);
859
+			for ($i = 0; $i < $row_count; $i++) {
860
+				//Update the questions when re-ordering
861
+				$updated = EEM_Question_Group::instance()->update(
862
+					array('QSG_order' => $qsgcount),
863
+					array(array('QSG_ID' => $row_ids[$i]))
864
+				);
865
+				if ($updated === false) {
866
+					$success = false;
867
+				}
868
+				$qsgcount++;
869
+			}
870
+		} else {
871
+			$success = false;
872
+		}
873
+
874
+		$errors = ! $success
875
+			? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
876
+			: false;
877
+
878
+		echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
879
+		die();
880
+
881
+	}
882
+
883
+
884
+
885
+	/***************************************        REGISTRATION SETTINGS        ***************************************/
886
+
887
+
888
+	/**
889
+	 * _reg_form_settings
890
+	 *
891
+	 * @throws \EE_Error
892
+	 */
893
+	protected function _reg_form_settings()
894
+	{
895
+		$this->_template_args['values'] = $this->_yes_no_values;
896
+		add_action(
897
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
898
+			array($this, 'email_validation_settings_form'),
899
+			2
900
+		);
901
+		$this->_template_args = (array)apply_filters(
902
+			'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
903
+			$this->_template_args
904
+		);
905
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
906
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
907
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
908
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
909
+			$this->_template_args,
910
+			true
911
+		);
912
+		$this->display_admin_page_with_sidebar();
913
+	}
914
+
915
+
916
+	/**
917
+	 * _update_reg_form_settings
918
+	 */
919
+	protected function _update_reg_form_settings()
920
+	{
921
+		EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
922
+			EE_Registry::instance()->CFG->registration
923
+		);
924
+		EE_Registry::instance()->CFG->registration = apply_filters(
925
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
926
+			EE_Registry::instance()->CFG->registration
927
+		);
928
+		$success                                   = $this->_update_espresso_configuration(
929
+			esc_html__('Registration Form Options', 'event_espresso'),
930
+			EE_Registry::instance()->CFG,
931
+			__FILE__, __FUNCTION__, __LINE__
932
+		);
933
+		$this->_redirect_after_action($success, esc_html__('Registration Form Options', 'event_espresso'), 'updated',
934
+			array('action' => 'view_reg_form_settings'));
935
+	}
936
+
937
+
938
+	/**
939
+	 * email_validation_settings_form
940
+	 *
941
+	 * @access    public
942
+	 * @return    void
943
+	 * @throws \EE_Error
944
+	 */
945
+	public function email_validation_settings_form()
946
+	{
947
+		echo $this->_email_validation_settings_form()->get_html();
948
+	}
949
+
950
+
951
+	/**
952
+	 * _email_validation_settings_form
953
+	 *
954
+	 * @access protected
955
+	 * @return EE_Form_Section_Proper
956
+	 * @throws \EE_Error
957
+	 */
958
+	protected function _email_validation_settings_form()
959
+	{
960
+		return new EE_Form_Section_Proper(
961
+			array(
962
+				'name'            => 'email_validation_settings',
963
+				'html_id'         => 'email_validation_settings',
964
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
965
+				'subsections'     => apply_filters(
966
+					'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
967
+					array(
968
+						'email_validation_hdr'   => new EE_Form_Section_HTML(
969
+							EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
970
+						),
971
+						'email_validation_level' => new EE_Select_Input(
972
+							array(
973
+								'basic'      => esc_html__('Basic', 'event_espresso'),
974
+								'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
975
+								'i18n'       => esc_html__('International', 'event_espresso'),
976
+								'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
977
+							),
978
+							array(
979
+								'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
980
+													 . EEH_Template::get_help_tab_link('email_validation_info'),
981
+								'html_help_text'  => esc_html__('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
982
+									'event_espresso'),
983
+								'default'         => isset(EE_Registry::instance()->CFG->registration->email_validation_level)
984
+									? EE_Registry::instance()->CFG->registration->email_validation_level
985
+									: 'wp_default',
986
+								'required'        => false,
987
+							)
988
+						),
989
+					)
990
+				),
991
+			)
992
+		);
993
+	}
994
+
995
+
996
+	/**
997
+	 * update_email_validation_settings_form
998
+	 *
999
+	 * @access    public
1000
+	 * @param \EE_Registration_Config $EE_Registration_Config
1001
+	 * @return \EE_Registration_Config
1002
+	 */
1003
+	public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1004
+	{
1005
+		$prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1006
+		try {
1007
+			$email_validation_settings_form = $this->_email_validation_settings_form();
1008
+			// if not displaying a form, then check for form submission
1009
+			if ($email_validation_settings_form->was_submitted()) {
1010
+				// capture form data
1011
+				$email_validation_settings_form->receive_form_submission();
1012
+				// validate form data
1013
+				if ($email_validation_settings_form->is_valid()) {
1014
+					// grab validated data from form
1015
+					$valid_data = $email_validation_settings_form->valid_data();
1016
+					if (isset($valid_data['email_validation_level'])) {
1017
+						$email_validation_level = $valid_data['email_validation_level'];
1018
+						// now if they want to use international email addresses
1019
+						if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1020
+							// in case we need to reset their email validation level,
1021
+							// make sure that the previous value wasn't already set to one of the i18n options.
1022
+							if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1023
+								// if so, then reset it back to "basic" since that is the only other option that,
1024
+								// despite offering poor validation, supports i18n email addresses
1025
+								$prev_email_validation_level = 'basic';
1026
+							}
1027
+							// confirm our i18n email validation will work on the server
1028
+							if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1029
+								// or reset email validation level to previous value
1030
+								$email_validation_level = $prev_email_validation_level;
1031
+							}
1032
+						}
1033
+						$EE_Registration_Config->email_validation_level = $email_validation_level;
1034
+					} else {
1035
+						EE_Error::add_error(
1036
+							esc_html__(
1037
+								'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1038
+								'event_espresso'
1039
+							),
1040
+							__FILE__, __FUNCTION__, __LINE__
1041
+						);
1042
+					}
1043
+				} else {
1044
+					if ($email_validation_settings_form->submission_error_message() !== '') {
1045
+						EE_Error::add_error(
1046
+							$email_validation_settings_form->submission_error_message(),
1047
+							__FILE__, __FUNCTION__, __LINE__
1048
+						);
1049
+					}
1050
+				}
1051
+			}
1052
+		} catch (EE_Error $e) {
1053
+			$e->get_error();
1054
+		}
1055
+		return $EE_Registration_Config;
1056
+	}
1057
+
1058
+
1059
+	/**
1060
+	 * confirms that the server's PHP version has the PCRE module enabled,
1061
+	 * and that the PCRE version works with our i18n email validation
1062
+	 *
1063
+	 * @param \EE_Registration_Config $EE_Registration_Config
1064
+	 * @param string                  $email_validation_level
1065
+	 * @return bool
1066
+	 */
1067
+	private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1068
+	{
1069
+		// first check that PCRE is enabled
1070
+		if (! defined('PREG_BAD_UTF8_ERROR')) {
1071
+			EE_Error::add_error(
1072
+				sprintf(
1073
+					esc_html__(
1074
+						'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1075
+						'event_espresso'
1076
+					),
1077
+					'<br />'
1078
+				),
1079
+				__FILE__,
1080
+				__FUNCTION__,
1081
+				__LINE__
1082
+			);
1083
+			return false;
1084
+		} else {
1085
+			// PCRE support is enabled, but let's still
1086
+			// perform a test to see if the server will support it.
1087
+			// but first, save the updated validation level to the config,
1088
+			// so that the validation strategy picks it up.
1089
+			// this will get bumped back down if it doesn't work
1090
+			$EE_Registration_Config->email_validation_level = $email_validation_level;
1091
+			try {
1092
+				$email_validator    = new EE_Email_Validation_Strategy();
1093
+				$i18n_email_address = apply_filters(
1094
+					'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1095
+					'jägerjü[email protected]'
1096
+				);
1097
+				$email_validator->validate($i18n_email_address);
1098
+			} catch (Exception $e) {
1099
+				EE_Error::add_error(
1100
+					sprintf(
1101
+						esc_html__(
1102
+							'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1103
+							'event_espresso'
1104
+						),
1105
+						'<br />',
1106
+						'<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>'
1107
+					),
1108
+					__FILE__, __FUNCTION__, __LINE__
1109
+				);
1110
+				return false;
1111
+			}
1112
+		}
1113
+		return true;
1114
+	}
1115 1115
 
1116 1116
 
1117 1117
 }
Please login to merge, or discard this patch.
core/wordpress-shims.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -5,51 +5,51 @@
 block discarded – undo
5 5
  * it does not override any existing definition of the function in WP.
6 6
  */
7 7
 if ( ! function_exists( 'get_preview_post_link' ) ) {
8
-    /**
9
-     * Function was added in WordPress 4.4.0
10
-     * @param null   $post
11
-     * @param array  $query_args
12
-     * @param string $preview_link
13
-     * @return mixed
14
-     */
15
-    function get_preview_post_link($post = null, $query_args = array(), $preview_link = '')
16
-    {
17
-        $post = get_post($post);
18
-        if (! $post) {
19
-            return '';
20
-        }
8
+	/**
9
+	 * Function was added in WordPress 4.4.0
10
+	 * @param null   $post
11
+	 * @param array  $query_args
12
+	 * @param string $preview_link
13
+	 * @return mixed
14
+	 */
15
+	function get_preview_post_link($post = null, $query_args = array(), $preview_link = '')
16
+	{
17
+		$post = get_post($post);
18
+		if (! $post) {
19
+			return '';
20
+		}
21 21
 
22
-        $post_type_object = get_post_type_object($post->post_type);
23
-        if (is_post_type_viewable($post_type_object)) {
24
-            if (! $preview_link) {
25
-                $preview_link = set_url_scheme(get_permalink($post));
26
-            }
22
+		$post_type_object = get_post_type_object($post->post_type);
23
+		if (is_post_type_viewable($post_type_object)) {
24
+			if (! $preview_link) {
25
+				$preview_link = set_url_scheme(get_permalink($post));
26
+			}
27 27
 
28
-            $query_args['preview'] = 'true';
29
-            $preview_link          = add_query_arg($query_args, $preview_link);
30
-        }
28
+			$query_args['preview'] = 'true';
29
+			$preview_link          = add_query_arg($query_args, $preview_link);
30
+		}
31 31
 
32
-        /**
33
-         * Filters the URL used for a post preview.
34
-         *
35
-         * @since 2.0.5
36
-         * @since 4.0.0 Added the `$post` parameter.
37
-         * @param string  $preview_link URL used for the post preview.
38
-         * @param WP_Post $post         Post object.
39
-         */
40
-        return apply_filters('preview_post_link', $preview_link, $post);
41
-    }
32
+		/**
33
+		 * Filters the URL used for a post preview.
34
+		 *
35
+		 * @since 2.0.5
36
+		 * @since 4.0.0 Added the `$post` parameter.
37
+		 * @param string  $preview_link URL used for the post preview.
38
+		 * @param WP_Post $post         Post object.
39
+		 */
40
+		return apply_filters('preview_post_link', $preview_link, $post);
41
+	}
42 42
 }
43 43
 
44 44
 if ( ! function_exists( 'is_post_type_viewable' ) ) {
45
-    function is_post_type_viewable( $post_type ) {
46
-        if ( is_scalar( $post_type ) ) {
47
-            $post_type = get_post_type_object( $post_type );
48
-            if ( ! $post_type ) {
49
-                return false;
50
-            }
51
-        }
45
+	function is_post_type_viewable( $post_type ) {
46
+		if ( is_scalar( $post_type ) ) {
47
+			$post_type = get_post_type_object( $post_type );
48
+			if ( ! $post_type ) {
49
+				return false;
50
+			}
51
+		}
52 52
      
53
-        return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
54
-    }
53
+		return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
54
+	}
55 55
 }
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * Note: this file should only be required right before calling the function the shim is for.  This is to ensure that
5 5
  * it does not override any existing definition of the function in WP.
6 6
  */
7
-if ( ! function_exists( 'get_preview_post_link' ) ) {
7
+if ( ! function_exists('get_preview_post_link')) {
8 8
     /**
9 9
      * Function was added in WordPress 4.4.0
10 10
      * @param null   $post
@@ -15,13 +15,13 @@  discard block
 block discarded – undo
15 15
     function get_preview_post_link($post = null, $query_args = array(), $preview_link = '')
16 16
     {
17 17
         $post = get_post($post);
18
-        if (! $post) {
18
+        if ( ! $post) {
19 19
             return '';
20 20
         }
21 21
 
22 22
         $post_type_object = get_post_type_object($post->post_type);
23 23
         if (is_post_type_viewable($post_type_object)) {
24
-            if (! $preview_link) {
24
+            if ( ! $preview_link) {
25 25
                 $preview_link = set_url_scheme(get_permalink($post));
26 26
             }
27 27
 
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
     }
42 42
 }
43 43
 
44
-if ( ! function_exists( 'is_post_type_viewable' ) ) {
45
-    function is_post_type_viewable( $post_type ) {
46
-        if ( is_scalar( $post_type ) ) {
47
-            $post_type = get_post_type_object( $post_type );
48
-            if ( ! $post_type ) {
44
+if ( ! function_exists('is_post_type_viewable')) {
45
+    function is_post_type_viewable($post_type) {
46
+        if (is_scalar($post_type)) {
47
+            $post_type = get_post_type_object($post_type);
48
+            if ( ! $post_type) {
49 49
                 return false;
50 50
             }
51 51
         }
52 52
      
53
-        return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
53
+        return $post_type->publicly_queryable || ($post_type->_builtin && $post_type->public);
54 54
     }
55 55
 }
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
core/helpers/EEH_File.helper.php 4 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -325,8 +325,8 @@
 block discarded – undo
325 325
 		//eg if given "/var/something/somewhere/", we want to get "somewhere"'s
326 326
 		//parent folder, "/var/something/"
327 327
 		$ds = strlen($file_or_folder_path) > 1
328
-            ? strrpos($file_or_folder_path, DS, -2)
329
-            : strlen($file_or_folder_path);
328
+			? strrpos($file_or_folder_path, DS, -2)
329
+			: strlen($file_or_folder_path);
330 330
 		return substr($file_or_folder_path, 0, $ds + 1);
331 331
 	}
332 332
 
Please login to merge, or discard this patch.
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -658,8 +658,6 @@
 block discarded – undo
658 658
 	 * converts it into a "remote" filepath (the filepath the currently-in-use
659 659
 	 * $wp_filesystem needs to use access the folder or file).
660 660
 	 * See http://wordpress.stackexchange.com/questions/124900/using-wp-filesystem-in-plugins
661
-	 * @param WP_Filesystem_Base $wp_filesystem we aren't initially sure which one
662
-	 * is in use, so you need to provide it
663 661
 	 * @param string $local_filepath the filepath to the folder/file locally
664 662
 	 * @throws EE_Error if filesystem credentials are required
665 663
 	 * @return string the remote filepath (eg the filepath the filesystem method, eg
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -38,30 +38,30 @@  discard block
 block discarded – undo
38 38
 	 * @throws EE_Error if filesystem credentials are required
39 39
 	 * @return WP_Filesystem_Base
40 40
 	 */
41
-	private static function _get_wp_filesystem( $filepath = null) {
42
-		if( apply_filters(
41
+	private static function _get_wp_filesystem($filepath = null) {
42
+		if (apply_filters(
43 43
 				'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct',
44
-				$filepath && EEH_File::is_in_uploads_folder( $filepath ),
45
-				$filepath ) ) {
46
-			if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) {
47
-				require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
44
+				$filepath && EEH_File::is_in_uploads_folder($filepath),
45
+				$filepath )) {
46
+			if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) {
47
+				require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php');
48 48
 				$method = 'direct';
49
-				$wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
49
+				$wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method);
50 50
 				//check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem()
51
-				if ( ! defined('FS_CHMOD_DIR') ) {
52
-					define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
51
+				if ( ! defined('FS_CHMOD_DIR')) {
52
+					define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755));
53 53
 				}
54
-				if ( ! defined('FS_CHMOD_FILE') ) {
55
-					define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
54
+				if ( ! defined('FS_CHMOD_FILE')) {
55
+					define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644));
56 56
 				}
57
-				require_once( $wp_filesystem_direct_file );
58
-				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() );
57
+				require_once($wp_filesystem_direct_file);
58
+				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array());
59 59
 			}
60 60
 			return EEH_File::$_wp_filesystem_direct;
61 61
 		}
62 62
 		global $wp_filesystem;
63 63
 		// no filesystem setup ???
64
-		if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
64
+		if ( ! $wp_filesystem instanceof WP_Filesystem_Base) {
65 65
 			// if some eager beaver's just trying to get in there too early...
66 66
 			// let them do it, because we are one of those eager beavers! :P
67 67
 			/**
@@ -74,34 +74,34 @@  discard block
 block discarded – undo
74 74
 			 * and there may be troubles if the WP files are owned by a different user
75 75
 			 * than the server user. But both of these issues should exist in 4.4 and earlier too
76 76
 			 */
77
-			if ( FALSE && ! did_action( 'wp_loaded' )) {
77
+			if (FALSE && ! did_action('wp_loaded')) {
78 78
 				$msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso');
79
-				if ( WP_DEBUG ) {
80
-					$msg .= '<br />' .  __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
79
+				if (WP_DEBUG) {
80
+					$msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
81 81
 				}
82
-				throw new EE_Error( $msg );
82
+				throw new EE_Error($msg);
83 83
 			} else {
84 84
 				// should be loaded if we are past the wp_loaded hook...
85
-				if ( ! function_exists( 'WP_Filesystem' )) {
86
-					require_once( ABSPATH . 'wp-admin/includes/file.php' );
87
-					require_once( ABSPATH . 'wp-admin/includes/template.php' );
85
+				if ( ! function_exists('WP_Filesystem')) {
86
+					require_once(ABSPATH.'wp-admin/includes/file.php');
87
+					require_once(ABSPATH.'wp-admin/includes/template.php');
88 88
 				}
89 89
 				// turn on output buffering so that we can capture the credentials form
90 90
 				ob_start();
91
-				$credentials = request_filesystem_credentials( '' );
91
+				$credentials = request_filesystem_credentials('');
92 92
 				// store credentials form for the time being
93 93
 				EEH_File::$_credentials_form = ob_get_clean();
94 94
 				// basically check for direct or previously configured access
95
-				if ( ! WP_Filesystem( $credentials ) ) {
95
+				if ( ! WP_Filesystem($credentials)) {
96 96
 					// if credentials do NOT exist
97
-					if ( $credentials === FALSE ) {
98
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
99
-						throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
100
-					} elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
101
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
97
+					if ($credentials === FALSE) {
98
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
99
+						throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
100
+					} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
101
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
102 102
 						throw new EE_Error(
103 103
 								sprintf(
104
-										__( 'WP Filesystem Error: $1%s', 'event_espresso' ),
104
+										__('WP Filesystem Error: $1%s', 'event_espresso'),
105 105
 										$wp_filesystem->errors->get_error_message() ) );
106 106
 					}
107 107
 				}
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * display_request_filesystem_credentials_form
115 115
 	 */
116 116
 	public static function display_request_filesystem_credentials_form() {
117
-		if ( ! empty( EEH_File::$_credentials_form )) {
118
-			echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>';
117
+		if ( ! empty(EEH_File::$_credentials_form)) {
118
+			echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>';
119 119
 		}
120 120
 	}
121 121
 
@@ -133,29 +133,29 @@  discard block
 block discarded – undo
133 133
 	 * @throws EE_Error if filesystem credentials are required
134 134
 	 * @return bool
135 135
 	 */
136
-	public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) {
136
+	public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') {
137 137
 		// load WP_Filesystem and set file permissions
138
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
139
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
140
-		if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) {
141
-			$file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name;
142
-			$file_name .= ! empty( $file_ext ) ? ' file' : ' folder';
138
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
139
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
140
+		if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
141
+			$file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name;
142
+			$file_name .= ! empty($file_ext) ? ' file' : ' folder';
143 143
 			$msg = sprintf(
144
-				__( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ),
144
+				__('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'),
145 145
 				$file_name,
146 146
 				'<br />'
147 147
 			);
148
-			if ( EEH_File::exists( $full_file_path )) {
149
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file );
148
+			if (EEH_File::exists($full_file_path)) {
149
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file);
150 150
 			} else {
151 151
 				// no file permissions means the file was not found
152 152
 				$msg .= sprintf(
153
-					__( 'Please ensure the following path is correct: "%s".', 'event_espresso' ),
153
+					__('Please ensure the following path is correct: "%s".', 'event_espresso'),
154 154
 					$full_file_path
155 155
 				);
156 156
 			}
157
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
158
-				throw new EE_Error( $msg . '||' . $msg );
157
+			if (defined('WP_DEBUG') && WP_DEBUG) {
158
+				throw new EE_Error($msg.'||'.$msg);
159 159
 			}
160 160
 			return FALSE;
161 161
 		}
@@ -173,24 +173,24 @@  discard block
 block discarded – undo
173 173
 	 * @throws EE_Error if filesystem credentials are required
174 174
 	 * @return string
175 175
 	 */
176
-	private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){
176
+	private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') {
177 177
 		// load WP_Filesystem and set file permissions
178
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
178
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
179 179
 		// check file permissions
180
-		$perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
181
-		if ( $perms ) {
180
+		$perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
181
+		if ($perms) {
182 182
 			// file permissions exist, but way be set incorrectly
183
-			$type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : '';
184
-			$type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder';
183
+			$type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : '';
184
+			$type_of_file .= ! empty($type_of_file) ? 'file' : 'folder';
185 185
 			return sprintf(
186
-				__( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ),
186
+				__('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'),
187 187
 				$type_of_file,
188 188
 				$perms
189 189
 			);
190 190
 		} else {
191 191
 			// file exists but file permissions could not be read ?!?!
192 192
 			return sprintf(
193
-				__( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ),
193
+				__('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'),
194 194
 				$full_file_path
195 195
 			);
196 196
 		}
@@ -208,35 +208,35 @@  discard block
 block discarded – undo
208 208
 	 * can't write to it
209 209
 	 * @return bool false if folder isn't writable; true if it exists and is writeable,
210 210
 	 */
211
-	public static function ensure_folder_exists_and_is_writable( $folder = '' ){
212
-		if ( empty( $folder )) {
211
+	public static function ensure_folder_exists_and_is_writable($folder = '') {
212
+		if (empty($folder)) {
213 213
 			return false;
214 214
 		}
215 215
 		// remove ending DS
216
-		$folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' ));
217
-		$parent_folder = EEH_File::get_parent_folder( $folder );
216
+		$folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\'));
217
+		$parent_folder = EEH_File::get_parent_folder($folder);
218 218
 		// add DS to folder
219
-		$folder = EEH_File::end_with_directory_separator( $folder );
220
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $folder );
221
-		if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) {
219
+		$folder = EEH_File::end_with_directory_separator($folder);
220
+		$wp_filesystem = EEH_File::_get_wp_filesystem($folder);
221
+		if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
222 222
 			//ok so it doesn't exist. Does its parent? Can we write to it?
223
-			if(	! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
223
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
224 224
 				return false;
225 225
 			}
226
-			if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) {
226
+			if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) {
227 227
 				return false;
228 228
 			} else {
229
-				if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath(  $folder ) ) ) {
230
-					if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
231
-						$msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder );
232
-						$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder );
233
-						throw new EE_Error( $msg );
229
+				if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
230
+					if (defined('WP_DEBUG') && WP_DEBUG) {
231
+						$msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder);
232
+						$msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder);
233
+						throw new EE_Error($msg);
234 234
 					}
235 235
 					return false;
236 236
 				}
237
-				EEH_File::add_index_file( $folder );
237
+				EEH_File::add_index_file($folder);
238 238
 			}
239
-		} elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
239
+		} elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) {
240 240
 			return false;
241 241
 		}
242 242
 		return true;
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
 	 * @throws EE_Error if filesystem credentials are required
252 252
 	 * @return bool
253 253
 	 */
254
-	public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){
254
+	public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') {
255 255
 		// load WP_Filesystem and set file permissions
256
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_path );
257
-		$full_path = EEH_File::standardise_directory_separators( $full_path );
258
-		if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) {
259
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
260
-				$msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder );
261
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path );
262
-				throw new EE_Error( $msg );
256
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_path);
257
+		$full_path = EEH_File::standardise_directory_separators($full_path);
258
+		if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) {
259
+			if (defined('WP_DEBUG') && WP_DEBUG) {
260
+				$msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder);
261
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path);
262
+				throw new EE_Error($msg);
263 263
 			}
264 264
 			return FALSE;
265 265
 		}
@@ -276,25 +276,25 @@  discard block
 block discarded – undo
276 276
 	 * @throws EE_Error if filesystem credentials are required
277 277
 	 * @return bool
278 278
 	 */
279
-	public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) {
279
+	public static function ensure_file_exists_and_is_writable($full_file_path = '') {
280 280
 		// load WP_Filesystem and set file permissions
281
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
282
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
283
-		$parent_folder = EEH_File::get_parent_folder( $full_file_path );
284
-		if ( ! EEH_File::exists( $full_file_path )) {
285
-			if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
281
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
282
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
283
+		$parent_folder = EEH_File::get_parent_folder($full_file_path);
284
+		if ( ! EEH_File::exists($full_file_path)) {
285
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
286 286
 				return false;
287 287
 			}
288
-			if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) {
289
-				if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
290
-					$msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path );
291
-					$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
292
-					throw new EE_Error( $msg );
288
+			if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
289
+				if (defined('WP_DEBUG') && WP_DEBUG) {
290
+					$msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path);
291
+					$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
292
+					throw new EE_Error($msg);
293 293
 				}
294 294
 				return false;
295 295
 			}
296 296
 		}
297
-		if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) {
297
+		if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) {
298 298
 			return false;
299 299
 		}
300 300
 		return true;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @param string $file_or_folder_path
307 307
 	 * @return string parent folder, ENDING with a directory separator
308 308
 	 */
309
-	public static function get_parent_folder( $file_or_folder_path ) {
309
+	public static function get_parent_folder($file_or_folder_path) {
310 310
 		//find the last DS, ignoring a DS on the very end
311 311
 		//eg if given "/var/something/somewhere/", we want to get "somewhere"'s
312 312
 		//parent folder, "/var/something/"
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
 	 * @throws EE_Error if filesystem credentials are required
329 329
 	 * @return string
330 330
 	 */
331
-	public static function get_file_contents( $full_file_path = '' ){
332
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
333
-		if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) {
331
+	public static function get_file_contents($full_file_path = '') {
332
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
333
+		if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) {
334 334
 			// load WP_Filesystem and set file permissions
335
-			$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
336
-			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
335
+			$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
336
+			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
337 337
 		}
338 338
 		return '';
339 339
 	}
@@ -348,26 +348,26 @@  discard block
 block discarded – undo
348 348
 	 * @throws EE_Error if filesystem credentials are required
349 349
 	 * @return bool
350 350
 	 */
351
-	public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){
352
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
353
-		$file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : '';
354
-		$folder = EEH_File::remove_filename_from_filepath( $full_file_path );
355
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
356
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
357
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path );
358
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
359
-				throw new EE_Error( $msg );
351
+	public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') {
352
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
353
+		$file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : '';
354
+		$folder = EEH_File::remove_filename_from_filepath($full_file_path);
355
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
356
+			if (defined('WP_DEBUG') && WP_DEBUG) {
357
+				$msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path);
358
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
359
+				throw new EE_Error($msg);
360 360
 			}
361 361
 			return FALSE;
362 362
 		}
363 363
 		// load WP_Filesystem and set file permissions
364
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
364
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
365 365
 		// write the file
366
-		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) {
367
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
368
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path );
369
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' );
370
-				throw new EE_Error( $msg );
366
+		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) {
367
+			if (defined('WP_DEBUG') && WP_DEBUG) {
368
+				$msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path);
369
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f');
370
+				throw new EE_Error($msg);
371 371
 			}
372 372
 			return FALSE;
373 373
 		}
@@ -383,9 +383,9 @@  discard block
 block discarded – undo
383 383
 	 * @throws EE_Error if filesystem credentials are required
384 384
 	 * @return boolean
385 385
 	 */
386
-	public static function delete( $filepath, $recursive = false, $type = false ) {
386
+	public static function delete($filepath, $recursive = false, $type = false) {
387 387
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
388
-		return $wp_filesystem->delete( $filepath, $recursive, $type ) ? TRUE : FALSE;
388
+		return $wp_filesystem->delete($filepath, $recursive, $type) ? TRUE : FALSE;
389 389
 	}
390 390
 
391 391
 
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 	 * @throws EE_Error if filesystem credentials are required
398 398
 	 * @return bool
399 399
 	 */
400
-	public static function exists( $full_file_path = '' ) {
401
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
402
-		return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE;
400
+	public static function exists($full_file_path = '') {
401
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
402
+		return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE;
403 403
 	}
404 404
 
405 405
 
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 	 * @throws EE_Error if filesystem credentials are required
413 413
 	 * @return bool
414 414
 	 */
415
-	public static function is_readable( $full_file_path = '' ) {
416
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
417
-		if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath(  $full_file_path ) ) ) {
415
+	public static function is_readable($full_file_path = '') {
416
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
417
+		if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
418 418
 			return true;
419 419
 		} else {
420 420
 			return false;
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 	 * @param string $full_file_path
431 431
 	 * @return string
432 432
 	 */
433
-	public static function remove_filename_from_filepath( $full_file_path = '' ) {
434
-		return pathinfo( $full_file_path, PATHINFO_DIRNAME );
433
+	public static function remove_filename_from_filepath($full_file_path = '') {
434
+		return pathinfo($full_file_path, PATHINFO_DIRNAME);
435 435
 	}
436 436
 
437 437
 
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @param string $full_file_path
442 442
 	 * @return string
443 443
 	 */
444
-	public static function get_filename_from_filepath( $full_file_path = '' ) {
445
-		return pathinfo( $full_file_path, PATHINFO_BASENAME );
444
+	public static function get_filename_from_filepath($full_file_path = '') {
445
+		return pathinfo($full_file_path, PATHINFO_BASENAME);
446 446
 	}
447 447
 
448 448
 
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 * @param string $full_file_path
453 453
 	 * @return string
454 454
 	 */
455
-	public static function get_file_extension( $full_file_path = '' ) {
456
-		return pathinfo( $full_file_path, PATHINFO_EXTENSION );
455
+	public static function get_file_extension($full_file_path = '') {
456
+		return pathinfo($full_file_path, PATHINFO_EXTENSION);
457 457
 	}
458 458
 
459 459
 
@@ -464,10 +464,10 @@  discard block
 block discarded – undo
464 464
 	 * @throws EE_Error if filesystem credentials are required
465 465
 	 * @return bool
466 466
 	 */
467
-	public static function add_htaccess_deny_from_all( $folder = '' ) {
468
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
469
-		if ( ! EEH_File::exists( $folder . '.htaccess' ) ) {
470
-			if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) {
467
+	public static function add_htaccess_deny_from_all($folder = '') {
468
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
469
+		if ( ! EEH_File::exists($folder.'.htaccess')) {
470
+			if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) {
471 471
 				return FALSE;
472 472
 			}
473 473
 		}
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	 * @throws EE_Error if filesystem credentials are required
482 482
 	 * @return boolean
483 483
 	 */
484
-	public static function add_index_file( $folder ) {
485
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
486
-		if ( ! EEH_File::exists( $folder . 'index.php' ) ) {
487
-			if ( ! EEH_File::write_to_file( $folder . 'index.php', 'You are not permitted to read from this folder', '.php' )) {
484
+	public static function add_index_file($folder) {
485
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
486
+		if ( ! EEH_File::exists($folder.'index.php')) {
487
+			if ( ! EEH_File::write_to_file($folder.'index.php', 'You are not permitted to read from this folder', '.php')) {
488 488
 				return false;
489 489
 			}
490 490
 		}
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
 	 * @param string $file_path
500 500
 	 * @return string
501 501
 	 */
502
-	public static function get_classname_from_filepath_with_standard_filename( $file_path ){
502
+	public static function get_classname_from_filepath_with_standard_filename($file_path) {
503 503
 		//extract file from path
504
-		$filename = basename( $file_path );
504
+		$filename = basename($file_path);
505 505
 		//now remove the first period and everything after
506
-		$pos_of_first_period = strpos( $filename,'.' );
506
+		$pos_of_first_period = strpos($filename, '.');
507 507
 		return substr($filename, 0, $pos_of_first_period);
508 508
 	}
509 509
 
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
 	 * @param string $file_path
516 516
 	 * @return string
517 517
 	 */
518
-	public static function standardise_directory_separators( $file_path ){
519
-		return str_replace( array( '\\', '/' ), DS, $file_path );
518
+	public static function standardise_directory_separators($file_path) {
519
+		return str_replace(array('\\', '/'), DS, $file_path);
520 520
 	}
521 521
 
522 522
 
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	 * @param string $file_path
528 528
 	 * @return string
529 529
 	 */
530
-	public static function end_with_directory_separator( $file_path ){
531
-		return rtrim( $file_path, '/\\' ) . DS;
530
+	public static function end_with_directory_separator($file_path) {
531
+		return rtrim($file_path, '/\\').DS;
532 532
 	}
533 533
 
534 534
 
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 	 * @param $file_path
539 539
 	 * @return string
540 540
 	 */
541
-	public static function standardise_and_end_with_directory_separator( $file_path ){
542
-		return self::end_with_directory_separator( self::standardise_directory_separators( $file_path ));
541
+	public static function standardise_and_end_with_directory_separator($file_path) {
542
+		return self::end_with_directory_separator(self::standardise_directory_separators($file_path));
543 543
 	}
544 544
 
545 545
 
@@ -556,21 +556,21 @@  discard block
 block discarded – undo
556 556
 	 *		if $index_numerically == FALSE (Default) keys are what the class names SHOULD be;
557 557
 	 *		 and values are their filepaths
558 558
 	 */
559
-	public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){
559
+	public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) {
560 560
 		$class_to_folder_path = array();
561
-		foreach( $folder_paths as $folder_path ){
562
-			$folder_path = self::standardise_and_end_with_directory_separator( $folder_path );
561
+		foreach ($folder_paths as $folder_path) {
562
+			$folder_path = self::standardise_and_end_with_directory_separator($folder_path);
563 563
 			// load WP_Filesystem and set file permissions
564
-			$files_in_folder = glob( $folder_path . '*' );
564
+			$files_in_folder = glob($folder_path.'*');
565 565
 			$class_to_folder_path = array();
566
-			if ( $files_in_folder ) {
567
-				foreach( $files_in_folder as $file_path ){
566
+			if ($files_in_folder) {
567
+				foreach ($files_in_folder as $file_path) {
568 568
 					//only add files, not folders
569
-					if ( ! is_dir( $file_path )) {
570
-						if ( $index_numerically ) {
569
+					if ( ! is_dir($file_path)) {
570
+						if ($index_numerically) {
571 571
 							$class_to_folder_path[] = $file_path;
572 572
 						} else {
573
-							$classname = self::get_classname_from_filepath_with_standard_filename( $file_path );
573
+							$classname = self::get_classname_from_filepath_with_standard_filename($file_path);
574 574
 							$class_to_folder_path[$classname] = $file_path;
575 575
 						}
576 576
 					}
@@ -590,39 +590,39 @@  discard block
 block discarded – undo
590 590
 	 * @throws EE_Error if filesystem credentials are required
591 591
 	 * @return boolean success
592 592
 	 */
593
-	public static function copy( $source_file, $destination_file, $overwrite = FALSE ){
594
-		$full_source_path = EEH_File::standardise_directory_separators( $source_file );
595
-		if( ! EEH_File::exists( $full_source_path ) ){
596
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
597
-				$msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path );
598
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path );
599
-				throw new EE_Error( $msg );
593
+	public static function copy($source_file, $destination_file, $overwrite = FALSE) {
594
+		$full_source_path = EEH_File::standardise_directory_separators($source_file);
595
+		if ( ! EEH_File::exists($full_source_path)) {
596
+			if (defined('WP_DEBUG') && WP_DEBUG) {
597
+				$msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path);
598
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path);
599
+				throw new EE_Error($msg);
600 600
 			}
601 601
 			return FALSE;
602 602
 		}
603 603
 
604
-		$full_dest_path = EEH_File::standardise_directory_separators( $destination_file );
605
-		$folder = EEH_File::remove_filename_from_filepath( $full_dest_path );
606
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
607
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
608
-				$msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path );
609
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path );
610
-				throw new EE_Error( $msg );
604
+		$full_dest_path = EEH_File::standardise_directory_separators($destination_file);
605
+		$folder = EEH_File::remove_filename_from_filepath($full_dest_path);
606
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
607
+			if (defined('WP_DEBUG') && WP_DEBUG) {
608
+				$msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path);
609
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path);
610
+				throw new EE_Error($msg);
611 611
 			}
612 612
 			return FALSE;
613 613
 		}
614 614
 
615 615
 		// load WP_Filesystem and set file permissions
616
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file );
616
+		$wp_filesystem = EEH_File::_get_wp_filesystem($destination_file);
617 617
 		// write the file
618 618
 		if ( ! $wp_filesystem->copy(
619
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ),
620
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ),
619
+						EEH_File::convert_local_filepath_to_remote_filepath($full_source_path),
620
+						EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path),
621 621
 						$overwrite )) {
622
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
623
-				$msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path );
624
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' );
625
-				throw new EE_Error( $msg );
622
+			if (defined('WP_DEBUG') && WP_DEBUG) {
623
+				$msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path);
624
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f');
625
+				throw new EE_Error($msg);
626 626
 			}
627 627
 			return FALSE;
628 628
 		}
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 * @param string $filepath
635 635
 	 * @return boolean
636 636
 	 */
637
-	public static function is_in_uploads_folder( $filepath ) {
637
+	public static function is_in_uploads_folder($filepath) {
638 638
 		$uploads = wp_upload_dir();
639
-		return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false;
639
+		return strpos($filepath, $uploads['basedir']) === 0 ? true : false;
640 640
 	}
641 641
 
642 642
 	/**
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 	 * @return string the remote filepath (eg the filepath the filesystem method, eg
652 652
 	 * ftp or ssh, will use to access the folder
653 653
 	 */
654
-	public static function convert_local_filepath_to_remote_filepath( $local_filepath ) {
655
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath );
656
-		return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath );
654
+	public static function convert_local_filepath_to_remote_filepath($local_filepath) {
655
+		$wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath);
656
+		return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath);
657 657
 	}
658 658
 }
659 659
 // End of file EEH_File.helper.php
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 
3 5
 /**
4 6
  *
Please login to merge, or discard this patch.
help_tours/Registration_Form_Questions_Overview_Help_Tour.class.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -116,42 +116,42 @@  discard block
 block discarded – undo
116 116
 
117 117
 
118 118
 	protected function _start() {
119
-		$content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>';
120
-		$content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso') . '</p>';
119
+		$content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>';
120
+		$content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso').'</p>';
121 121
 
122 122
 		return $content;
123 123
 	}
124 124
 
125 125
 	protected function _display_text_stop() {
126
-		return '<p>' . __('View available questions.', 'event_espresso') . '</p>';
126
+		return '<p>'.__('View available questions.', 'event_espresso').'</p>';
127 127
 	}
128 128
 
129 129
 	protected function _admin_label_stop() {
130
-		return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>';
130
+		return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>';
131 131
 	}
132 132
 
133 133
 	protected function _type_stop() {
134
-		return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso') . '</p>';
134
+		return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso').'</p>';
135 135
 	}
136 136
 
137 137
 	protected function _values_stop() {
138
-		return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso') . '</p>';
138
+		return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso').'</p>';
139 139
 	}
140 140
 
141 141
 	protected function _required_stop() {
142
-		return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>';
142
+		return '<p>'.__('View if a question is required.', 'event_espresso').'</p>';
143 143
 	}
144 144
 
145 145
 	protected function _bulk_actions_stop() {
146
-		return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>';
146
+		return '<p>'.__('Perform bulk actions to multiple questions.', 'event_espresso').'</p>';
147 147
 	}
148 148
 
149 149
 	protected function _search_stop() {
150
-		return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso') . '</p>';
150
+		return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso').'</p>';
151 151
 	}
152 152
 
153 153
 	protected function _add_new_question_stop() {
154
-		return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>';
154
+		return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>';
155 155
 	}
156 156
 
157 157
 }
158 158
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
Please login to merge, or discard this patch.
help_tours/Registration_Form_Questions_Overview_Help_Tour.class.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -18,64 +18,64 @@  discard block
 block discarded – undo
18 18
 class Registration_Form_Questions_Overview_Help_Tour extends EE_Help_Tour
19 19
 {
20 20
     
21
-    protected function _set_tour_properties()
22
-    {
23
-        $this->_label = __('Questions Overview Tour', 'event_espresso');
24
-        $this->_slug  = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride';
25
-    }
21
+	protected function _set_tour_properties()
22
+	{
23
+		$this->_label = __('Questions Overview Tour', 'event_espresso');
24
+		$this->_slug  = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride';
25
+	}
26 26
     
27
-    protected function _set_tour_stops()
28
-    {
29
-        $this->_stops = array(
30
-            10  => array(
31
-                'content' => $this->_start(),
32
-            ),
33
-            30  => array(
34
-                'id'      => 'display_text',
35
-                'content' => $this->_display_text_stop(),
36
-                'options' => array(
37
-                    'tipLocation'    => 'top',
38
-                    'tipAdjustmentX' => -5,
39
-                    'tipAdjustmentY' => -25
40
-                )
41
-            ),
42
-            40  => array(
43
-                'id'      => 'admin_label',
44
-                'content' => $this->_admin_label_stop(),
45
-                'options' => array(
46
-                    'tipLocation'    => 'top',
47
-                    'tipAdjustmentX' => 20,
48
-                    'tipAdjustmentY' => -25
49
-                )
50
-            ),
51
-            50  => array(
52
-                'id'      => 'type',
53
-                'content' => $this->_type_stop(),
54
-                'options' => array(
55
-                    'tipLocation'    => 'top',
56
-                    'tipAdjustmentX' => -5,
57
-                    'tipAdjustmentY' => -25
58
-                )
59
-            ),
60
-            60  => array(
61
-                'id'      => 'values',
62
-                'content' => $this->_values_stop(),
63
-                'options' => array(
64
-                    'tipLocation'    => 'top',
65
-                    'tipAdjustmentX' => -5,
66
-                    'tipAdjustmentY' => -25
67
-                )
68
-            ),
69
-            70  => array(
70
-                'id'      => 'required',
71
-                'content' => $this->_required_stop(),
72
-                'options' => array(
73
-                    'tipLocation'    => 'top',
74
-                    'tipAdjustmentY' => -20,
75
-                    'tipAdjustmentX' => -15
76
-                )
77
-            ),
78
-            /*80 => array(
27
+	protected function _set_tour_stops()
28
+	{
29
+		$this->_stops = array(
30
+			10  => array(
31
+				'content' => $this->_start(),
32
+			),
33
+			30  => array(
34
+				'id'      => 'display_text',
35
+				'content' => $this->_display_text_stop(),
36
+				'options' => array(
37
+					'tipLocation'    => 'top',
38
+					'tipAdjustmentX' => -5,
39
+					'tipAdjustmentY' => -25
40
+				)
41
+			),
42
+			40  => array(
43
+				'id'      => 'admin_label',
44
+				'content' => $this->_admin_label_stop(),
45
+				'options' => array(
46
+					'tipLocation'    => 'top',
47
+					'tipAdjustmentX' => 20,
48
+					'tipAdjustmentY' => -25
49
+				)
50
+			),
51
+			50  => array(
52
+				'id'      => 'type',
53
+				'content' => $this->_type_stop(),
54
+				'options' => array(
55
+					'tipLocation'    => 'top',
56
+					'tipAdjustmentX' => -5,
57
+					'tipAdjustmentY' => -25
58
+				)
59
+			),
60
+			60  => array(
61
+				'id'      => 'values',
62
+				'content' => $this->_values_stop(),
63
+				'options' => array(
64
+					'tipLocation'    => 'top',
65
+					'tipAdjustmentX' => -5,
66
+					'tipAdjustmentY' => -25
67
+				)
68
+			),
69
+			70  => array(
70
+				'id'      => 'required',
71
+				'content' => $this->_required_stop(),
72
+				'options' => array(
73
+					'tipLocation'    => 'top',
74
+					'tipAdjustmentY' => -20,
75
+					'tipAdjustmentX' => -15
76
+				)
77
+			),
78
+			/*80 => array(
79 79
                 'class' => 'bulkactions',
80 80
                 'content' => $this->_bulk_actions_stop(),
81 81
                 'options' => array(
@@ -84,77 +84,77 @@  discard block
 block discarded – undo
84 84
                     'tipAdjustmentX' => -15
85 85
                     )
86 86
                 ),*/
87
-            90  => array(
88
-                'id'      => 'event-espresso_page_espresso_registration_form-search-input',
89
-                'content' => $this->_search_stop(),
90
-                'options' => array(
91
-                    'tipLocation'    => 'left',
92
-                    'tipAdjustmentY' => -50,
93
-                    'tipAdjustmentX' => -15
94
-                )
95
-            ),
96
-            100 => array(
97
-                'id'      => 'add-new-question',
98
-                'content' => $this->_add_new_question_stop(),
99
-                'options' => array(
100
-                    'tipLocation'    => 'right',
101
-                    'tipAdjustmentY' => -50,
102
-                    'tipAdjustmentX' => 15
103
-                )
104
-            ),
105
-        );
106
-    }
87
+			90  => array(
88
+				'id'      => 'event-espresso_page_espresso_registration_form-search-input',
89
+				'content' => $this->_search_stop(),
90
+				'options' => array(
91
+					'tipLocation'    => 'left',
92
+					'tipAdjustmentY' => -50,
93
+					'tipAdjustmentX' => -15
94
+				)
95
+			),
96
+			100 => array(
97
+				'id'      => 'add-new-question',
98
+				'content' => $this->_add_new_question_stop(),
99
+				'options' => array(
100
+					'tipLocation'    => 'right',
101
+					'tipAdjustmentY' => -50,
102
+					'tipAdjustmentX' => 15
103
+				)
104
+			),
105
+		);
106
+	}
107 107
     
108 108
     
109
-    protected function _start()
110
-    {
111
-        $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>';
112
-        $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.',
113
-                'event_espresso') . '</p>';
109
+	protected function _start()
110
+	{
111
+		$content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>';
112
+		$content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.',
113
+				'event_espresso') . '</p>';
114 114
         
115
-        return $content;
116
-    }
115
+		return $content;
116
+	}
117 117
     
118
-    protected function _display_text_stop()
119
-    {
120
-        return '<p>' . __('View available questions.', 'event_espresso') . '</p>';
121
-    }
118
+	protected function _display_text_stop()
119
+	{
120
+		return '<p>' . __('View available questions.', 'event_espresso') . '</p>';
121
+	}
122 122
     
123
-    protected function _admin_label_stop()
124
-    {
125
-        return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>';
126
-    }
123
+	protected function _admin_label_stop()
124
+	{
125
+		return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>';
126
+	}
127 127
     
128
-    protected function _type_stop()
129
-    {
130
-        return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.',
131
-            'event_espresso') . '</p>';
132
-    }
128
+	protected function _type_stop()
129
+	{
130
+		return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.',
131
+			'event_espresso') . '</p>';
132
+	}
133 133
     
134
-    protected function _values_stop()
135
-    {
136
-        return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.',
137
-            'event_espresso') . '</p>';
138
-    }
134
+	protected function _values_stop()
135
+	{
136
+		return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.',
137
+			'event_espresso') . '</p>';
138
+	}
139 139
     
140
-    protected function _required_stop()
141
-    {
142
-        return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>';
143
-    }
140
+	protected function _required_stop()
141
+	{
142
+		return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>';
143
+	}
144 144
     
145
-    /* protected function _bulk_actions_stop() {
145
+	/* protected function _bulk_actions_stop() {
146 146
         return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>';
147 147
     } */
148 148
     
149
-    protected function _search_stop()
150
-    {
151
-        return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).',
152
-            'event_espresso') . '</p>';
153
-    }
149
+	protected function _search_stop()
150
+	{
151
+		return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).',
152
+			'event_espresso') . '</p>';
153
+	}
154 154
     
155
-    protected function _add_new_question_stop()
156
-    {
157
-        return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>';
158
-    }
155
+	protected function _add_new_question_stop()
156
+	{
157
+		return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>';
158
+	}
159 159
     
160 160
 }
161 161
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -108,38 +108,38 @@  discard block
 block discarded – undo
108 108
     
109 109
     protected function _start()
110 110
     {
111
-        $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>';
112
-        $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.',
113
-                'event_espresso') . '</p>';
111
+        $content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>';
112
+        $content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.',
113
+                'event_espresso').'</p>';
114 114
         
115 115
         return $content;
116 116
     }
117 117
     
118 118
     protected function _display_text_stop()
119 119
     {
120
-        return '<p>' . __('View available questions.', 'event_espresso') . '</p>';
120
+        return '<p>'.__('View available questions.', 'event_espresso').'</p>';
121 121
     }
122 122
     
123 123
     protected function _admin_label_stop()
124 124
     {
125
-        return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>';
125
+        return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>';
126 126
     }
127 127
     
128 128
     protected function _type_stop()
129 129
     {
130
-        return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.',
131
-            'event_espresso') . '</p>';
130
+        return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.',
131
+            'event_espresso').'</p>';
132 132
     }
133 133
     
134 134
     protected function _values_stop()
135 135
     {
136
-        return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.',
137
-            'event_espresso') . '</p>';
136
+        return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.',
137
+            'event_espresso').'</p>';
138 138
     }
139 139
     
140 140
     protected function _required_stop()
141 141
     {
142
-        return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>';
142
+        return '<p>'.__('View if a question is required.', 'event_espresso').'</p>';
143 143
     }
144 144
     
145 145
     /* protected function _bulk_actions_stop() {
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
     
149 149
     protected function _search_stop()
150 150
     {
151
-        return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).',
152
-            'event_espresso') . '</p>';
151
+        return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).',
152
+            'event_espresso').'</p>';
153 153
     }
154 154
     
155 155
     protected function _add_new_question_stop()
156 156
     {
157
-        return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>';
157
+        return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>';
158 158
     }
159 159
     
160 160
 }
161 161
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Field_With_Model_Name.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
      * Returns the name of the model(s) pointed to
36 36
      *
37 37
      * @deprecated since version 4.6.7
38
-     * @return mixed string or array of strings
38
+     * @return string string or array of strings
39 39
      */
40 40
     function get_model_name_pointed_to()
41 41
     {
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -8,83 +8,83 @@
 block discarded – undo
8 8
  */
9 9
 abstract class EE_Field_With_Model_Name extends EE_Model_Field_Base
10 10
 {
11
-    /**
12
-     * Usually the name of a single model. However, as in the case for custom post types,
13
-     * it can actually be an array of models
14
-     *
15
-     * @var string or array
16
-     */
17
-    protected $_model_name_pointed_to;
11
+	/**
12
+	 * Usually the name of a single model. However, as in the case for custom post types,
13
+	 * it can actually be an array of models
14
+	 *
15
+	 * @var string or array
16
+	 */
17
+	protected $_model_name_pointed_to;
18 18
 
19
-    /**
20
-     * @param string  $table_column  name fo column for field
21
-     * @param string  $nicename      should eb internationalized with __('blah','event_espresso')
22
-     * @param boolean $nullable
23
-     * @param mixed   $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul
24
-     *                               dbe a string
25
-     * @param string  $model_name    eg 'Event','Answer','Term', etc. Basically its the model class's name without the
26
-     *                               "EEM_"
27
-     */
28
-    function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
29
-    {
30
-        $this->_model_name_pointed_to = $model_name;
31
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
32
-    }
19
+	/**
20
+	 * @param string  $table_column  name fo column for field
21
+	 * @param string  $nicename      should eb internationalized with __('blah','event_espresso')
22
+	 * @param boolean $nullable
23
+	 * @param mixed   $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul
24
+	 *                               dbe a string
25
+	 * @param string  $model_name    eg 'Event','Answer','Term', etc. Basically its the model class's name without the
26
+	 *                               "EEM_"
27
+	 */
28
+	function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
29
+	{
30
+		$this->_model_name_pointed_to = $model_name;
31
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
32
+	}
33 33
 
34
-    /**
35
-     * Returns the name of the model(s) pointed to
36
-     *
37
-     * @deprecated since version 4.6.7
38
-     * @return mixed string or array of strings
39
-     */
40
-    function get_model_name_pointed_to()
41
-    {
42
-        EE_Error::doing_it_wrong('get_model_name_pointed_to',
43
-            __('This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array',
44
-                'event_espresso'), '4.6.7');
45
-        return $this->_model_name_pointed_to;
46
-    }
34
+	/**
35
+	 * Returns the name of the model(s) pointed to
36
+	 *
37
+	 * @deprecated since version 4.6.7
38
+	 * @return mixed string or array of strings
39
+	 */
40
+	function get_model_name_pointed_to()
41
+	{
42
+		EE_Error::doing_it_wrong('get_model_name_pointed_to',
43
+			__('This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array',
44
+				'event_espresso'), '4.6.7');
45
+		return $this->_model_name_pointed_to;
46
+	}
47 47
 
48
-    /**
49
-     * Gets the model names pointed to by this field, always as an array
50
-     * (even if there's only one)
51
-     *
52
-     * @return array of model names pointed to by this field
53
-     */
54
-    function get_model_names_pointed_to()
55
-    {
56
-        if (is_array($this->_model_name_pointed_to)) {
57
-            return $this->_model_name_pointed_to;
58
-        } else {
59
-            return array($this->_model_name_pointed_to);
60
-        }
61
-    }
48
+	/**
49
+	 * Gets the model names pointed to by this field, always as an array
50
+	 * (even if there's only one)
51
+	 *
52
+	 * @return array of model names pointed to by this field
53
+	 */
54
+	function get_model_names_pointed_to()
55
+	{
56
+		if (is_array($this->_model_name_pointed_to)) {
57
+			return $this->_model_name_pointed_to;
58
+		} else {
59
+			return array($this->_model_name_pointed_to);
60
+		}
61
+	}
62 62
 
63
-    /**
64
-     * Returns the model's classname (eg EE_Event instead of just Event)
65
-     *
66
-     * @return array
67
-     */
68
-    function get_model_class_names_pointed_to()
69
-    {
70
-        $model_names = array();
71
-        if (is_array($this->_model_name_pointed_to)) {
72
-            foreach ($this->_model_name_pointed_to as $model_name) {
73
-                $model_names[] = "EE_" . $model_name;
74
-            }
75
-        } else {
76
-            $model_names = array("EE_" . $this->_model_name_pointed_to);
77
-        }
78
-        return $model_names;
79
-    }
63
+	/**
64
+	 * Returns the model's classname (eg EE_Event instead of just Event)
65
+	 *
66
+	 * @return array
67
+	 */
68
+	function get_model_class_names_pointed_to()
69
+	{
70
+		$model_names = array();
71
+		if (is_array($this->_model_name_pointed_to)) {
72
+			foreach ($this->_model_name_pointed_to as $model_name) {
73
+				$model_names[] = "EE_" . $model_name;
74
+			}
75
+		} else {
76
+			$model_names = array("EE_" . $this->_model_name_pointed_to);
77
+		}
78
+		return $model_names;
79
+	}
80 80
 
81
-    function is_model_obj_of_type_pointed_to($model_obj_or_ID)
82
-    {
83
-        foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
84
-            if ($model_obj_or_ID instanceof $model_obj_classname) {
85
-                return true;
86
-            }
87
-        }
88
-        return false;
89
-    }
81
+	function is_model_obj_of_type_pointed_to($model_obj_or_ID)
82
+	{
83
+		foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
84
+			if ($model_obj_or_ID instanceof $model_obj_classname) {
85
+				return true;
86
+			}
87
+		}
88
+		return false;
89
+	}
90 90
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,10 +70,10 @@
 block discarded – undo
70 70
         $model_names = array();
71 71
         if (is_array($this->_model_name_pointed_to)) {
72 72
             foreach ($this->_model_name_pointed_to as $model_name) {
73
-                $model_names[] = "EE_" . $model_name;
73
+                $model_names[] = "EE_".$model_name;
74 74
             }
75 75
         } else {
76
-            $model_names = array("EE_" . $this->_model_name_pointed_to);
76
+            $model_names = array("EE_".$this->_model_name_pointed_to);
77 77
         }
78 78
         return $model_names;
79 79
     }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Primary_Key_Field_Base.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -7,6 +7,7 @@
 block discarded – undo
7 7
      *
8 8
      * @param string $table_column
9 9
      * @param string $nicename
10
+     * @param integer|null $default
10 11
      */
11 12
     public function __construct($table_column, $nicename, $default)
12 13
     {
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -2,24 +2,24 @@
 block discarded – undo
2 2
 
3 3
 abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name
4 4
 {
5
-    /**
6
-     * Overrides parent so it doesn't need to provide so many non-applicable fields
7
-     *
8
-     * @param string $table_column
9
-     * @param string $nicename
10
-     */
11
-    public function __construct($table_column, $nicename, $default)
12
-    {
13
-        parent::__construct($table_column, $nicename, false, $default, null);
14
-    }
5
+	/**
6
+	 * Overrides parent so it doesn't need to provide so many non-applicable fields
7
+	 *
8
+	 * @param string $table_column
9
+	 * @param string $nicename
10
+	 */
11
+	public function __construct($table_column, $nicename, $default)
12
+	{
13
+		parent::__construct($table_column, $nicename, false, $default, null);
14
+	}
15 15
 
16
-    /**
17
-     * @param $table_alias
18
-     * @param $name
19
-     */
20
-    function _construct_finalize($table_alias, $name, $model_name)
21
-    {
22
-        $this->_model_name_pointed_to = $model_name;
23
-        parent::_construct_finalize($table_alias, $name, $model_name);
24
-    }
16
+	/**
17
+	 * @param $table_alias
18
+	 * @param $name
19
+	 */
20
+	function _construct_finalize($table_alias, $name, $model_name)
21
+	{
22
+		$this->_model_name_pointed_to = $model_name;
23
+		parent::_construct_finalize($table_alias, $name, $model_name);
24
+	}
25 25
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_WP_Post_Status_Field.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,6 @@
 block discarded – undo
33 33
      *                                    )
34 34
      *                                    )
35 35
      * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
36
-     * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is
37
-     *                                    set to true, it will be stored as an INT
38 36
      */
39 37
     function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array())
40 38
     {
Please login to merge, or discard this patch.
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -4,116 +4,116 @@
 block discarded – undo
4 4
 class EE_WP_Post_Status_Field extends EE_Enum_Text_Field
5 5
 {
6 6
 
7
-    protected $_wp_post_stati;
8
-
9
-
10
-    /**
11
-     * constructor
12
-     *
13
-     * @param string  $table_column       column on table
14
-     * @param string  $nicename           nice name for column(field)
15
-     * @param bool    $nullable           is this field nullable
16
-     * @param string  $default_value      default status
17
-     * @param array   $new_stati          If additional stati are to be used other than the default WP statuses then
18
-     *                                    they can be registered via this property.  The format of the array should be
19
-     *                                    as follows: array(
20
-     *                                    'status_reference' => array(
21
-     *                                    'label' => __('Status Reference Label', 'event_espresso')
22
-     *                                    'public' => true, //'Whether posts of this status should be shown on the
23
-     *                                    frontend of the site'
24
-     *                                    'exclude_from_search' => false, //'Whether posts of this status should be
25
-     *                                    excluded from wp searches'
26
-     *                                    'show_in_admin_all_list' => true, //whether posts of this status are included
27
-     *                                    in queries for the admin "all" view in list table views.
28
-     *                                    'show_in_admin_status_list' => true, //Show in the list of statuses with post
29
-     *                                    counts at the top of the admin list tables (i.e. Status Reference(2) )
30
-     *                                    'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>',
31
-     *                                    'Status References <span class="count">(%s)</span>' ), //the text to display
32
-     *                                    on the admin screen( or you won't see your status count ).
33
-     *                                    )
34
-     *                                    )
35
-     * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
36
-     * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is
37
-     *                                    set to true, it will be stored as an INT
38
-     */
39
-    function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array())
40
-    {
41
-        $this->_register_new_stati($new_stati);
42
-        $this->_set_allowed_enum_values();
43
-        parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values);
44
-    }
45
-
46
-
47
-    /**
48
-     * This registers any new statuses sent via the $new_stati array on construct
49
-     *
50
-     * @access protected
51
-     * @param  array $new_stati statuses
52
-     * @return void
53
-     */
54
-    protected function _register_new_stati($new_stati)
55
-    {
56
-
57
-        foreach ((array)$new_stati as $status_key => $status_args) {
58
-            $args = array(
59
-                'label'                     => isset($status_args['label']) ? $status_args['label'] : $status_key,
60
-                'public'                    => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true,
61
-                'exclude_from_search'       => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false,
62
-                'show_in_admin_all_list'    => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false,
63
-                'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true,
64
-                'label_count'               => isset($status_args['label_count']) ? $status_args['label_count'] : '',
65
-            );
66
-            register_post_status($status_key, $status_args);
67
-        }
68
-
69
-    }
70
-
71
-
72
-    /**
73
-     * This sets the _allowed_enum_values property using the $wp_post_stati array
74
-     *
75
-     * @access protected
76
-     * @regurn void
77
-     */
78
-    protected function _set_allowed_enum_values()
79
-    {
80
-        //first let's get the post_statuses
81
-        global $wp_post_statuses;
82
-        $this->_wp_post_stati = $wp_post_statuses;
83
-
84
-        foreach ($this->_wp_post_stati as $post_status => $args_object) {
85
-            $this->_allowed_enum_values[$post_status] = $args_object->label;
86
-        }
87
-
88
-    }
89
-
90
-    /**
91
-     * Before calling parent, first double-checks our list of acceptable post
92
-     * types is up-to-date
93
-     *
94
-     * @param string $value_inputted_for_field_on_model_object
95
-     * @return string
96
-     */
97
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
98
-    {
99
-        $this->_set_allowed_enum_values();
100
-        return parent::prepare_for_set($value_inputted_for_field_on_model_object);
101
-    }
102
-
103
-
104
-
105
-    //helper methods for getting various $wp_post_statuses stuff.
106
-
107
-    /**
108
-     * This just returns the status object for the given status
109
-     *
110
-     * @access public
111
-     * @see    wp_register_post_status in wp-includes/post.php for a list of properties of the status object
112
-     * @param  string $status What status object you want
113
-     * @return std_object         the status object or FALSE if it doesn't exist.
114
-     */
115
-    public function get_status_object($status)
116
-    {
117
-        return isset($this->_wp_post_stati[$status]) ? $this->_wp_post_stati[$status] : false;
118
-    }
7
+	protected $_wp_post_stati;
8
+
9
+
10
+	/**
11
+	 * constructor
12
+	 *
13
+	 * @param string  $table_column       column on table
14
+	 * @param string  $nicename           nice name for column(field)
15
+	 * @param bool    $nullable           is this field nullable
16
+	 * @param string  $default_value      default status
17
+	 * @param array   $new_stati          If additional stati are to be used other than the default WP statuses then
18
+	 *                                    they can be registered via this property.  The format of the array should be
19
+	 *                                    as follows: array(
20
+	 *                                    'status_reference' => array(
21
+	 *                                    'label' => __('Status Reference Label', 'event_espresso')
22
+	 *                                    'public' => true, //'Whether posts of this status should be shown on the
23
+	 *                                    frontend of the site'
24
+	 *                                    'exclude_from_search' => false, //'Whether posts of this status should be
25
+	 *                                    excluded from wp searches'
26
+	 *                                    'show_in_admin_all_list' => true, //whether posts of this status are included
27
+	 *                                    in queries for the admin "all" view in list table views.
28
+	 *                                    'show_in_admin_status_list' => true, //Show in the list of statuses with post
29
+	 *                                    counts at the top of the admin list tables (i.e. Status Reference(2) )
30
+	 *                                    'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>',
31
+	 *                                    'Status References <span class="count">(%s)</span>' ), //the text to display
32
+	 *                                    on the admin screen( or you won't see your status count ).
33
+	 *                                    )
34
+	 *                                    )
35
+	 * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
36
+	 * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is
37
+	 *                                    set to true, it will be stored as an INT
38
+	 */
39
+	function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array())
40
+	{
41
+		$this->_register_new_stati($new_stati);
42
+		$this->_set_allowed_enum_values();
43
+		parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values);
44
+	}
45
+
46
+
47
+	/**
48
+	 * This registers any new statuses sent via the $new_stati array on construct
49
+	 *
50
+	 * @access protected
51
+	 * @param  array $new_stati statuses
52
+	 * @return void
53
+	 */
54
+	protected function _register_new_stati($new_stati)
55
+	{
56
+
57
+		foreach ((array)$new_stati as $status_key => $status_args) {
58
+			$args = array(
59
+				'label'                     => isset($status_args['label']) ? $status_args['label'] : $status_key,
60
+				'public'                    => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true,
61
+				'exclude_from_search'       => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false,
62
+				'show_in_admin_all_list'    => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false,
63
+				'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true,
64
+				'label_count'               => isset($status_args['label_count']) ? $status_args['label_count'] : '',
65
+			);
66
+			register_post_status($status_key, $status_args);
67
+		}
68
+
69
+	}
70
+
71
+
72
+	/**
73
+	 * This sets the _allowed_enum_values property using the $wp_post_stati array
74
+	 *
75
+	 * @access protected
76
+	 * @regurn void
77
+	 */
78
+	protected function _set_allowed_enum_values()
79
+	{
80
+		//first let's get the post_statuses
81
+		global $wp_post_statuses;
82
+		$this->_wp_post_stati = $wp_post_statuses;
83
+
84
+		foreach ($this->_wp_post_stati as $post_status => $args_object) {
85
+			$this->_allowed_enum_values[$post_status] = $args_object->label;
86
+		}
87
+
88
+	}
89
+
90
+	/**
91
+	 * Before calling parent, first double-checks our list of acceptable post
92
+	 * types is up-to-date
93
+	 *
94
+	 * @param string $value_inputted_for_field_on_model_object
95
+	 * @return string
96
+	 */
97
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
98
+	{
99
+		$this->_set_allowed_enum_values();
100
+		return parent::prepare_for_set($value_inputted_for_field_on_model_object);
101
+	}
102
+
103
+
104
+
105
+	//helper methods for getting various $wp_post_statuses stuff.
106
+
107
+	/**
108
+	 * This just returns the status object for the given status
109
+	 *
110
+	 * @access public
111
+	 * @see    wp_register_post_status in wp-includes/post.php for a list of properties of the status object
112
+	 * @param  string $status What status object you want
113
+	 * @return std_object         the status object or FALSE if it doesn't exist.
114
+	 */
115
+	public function get_status_object($status)
116
+	{
117
+		return isset($this->_wp_post_stati[$status]) ? $this->_wp_post_stati[$status] : false;
118
+	}
119 119
 }
120 120
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once(EE_MODELS . 'fields/EE_Enum_Text_Field.php');
2
+require_once(EE_MODELS.'fields/EE_Enum_Text_Field.php');
3 3
 
4 4
 class EE_WP_Post_Status_Field extends EE_Enum_Text_Field
5 5
 {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     protected function _register_new_stati($new_stati)
55 55
     {
56 56
 
57
-        foreach ((array)$new_stati as $status_key => $status_args) {
57
+        foreach ((array) $new_stati as $status_key => $status_args) {
58 58
             $args = array(
59 59
                 'label'                     => isset($status_args['label']) ? $status_args['label'] : $status_key,
60 60
                 'public'                    => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true,
Please login to merge, or discard this patch.