Completed
Branch EE5Update (bc64e6)
by
unknown
09:36 queued 05:38
created
core/db_models/EEM_Message.model.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             self::priority_low    => esc_html__('low', 'event_espresso'),
127 127
         );
128 128
 
129
-        $this->_fields          = array(
129
+        $this->_fields = array(
130 130
             'Message' => array(
131 131
                 'MSG_ID'             => new EE_Primary_Key_Int_Field('MSG_ID', esc_html__('Message ID', 'event_espresso')),
132 132
                 'MSG_token'          => new EE_Plain_Text_Field(
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
                         );
437 437
                         break;
438 438
                     default:
439
-                        $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value;
439
+                        $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value;
440 440
                         break;
441 441
                 }
442 442
             }
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
         if ($label_parts) {
500 500
             // prepend to the last element of $label_parts an "and".
501 501
             if (count($label_parts) > 1) {
502
-                $label_parts_index_to_prepend               = count($label_parts) - 1;
503
-                $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ];
502
+                $label_parts_index_to_prepend = count($label_parts) - 1;
503
+                $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend];
504 504
             }
505 505
 
506 506
             $pretty_label .= sprintf(
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
             $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES;
561 561
         }
562 562
 
563
-        if (! is_null($set_debug)) {
563
+        if ( ! is_null($set_debug)) {
564 564
             $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN);
565 565
         }
566 566
 
@@ -627,13 +627,13 @@  discard block
 block discarded – undo
627 627
             )
628 628
         );
629 629
 
630
-        if (! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
630
+        if ( ! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
631 631
             global $wpdb;
632 632
             $number_deleted = $wpdb->query('
633 633
                 DELETE
634
-                FROM ' . $this->table() . '
634
+                FROM ' . $this->table().'
635 635
                 WHERE
636
-                    MSG_ID IN (' . implode(",", $message_ids_to_delete) . ')
636
+                    MSG_ID IN (' . implode(",", $message_ids_to_delete).')
637 637
             ');
638 638
         }
639 639
 
Please login to merge, or discard this patch.
Indentation   +640 added lines, -640 removed lines patch added patch discarded remove patch
@@ -12,649 +12,649 @@
 block discarded – undo
12 12
  */
13 13
 class EEM_Message extends EEM_Base implements EEI_Query_Filter
14 14
 {
15
-    // private instance of the Message object
16
-    protected static $_instance = null;
17
-
18
-
19
-    /**
20
-     * This priority indicates a message should be generated and sent ASAP
21
-     *
22
-     * @type int
23
-     */
24
-    const priority_high = 10;
25
-
26
-
27
-    /**
28
-     * This priority indicates a message should be generated ASAP and queued for sending.
29
-     *
30
-     * @type
31
-     */
32
-    const priority_medium = 20;
33
-
34
-
35
-    /**
36
-     * This priority indicates a message should be queued for generating.
37
-     *
38
-     * @type int
39
-     */
40
-    const priority_low = 30;
41
-
42
-
43
-    /**
44
-     * indicates this message was sent at the time modified
45
-     */
46
-    const status_sent = 'MSN';
47
-
48
-
49
-    /**
50
-     * indicates this message is waiting to be sent
51
-     */
52
-    const status_idle = 'MID';
53
-
54
-
55
-    /**
56
-     * indicates an attempt was a made to send this message
57
-     * at the scheduled time, but it failed at the time modified.  This differs from MDO status in that it will ALWAYS
58
-     * appear to the end user.
59
-     */
60
-    const status_failed = 'MFL';
61
-
62
-
63
-    /**
64
-     * indicates the message has been flagged for resending (at the time modified).
65
-     */
66
-    const status_resend = 'MRS';
67
-
68
-
69
-    /**
70
-     * indicates the message has been flagged for generation but has not been generated yet.  Messages always start as
71
-     * this status when added to the queue.
72
-     */
73
-    const status_incomplete = 'MIC';
74
-
75
-
76
-    /**
77
-     * Indicates everything was generated fine for the message, however, the messenger was unable to send.
78
-     * This status means that its possible to retry sending the message.
79
-     */
80
-    const status_retry = 'MRT';
81
-
82
-
83
-    /**
84
-     * This is used for more informational messages that may not indicate anything is broken but still cannot be
85
-     * generated or sent correctly. An example of a message that would get flagged this way would be when a not
86
-     * approved message was queued for generation, but at time of generation, the attached registration(s) are
87
-     * approved. So the message queued for generation is no longer valid.  Messages for this status will only persist
88
-     * in the db and be viewable in the message activity list table when the messages system is in debug mode.
89
-     *
90
-     * @see EEM_Message::debug()
91
-     */
92
-    const status_debug_only = 'MDO';
93
-
94
-
95
-    /**
96
-     * This status is given to messages it is processed by the messenger send method.
97
-     * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually
98
-     * indicative of a PHP timeout or memory limit issue.
99
-     */
100
-    const status_messenger_executing = 'MEX';
101
-
102
-
103
-    /**
104
-     *    Private constructor to prevent direct creation.
105
-     *
106
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and
107
-     *                         any incoming timezone data that gets saved).  Note this just sends the timezone info to
108
-     *                         the date time model field objects.  Default is null (and will be assumed using the set
109
-     *                         timezone in the 'timezone_string' wp option)
110
-     * @throws EE_Error
111
-     * @throws EE_Error
112
-     * @throws EE_Error
113
-     */
114
-    protected function __construct($timezone = null)
115
-    {
116
-        $this->singular_item = esc_html__('Message', 'event_espresso');
117
-        $this->plural_item   = esc_html__('Messages', 'event_espresso');
118
-
119
-        $this->_tables = array(
120
-            'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'),
121
-        );
122
-
123
-        $allowed_priority = array(
124
-            self::priority_high   => esc_html__('high', 'event_espresso'),
125
-            self::priority_medium => esc_html__('medium', 'event_espresso'),
126
-            self::priority_low    => esc_html__('low', 'event_espresso'),
127
-        );
128
-
129
-        $this->_fields          = array(
130
-            'Message' => array(
131
-                'MSG_ID'             => new EE_Primary_Key_Int_Field('MSG_ID', esc_html__('Message ID', 'event_espresso')),
132
-                'MSG_token'          => new EE_Plain_Text_Field(
133
-                    'MSG_token',
134
-                    esc_html__(
135
-                        'Unique Token used to represent this row in publicly viewable contexts (eg. a url).',
136
-                        'event_espresso'
137
-                    ),
138
-                    false,
139
-                    EEH_URL::generate_unique_token()
140
-                ),
141
-                'GRP_ID'             => new EE_Foreign_Key_Int_Field(
142
-                    'GRP_ID',
143
-                    esc_html__('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'),
144
-                    true,
145
-                    0,
146
-                    'Message_Template_Group'
147
-                ),
148
-                'TXN_ID'             => new EE_Foreign_Key_Int_Field(
149
-                    'TXN_ID',
150
-                    esc_html__(
151
-                        'Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message',
152
-                        'event_espresso'
153
-                    ),
154
-                    true,
155
-                    0,
156
-                    'Transaction'
157
-                ),
158
-                'MSG_messenger'      => new EE_Plain_Text_Field(
159
-                    'MSG_messenger',
160
-                    esc_html__(
161
-                        'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.',
162
-                        'event_espresso'
163
-                    ),
164
-                    false,
165
-                    'email'
166
-                ),
167
-                'MSG_message_type'   => new EE_Plain_Text_Field(
168
-                    'MSG_message_type',
169
-                    esc_html__('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'),
170
-                    false,
171
-                    'receipt'
172
-                ),
173
-                'MSG_context'        => new EE_Plain_Text_Field('MSG_context', esc_html__('Context', 'event_espresso'), false),
174
-                'MSG_recipient_ID'   => new EE_Foreign_Key_Int_Field(
175
-                    'MSG_recipient_ID',
176
-                    esc_html__('Recipient ID', 'event_espresso'),
177
-                    true,
178
-                    null,
179
-                    array('Registration', 'Attendee', 'WP_User')
180
-                ),
181
-                'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field(
182
-                    'MSG_recipient_type',
183
-                    esc_html__('Recipient Type', 'event_espresso'),
184
-                    true,
185
-                    null,
186
-                    array('Registration', 'Attendee', 'WP_User')
187
-                ),
188
-                'MSG_content'        => new EE_Maybe_Serialized_Text_Field(
189
-                    'MSG_content',
190
-                    esc_html__('Content', 'event_espresso'),
191
-                    true,
192
-                    ''
193
-                ),
194
-                'MSG_to'             => new EE_Maybe_Serialized_Text_Field(
195
-                    'MSG_to',
196
-                    esc_html__('Address To', 'event_espresso'),
197
-                    true
198
-                ),
199
-                'MSG_from'           => new EE_Maybe_Serialized_Text_Field(
200
-                    'MSG_from',
201
-                    esc_html__('Address From', 'event_espresso'),
202
-                    true
203
-                ),
204
-                'MSG_subject'        => new EE_Maybe_Serialized_Text_Field(
205
-                    'MSG_subject',
206
-                    esc_html__('Subject', 'event_espresso'),
207
-                    true,
208
-                    ''
209
-                ),
210
-                'MSG_priority'       => new EE_Enum_Integer_Field(
211
-                    'MSG_priority',
212
-                    esc_html__('Priority', 'event_espresso'),
213
-                    false,
214
-                    self::priority_low,
215
-                    $allowed_priority
216
-                ),
217
-                'STS_ID'             => new EE_Foreign_Key_String_Field(
218
-                    'STS_ID',
219
-                    esc_html__('Status', 'event_espresso'),
220
-                    false,
221
-                    self::status_incomplete,
222
-                    'Status'
223
-                ),
224
-                'MSG_created'        => new EE_Datetime_Field(
225
-                    'MSG_created',
226
-                    esc_html__('Created', 'event_espresso'),
227
-                    false,
228
-                    EE_Datetime_Field::now
229
-                ),
230
-                'MSG_modified'       => new EE_Datetime_Field(
231
-                    'MSG_modified',
232
-                    esc_html__('Modified', 'event_espresso'),
233
-                    true,
234
-                    EE_Datetime_Field::now
235
-                ),
236
-            ),
237
-        );
238
-        $this->_model_relations = array(
239
-            'Attendee'               => new EE_Belongs_To_Any_Relation(),
240
-            'Registration'           => new EE_Belongs_To_Any_Relation(),
241
-            'WP_User'                => new EE_Belongs_To_Any_Relation(),
242
-            'Message_Template_Group' => new EE_Belongs_To_Relation(),
243
-            'Transaction'            => new EE_Belongs_To_Relation(),
244
-        );
245
-        parent::__construct($timezone);
246
-    }
247
-
248
-
249
-    /**
250
-     * @return EE_Message
251
-     * @throws EE_Error
252
-     */
253
-    public function create_default_object()
254
-    {
255
-        /** @type EE_Message $message */
256
-        $message = parent::create_default_object();
257
-        if ($message instanceof EE_Message) {
258
-            return EE_Message_Factory::set_messenger_and_message_type($message);
259
-        }
260
-        return null;
261
-    }
262
-
263
-
264
-    /**
265
-     * @param mixed $cols_n_values
266
-     * @return EE_Message
267
-     * @throws EE_Error
268
-     * @throws EE_Error
269
-     */
270
-    public function instantiate_class_from_array_or_object($cols_n_values)
271
-    {
272
-        /** @type EE_Message $message */
273
-        $message = parent::instantiate_class_from_array_or_object($cols_n_values);
274
-        if ($message instanceof EE_Message) {
275
-            return EE_Message_Factory::set_messenger_and_message_type($message);
276
-        }
277
-        return null;
278
-    }
279
-
280
-
281
-    /**
282
-     * Returns whether or not a message of that type was sent for a given attendee.
283
-     *
284
-     * @param EE_Attendee|int $attendee
285
-     * @param string          $message_type the message type slug
286
-     * @return boolean
287
-     * @throws EE_Error
288
-     * @throws EE_Error
289
-     * @throws EE_Error
290
-     */
291
-    public function message_sent_for_attendee($attendee, $message_type)
292
-    {
293
-        $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee);
294
-        return $this->exists(array(
295
-            array(
296
-                'Attendee.ATT_ID'  => $attendee_ID,
297
-                'MSG_message_type' => $message_type,
298
-                'STS_ID'           => array('IN', $this->stati_indicating_sent()),
299
-            ),
300
-        ));
301
-    }
302
-
303
-
304
-    /**
305
-     * Returns whether or not a message of that type was sent for a given registration
306
-     *
307
-     * @param EE_Registration|int $registration
308
-     * @param string              $message_type the message type slug
309
-     * @return boolean
310
-     * @throws EE_Error
311
-     * @throws EE_Error
312
-     * @throws EE_Error
313
-     */
314
-    public function message_sent_for_registration($registration, $message_type)
315
-    {
316
-        $registrationID = EEM_Registration::instance()->ensure_is_ID($registration);
317
-        return $this->exists(array(
318
-            array(
319
-                'Registration.REG_ID' => $registrationID,
320
-                'MSG_message_type'    => $message_type,
321
-                'STS_ID'              => array('IN', $this->stati_indicating_sent()),
322
-            ),
323
-        ));
324
-    }
325
-
326
-
327
-    /**
328
-     * This retrieves an EE_Message object from the db matching the given token string.
329
-     *
330
-     * @param string $token
331
-     * @return EE_Message
332
-     * @throws EE_Error
333
-     */
334
-    public function get_one_by_token($token)
335
-    {
336
-        return $this->get_one(array(
337
-            array(
338
-                'MSG_token' => $token,
339
-            ),
340
-        ));
341
-    }
342
-
343
-
344
-    /**
345
-     * Returns stati that indicate the message HAS been sent
346
-     *
347
-     * @return array of strings for possible stati
348
-     */
349
-    public function stati_indicating_sent()
350
-    {
351
-        return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent));
352
-    }
353
-
354
-
355
-    /**
356
-     * Returns stati that indicate the message is waiting to be sent.
357
-     *
358
-     * @return array of strings for possible stati.
359
-     */
360
-    public function stati_indicating_to_send()
361
-    {
362
-        return apply_filters(
363
-            'FHEE__EEM_Message__stati_indicating_to_send',
364
-            array(self::status_idle, self::status_resend)
365
-        );
366
-    }
367
-
368
-
369
-    /**
370
-     * Returns stati that indicate the message has failed sending
371
-     *
372
-     * @return array  array of strings for possible stati.
373
-     */
374
-    public function stati_indicating_failed_sending()
375
-    {
376
-        $failed_stati = array(
377
-            self::status_failed,
378
-            self::status_retry,
379
-            self::status_messenger_executing,
380
-        );
381
-        // if WP_DEBUG is set, then let's include debug_only fails
382
-        if (WP_DEBUG) {
383
-            $failed_stati[] = self::status_debug_only;
384
-        }
385
-        return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati);
386
-    }
387
-
388
-
389
-    /**
390
-     * Returns filterable array of all EEM_Message statuses.
391
-     *
392
-     * @return array
393
-     */
394
-    public function all_statuses()
395
-    {
396
-        return apply_filters(
397
-            'FHEE__EEM_Message__all_statuses',
398
-            array(
399
-                EEM_Message::status_sent,
400
-                EEM_Message::status_incomplete,
401
-                EEM_Message::status_idle,
402
-                EEM_Message::status_resend,
403
-                EEM_Message::status_retry,
404
-                EEM_Message::status_failed,
405
-                EEM_Message::status_messenger_executing,
406
-                EEM_Message::status_debug_only,
407
-            )
408
-        );
409
-    }
410
-
411
-    /**
412
-     * Detects any specific query variables in the request and uses those to setup appropriate
413
-     * filter for any queries.
414
-     *
415
-     * @return array
416
-     */
417
-    public function filter_by_query_params()
418
-    {
419
-        /** @var RequestInterface $request */
420
-        $request = EEM_Base::$loader->getShared(RequestInterface::class);
421
-        // expected possible query_vars, the key in this array matches an expected key in the request,
422
-        // the value, matches the corresponding EEM_Base child reference.
423
-        $expected_vars   = $this->_expected_vars_for_query_inject();
424
-        $query_params[0] = array();
425
-        foreach ($expected_vars as $request_key => $model_name) {
426
-            $request_value = $request->getRequestParam($request_key);
427
-            if ($request_value) {
428
-                // special case
429
-                switch ($request_key) {
430
-                    case '_REG_ID':
431
-                        $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array(
432
-                            'Transaction.Registration.REG_ID' => $request_value,
433
-                        );
434
-                        break;
435
-                    case 'EVT_ID':
436
-                        $query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array(
437
-                            'Transaction.Registration.EVT_ID' => $request_value,
438
-                        );
439
-                        break;
440
-                    default:
441
-                        $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value;
442
-                        break;
443
-                }
444
-            }
445
-        }
446
-        return $query_params;
447
-    }
448
-
449
-
450
-    /**
451
-     * @return string
452
-     * @throws EE_Error
453
-     * @throws ReflectionException
454
-     */
455
-    public function get_pretty_label_for_results()
456
-    {
457
-        /** @var RequestInterface $request */
458
-        $request = EEM_Base::$loader->getShared(RequestInterface::class);
459
-        $expected_vars = $this->_expected_vars_for_query_inject();
460
-        $pretty_label  = '';
461
-        $label_parts   = array();
462
-        foreach ($expected_vars as $request_key => $model_name) {
463
-            $model_name = strpos($model_name, 'EEM_', true) === 0 ? $model_name : "EEM_{$model_name}";
464
-            $model = EEM_Base::$loader->getShared($model_name);
465
-            $model_field_value = $request->getRequestParam($request_key);
466
-            if ($model instanceof EEM_Base && $model_field_value !== '') {
467
-                switch ($request_key) {
468
-                    case '_REG_ID':
469
-                        $label_parts[] = sprintf(
470
-                            esc_html__('Registration with the ID: %s', 'event_espresso'),
471
-                            $model_field_value
472
-                        );
473
-                        break;
474
-                    case 'ATT_ID':
475
-                        /** @var EE_Attendee $attendee */
476
-                        $attendee      = $model->get_one_by_ID($model_field_value);
477
-                        $label_parts[] = $attendee instanceof EE_Attendee
478
-                            ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name())
479
-                            : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value);
480
-                        break;
481
-                    case 'ID':
482
-                        /** @var EE_WP_User $wpUser */
483
-                        $wpUser        = $model->get_one_by_ID($model_field_value);
484
-                        $label_parts[] = $wpUser instanceof EE_WP_User
485
-                            ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name())
486
-                            : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value);
487
-                        break;
488
-                    case 'TXN_ID':
489
-                        $label_parts[] = sprintf(
490
-                            esc_html__('Transaction with the ID: %s', 'event_espresso'),
491
-                            $model_field_value
492
-                        );
493
-                        break;
494
-                    case 'EVT_ID':
495
-                        /** @var EE_Event $Event */
496
-                        $Event         = $model->get_one_by_ID($model_field_value);
497
-                        $label_parts[] = $Event instanceof EE_Event
498
-                            ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name())
499
-                            : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value);
500
-                        break;
501
-                }
502
-            }
503
-        }
504
-
505
-        if ($label_parts) {
506
-            // prepend to the last element of $label_parts an "and".
507
-            if (count($label_parts) > 1) {
508
-                $label_parts_index_to_prepend               = count($label_parts) - 1;
509
-                $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ];
510
-            }
511
-
512
-            $pretty_label .= sprintf(
513
-                esc_html_x(
514
-                    'Showing messages for %s',
515
-                    'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.',
516
-                    'event_espresso'
517
-                ),
518
-                implode(', ', $label_parts)
519
-            );
520
-        }
521
-        return $pretty_label;
522
-    }
523
-
524
-
525
-    /**
526
-     * This returns the array of expected variables for the EEI_Query_Filter methods being implemented
527
-     * The array is in the format:
528
-     * array(
529
-     *  {$field_name} => {$model_name}
530
-     * );
531
-     *
532
-     * @since 4.9.0
533
-     * @return array
534
-     */
535
-    protected function _expected_vars_for_query_inject()
536
-    {
537
-        return array(
538
-            '_REG_ID' => 'Registration',
539
-            'ATT_ID'  => 'Attendee',
540
-            'ID'      => 'WP_User',
541
-            'TXN_ID'  => 'Transaction',
542
-            'EVT_ID'  => 'Event',
543
-        );
544
-    }
545
-
546
-
547
-    /**
548
-     * This returns whether EEM_Message is in debug mode or not.
549
-     * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when
550
-     * generating/sending messages. Debug mode can be set by either:
551
-     * 1. Sending in a value for the $set_debug argument
552
-     * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php
553
-     * 3. Overriding the above via the provided filter.
554
-     *
555
-     * @param bool|null $set_debug      If provided, then the debug mode will be set internally until reset via the
556
-     *                                  provided boolean. When no argument is provided (default null) then the debug
557
-     *                                  mode will be returned.
558
-     * @return bool         true means Messages is in debug mode.  false means messages system is not in debug mode.
559
-     */
560
-    public static function debug($set_debug = null)
561
-    {
562
-        static $is_debugging = null;
563
-
564
-        // initialize (use constant if set).
565
-        if (is_null($set_debug) && is_null($is_debugging)) {
566
-            $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES;
567
-        }
568
-
569
-        if (! is_null($set_debug)) {
570
-            $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN);
571
-        }
572
-
573
-        // return filtered value
574
-        return apply_filters('FHEE__EEM_Message__debug', $is_debugging);
575
-    }
576
-
577
-
578
-    /**
579
-     * Deletes old messages meeting certain criteria for removal from the database.
580
-     * By default, this will delete messages that:
581
-     * - are older than the value of the delete_threshold in months.
582
-     * - have a STS_ID other than EEM_Message::status_idle
583
-     *
584
-     * @param int $delete_threshold This integer will be used to set the boundary for what messages are deleted in
585
-     *                              months.
586
-     * @return bool|false|int Either the number of records affected or false if there was an error (you can call
587
-     *                              $wpdb->last_error to find out what the error was.
588
-     * @throws EE_Error
589
-     * @throws EE_Error
590
-     * @throws EE_Error
591
-     */
592
-    public function delete_old_messages($delete_threshold = 6)
593
-    {
594
-        $number_deleted = 0;
595
-        /**
596
-         * Allows code to change the boundary for what messages are kept.
597
-         * Uses the value of the `delete_threshold` variable by default.
598
-         *
599
-         * @param int $seconds seconds that will be subtracted from the timestamp for now.
600
-         * @return int
601
-         */
602
-        $time_to_leave_alone = absint(
603
-            apply_filters(
604
-                'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone',
605
-                ((int) $delete_threshold) * MONTH_IN_SECONDS
606
-            )
607
-        );
608
-
609
-
610
-        /**
611
-         * Allows code to change what message stati are ignored when deleting.
612
-         * Defaults to only ignore EEM_Message::status_idle messages.
613
-         *
614
-         * @param string $message_stati_to_keep  An array of message statuses that will be ignored when deleting.
615
-         */
616
-        $message_stati_to_keep = (array) apply_filters(
617
-            'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep',
618
-            array(
619
-                EEM_Message::status_idle
620
-            )
621
-        );
622
-
623
-        // first get all the ids of messages being deleted
624
-        $message_ids_to_delete = EEM_Message::instance()->get_col(
625
-            array(
626
-                0 => array(
627
-                    'STS_ID' => array('NOT_IN', $message_stati_to_keep),
628
-                    'MSG_modified' => array('<', time() - $time_to_leave_alone)
629
-                ),
630
-                'limit' => apply_filters(
631
-                    'EEM_Message__delete_old_messages__limit',
632
-                    2000,
633
-                    $delete_threshold
634
-                )
635
-            )
636
-        );
637
-
638
-        if (! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
639
-            global $wpdb;
640
-            $number_deleted = $wpdb->query('
15
+	// private instance of the Message object
16
+	protected static $_instance = null;
17
+
18
+
19
+	/**
20
+	 * This priority indicates a message should be generated and sent ASAP
21
+	 *
22
+	 * @type int
23
+	 */
24
+	const priority_high = 10;
25
+
26
+
27
+	/**
28
+	 * This priority indicates a message should be generated ASAP and queued for sending.
29
+	 *
30
+	 * @type
31
+	 */
32
+	const priority_medium = 20;
33
+
34
+
35
+	/**
36
+	 * This priority indicates a message should be queued for generating.
37
+	 *
38
+	 * @type int
39
+	 */
40
+	const priority_low = 30;
41
+
42
+
43
+	/**
44
+	 * indicates this message was sent at the time modified
45
+	 */
46
+	const status_sent = 'MSN';
47
+
48
+
49
+	/**
50
+	 * indicates this message is waiting to be sent
51
+	 */
52
+	const status_idle = 'MID';
53
+
54
+
55
+	/**
56
+	 * indicates an attempt was a made to send this message
57
+	 * at the scheduled time, but it failed at the time modified.  This differs from MDO status in that it will ALWAYS
58
+	 * appear to the end user.
59
+	 */
60
+	const status_failed = 'MFL';
61
+
62
+
63
+	/**
64
+	 * indicates the message has been flagged for resending (at the time modified).
65
+	 */
66
+	const status_resend = 'MRS';
67
+
68
+
69
+	/**
70
+	 * indicates the message has been flagged for generation but has not been generated yet.  Messages always start as
71
+	 * this status when added to the queue.
72
+	 */
73
+	const status_incomplete = 'MIC';
74
+
75
+
76
+	/**
77
+	 * Indicates everything was generated fine for the message, however, the messenger was unable to send.
78
+	 * This status means that its possible to retry sending the message.
79
+	 */
80
+	const status_retry = 'MRT';
81
+
82
+
83
+	/**
84
+	 * This is used for more informational messages that may not indicate anything is broken but still cannot be
85
+	 * generated or sent correctly. An example of a message that would get flagged this way would be when a not
86
+	 * approved message was queued for generation, but at time of generation, the attached registration(s) are
87
+	 * approved. So the message queued for generation is no longer valid.  Messages for this status will only persist
88
+	 * in the db and be viewable in the message activity list table when the messages system is in debug mode.
89
+	 *
90
+	 * @see EEM_Message::debug()
91
+	 */
92
+	const status_debug_only = 'MDO';
93
+
94
+
95
+	/**
96
+	 * This status is given to messages it is processed by the messenger send method.
97
+	 * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually
98
+	 * indicative of a PHP timeout or memory limit issue.
99
+	 */
100
+	const status_messenger_executing = 'MEX';
101
+
102
+
103
+	/**
104
+	 *    Private constructor to prevent direct creation.
105
+	 *
106
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and
107
+	 *                         any incoming timezone data that gets saved).  Note this just sends the timezone info to
108
+	 *                         the date time model field objects.  Default is null (and will be assumed using the set
109
+	 *                         timezone in the 'timezone_string' wp option)
110
+	 * @throws EE_Error
111
+	 * @throws EE_Error
112
+	 * @throws EE_Error
113
+	 */
114
+	protected function __construct($timezone = null)
115
+	{
116
+		$this->singular_item = esc_html__('Message', 'event_espresso');
117
+		$this->plural_item   = esc_html__('Messages', 'event_espresso');
118
+
119
+		$this->_tables = array(
120
+			'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'),
121
+		);
122
+
123
+		$allowed_priority = array(
124
+			self::priority_high   => esc_html__('high', 'event_espresso'),
125
+			self::priority_medium => esc_html__('medium', 'event_espresso'),
126
+			self::priority_low    => esc_html__('low', 'event_espresso'),
127
+		);
128
+
129
+		$this->_fields          = array(
130
+			'Message' => array(
131
+				'MSG_ID'             => new EE_Primary_Key_Int_Field('MSG_ID', esc_html__('Message ID', 'event_espresso')),
132
+				'MSG_token'          => new EE_Plain_Text_Field(
133
+					'MSG_token',
134
+					esc_html__(
135
+						'Unique Token used to represent this row in publicly viewable contexts (eg. a url).',
136
+						'event_espresso'
137
+					),
138
+					false,
139
+					EEH_URL::generate_unique_token()
140
+				),
141
+				'GRP_ID'             => new EE_Foreign_Key_Int_Field(
142
+					'GRP_ID',
143
+					esc_html__('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'),
144
+					true,
145
+					0,
146
+					'Message_Template_Group'
147
+				),
148
+				'TXN_ID'             => new EE_Foreign_Key_Int_Field(
149
+					'TXN_ID',
150
+					esc_html__(
151
+						'Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message',
152
+						'event_espresso'
153
+					),
154
+					true,
155
+					0,
156
+					'Transaction'
157
+				),
158
+				'MSG_messenger'      => new EE_Plain_Text_Field(
159
+					'MSG_messenger',
160
+					esc_html__(
161
+						'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.',
162
+						'event_espresso'
163
+					),
164
+					false,
165
+					'email'
166
+				),
167
+				'MSG_message_type'   => new EE_Plain_Text_Field(
168
+					'MSG_message_type',
169
+					esc_html__('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'),
170
+					false,
171
+					'receipt'
172
+				),
173
+				'MSG_context'        => new EE_Plain_Text_Field('MSG_context', esc_html__('Context', 'event_espresso'), false),
174
+				'MSG_recipient_ID'   => new EE_Foreign_Key_Int_Field(
175
+					'MSG_recipient_ID',
176
+					esc_html__('Recipient ID', 'event_espresso'),
177
+					true,
178
+					null,
179
+					array('Registration', 'Attendee', 'WP_User')
180
+				),
181
+				'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field(
182
+					'MSG_recipient_type',
183
+					esc_html__('Recipient Type', 'event_espresso'),
184
+					true,
185
+					null,
186
+					array('Registration', 'Attendee', 'WP_User')
187
+				),
188
+				'MSG_content'        => new EE_Maybe_Serialized_Text_Field(
189
+					'MSG_content',
190
+					esc_html__('Content', 'event_espresso'),
191
+					true,
192
+					''
193
+				),
194
+				'MSG_to'             => new EE_Maybe_Serialized_Text_Field(
195
+					'MSG_to',
196
+					esc_html__('Address To', 'event_espresso'),
197
+					true
198
+				),
199
+				'MSG_from'           => new EE_Maybe_Serialized_Text_Field(
200
+					'MSG_from',
201
+					esc_html__('Address From', 'event_espresso'),
202
+					true
203
+				),
204
+				'MSG_subject'        => new EE_Maybe_Serialized_Text_Field(
205
+					'MSG_subject',
206
+					esc_html__('Subject', 'event_espresso'),
207
+					true,
208
+					''
209
+				),
210
+				'MSG_priority'       => new EE_Enum_Integer_Field(
211
+					'MSG_priority',
212
+					esc_html__('Priority', 'event_espresso'),
213
+					false,
214
+					self::priority_low,
215
+					$allowed_priority
216
+				),
217
+				'STS_ID'             => new EE_Foreign_Key_String_Field(
218
+					'STS_ID',
219
+					esc_html__('Status', 'event_espresso'),
220
+					false,
221
+					self::status_incomplete,
222
+					'Status'
223
+				),
224
+				'MSG_created'        => new EE_Datetime_Field(
225
+					'MSG_created',
226
+					esc_html__('Created', 'event_espresso'),
227
+					false,
228
+					EE_Datetime_Field::now
229
+				),
230
+				'MSG_modified'       => new EE_Datetime_Field(
231
+					'MSG_modified',
232
+					esc_html__('Modified', 'event_espresso'),
233
+					true,
234
+					EE_Datetime_Field::now
235
+				),
236
+			),
237
+		);
238
+		$this->_model_relations = array(
239
+			'Attendee'               => new EE_Belongs_To_Any_Relation(),
240
+			'Registration'           => new EE_Belongs_To_Any_Relation(),
241
+			'WP_User'                => new EE_Belongs_To_Any_Relation(),
242
+			'Message_Template_Group' => new EE_Belongs_To_Relation(),
243
+			'Transaction'            => new EE_Belongs_To_Relation(),
244
+		);
245
+		parent::__construct($timezone);
246
+	}
247
+
248
+
249
+	/**
250
+	 * @return EE_Message
251
+	 * @throws EE_Error
252
+	 */
253
+	public function create_default_object()
254
+	{
255
+		/** @type EE_Message $message */
256
+		$message = parent::create_default_object();
257
+		if ($message instanceof EE_Message) {
258
+			return EE_Message_Factory::set_messenger_and_message_type($message);
259
+		}
260
+		return null;
261
+	}
262
+
263
+
264
+	/**
265
+	 * @param mixed $cols_n_values
266
+	 * @return EE_Message
267
+	 * @throws EE_Error
268
+	 * @throws EE_Error
269
+	 */
270
+	public function instantiate_class_from_array_or_object($cols_n_values)
271
+	{
272
+		/** @type EE_Message $message */
273
+		$message = parent::instantiate_class_from_array_or_object($cols_n_values);
274
+		if ($message instanceof EE_Message) {
275
+			return EE_Message_Factory::set_messenger_and_message_type($message);
276
+		}
277
+		return null;
278
+	}
279
+
280
+
281
+	/**
282
+	 * Returns whether or not a message of that type was sent for a given attendee.
283
+	 *
284
+	 * @param EE_Attendee|int $attendee
285
+	 * @param string          $message_type the message type slug
286
+	 * @return boolean
287
+	 * @throws EE_Error
288
+	 * @throws EE_Error
289
+	 * @throws EE_Error
290
+	 */
291
+	public function message_sent_for_attendee($attendee, $message_type)
292
+	{
293
+		$attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee);
294
+		return $this->exists(array(
295
+			array(
296
+				'Attendee.ATT_ID'  => $attendee_ID,
297
+				'MSG_message_type' => $message_type,
298
+				'STS_ID'           => array('IN', $this->stati_indicating_sent()),
299
+			),
300
+		));
301
+	}
302
+
303
+
304
+	/**
305
+	 * Returns whether or not a message of that type was sent for a given registration
306
+	 *
307
+	 * @param EE_Registration|int $registration
308
+	 * @param string              $message_type the message type slug
309
+	 * @return boolean
310
+	 * @throws EE_Error
311
+	 * @throws EE_Error
312
+	 * @throws EE_Error
313
+	 */
314
+	public function message_sent_for_registration($registration, $message_type)
315
+	{
316
+		$registrationID = EEM_Registration::instance()->ensure_is_ID($registration);
317
+		return $this->exists(array(
318
+			array(
319
+				'Registration.REG_ID' => $registrationID,
320
+				'MSG_message_type'    => $message_type,
321
+				'STS_ID'              => array('IN', $this->stati_indicating_sent()),
322
+			),
323
+		));
324
+	}
325
+
326
+
327
+	/**
328
+	 * This retrieves an EE_Message object from the db matching the given token string.
329
+	 *
330
+	 * @param string $token
331
+	 * @return EE_Message
332
+	 * @throws EE_Error
333
+	 */
334
+	public function get_one_by_token($token)
335
+	{
336
+		return $this->get_one(array(
337
+			array(
338
+				'MSG_token' => $token,
339
+			),
340
+		));
341
+	}
342
+
343
+
344
+	/**
345
+	 * Returns stati that indicate the message HAS been sent
346
+	 *
347
+	 * @return array of strings for possible stati
348
+	 */
349
+	public function stati_indicating_sent()
350
+	{
351
+		return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent));
352
+	}
353
+
354
+
355
+	/**
356
+	 * Returns stati that indicate the message is waiting to be sent.
357
+	 *
358
+	 * @return array of strings for possible stati.
359
+	 */
360
+	public function stati_indicating_to_send()
361
+	{
362
+		return apply_filters(
363
+			'FHEE__EEM_Message__stati_indicating_to_send',
364
+			array(self::status_idle, self::status_resend)
365
+		);
366
+	}
367
+
368
+
369
+	/**
370
+	 * Returns stati that indicate the message has failed sending
371
+	 *
372
+	 * @return array  array of strings for possible stati.
373
+	 */
374
+	public function stati_indicating_failed_sending()
375
+	{
376
+		$failed_stati = array(
377
+			self::status_failed,
378
+			self::status_retry,
379
+			self::status_messenger_executing,
380
+		);
381
+		// if WP_DEBUG is set, then let's include debug_only fails
382
+		if (WP_DEBUG) {
383
+			$failed_stati[] = self::status_debug_only;
384
+		}
385
+		return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati);
386
+	}
387
+
388
+
389
+	/**
390
+	 * Returns filterable array of all EEM_Message statuses.
391
+	 *
392
+	 * @return array
393
+	 */
394
+	public function all_statuses()
395
+	{
396
+		return apply_filters(
397
+			'FHEE__EEM_Message__all_statuses',
398
+			array(
399
+				EEM_Message::status_sent,
400
+				EEM_Message::status_incomplete,
401
+				EEM_Message::status_idle,
402
+				EEM_Message::status_resend,
403
+				EEM_Message::status_retry,
404
+				EEM_Message::status_failed,
405
+				EEM_Message::status_messenger_executing,
406
+				EEM_Message::status_debug_only,
407
+			)
408
+		);
409
+	}
410
+
411
+	/**
412
+	 * Detects any specific query variables in the request and uses those to setup appropriate
413
+	 * filter for any queries.
414
+	 *
415
+	 * @return array
416
+	 */
417
+	public function filter_by_query_params()
418
+	{
419
+		/** @var RequestInterface $request */
420
+		$request = EEM_Base::$loader->getShared(RequestInterface::class);
421
+		// expected possible query_vars, the key in this array matches an expected key in the request,
422
+		// the value, matches the corresponding EEM_Base child reference.
423
+		$expected_vars   = $this->_expected_vars_for_query_inject();
424
+		$query_params[0] = array();
425
+		foreach ($expected_vars as $request_key => $model_name) {
426
+			$request_value = $request->getRequestParam($request_key);
427
+			if ($request_value) {
428
+				// special case
429
+				switch ($request_key) {
430
+					case '_REG_ID':
431
+						$query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array(
432
+							'Transaction.Registration.REG_ID' => $request_value,
433
+						);
434
+						break;
435
+					case 'EVT_ID':
436
+						$query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array(
437
+							'Transaction.Registration.EVT_ID' => $request_value,
438
+						);
439
+						break;
440
+					default:
441
+						$query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value;
442
+						break;
443
+				}
444
+			}
445
+		}
446
+		return $query_params;
447
+	}
448
+
449
+
450
+	/**
451
+	 * @return string
452
+	 * @throws EE_Error
453
+	 * @throws ReflectionException
454
+	 */
455
+	public function get_pretty_label_for_results()
456
+	{
457
+		/** @var RequestInterface $request */
458
+		$request = EEM_Base::$loader->getShared(RequestInterface::class);
459
+		$expected_vars = $this->_expected_vars_for_query_inject();
460
+		$pretty_label  = '';
461
+		$label_parts   = array();
462
+		foreach ($expected_vars as $request_key => $model_name) {
463
+			$model_name = strpos($model_name, 'EEM_', true) === 0 ? $model_name : "EEM_{$model_name}";
464
+			$model = EEM_Base::$loader->getShared($model_name);
465
+			$model_field_value = $request->getRequestParam($request_key);
466
+			if ($model instanceof EEM_Base && $model_field_value !== '') {
467
+				switch ($request_key) {
468
+					case '_REG_ID':
469
+						$label_parts[] = sprintf(
470
+							esc_html__('Registration with the ID: %s', 'event_espresso'),
471
+							$model_field_value
472
+						);
473
+						break;
474
+					case 'ATT_ID':
475
+						/** @var EE_Attendee $attendee */
476
+						$attendee      = $model->get_one_by_ID($model_field_value);
477
+						$label_parts[] = $attendee instanceof EE_Attendee
478
+							? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name())
479
+							: sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value);
480
+						break;
481
+					case 'ID':
482
+						/** @var EE_WP_User $wpUser */
483
+						$wpUser        = $model->get_one_by_ID($model_field_value);
484
+						$label_parts[] = $wpUser instanceof EE_WP_User
485
+							? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name())
486
+							: sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value);
487
+						break;
488
+					case 'TXN_ID':
489
+						$label_parts[] = sprintf(
490
+							esc_html__('Transaction with the ID: %s', 'event_espresso'),
491
+							$model_field_value
492
+						);
493
+						break;
494
+					case 'EVT_ID':
495
+						/** @var EE_Event $Event */
496
+						$Event         = $model->get_one_by_ID($model_field_value);
497
+						$label_parts[] = $Event instanceof EE_Event
498
+							? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name())
499
+							: sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value);
500
+						break;
501
+				}
502
+			}
503
+		}
504
+
505
+		if ($label_parts) {
506
+			// prepend to the last element of $label_parts an "and".
507
+			if (count($label_parts) > 1) {
508
+				$label_parts_index_to_prepend               = count($label_parts) - 1;
509
+				$label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ];
510
+			}
511
+
512
+			$pretty_label .= sprintf(
513
+				esc_html_x(
514
+					'Showing messages for %s',
515
+					'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.',
516
+					'event_espresso'
517
+				),
518
+				implode(', ', $label_parts)
519
+			);
520
+		}
521
+		return $pretty_label;
522
+	}
523
+
524
+
525
+	/**
526
+	 * This returns the array of expected variables for the EEI_Query_Filter methods being implemented
527
+	 * The array is in the format:
528
+	 * array(
529
+	 *  {$field_name} => {$model_name}
530
+	 * );
531
+	 *
532
+	 * @since 4.9.0
533
+	 * @return array
534
+	 */
535
+	protected function _expected_vars_for_query_inject()
536
+	{
537
+		return array(
538
+			'_REG_ID' => 'Registration',
539
+			'ATT_ID'  => 'Attendee',
540
+			'ID'      => 'WP_User',
541
+			'TXN_ID'  => 'Transaction',
542
+			'EVT_ID'  => 'Event',
543
+		);
544
+	}
545
+
546
+
547
+	/**
548
+	 * This returns whether EEM_Message is in debug mode or not.
549
+	 * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when
550
+	 * generating/sending messages. Debug mode can be set by either:
551
+	 * 1. Sending in a value for the $set_debug argument
552
+	 * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php
553
+	 * 3. Overriding the above via the provided filter.
554
+	 *
555
+	 * @param bool|null $set_debug      If provided, then the debug mode will be set internally until reset via the
556
+	 *                                  provided boolean. When no argument is provided (default null) then the debug
557
+	 *                                  mode will be returned.
558
+	 * @return bool         true means Messages is in debug mode.  false means messages system is not in debug mode.
559
+	 */
560
+	public static function debug($set_debug = null)
561
+	{
562
+		static $is_debugging = null;
563
+
564
+		// initialize (use constant if set).
565
+		if (is_null($set_debug) && is_null($is_debugging)) {
566
+			$is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES;
567
+		}
568
+
569
+		if (! is_null($set_debug)) {
570
+			$is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN);
571
+		}
572
+
573
+		// return filtered value
574
+		return apply_filters('FHEE__EEM_Message__debug', $is_debugging);
575
+	}
576
+
577
+
578
+	/**
579
+	 * Deletes old messages meeting certain criteria for removal from the database.
580
+	 * By default, this will delete messages that:
581
+	 * - are older than the value of the delete_threshold in months.
582
+	 * - have a STS_ID other than EEM_Message::status_idle
583
+	 *
584
+	 * @param int $delete_threshold This integer will be used to set the boundary for what messages are deleted in
585
+	 *                              months.
586
+	 * @return bool|false|int Either the number of records affected or false if there was an error (you can call
587
+	 *                              $wpdb->last_error to find out what the error was.
588
+	 * @throws EE_Error
589
+	 * @throws EE_Error
590
+	 * @throws EE_Error
591
+	 */
592
+	public function delete_old_messages($delete_threshold = 6)
593
+	{
594
+		$number_deleted = 0;
595
+		/**
596
+		 * Allows code to change the boundary for what messages are kept.
597
+		 * Uses the value of the `delete_threshold` variable by default.
598
+		 *
599
+		 * @param int $seconds seconds that will be subtracted from the timestamp for now.
600
+		 * @return int
601
+		 */
602
+		$time_to_leave_alone = absint(
603
+			apply_filters(
604
+				'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone',
605
+				((int) $delete_threshold) * MONTH_IN_SECONDS
606
+			)
607
+		);
608
+
609
+
610
+		/**
611
+		 * Allows code to change what message stati are ignored when deleting.
612
+		 * Defaults to only ignore EEM_Message::status_idle messages.
613
+		 *
614
+		 * @param string $message_stati_to_keep  An array of message statuses that will be ignored when deleting.
615
+		 */
616
+		$message_stati_to_keep = (array) apply_filters(
617
+			'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep',
618
+			array(
619
+				EEM_Message::status_idle
620
+			)
621
+		);
622
+
623
+		// first get all the ids of messages being deleted
624
+		$message_ids_to_delete = EEM_Message::instance()->get_col(
625
+			array(
626
+				0 => array(
627
+					'STS_ID' => array('NOT_IN', $message_stati_to_keep),
628
+					'MSG_modified' => array('<', time() - $time_to_leave_alone)
629
+				),
630
+				'limit' => apply_filters(
631
+					'EEM_Message__delete_old_messages__limit',
632
+					2000,
633
+					$delete_threshold
634
+				)
635
+			)
636
+		);
637
+
638
+		if (! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) {
639
+			global $wpdb;
640
+			$number_deleted = $wpdb->query('
641 641
                 DELETE
642 642
                 FROM ' . $this->table() . '
643 643
                 WHERE
644 644
                     MSG_ID IN (' . implode(",", $message_ids_to_delete) . ')
645 645
             ');
646
-        }
647
-
648
-        /**
649
-         * This will get called if the number of records deleted 0 or greater.  So a successful deletion is one where
650
-         * there were no errors.  An unsuccessful deletion is where there were errors.  Keep that in mind for the actions
651
-         * below.
652
-         */
653
-        if ($number_deleted !== false) {
654
-            do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted);
655
-        } else {
656
-            do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted);
657
-        }
658
-        return $number_deleted;
659
-    }
646
+		}
647
+
648
+		/**
649
+		 * This will get called if the number of records deleted 0 or greater.  So a successful deletion is one where
650
+		 * there were no errors.  An unsuccessful deletion is where there were errors.  Keep that in mind for the actions
651
+		 * below.
652
+		 */
653
+		if ($number_deleted !== false) {
654
+			do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted);
655
+		} else {
656
+			do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted);
657
+		}
658
+		return $number_deleted;
659
+	}
660 660
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Field_With_Model_Name.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,10 +79,10 @@
 block discarded – undo
79 79
         $model_names = [];
80 80
         if (is_array($this->_model_name_pointed_to)) {
81 81
             foreach ($this->_model_name_pointed_to as $model_name) {
82
-                $model_names[] = "EE_" . $model_name;
82
+                $model_names[] = "EE_".$model_name;
83 83
             }
84 84
         } else {
85
-            $model_names = ["EE_" . $this->_model_name_pointed_to];
85
+            $model_names = ["EE_".$this->_model_name_pointed_to];
86 86
         }
87 87
         return $model_names;
88 88
     }
Please login to merge, or discard this patch.
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -8,94 +8,94 @@
 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[]
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[]
16
+	 */
17
+	protected $_model_name_pointed_to;
18 18
 
19 19
 
20
-    /**
21
-     * @param string          $table_column  name of column for field
22
-     * @param string          $nicename      should be internationalized with __('blah','event_espresso')
23
-     * @param boolean         $nullable
24
-     * @param int|string      $default_value data type should match field type
25
-     * @param string|string[] $model_name    eg 'Event','Answer','Term', etc.
26
-     *                                       Basically its the model class's name without the "EEM_"
27
-     */
28
-    public function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
29
-    {
30
-        $this->_model_name_pointed_to = (array) $model_name;
31
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
32
-    }
20
+	/**
21
+	 * @param string          $table_column  name of column for field
22
+	 * @param string          $nicename      should be internationalized with __('blah','event_espresso')
23
+	 * @param boolean         $nullable
24
+	 * @param int|string      $default_value data type should match field type
25
+	 * @param string|string[] $model_name    eg 'Event','Answer','Term', etc.
26
+	 *                                       Basically its the model class's name without the "EEM_"
27
+	 */
28
+	public function __construct($table_column, $nicename, $nullable, $default_value, $model_name)
29
+	{
30
+		$this->_model_name_pointed_to = (array) $model_name;
31
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * Returns the name of the model(s) pointed to
37
-     *
38
-     * @return string[] string or array of strings
39
-     * @deprecated since version 4.6.7
40
-     */
41
-    public function get_model_name_pointed_to(): array
42
-    {
43
-        EE_Error::doing_it_wrong(
44
-            'get_model_name_pointed_to',
45
-            esc_html__(
46
-                'This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array',
47
-                'event_espresso'
48
-            ),
49
-            '4.6.7'
50
-        );
51
-        return $this->_model_name_pointed_to;
52
-    }
35
+	/**
36
+	 * Returns the name of the model(s) pointed to
37
+	 *
38
+	 * @return string[] string or array of strings
39
+	 * @deprecated since version 4.6.7
40
+	 */
41
+	public function get_model_name_pointed_to(): array
42
+	{
43
+		EE_Error::doing_it_wrong(
44
+			'get_model_name_pointed_to',
45
+			esc_html__(
46
+				'This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array',
47
+				'event_espresso'
48
+			),
49
+			'4.6.7'
50
+		);
51
+		return $this->_model_name_pointed_to;
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Gets the model names pointed to by this field, always as an array
57
-     * (even if there's only one)
58
-     *
59
-     * @return string[] of model names pointed to by this field
60
-     */
61
-    public function get_model_names_pointed_to(): array
62
-    {
63
-        return is_array($this->_model_name_pointed_to)
64
-            ? $this->_model_name_pointed_to
65
-            : [$this->_model_name_pointed_to];
66
-    }
55
+	/**
56
+	 * Gets the model names pointed to by this field, always as an array
57
+	 * (even if there's only one)
58
+	 *
59
+	 * @return string[] of model names pointed to by this field
60
+	 */
61
+	public function get_model_names_pointed_to(): array
62
+	{
63
+		return is_array($this->_model_name_pointed_to)
64
+			? $this->_model_name_pointed_to
65
+			: [$this->_model_name_pointed_to];
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * Returns the model's classname (eg EE_Event instead of just Event)
71
-     *
72
-     * @return string[]
73
-     */
74
-    public function get_model_class_names_pointed_to(): array
75
-    {
76
-        $model_names = [];
77
-        if (is_array($this->_model_name_pointed_to)) {
78
-            foreach ($this->_model_name_pointed_to as $model_name) {
79
-                $model_names[] = "EE_" . $model_name;
80
-            }
81
-        } else {
82
-            $model_names = ["EE_" . $this->_model_name_pointed_to];
83
-        }
84
-        return $model_names;
85
-    }
69
+	/**
70
+	 * Returns the model's classname (eg EE_Event instead of just Event)
71
+	 *
72
+	 * @return string[]
73
+	 */
74
+	public function get_model_class_names_pointed_to(): array
75
+	{
76
+		$model_names = [];
77
+		if (is_array($this->_model_name_pointed_to)) {
78
+			foreach ($this->_model_name_pointed_to as $model_name) {
79
+				$model_names[] = "EE_" . $model_name;
80
+			}
81
+		} else {
82
+			$model_names = ["EE_" . $this->_model_name_pointed_to];
83
+		}
84
+		return $model_names;
85
+	}
86 86
 
87 87
 
88
-    /**
89
-     * @param int|EE_Base_Class $model_obj
90
-     * @return bool
91
-     */
92
-    public function is_model_obj_of_type_pointed_to($model_obj): bool
93
-    {
94
-        foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
95
-            if ($model_obj instanceof $model_obj_classname) {
96
-                return true;
97
-            }
98
-        }
99
-        return false;
100
-    }
88
+	/**
89
+	 * @param int|EE_Base_Class $model_obj
90
+	 * @return bool
91
+	 */
92
+	public function is_model_obj_of_type_pointed_to($model_obj): bool
93
+	{
94
+		foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
95
+			if ($model_obj instanceof $model_obj_classname) {
96
+				return true;
97
+			}
98
+		}
99
+		return false;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_WP_Post_Type_Field.php.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@
 block discarded – undo
5 5
  */
6 6
 class EE_WP_Post_Type_Field extends EE_DB_Only_Text_Field
7 7
 {
8
-    /**
9
-     * @param string $post_type the exact string to be used for the post type
10
-     *                          of all these post type model objects/rows
11
-     */
12
-    public function __construct($post_type)
13
-    {
14
-        parent::__construct('post_type', esc_html__("Post Type", 'event_espresso'), false, $post_type);
15
-    }
8
+	/**
9
+	 * @param string $post_type the exact string to be used for the post type
10
+	 *                          of all these post type model objects/rows
11
+	 */
12
+	public function __construct($post_type)
13
+	{
14
+		parent::__construct('post_type', esc_html__("Post Type", 'event_espresso'), false, $post_type);
15
+	}
16 16
 }
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Button.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -4,49 +4,49 @@
 block discarded – undo
4 4
 
5 5
 class Button
6 6
 {
7
-    /**
8
-     * indicates that the HTML input type is 'button'
9
-     */
10
-    public const TYPE_BUTTON = 'button';
11
-
12
-    /**
13
-     * indicates that the HTML input type is 'reset'
14
-     */
15
-    public const TYPE_BUTTON_RESET = 'reset';
16
-
17
-    /**
18
-     * indicates that the HTML input type is 'submit'
19
-     */
20
-    public const TYPE_BUTTON_SUBMIT = 'submit';
21
-
22
-
23
-    /**
24
-     * @var array
25
-     */
26
-    private $valid_type_options;
27
-
28
-
29
-    public function __construct()
30
-    {
31
-        $this->valid_type_options = apply_filters(
32
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Button__valid_type_options',
33
-            [
34
-                Button::TYPE_BUTTON        => esc_html__('Button', 'event_espresso'),
35
-                Button::TYPE_BUTTON_RESET  => esc_html__('Reset Button', 'event_espresso'),
36
-                Button::TYPE_BUTTON_SUBMIT => esc_html__('Submit Button', 'event_espresso'),
37
-            ]
38
-        );
39
-    }
40
-
41
-
42
-    /**
43
-     * @param bool $constants_only
44
-     * @return array
45
-     */
46
-    public function validTypeOptions(bool $constants_only = false): array
47
-    {
48
-        return $constants_only
49
-            ? array_keys($this->valid_type_options)
50
-            : $this->valid_type_options;
51
-    }
7
+	/**
8
+	 * indicates that the HTML input type is 'button'
9
+	 */
10
+	public const TYPE_BUTTON = 'button';
11
+
12
+	/**
13
+	 * indicates that the HTML input type is 'reset'
14
+	 */
15
+	public const TYPE_BUTTON_RESET = 'reset';
16
+
17
+	/**
18
+	 * indicates that the HTML input type is 'submit'
19
+	 */
20
+	public const TYPE_BUTTON_SUBMIT = 'submit';
21
+
22
+
23
+	/**
24
+	 * @var array
25
+	 */
26
+	private $valid_type_options;
27
+
28
+
29
+	public function __construct()
30
+	{
31
+		$this->valid_type_options = apply_filters(
32
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Button__valid_type_options',
33
+			[
34
+				Button::TYPE_BUTTON        => esc_html__('Button', 'event_espresso'),
35
+				Button::TYPE_BUTTON_RESET  => esc_html__('Reset Button', 'event_espresso'),
36
+				Button::TYPE_BUTTON_SUBMIT => esc_html__('Submit Button', 'event_espresso'),
37
+			]
38
+		);
39
+	}
40
+
41
+
42
+	/**
43
+	 * @param bool $constants_only
44
+	 * @return array
45
+	 */
46
+	public function validTypeOptions(bool $constants_only = false): array
47
+	{
48
+		return $constants_only
49
+			? array_keys($this->valid_type_options)
50
+			: $this->valid_type_options;
51
+	}
52 52
 }
Please login to merge, or discard this patch.
core/services/form/meta/inputs/DateTime.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -5,81 +5,81 @@
 block discarded – undo
5 5
 class DateTime
6 6
 {
7 7
 
8
-    /**
9
-     * indicates that the HTML input type is 'date'
10
-     */
11
-    public const TYPE_DATE = 'date';
12
-
13
-    /**
14
-     * indicates that the HTML input type is 'datetime-local'
15
-     */
16
-    public const TYPE_DATETIME_LOCAL = 'datetime-local';
17
-
18
-    /**
19
-     * indicates that the HTML input type is 'month'
20
-     */
21
-    public const TYPE_MONTH = 'month';
22
-
23
-    /**
24
-     * indicates that the HTML input type is 'time'
25
-     */
26
-    public const TYPE_TIME = 'time';
27
-
28
-    /**
29
-     * indicates that the HTML input type is 'week'
30
-     */
31
-    public const TYPE_WEEK = 'week';
32
-
33
-    // CUSTOM EE DATE TYPES
34
-
35
-    /**
36
-     * indicates that the input is an HTML dropdown used for selecting the day for a date
37
-     */
38
-    public const TYPE_SELECT_DAY = 'day-select';
39
-
40
-    /**
41
-     * indicates that the input is an HTML dropdown used for selecting the month for a date
42
-     */
43
-    public const TYPE_SELECT_MONTH = 'month-select';
44
-
45
-    /**
46
-     * indicates that the input is an HTML dropdown used for selecting the year for a date
47
-     */
48
-    public const TYPE_SELECT_YEAR = 'year-select';
49
-
50
-
51
-    /**
52
-     * @var array
53
-     */
54
-    private $valid_type_options;
55
-
56
-
57
-    public function __construct()
58
-    {
59
-        $this->valid_type_options = apply_filters(
60
-            'FHEE__EventEspresso_core_services_form_meta_inputs_DateTime__valid_type_options',
61
-            [
62
-                DateTime::TYPE_DATE           => esc_html__('Date Picker', 'event_espresso'),
63
-                DateTime::TYPE_DATETIME_LOCAL => esc_html__('Local Date Picker', 'event_espresso'),
64
-                DateTime::TYPE_MONTH          => esc_html__('Month Picker', 'event_espresso'),
65
-                DateTime::TYPE_TIME           => esc_html__('Time Picker', 'event_espresso'),
66
-                DateTime::TYPE_WEEK           => esc_html__('Week Picker', 'event_espresso'),
67
-                DateTime::TYPE_SELECT_DAY     => esc_html__('Day Selector', 'event_espresso'),
68
-                DateTime::TYPE_SELECT_MONTH   => esc_html__('Month Selector', 'event_espresso'),
69
-                DateTime::TYPE_SELECT_YEAR    => esc_html__('Year Selector', 'event_espresso'),
70
-            ]
71
-        );
72
-    }
73
-
74
-
75
-    /**
76
-     * @param bool $constants_only
77
-     * @return array
78
-     */
79
-    public function validTypeOptions(bool $constants_only = false): array
80
-    {
81
-        return $constants_only
82
-            ? array_keys($this->valid_type_options)
83
-            : $this->valid_type_options;
84
-    }
8
+	/**
9
+	 * indicates that the HTML input type is 'date'
10
+	 */
11
+	public const TYPE_DATE = 'date';
12
+
13
+	/**
14
+	 * indicates that the HTML input type is 'datetime-local'
15
+	 */
16
+	public const TYPE_DATETIME_LOCAL = 'datetime-local';
17
+
18
+	/**
19
+	 * indicates that the HTML input type is 'month'
20
+	 */
21
+	public const TYPE_MONTH = 'month';
22
+
23
+	/**
24
+	 * indicates that the HTML input type is 'time'
25
+	 */
26
+	public const TYPE_TIME = 'time';
27
+
28
+	/**
29
+	 * indicates that the HTML input type is 'week'
30
+	 */
31
+	public const TYPE_WEEK = 'week';
32
+
33
+	// CUSTOM EE DATE TYPES
34
+
35
+	/**
36
+	 * indicates that the input is an HTML dropdown used for selecting the day for a date
37
+	 */
38
+	public const TYPE_SELECT_DAY = 'day-select';
39
+
40
+	/**
41
+	 * indicates that the input is an HTML dropdown used for selecting the month for a date
42
+	 */
43
+	public const TYPE_SELECT_MONTH = 'month-select';
44
+
45
+	/**
46
+	 * indicates that the input is an HTML dropdown used for selecting the year for a date
47
+	 */
48
+	public const TYPE_SELECT_YEAR = 'year-select';
49
+
50
+
51
+	/**
52
+	 * @var array
53
+	 */
54
+	private $valid_type_options;
55
+
56
+
57
+	public function __construct()
58
+	{
59
+		$this->valid_type_options = apply_filters(
60
+			'FHEE__EventEspresso_core_services_form_meta_inputs_DateTime__valid_type_options',
61
+			[
62
+				DateTime::TYPE_DATE           => esc_html__('Date Picker', 'event_espresso'),
63
+				DateTime::TYPE_DATETIME_LOCAL => esc_html__('Local Date Picker', 'event_espresso'),
64
+				DateTime::TYPE_MONTH          => esc_html__('Month Picker', 'event_espresso'),
65
+				DateTime::TYPE_TIME           => esc_html__('Time Picker', 'event_espresso'),
66
+				DateTime::TYPE_WEEK           => esc_html__('Week Picker', 'event_espresso'),
67
+				DateTime::TYPE_SELECT_DAY     => esc_html__('Day Selector', 'event_espresso'),
68
+				DateTime::TYPE_SELECT_MONTH   => esc_html__('Month Selector', 'event_espresso'),
69
+				DateTime::TYPE_SELECT_YEAR    => esc_html__('Year Selector', 'event_espresso'),
70
+			]
71
+		);
72
+	}
73
+
74
+
75
+	/**
76
+	 * @param bool $constants_only
77
+	 * @return array
78
+	 */
79
+	public function validTypeOptions(bool $constants_only = false): array
80
+	{
81
+		return $constants_only
82
+			? array_keys($this->valid_type_options)
83
+			: $this->valid_type_options;
84
+	}
85 85
 }
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Number.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -5,49 +5,49 @@
 block discarded – undo
5 5
 class Number
6 6
 {
7 7
 
8
-    /**
9
-     * indicates that the HTML input type is 'number' whose value is a decimal (float)
10
-     */
11
-    public const TYPE_FLOAT = 'decimal';
12
-
13
-    /**
14
-     * indicates that the HTML input type is 'number' whose value is an integer (whole number)
15
-     */
16
-    public const TYPE_INT = 'integer';
17
-
18
-    /**
19
-     * indicates that the HTML input type is 'range'
20
-     */
21
-    public const TYPE_RANGE = 'range';
22
-
23
-
24
-    /**
25
-     * @var array
26
-     */
27
-    private $valid_type_options;
28
-
29
-
30
-    public function __construct()
31
-    {
32
-        $this->valid_type_options = apply_filters(
33
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Number__valid_type_options',
34
-            [
35
-                Number::TYPE_FLOAT => esc_html__('Decimal Number', 'event_espresso'),
36
-                Number::TYPE_INT   => esc_html__('Integer (Whole) Number', 'event_espresso'),
37
-                Number::TYPE_RANGE => esc_html__('Number Range', 'event_espresso'),
38
-            ]
39
-        );
40
-    }
41
-
42
-
43
-    /**
44
-     * @param bool $constants_only
45
-     * @return array
46
-     */
47
-    public function validTypeOptions(bool $constants_only = false): array
48
-    {
49
-        return $constants_only
50
-            ? array_keys($this->valid_type_options)
51
-            : $this->valid_type_options;
52
-    }
8
+	/**
9
+	 * indicates that the HTML input type is 'number' whose value is a decimal (float)
10
+	 */
11
+	public const TYPE_FLOAT = 'decimal';
12
+
13
+	/**
14
+	 * indicates that the HTML input type is 'number' whose value is an integer (whole number)
15
+	 */
16
+	public const TYPE_INT = 'integer';
17
+
18
+	/**
19
+	 * indicates that the HTML input type is 'range'
20
+	 */
21
+	public const TYPE_RANGE = 'range';
22
+
23
+
24
+	/**
25
+	 * @var array
26
+	 */
27
+	private $valid_type_options;
28
+
29
+
30
+	public function __construct()
31
+	{
32
+		$this->valid_type_options = apply_filters(
33
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Number__valid_type_options',
34
+			[
35
+				Number::TYPE_FLOAT => esc_html__('Decimal Number', 'event_espresso'),
36
+				Number::TYPE_INT   => esc_html__('Integer (Whole) Number', 'event_espresso'),
37
+				Number::TYPE_RANGE => esc_html__('Number Range', 'event_espresso'),
38
+			]
39
+		);
40
+	}
41
+
42
+
43
+	/**
44
+	 * @param bool $constants_only
45
+	 * @return array
46
+	 */
47
+	public function validTypeOptions(bool $constants_only = false): array
48
+	{
49
+		return $constants_only
50
+			? array_keys($this->valid_type_options)
51
+			: $this->valid_type_options;
52
+	}
53 53
 }
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Select.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -5,59 +5,59 @@
 block discarded – undo
5 5
 class Select
6 6
 {
7 7
 
8
-    /**
9
-     * indicates that the input is an HTML dropdown (select input) that accepts only one value
10
-     */
11
-    public const TYPE_SELECT = 'select';
12
-
13
-    /**
14
-     * indicates that the input is an HTML dropdown (select input) that accepts multiple values
15
-     */
16
-    public const TYPE_SELECT_MULTI = 'select-multi';
17
-
18
-    // CUSTOM EE SELECT TYPES
19
-
20
-    /**
21
-     * indicates that input is an HTML dropdown (select input)
22
-     * populated with names of countries that are enabled for the site
23
-     */
24
-    public const TYPE_SELECT_COUNTRY = 'select-country';
25
-
26
-    /**
27
-     * indicates that the input is an HTML dropdown (select input)
28
-     * populated with names of states for the countries that are enabled for the site
29
-     */
30
-    public const TYPE_SELECT_STATE = 'select-state';
31
-
32
-
33
-    /**
34
-     * @var array
35
-     */
36
-    private $valid_type_options;
37
-
38
-
39
-    public function __construct()
40
-    {
41
-        $this->valid_type_options = apply_filters(
42
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Select__valid_type_options',
43
-            [
44
-                Select::TYPE_SELECT         => esc_html__('Dropdown', 'event_espresso'),
45
-                Select::TYPE_SELECT_MULTI   => esc_html__('Multi-Select Dropdown', 'event_espresso'),
46
-                Select::TYPE_SELECT_COUNTRY => esc_html__('Country Selector', 'event_espresso'),
47
-                Select::TYPE_SELECT_STATE   => esc_html__('State Selector', 'event_espresso'),
48
-            ]
49
-        );
50
-    }
51
-
52
-
53
-    /**
54
-     * @param bool $constants_only
55
-     * @return array
56
-     */
57
-    public function validTypeOptions(bool $constants_only = false): array
58
-    {
59
-        return $constants_only
60
-            ? array_keys($this->valid_type_options)
61
-            : $this->valid_type_options;
62
-    }
8
+	/**
9
+	 * indicates that the input is an HTML dropdown (select input) that accepts only one value
10
+	 */
11
+	public const TYPE_SELECT = 'select';
12
+
13
+	/**
14
+	 * indicates that the input is an HTML dropdown (select input) that accepts multiple values
15
+	 */
16
+	public const TYPE_SELECT_MULTI = 'select-multi';
17
+
18
+	// CUSTOM EE SELECT TYPES
19
+
20
+	/**
21
+	 * indicates that input is an HTML dropdown (select input)
22
+	 * populated with names of countries that are enabled for the site
23
+	 */
24
+	public const TYPE_SELECT_COUNTRY = 'select-country';
25
+
26
+	/**
27
+	 * indicates that the input is an HTML dropdown (select input)
28
+	 * populated with names of states for the countries that are enabled for the site
29
+	 */
30
+	public const TYPE_SELECT_STATE = 'select-state';
31
+
32
+
33
+	/**
34
+	 * @var array
35
+	 */
36
+	private $valid_type_options;
37
+
38
+
39
+	public function __construct()
40
+	{
41
+		$this->valid_type_options = apply_filters(
42
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Select__valid_type_options',
43
+			[
44
+				Select::TYPE_SELECT         => esc_html__('Dropdown', 'event_espresso'),
45
+				Select::TYPE_SELECT_MULTI   => esc_html__('Multi-Select Dropdown', 'event_espresso'),
46
+				Select::TYPE_SELECT_COUNTRY => esc_html__('Country Selector', 'event_espresso'),
47
+				Select::TYPE_SELECT_STATE   => esc_html__('State Selector', 'event_espresso'),
48
+			]
49
+		);
50
+	}
51
+
52
+
53
+	/**
54
+	 * @param bool $constants_only
55
+	 * @return array
56
+	 */
57
+	public function validTypeOptions(bool $constants_only = false): array
58
+	{
59
+		return $constants_only
60
+			? array_keys($this->valid_type_options)
61
+			: $this->valid_type_options;
62
+	}
63 63
 }
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Phone.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -5,109 +5,109 @@
 block discarded – undo
5 5
 class Phone
6 6
 {
7 7
 
8
-    /**
9
-     * indicates that the HTML input type is 'tel'
10
-     */
11
-    public const INPUT_TYPE = 'tel';
8
+	/**
9
+	 * indicates that the HTML input type is 'tel'
10
+	 */
11
+	public const INPUT_TYPE = 'tel';
12 12
 
13
-    /**
14
-     * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples:
15
-     *      ##########
16
-     *      ###-###-####
17
-     *      ### ### ####
18
-     *      (###)-###-####
19
-     *      (###) ###-####
20
-     *
21
-     * captures the intl code to the first group (+1) and the rest of the number to group 2
22
-     *      +1 (###) ###-####
23
-     */
24
-    public const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})';
13
+	/**
14
+	 * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples:
15
+	 *      ##########
16
+	 *      ###-###-####
17
+	 *      ### ### ####
18
+	 *      (###)-###-####
19
+	 *      (###) ###-####
20
+	 *
21
+	 * captures the intl code to the first group (+1) and the rest of the number to group 2
22
+	 *      +1 (###) ###-####
23
+	 */
24
+	public const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})';
25 25
 
26
-    /**
27
-     * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples:
28
-     *      (###) #### ####
29
-     *      (####) ### ####
30
-     *      (#####) ## ####
31
-     *
32
-     * captures the intl code to the first group (+44) and the rest of the number to group 2
33
-     *      +44 (###) #### ####
34
-     */
35
-    public const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})';
26
+	/**
27
+	 * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples:
28
+	 *      (###) #### ####
29
+	 *      (####) ### ####
30
+	 *      (#####) ## ####
31
+	 *
32
+	 * captures the intl code to the first group (+44) and the rest of the number to group 2
33
+	 *      +44 (###) #### ####
34
+	 */
35
+	public const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})';
36 36
 
37
-    /**
38
-     * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples:
39
-     *      0# ## ## ## ##
40
-     *      0### ## ## ##
41
-     *
42
-     * captures the intl code to the first group (+33) and the rest of the number to group 2
43
-     *      +33 # ## ## ## ##
44
-     *      0033 # ## ## ## ##
45
-     */
46
-    public const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))';
37
+	/**
38
+	 * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples:
39
+	 *      0# ## ## ## ##
40
+	 *      0### ## ## ##
41
+	 *
42
+	 * captures the intl code to the first group (+33) and the rest of the number to group 2
43
+	 *      +33 # ## ## ## ##
44
+	 *      0033 # ## ## ## ##
45
+	 */
46
+	public const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))';
47 47
 
48
-    /**
49
-     * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples:
50
-     *      (0##) ####-####
51
-     *      (0###) ####-####
52
-     *      (0####) ###-####
53
-     *      (03####) ##-####
54
-     *
55
-     * captures the intl code to the first group (+49) and the rest of the number to group 2
56
-     *      +49 (0##) ####-####
57
-     */
58
-    public const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))';
48
+	/**
49
+	 * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples:
50
+	 *      (0##) ####-####
51
+	 *      (0###) ####-####
52
+	 *      (0####) ###-####
53
+	 *      (03####) ##-####
54
+	 *
55
+	 * captures the intl code to the first group (+49) and the rest of the number to group 2
56
+	 *      +49 (0##) ####-####
57
+	 */
58
+	public const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))';
59 59
 
60
-    /**
61
-     * @var array
62
-     */
63
-    private $regex_patterns;
60
+	/**
61
+	 * @var array
62
+	 */
63
+	private $regex_patterns;
64 64
 
65
-    /**
66
-     * @var array
67
-     */
68
-    private $valid_type_options;
65
+	/**
66
+	 * @var array
67
+	 */
68
+	private $valid_type_options;
69 69
 
70 70
 
71
-    /**
72
-     * Phone constructor.
73
-     */
74
-    public function __construct()
75
-    {
76
-        $this->regex_patterns     = (array) apply_filters(
77
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns',
78
-            [
79
-                'de_DE' => Phone::PATTERN_DE,
80
-                'fr_FR' => Phone::PATTERN_FR,
81
-                'en_UK' => Phone::PATTERN_UK,
82
-                'en_US' => Phone::PATTERN_US,
83
-            ]
84
-        );
85
-        $this->valid_type_options = apply_filters(
86
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options',
87
-            [
88
-                Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'),
89
-            ]
90
-        );
91
-    }
71
+	/**
72
+	 * Phone constructor.
73
+	 */
74
+	public function __construct()
75
+	{
76
+		$this->regex_patterns     = (array) apply_filters(
77
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns',
78
+			[
79
+				'de_DE' => Phone::PATTERN_DE,
80
+				'fr_FR' => Phone::PATTERN_FR,
81
+				'en_UK' => Phone::PATTERN_UK,
82
+				'en_US' => Phone::PATTERN_US,
83
+			]
84
+		);
85
+		$this->valid_type_options = apply_filters(
86
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options',
87
+			[
88
+				Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'),
89
+			]
90
+		);
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * @return array
96
-     */
97
-    public function regexPatterns(): array
98
-    {
99
-        return $this->regex_patterns;
100
-    }
94
+	/**
95
+	 * @return array
96
+	 */
97
+	public function regexPatterns(): array
98
+	{
99
+		return $this->regex_patterns;
100
+	}
101 101
 
102 102
 
103
-    /**
104
-     * @param bool $constants_only
105
-     * @return array
106
-     */
107
-    public function validTypeOptions(bool $constants_only = false): array
108
-    {
109
-        return $constants_only
110
-            ? array_keys($this->valid_type_options)
111
-            : $this->valid_type_options;
112
-    }
103
+	/**
104
+	 * @param bool $constants_only
105
+	 * @return array
106
+	 */
107
+	public function validTypeOptions(bool $constants_only = false): array
108
+	{
109
+		return $constants_only
110
+			? array_keys($this->valid_type_options)
111
+			: $this->valid_type_options;
112
+	}
113 113
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
      */
74 74
     public function __construct()
75 75
     {
76
-        $this->regex_patterns     = (array) apply_filters(
76
+        $this->regex_patterns = (array) apply_filters(
77 77
             'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns',
78 78
             [
79 79
                 'de_DE' => Phone::PATTERN_DE,
Please login to merge, or discard this patch.
core/services/orm/ModelFieldFactory.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@
 block discarded – undo
139 139
         bool $nullable = false,
140 140
         string $default_value = EE_Datetime_Field::now
141 141
     ): EE_Datetime_Field {
142
-        return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value,]);
142
+        return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value, ]);
143 143
     }
144 144
 
145 145
 
Please login to merge, or discard this patch.
Indentation   +614 added lines, -614 removed lines patch added patch discarded remove patch
@@ -46,618 +46,618 @@
 block discarded – undo
46 46
  */
47 47
 class ModelFieldFactory
48 48
 {
49
-    /**
50
-     * @var LoaderInterface $loader
51
-     */
52
-    private $loader;
53
-
54
-
55
-    /**
56
-     * ModelFieldFactory constructor.
57
-     *
58
-     * @param LoaderInterface $loader
59
-     */
60
-    public function __construct(LoaderInterface $loader)
61
-    {
62
-        $this->loader = $loader;
63
-    }
64
-
65
-
66
-    /**
67
-     * @param string $table_column
68
-     * @param string $nice_name
69
-     * @param bool   $nullable
70
-     * @param null   $default_value
71
-     * @return EE_All_Caps_Text_Field
72
-     */
73
-    public function createAllCapsTextField(
74
-        string $table_column,
75
-        string $nice_name,
76
-        bool $nullable,
77
-        $default_value = null
78
-    ): EE_All_Caps_Text_Field {
79
-        return $this->loader->getNew(
80
-            'EE_All_Caps_Text_Field',
81
-            [$table_column, $nice_name, $nullable, $default_value]
82
-        );
83
-    }
84
-
85
-
86
-    /**
87
-     * @param string $table_column
88
-     * @param string $nice_name
89
-     * @param bool   $nullable
90
-     * @param null   $default_value
91
-     * @param string $model_name
92
-     * @return EE_Any_Foreign_Model_Name_Field
93
-     */
94
-    public function createAnyForeignModelNameField(
95
-        string $table_column,
96
-        string $nice_name,
97
-        bool $nullable,
98
-        $default_value = null,
99
-        string $model_name = ''
100
-    ): EE_Any_Foreign_Model_Name_Field {
101
-        return $this->loader->getNew(
102
-            'EE_Any_Foreign_Model_Name_Field',
103
-            [$table_column, $nice_name, $nullable, $default_value, $model_name]
104
-        );
105
-    }
106
-
107
-
108
-    /**
109
-     * @param string $table_column
110
-     * @param string $nice_name
111
-     * @param bool   $nullable
112
-     * @param null   $default_value
113
-     * @return EE_Boolean_Field
114
-     */
115
-    public function createBooleanField(
116
-        string $table_column,
117
-        string $nice_name,
118
-        bool $nullable,
119
-        $default_value = null
120
-    ): EE_Boolean_Field {
121
-        return $this->loader->getNew(
122
-            'EE_Boolean_Field',
123
-            [$table_column, $nice_name, $nullable, $default_value]
124
-        );
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string $table_column
130
-     * @param string $nice_name
131
-     * @param bool   $nullable
132
-     * @param string $default_value
133
-     * @return EE_Datetime_Field
134
-     */
135
-    public function createDatetimeField(
136
-        string $table_column,
137
-        string $nice_name,
138
-        bool $nullable = false,
139
-        string $default_value = EE_Datetime_Field::now
140
-    ): EE_Datetime_Field {
141
-        return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value,]);
142
-    }
143
-
144
-
145
-    /**
146
-     * @param string $table_column
147
-     * @param string $nice_name
148
-     * @param bool   $nullable
149
-     * @param null   $default_value
150
-     * @return EE_DB_Only_Float_Field
151
-     */
152
-    public function createDbOnlyFloatField(
153
-        string $table_column,
154
-        string $nice_name,
155
-        bool $nullable,
156
-        $default_value = null
157
-    ): EE_DB_Only_Float_Field {
158
-        return $this->loader->getNew(
159
-            'EE_DB_Only_Float_Field',
160
-            [$table_column, $nice_name, $nullable, $default_value]
161
-        );
162
-    }
163
-
164
-
165
-    /**
166
-     * @param string $table_column
167
-     * @param string $nice_name
168
-     * @param bool   $nullable
169
-     * @param null   $default_value
170
-     * @return EE_DB_Only_Int_Field
171
-     */
172
-    public function createDbOnlyIntField(
173
-        string $table_column,
174
-        string $nice_name,
175
-        bool $nullable,
176
-        $default_value = null
177
-    ): EE_DB_Only_Int_Field {
178
-        return $this->loader->getNew(
179
-            'EE_DB_Only_Int_Field',
180
-            [$table_column, $nice_name, $nullable, $default_value]
181
-        );
182
-    }
183
-
184
-
185
-    /**
186
-     * @param string $table_column
187
-     * @param string $nice_name
188
-     * @param bool   $nullable
189
-     * @param null   $default_value
190
-     * @return EE_DB_Only_Text_Field
191
-     */
192
-    public function createDbOnlyTextField(
193
-        string $table_column,
194
-        string $nice_name,
195
-        bool $nullable,
196
-        $default_value = null
197
-    ): EE_DB_Only_Text_Field {
198
-        return $this->loader->getNew(
199
-            'EE_DB_Only_Text_Field',
200
-            [$table_column, $nice_name, $nullable, $default_value]
201
-        );
202
-    }
203
-
204
-
205
-    /**
206
-     * @param string      $table_column
207
-     * @param string      $nice_name
208
-     * @param bool        $nullable
209
-     * @param string|null $default_value
210
-     * @return EE_Email_Field
211
-     */
212
-    public function createEmailField(
213
-        string $table_column,
214
-        string $nice_name,
215
-        bool $nullable = true,
216
-        string $default_value = ''
217
-    ): EE_Email_Field {
218
-        return $this->loader->getNew(
219
-            'EE_Email_Field',
220
-            [$table_column, $nice_name, $nullable, $default_value]
221
-        );
222
-    }
223
-
224
-
225
-    /**
226
-     * @param string $table_column
227
-     * @param string $nice_name
228
-     * @param bool   $nullable
229
-     * @param null   $default_value
230
-     * @param array  $allowed_enum_values keys are values to be used in the DB,
231
-     *                                    values are how they should be displayed
232
-     * @return EE_Enum_Integer_Field
233
-     */
234
-    public function createEnumIntegerField(
235
-        string $table_column,
236
-        string $nice_name,
237
-        bool $nullable,
238
-        $default_value = null,
239
-        array $allowed_enum_values = []
240
-    ): EE_Enum_Integer_Field {
241
-        return $this->loader->getNew(
242
-            'EE_Enum_Integer_Field',
243
-            [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values]
244
-        );
245
-    }
246
-
247
-
248
-    /**
249
-     * @param string $table_column
250
-     * @param string $nice_name
251
-     * @param bool   $nullable
252
-     * @param null   $default_value
253
-     * @param array  $allowed_enum_values keys are values to be used in the DB,
254
-     *                                    values are how they should be displayed
255
-     * @return EE_Enum_Text_Field
256
-     */
257
-    public function createEnumTextField(
258
-        string $table_column,
259
-        string $nice_name,
260
-        bool $nullable,
261
-        $default_value,
262
-        array $allowed_enum_values
263
-    ): EE_Enum_Text_Field {
264
-        return $this->loader->getNew(
265
-            'EE_Enum_Text_Field',
266
-            [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values]
267
-        );
268
-    }
269
-
270
-
271
-    /**
272
-     * @param string $table_column
273
-     * @param string $nice_name
274
-     * @param bool   $nullable
275
-     * @param null   $default_value
276
-     * @return EE_Float_Field
277
-     */
278
-    public function createFloatField(
279
-        string $table_column,
280
-        string $nice_name,
281
-        bool $nullable,
282
-        $default_value = null
283
-    ): EE_Float_Field {
284
-        return $this->loader->getNew(
285
-            'EE_Float_Field',
286
-            [$table_column, $nice_name, $nullable, $default_value]
287
-        );
288
-    }
289
-
290
-
291
-    /**
292
-     * @param string $table_column
293
-     * @param string $nice_name
294
-     * @param bool   $nullable
295
-     * @param null   $default_value
296
-     * @param string $model_name
297
-     * @return EE_Foreign_Key_Int_Field
298
-     */
299
-    public function createForeignKeyIntField(
300
-        string $table_column,
301
-        string $nice_name,
302
-        bool $nullable,
303
-        $default_value,
304
-        string $model_name
305
-    ): EE_Foreign_Key_Int_Field {
306
-        return $this->loader->getNew(
307
-            'EE_Foreign_Key_Int_Field',
308
-            [$table_column, $nice_name, $nullable, $default_value, $model_name]
309
-        );
310
-    }
311
-
312
-
313
-    /**
314
-     * @param string $table_column
315
-     * @param string $nice_name
316
-     * @param bool   $nullable
317
-     * @param null   $default_value
318
-     * @param string $model_name
319
-     * @return EE_Foreign_Key_String_Field
320
-     */
321
-    public function createForeignKeyStringField(
322
-        string $table_column,
323
-        string $nice_name,
324
-        bool $nullable,
325
-        $default_value,
326
-        string $model_name
327
-    ): EE_Foreign_Key_String_Field {
328
-        return $this->loader->getNew(
329
-            'EE_Foreign_Key_String_Field',
330
-            [$table_column, $nice_name, $nullable, $default_value, $model_name]
331
-        );
332
-    }
333
-
334
-
335
-    /**
336
-     * @param string $table_column
337
-     * @param string $nice_name
338
-     * @param bool   $nullable
339
-     * @param null   $default_value
340
-     * @return EE_Full_HTML_Field
341
-     */
342
-    public function createFullHtmlField(
343
-        string $table_column,
344
-        string $nice_name,
345
-        bool $nullable,
346
-        $default_value = null
347
-    ): EE_Full_HTML_Field {
348
-        return $this->loader->getNew(
349
-            'EE_Full_HTML_Field',
350
-            [$table_column, $nice_name, $nullable, $default_value]
351
-        );
352
-    }
353
-
354
-
355
-    /**
356
-     * @param string $table_column
357
-     * @param string $nice_name
358
-     * @param bool   $nullable
359
-     * @param null   $default_value
360
-     * @return EE_Infinite_Integer_Field
361
-     */
362
-    public function createInfiniteIntegerField(
363
-        string $table_column,
364
-        string $nice_name,
365
-        bool $nullable,
366
-        $default_value = null
367
-    ): EE_Infinite_Integer_Field {
368
-        return $this->loader->getNew(
369
-            'EE_Infinite_Integer_Field',
370
-            [$table_column, $nice_name, $nullable, $default_value]
371
-        );
372
-    }
373
-
374
-
375
-    /**
376
-     * @param string  $table_column
377
-     * @param string  $nice_name
378
-     * @param bool    $nullable
379
-     * @param integer $default_value
380
-     * @return EE_Integer_Field
381
-     */
382
-    public function createIntegerField(
383
-        string $table_column,
384
-        string $nice_name,
385
-        bool $nullable = false,
386
-        int $default_value = 0
387
-    ): EE_Integer_Field {
388
-        return $this->loader->getNew(
389
-            'EE_Integer_Field',
390
-            [$table_column, $nice_name, $nullable, $default_value]
391
-        );
392
-    }
393
-
394
-
395
-    /**
396
-     * @param string $table_column
397
-     * @param string $nice_name
398
-     * @param bool   $nullable
399
-     * @param null   $default_value
400
-     * @return EE_Maybe_Serialized_Simple_HTML_Field
401
-     */
402
-    public function createMaybeSerializedSimpleHtmlField(
403
-        string $table_column,
404
-        string $nice_name,
405
-        bool $nullable,
406
-        $default_value = null
407
-    ): EE_Maybe_Serialized_Simple_HTML_Field {
408
-        return $this->loader->getNew(
409
-            'EE_Maybe_Serialized_Simple_HTML_Field',
410
-            [$table_column, $nice_name, $nullable, $default_value]
411
-        );
412
-    }
413
-
414
-
415
-    /**
416
-     * @param string $table_column
417
-     * @param string $nice_name
418
-     * @param bool   $nullable
419
-     * @param null   $default_value
420
-     * @return EE_Maybe_Serialized_Text_Field
421
-     */
422
-    public function createMaybeSerializedTextField(
423
-        string $table_column,
424
-        string $nice_name,
425
-        bool $nullable,
426
-        $default_value = null
427
-    ): EE_Maybe_Serialized_Text_Field {
428
-        return $this->loader->getNew(
429
-            'EE_Maybe_Serialized_Text_Field',
430
-            [$table_column, $nice_name, $nullable, $default_value]
431
-        );
432
-    }
433
-
434
-
435
-    /**
436
-     * @param string $table_column
437
-     * @param string $nice_name
438
-     * @param bool   $nullable
439
-     * @param null   $default_value
440
-     * @return EE_Money_Field
441
-     */
442
-    public function createMoneyField(
443
-        string $table_column,
444
-        string $nice_name,
445
-        bool $nullable,
446
-        $default_value = null
447
-    ): EE_Money_Field {
448
-        return $this->loader->getNew(
449
-            'EE_Money_Field',
450
-            [$table_column, $nice_name, $nullable, $default_value]
451
-        );
452
-    }
453
-
454
-
455
-    /**
456
-     * @param string $table_column
457
-     * @param string $nice_name
458
-     * @param bool   $nullable
459
-     * @param string $default_value
460
-     * @return EE_Plain_Text_Field
461
-     */
462
-    public function createPlainTextField(
463
-        string $table_column,
464
-        string $nice_name,
465
-        bool $nullable = true,
466
-        string $default_value = ''
467
-    ): EE_Plain_Text_Field {
468
-        return $this->loader->getNew(
469
-            'EE_Plain_Text_Field',
470
-            [$table_column, $nice_name, $nullable, $default_value]
471
-        );
472
-    }
473
-
474
-
475
-    /**
476
-     * @param string $table_column
477
-     * @param string $nice_name
478
-     * @param bool   $nullable
479
-     * @param null   $default_value
480
-     * @return EE_Post_Content_Field
481
-     */
482
-    public function createPostContentField(
483
-        string $table_column,
484
-        string $nice_name,
485
-        bool $nullable,
486
-        $default_value = null
487
-    ): EE_Post_Content_Field {
488
-        return $this->loader->getNew(
489
-            'EE_Post_Content_Field',
490
-            [$table_column, $nice_name, $nullable, $default_value]
491
-        );
492
-    }
493
-
494
-
495
-    /**
496
-     * @param string $table_column
497
-     * @param string $nice_name
498
-     * @return EE_Primary_Key_Int_Field
499
-     */
500
-    public function createPrimaryKeyIntField(string $table_column, string $nice_name): EE_Primary_Key_Int_Field
501
-    {
502
-        return $this->loader->getNew('EE_Primary_Key_Int_Field', [$table_column, $nice_name]);
503
-    }
504
-
505
-
506
-    /**
507
-     * @param string $table_column
508
-     * @param string $nice_name
509
-     * @return EE_Primary_Key_String_Field
510
-     */
511
-    public function createPrimaryKeyStringField(string $table_column, string $nice_name): EE_Primary_Key_String_Field
512
-    {
513
-        return $this->loader->getNew('EE_Primary_Key_String_Field', [$table_column, $nice_name]);
514
-    }
515
-
516
-
517
-    /**
518
-     * @param string $table_column
519
-     * @param string $nice_name
520
-     * @param bool   $nullable
521
-     * @param null   $default_value
522
-     * @return EE_Serialized_Text_Field
523
-     */
524
-    public function createSerializedTextField(
525
-        string $table_column,
526
-        string $nice_name,
527
-        bool $nullable,
528
-        $default_value = null
529
-    ): EE_Serialized_Text_Field {
530
-        return $this->loader->getNew(
531
-            'EE_Serialized_Text_Field',
532
-            [$table_column, $nice_name, $nullable, $default_value]
533
-        );
534
-    }
535
-
536
-
537
-    /**
538
-     * @param string $table_column
539
-     * @param string $nice_name
540
-     * @param bool   $nullable
541
-     * @param null   $default_value
542
-     * @return EE_Simple_HTML_Field
543
-     */
544
-    public function createSimpleHtmlField(
545
-        string $table_column,
546
-        string $nice_name,
547
-        bool $nullable,
548
-        $default_value = null
549
-    ): EE_Simple_HTML_Field {
550
-        return $this->loader->getNew(
551
-            'EE_Simple_HTML_Field',
552
-            [$table_column, $nice_name, $nullable, $default_value]
553
-        );
554
-    }
555
-
556
-
557
-    /**
558
-     * @param string $table_column
559
-     * @param string $nice_name
560
-     * @param bool   $nullable
561
-     * @param null   $default_value
562
-     * @return EE_Slug_Field
563
-     */
564
-    public function createSlugField(
565
-        string $table_column,
566
-        string $nice_name,
567
-        bool $nullable = false,
568
-        $default_value = null
569
-    ): EE_Slug_Field {
570
-        return $this->loader->getNew(
571
-            'EE_Slug_Field',
572
-            [$table_column, $nice_name, $nullable, $default_value]
573
-        );
574
-    }
575
-
576
-
577
-    /**
578
-     * @param string $table_column
579
-     * @param string $nice_name
580
-     * @param bool   $nullable
581
-     * @param null   $default_value
582
-     * @return EE_Trashed_Flag_Field
583
-     */
584
-    public function createTrashedFlagField(
585
-        string $table_column,
586
-        string $nice_name,
587
-        bool $nullable,
588
-        $default_value = null
589
-    ): EE_Trashed_Flag_Field {
590
-        return $this->loader->getNew(
591
-            'EE_Trashed_Flag_Field',
592
-            [$table_column, $nice_name, $nullable, $default_value]
593
-        );
594
-    }
595
-
596
-
597
-    /**
598
-     * @param string $table_column
599
-     * @param string $nice_name
600
-     * @param bool   $nullable
601
-     * @param mixed  $default_value
602
-     * @param array $values     If additional statuses are to be used other than the default WP statuses,
603
-     *                          then they can be registered via this property.
604
-     *                          The format of the array should be as follows:
605
-     *                          [
606
-     *                              'status_reference' => [
607
-     *                                  'label' => __('Status Reference Label', 'event_espresso'),
608
-     *                                  // whether status is shown on the frontend of the site
609
-     *                                  'public' => true,
610
-     *                                  // whether status is excluded from wp searches
611
-     *                                  'exclude_from_search' => false,
612
-     *                                  // whether status is included in queries
613
-     *                                  for the admin 'all' view in list table views.
614
-     *                                  'show_in_admin_all_list' => true,
615
-     *                                  // show in the list of statuses with post counts
616
-     *                                  // at the top of the admin list tables (i.e. Status Reference(2) )
617
-     *                                  'show_in_admin_status_list' => true,
618
-     *                                  // the text to display on the admin screen
619
-     *                                  // ( or you won't see your status count )
620
-     *                                  'label_count' => _n_noop(
621
-     *                                      'Status Reference <span class="count">(%s)</span>',
622
-     *                                      'Status References <span class="count">(%s)</span>'
623
-     *                                  ),
624
-     *                              ]
625
-     *                          ]
626
-     * @return EE_WP_Post_Status_Field
627
-     * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
628
-     */
629
-    public function createWpPostStatusField(
630
-        string $table_column,
631
-        string $nice_name,
632
-        bool $nullable,
633
-        $default_value = null,
634
-        array $values = []
635
-    ): EE_WP_Post_Status_Field {
636
-        return $this->loader->getNew(
637
-            'EE_WP_Post_Status_Field',
638
-            [$table_column, $nice_name, $nullable, $default_value, $values]
639
-        );
640
-    }
641
-
642
-
643
-    /**
644
-     * @param string $post_type
645
-     * @return EE_WP_Post_Type_Field
646
-     */
647
-    public function createWpPostTypeField(string $post_type): EE_WP_Post_Type_Field
648
-    {
649
-        return $this->loader->getNew('EE_WP_Post_Type_Field', [$post_type]);
650
-    }
651
-
652
-
653
-    /**
654
-     * @param string $table_column
655
-     * @param string $nice_name
656
-     * @param bool   $nullable
657
-     * @return EE_WP_User_Field
658
-     */
659
-    public function createWpUserField(string $table_column, string $nice_name, bool $nullable): EE_WP_User_Field
660
-    {
661
-        return $this->loader->getNew('EE_WP_User_Field', [$table_column, $nice_name, $nullable]);
662
-    }
49
+	/**
50
+	 * @var LoaderInterface $loader
51
+	 */
52
+	private $loader;
53
+
54
+
55
+	/**
56
+	 * ModelFieldFactory constructor.
57
+	 *
58
+	 * @param LoaderInterface $loader
59
+	 */
60
+	public function __construct(LoaderInterface $loader)
61
+	{
62
+		$this->loader = $loader;
63
+	}
64
+
65
+
66
+	/**
67
+	 * @param string $table_column
68
+	 * @param string $nice_name
69
+	 * @param bool   $nullable
70
+	 * @param null   $default_value
71
+	 * @return EE_All_Caps_Text_Field
72
+	 */
73
+	public function createAllCapsTextField(
74
+		string $table_column,
75
+		string $nice_name,
76
+		bool $nullable,
77
+		$default_value = null
78
+	): EE_All_Caps_Text_Field {
79
+		return $this->loader->getNew(
80
+			'EE_All_Caps_Text_Field',
81
+			[$table_column, $nice_name, $nullable, $default_value]
82
+		);
83
+	}
84
+
85
+
86
+	/**
87
+	 * @param string $table_column
88
+	 * @param string $nice_name
89
+	 * @param bool   $nullable
90
+	 * @param null   $default_value
91
+	 * @param string $model_name
92
+	 * @return EE_Any_Foreign_Model_Name_Field
93
+	 */
94
+	public function createAnyForeignModelNameField(
95
+		string $table_column,
96
+		string $nice_name,
97
+		bool $nullable,
98
+		$default_value = null,
99
+		string $model_name = ''
100
+	): EE_Any_Foreign_Model_Name_Field {
101
+		return $this->loader->getNew(
102
+			'EE_Any_Foreign_Model_Name_Field',
103
+			[$table_column, $nice_name, $nullable, $default_value, $model_name]
104
+		);
105
+	}
106
+
107
+
108
+	/**
109
+	 * @param string $table_column
110
+	 * @param string $nice_name
111
+	 * @param bool   $nullable
112
+	 * @param null   $default_value
113
+	 * @return EE_Boolean_Field
114
+	 */
115
+	public function createBooleanField(
116
+		string $table_column,
117
+		string $nice_name,
118
+		bool $nullable,
119
+		$default_value = null
120
+	): EE_Boolean_Field {
121
+		return $this->loader->getNew(
122
+			'EE_Boolean_Field',
123
+			[$table_column, $nice_name, $nullable, $default_value]
124
+		);
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string $table_column
130
+	 * @param string $nice_name
131
+	 * @param bool   $nullable
132
+	 * @param string $default_value
133
+	 * @return EE_Datetime_Field
134
+	 */
135
+	public function createDatetimeField(
136
+		string $table_column,
137
+		string $nice_name,
138
+		bool $nullable = false,
139
+		string $default_value = EE_Datetime_Field::now
140
+	): EE_Datetime_Field {
141
+		return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value,]);
142
+	}
143
+
144
+
145
+	/**
146
+	 * @param string $table_column
147
+	 * @param string $nice_name
148
+	 * @param bool   $nullable
149
+	 * @param null   $default_value
150
+	 * @return EE_DB_Only_Float_Field
151
+	 */
152
+	public function createDbOnlyFloatField(
153
+		string $table_column,
154
+		string $nice_name,
155
+		bool $nullable,
156
+		$default_value = null
157
+	): EE_DB_Only_Float_Field {
158
+		return $this->loader->getNew(
159
+			'EE_DB_Only_Float_Field',
160
+			[$table_column, $nice_name, $nullable, $default_value]
161
+		);
162
+	}
163
+
164
+
165
+	/**
166
+	 * @param string $table_column
167
+	 * @param string $nice_name
168
+	 * @param bool   $nullable
169
+	 * @param null   $default_value
170
+	 * @return EE_DB_Only_Int_Field
171
+	 */
172
+	public function createDbOnlyIntField(
173
+		string $table_column,
174
+		string $nice_name,
175
+		bool $nullable,
176
+		$default_value = null
177
+	): EE_DB_Only_Int_Field {
178
+		return $this->loader->getNew(
179
+			'EE_DB_Only_Int_Field',
180
+			[$table_column, $nice_name, $nullable, $default_value]
181
+		);
182
+	}
183
+
184
+
185
+	/**
186
+	 * @param string $table_column
187
+	 * @param string $nice_name
188
+	 * @param bool   $nullable
189
+	 * @param null   $default_value
190
+	 * @return EE_DB_Only_Text_Field
191
+	 */
192
+	public function createDbOnlyTextField(
193
+		string $table_column,
194
+		string $nice_name,
195
+		bool $nullable,
196
+		$default_value = null
197
+	): EE_DB_Only_Text_Field {
198
+		return $this->loader->getNew(
199
+			'EE_DB_Only_Text_Field',
200
+			[$table_column, $nice_name, $nullable, $default_value]
201
+		);
202
+	}
203
+
204
+
205
+	/**
206
+	 * @param string      $table_column
207
+	 * @param string      $nice_name
208
+	 * @param bool        $nullable
209
+	 * @param string|null $default_value
210
+	 * @return EE_Email_Field
211
+	 */
212
+	public function createEmailField(
213
+		string $table_column,
214
+		string $nice_name,
215
+		bool $nullable = true,
216
+		string $default_value = ''
217
+	): EE_Email_Field {
218
+		return $this->loader->getNew(
219
+			'EE_Email_Field',
220
+			[$table_column, $nice_name, $nullable, $default_value]
221
+		);
222
+	}
223
+
224
+
225
+	/**
226
+	 * @param string $table_column
227
+	 * @param string $nice_name
228
+	 * @param bool   $nullable
229
+	 * @param null   $default_value
230
+	 * @param array  $allowed_enum_values keys are values to be used in the DB,
231
+	 *                                    values are how they should be displayed
232
+	 * @return EE_Enum_Integer_Field
233
+	 */
234
+	public function createEnumIntegerField(
235
+		string $table_column,
236
+		string $nice_name,
237
+		bool $nullable,
238
+		$default_value = null,
239
+		array $allowed_enum_values = []
240
+	): EE_Enum_Integer_Field {
241
+		return $this->loader->getNew(
242
+			'EE_Enum_Integer_Field',
243
+			[$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values]
244
+		);
245
+	}
246
+
247
+
248
+	/**
249
+	 * @param string $table_column
250
+	 * @param string $nice_name
251
+	 * @param bool   $nullable
252
+	 * @param null   $default_value
253
+	 * @param array  $allowed_enum_values keys are values to be used in the DB,
254
+	 *                                    values are how they should be displayed
255
+	 * @return EE_Enum_Text_Field
256
+	 */
257
+	public function createEnumTextField(
258
+		string $table_column,
259
+		string $nice_name,
260
+		bool $nullable,
261
+		$default_value,
262
+		array $allowed_enum_values
263
+	): EE_Enum_Text_Field {
264
+		return $this->loader->getNew(
265
+			'EE_Enum_Text_Field',
266
+			[$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values]
267
+		);
268
+	}
269
+
270
+
271
+	/**
272
+	 * @param string $table_column
273
+	 * @param string $nice_name
274
+	 * @param bool   $nullable
275
+	 * @param null   $default_value
276
+	 * @return EE_Float_Field
277
+	 */
278
+	public function createFloatField(
279
+		string $table_column,
280
+		string $nice_name,
281
+		bool $nullable,
282
+		$default_value = null
283
+	): EE_Float_Field {
284
+		return $this->loader->getNew(
285
+			'EE_Float_Field',
286
+			[$table_column, $nice_name, $nullable, $default_value]
287
+		);
288
+	}
289
+
290
+
291
+	/**
292
+	 * @param string $table_column
293
+	 * @param string $nice_name
294
+	 * @param bool   $nullable
295
+	 * @param null   $default_value
296
+	 * @param string $model_name
297
+	 * @return EE_Foreign_Key_Int_Field
298
+	 */
299
+	public function createForeignKeyIntField(
300
+		string $table_column,
301
+		string $nice_name,
302
+		bool $nullable,
303
+		$default_value,
304
+		string $model_name
305
+	): EE_Foreign_Key_Int_Field {
306
+		return $this->loader->getNew(
307
+			'EE_Foreign_Key_Int_Field',
308
+			[$table_column, $nice_name, $nullable, $default_value, $model_name]
309
+		);
310
+	}
311
+
312
+
313
+	/**
314
+	 * @param string $table_column
315
+	 * @param string $nice_name
316
+	 * @param bool   $nullable
317
+	 * @param null   $default_value
318
+	 * @param string $model_name
319
+	 * @return EE_Foreign_Key_String_Field
320
+	 */
321
+	public function createForeignKeyStringField(
322
+		string $table_column,
323
+		string $nice_name,
324
+		bool $nullable,
325
+		$default_value,
326
+		string $model_name
327
+	): EE_Foreign_Key_String_Field {
328
+		return $this->loader->getNew(
329
+			'EE_Foreign_Key_String_Field',
330
+			[$table_column, $nice_name, $nullable, $default_value, $model_name]
331
+		);
332
+	}
333
+
334
+
335
+	/**
336
+	 * @param string $table_column
337
+	 * @param string $nice_name
338
+	 * @param bool   $nullable
339
+	 * @param null   $default_value
340
+	 * @return EE_Full_HTML_Field
341
+	 */
342
+	public function createFullHtmlField(
343
+		string $table_column,
344
+		string $nice_name,
345
+		bool $nullable,
346
+		$default_value = null
347
+	): EE_Full_HTML_Field {
348
+		return $this->loader->getNew(
349
+			'EE_Full_HTML_Field',
350
+			[$table_column, $nice_name, $nullable, $default_value]
351
+		);
352
+	}
353
+
354
+
355
+	/**
356
+	 * @param string $table_column
357
+	 * @param string $nice_name
358
+	 * @param bool   $nullable
359
+	 * @param null   $default_value
360
+	 * @return EE_Infinite_Integer_Field
361
+	 */
362
+	public function createInfiniteIntegerField(
363
+		string $table_column,
364
+		string $nice_name,
365
+		bool $nullable,
366
+		$default_value = null
367
+	): EE_Infinite_Integer_Field {
368
+		return $this->loader->getNew(
369
+			'EE_Infinite_Integer_Field',
370
+			[$table_column, $nice_name, $nullable, $default_value]
371
+		);
372
+	}
373
+
374
+
375
+	/**
376
+	 * @param string  $table_column
377
+	 * @param string  $nice_name
378
+	 * @param bool    $nullable
379
+	 * @param integer $default_value
380
+	 * @return EE_Integer_Field
381
+	 */
382
+	public function createIntegerField(
383
+		string $table_column,
384
+		string $nice_name,
385
+		bool $nullable = false,
386
+		int $default_value = 0
387
+	): EE_Integer_Field {
388
+		return $this->loader->getNew(
389
+			'EE_Integer_Field',
390
+			[$table_column, $nice_name, $nullable, $default_value]
391
+		);
392
+	}
393
+
394
+
395
+	/**
396
+	 * @param string $table_column
397
+	 * @param string $nice_name
398
+	 * @param bool   $nullable
399
+	 * @param null   $default_value
400
+	 * @return EE_Maybe_Serialized_Simple_HTML_Field
401
+	 */
402
+	public function createMaybeSerializedSimpleHtmlField(
403
+		string $table_column,
404
+		string $nice_name,
405
+		bool $nullable,
406
+		$default_value = null
407
+	): EE_Maybe_Serialized_Simple_HTML_Field {
408
+		return $this->loader->getNew(
409
+			'EE_Maybe_Serialized_Simple_HTML_Field',
410
+			[$table_column, $nice_name, $nullable, $default_value]
411
+		);
412
+	}
413
+
414
+
415
+	/**
416
+	 * @param string $table_column
417
+	 * @param string $nice_name
418
+	 * @param bool   $nullable
419
+	 * @param null   $default_value
420
+	 * @return EE_Maybe_Serialized_Text_Field
421
+	 */
422
+	public function createMaybeSerializedTextField(
423
+		string $table_column,
424
+		string $nice_name,
425
+		bool $nullable,
426
+		$default_value = null
427
+	): EE_Maybe_Serialized_Text_Field {
428
+		return $this->loader->getNew(
429
+			'EE_Maybe_Serialized_Text_Field',
430
+			[$table_column, $nice_name, $nullable, $default_value]
431
+		);
432
+	}
433
+
434
+
435
+	/**
436
+	 * @param string $table_column
437
+	 * @param string $nice_name
438
+	 * @param bool   $nullable
439
+	 * @param null   $default_value
440
+	 * @return EE_Money_Field
441
+	 */
442
+	public function createMoneyField(
443
+		string $table_column,
444
+		string $nice_name,
445
+		bool $nullable,
446
+		$default_value = null
447
+	): EE_Money_Field {
448
+		return $this->loader->getNew(
449
+			'EE_Money_Field',
450
+			[$table_column, $nice_name, $nullable, $default_value]
451
+		);
452
+	}
453
+
454
+
455
+	/**
456
+	 * @param string $table_column
457
+	 * @param string $nice_name
458
+	 * @param bool   $nullable
459
+	 * @param string $default_value
460
+	 * @return EE_Plain_Text_Field
461
+	 */
462
+	public function createPlainTextField(
463
+		string $table_column,
464
+		string $nice_name,
465
+		bool $nullable = true,
466
+		string $default_value = ''
467
+	): EE_Plain_Text_Field {
468
+		return $this->loader->getNew(
469
+			'EE_Plain_Text_Field',
470
+			[$table_column, $nice_name, $nullable, $default_value]
471
+		);
472
+	}
473
+
474
+
475
+	/**
476
+	 * @param string $table_column
477
+	 * @param string $nice_name
478
+	 * @param bool   $nullable
479
+	 * @param null   $default_value
480
+	 * @return EE_Post_Content_Field
481
+	 */
482
+	public function createPostContentField(
483
+		string $table_column,
484
+		string $nice_name,
485
+		bool $nullable,
486
+		$default_value = null
487
+	): EE_Post_Content_Field {
488
+		return $this->loader->getNew(
489
+			'EE_Post_Content_Field',
490
+			[$table_column, $nice_name, $nullable, $default_value]
491
+		);
492
+	}
493
+
494
+
495
+	/**
496
+	 * @param string $table_column
497
+	 * @param string $nice_name
498
+	 * @return EE_Primary_Key_Int_Field
499
+	 */
500
+	public function createPrimaryKeyIntField(string $table_column, string $nice_name): EE_Primary_Key_Int_Field
501
+	{
502
+		return $this->loader->getNew('EE_Primary_Key_Int_Field', [$table_column, $nice_name]);
503
+	}
504
+
505
+
506
+	/**
507
+	 * @param string $table_column
508
+	 * @param string $nice_name
509
+	 * @return EE_Primary_Key_String_Field
510
+	 */
511
+	public function createPrimaryKeyStringField(string $table_column, string $nice_name): EE_Primary_Key_String_Field
512
+	{
513
+		return $this->loader->getNew('EE_Primary_Key_String_Field', [$table_column, $nice_name]);
514
+	}
515
+
516
+
517
+	/**
518
+	 * @param string $table_column
519
+	 * @param string $nice_name
520
+	 * @param bool   $nullable
521
+	 * @param null   $default_value
522
+	 * @return EE_Serialized_Text_Field
523
+	 */
524
+	public function createSerializedTextField(
525
+		string $table_column,
526
+		string $nice_name,
527
+		bool $nullable,
528
+		$default_value = null
529
+	): EE_Serialized_Text_Field {
530
+		return $this->loader->getNew(
531
+			'EE_Serialized_Text_Field',
532
+			[$table_column, $nice_name, $nullable, $default_value]
533
+		);
534
+	}
535
+
536
+
537
+	/**
538
+	 * @param string $table_column
539
+	 * @param string $nice_name
540
+	 * @param bool   $nullable
541
+	 * @param null   $default_value
542
+	 * @return EE_Simple_HTML_Field
543
+	 */
544
+	public function createSimpleHtmlField(
545
+		string $table_column,
546
+		string $nice_name,
547
+		bool $nullable,
548
+		$default_value = null
549
+	): EE_Simple_HTML_Field {
550
+		return $this->loader->getNew(
551
+			'EE_Simple_HTML_Field',
552
+			[$table_column, $nice_name, $nullable, $default_value]
553
+		);
554
+	}
555
+
556
+
557
+	/**
558
+	 * @param string $table_column
559
+	 * @param string $nice_name
560
+	 * @param bool   $nullable
561
+	 * @param null   $default_value
562
+	 * @return EE_Slug_Field
563
+	 */
564
+	public function createSlugField(
565
+		string $table_column,
566
+		string $nice_name,
567
+		bool $nullable = false,
568
+		$default_value = null
569
+	): EE_Slug_Field {
570
+		return $this->loader->getNew(
571
+			'EE_Slug_Field',
572
+			[$table_column, $nice_name, $nullable, $default_value]
573
+		);
574
+	}
575
+
576
+
577
+	/**
578
+	 * @param string $table_column
579
+	 * @param string $nice_name
580
+	 * @param bool   $nullable
581
+	 * @param null   $default_value
582
+	 * @return EE_Trashed_Flag_Field
583
+	 */
584
+	public function createTrashedFlagField(
585
+		string $table_column,
586
+		string $nice_name,
587
+		bool $nullable,
588
+		$default_value = null
589
+	): EE_Trashed_Flag_Field {
590
+		return $this->loader->getNew(
591
+			'EE_Trashed_Flag_Field',
592
+			[$table_column, $nice_name, $nullable, $default_value]
593
+		);
594
+	}
595
+
596
+
597
+	/**
598
+	 * @param string $table_column
599
+	 * @param string $nice_name
600
+	 * @param bool   $nullable
601
+	 * @param mixed  $default_value
602
+	 * @param array $values     If additional statuses are to be used other than the default WP statuses,
603
+	 *                          then they can be registered via this property.
604
+	 *                          The format of the array should be as follows:
605
+	 *                          [
606
+	 *                              'status_reference' => [
607
+	 *                                  'label' => __('Status Reference Label', 'event_espresso'),
608
+	 *                                  // whether status is shown on the frontend of the site
609
+	 *                                  'public' => true,
610
+	 *                                  // whether status is excluded from wp searches
611
+	 *                                  'exclude_from_search' => false,
612
+	 *                                  // whether status is included in queries
613
+	 *                                  for the admin 'all' view in list table views.
614
+	 *                                  'show_in_admin_all_list' => true,
615
+	 *                                  // show in the list of statuses with post counts
616
+	 *                                  // at the top of the admin list tables (i.e. Status Reference(2) )
617
+	 *                                  'show_in_admin_status_list' => true,
618
+	 *                                  // the text to display on the admin screen
619
+	 *                                  // ( or you won't see your status count )
620
+	 *                                  'label_count' => _n_noop(
621
+	 *                                      'Status Reference <span class="count">(%s)</span>',
622
+	 *                                      'Status References <span class="count">(%s)</span>'
623
+	 *                                  ),
624
+	 *                              ]
625
+	 *                          ]
626
+	 * @return EE_WP_Post_Status_Field
627
+	 * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
628
+	 */
629
+	public function createWpPostStatusField(
630
+		string $table_column,
631
+		string $nice_name,
632
+		bool $nullable,
633
+		$default_value = null,
634
+		array $values = []
635
+	): EE_WP_Post_Status_Field {
636
+		return $this->loader->getNew(
637
+			'EE_WP_Post_Status_Field',
638
+			[$table_column, $nice_name, $nullable, $default_value, $values]
639
+		);
640
+	}
641
+
642
+
643
+	/**
644
+	 * @param string $post_type
645
+	 * @return EE_WP_Post_Type_Field
646
+	 */
647
+	public function createWpPostTypeField(string $post_type): EE_WP_Post_Type_Field
648
+	{
649
+		return $this->loader->getNew('EE_WP_Post_Type_Field', [$post_type]);
650
+	}
651
+
652
+
653
+	/**
654
+	 * @param string $table_column
655
+	 * @param string $nice_name
656
+	 * @param bool   $nullable
657
+	 * @return EE_WP_User_Field
658
+	 */
659
+	public function createWpUserField(string $table_column, string $nice_name, bool $nullable): EE_WP_User_Field
660
+	{
661
+		return $this->loader->getNew('EE_WP_User_Field', [$table_column, $nice_name, $nullable]);
662
+	}
663 663
 }
Please login to merge, or discard this patch.