Completed
Branch refactor-status-change-notice (a2e2cb)
by
unknown
31:19 queued 24:40
created
services/admin/notices/status_change/status_change_notice.template.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -24,94 +24,94 @@  discard block
 block discarded – undo
24 24
             <h3><?php esc_html_e('Important Notice Regarding Status Color Codes', 'event_espresso'); ?></h3>
25 25
             <p>
26 26
                 <?php esc_html_e(
27
-                    'In order to correct some inconsistencies in our event, datetime, and ticket status color codes, we have made the following changes:',
28
-                    'event_espresso'
29
-                ); ?>
27
+					'In order to correct some inconsistencies in our event, datetime, and ticket status color codes, we have made the following changes:',
28
+					'event_espresso'
29
+				); ?>
30 30
             </p>
31 31
             <ul>
32 32
                 <li class="ee-status-event">
33 33
                     <?php printf(
34
-                        esc_html__(
35
-                            'The Event, Datetime, and Ticket "Sold Out" status colors have changed from %1$sYellow%3$s to %2$sPurple%3$s',
36
-                            'event_espresso'
37
-                        ),
38
-                        '<span class="yellow pill">',
39
-                        '<span class="purple pill">',
40
-                        '</span>'
41
-                    ); ?>
34
+						esc_html__(
35
+							'The Event, Datetime, and Ticket "Sold Out" status colors have changed from %1$sYellow%3$s to %2$sPurple%3$s',
36
+							'event_espresso'
37
+						),
38
+						'<span class="yellow pill">',
39
+						'<span class="purple pill">',
40
+						'</span>'
41
+					); ?>
42 42
                 </li>
43 43
                 <li class="ee-status-event">
44 44
                     <?php printf(
45
-                        esc_html__(
46
-                            'The Event and Datetime "Postponed" status colors have changed from %1$sPurple%3$s to %2$sYellow%3$s',
47
-                            'event_espresso'
48
-                        ),
49
-                        '<span class="purple pill">',
50
-                        '<span class="yellow pill">',
51
-                        '</span>'
52
-                    ); ?>
45
+						esc_html__(
46
+							'The Event and Datetime "Postponed" status colors have changed from %1$sPurple%3$s to %2$sYellow%3$s',
47
+							'event_espresso'
48
+						),
49
+						'<span class="purple pill">',
50
+						'<span class="yellow pill">',
51
+						'</span>'
52
+					); ?>
53 53
                 </li>
54 54
                 <li class="ee-status-event">
55 55
                     <?php printf(
56
-                        esc_html__(
57
-                            'The Event "Inactive" and Ticket "Archived" status colors have changed from %1$sPurple%3$s to %2$sCharcoal%3$s',
58
-                            'event_espresso'
59
-                        ),
60
-                        '<span class="purple pill">',
61
-                        '<span class="charcoal pill">',
62
-                        '</span>'
63
-                    ); ?>
56
+						esc_html__(
57
+							'The Event "Inactive" and Ticket "Archived" status colors have changed from %1$sPurple%3$s to %2$sCharcoal%3$s',
58
+							'event_espresso'
59
+						),
60
+						'<span class="purple pill">',
61
+						'<span class="charcoal pill">',
62
+						'</span>'
63
+					); ?>
64 64
                 </li>
65 65
                 <li class="ee-status-message">
66 66
                     <?php printf(
67
-                        esc_html__(
68
-                            'The Message "Queued For Resending" status color has changed from %1$sYellow%3$s to %2$sBlue%3$s',
69
-                            'event_espresso'
70
-                        ),
71
-                        '<span class="yellow pill">',
72
-                        '<span class="blue pill">',
73
-                        '</span>'
74
-                    ); ?>
67
+						esc_html__(
68
+							'The Message "Queued For Resending" status color has changed from %1$sYellow%3$s to %2$sBlue%3$s',
69
+							'event_espresso'
70
+						),
71
+						'<span class="yellow pill">',
72
+						'<span class="blue pill">',
73
+						'</span>'
74
+					); ?>
75 75
                 </li>
76 76
                 <li class="ee-status-message">
77 77
                     <?php printf(
78
-                        esc_html__(
79
-                            'The Message "Messenger Is Executing" status color has changed from %1$sPink%3$s to %2$sGreen%3$s',
80
-                            'event_espresso'
81
-                        ),
82
-                        '<span class="pink pill">',
83
-                        '<span class="green pill">',
84
-                        '</span>'
85
-                    ); ?>
78
+						esc_html__(
79
+							'The Message "Messenger Is Executing" status color has changed from %1$sPink%3$s to %2$sGreen%3$s',
80
+							'event_espresso'
81
+						),
82
+						'<span class="pink pill">',
83
+						'<span class="green pill">',
84
+						'</span>'
85
+					); ?>
86 86
                 </li>
87 87
                 <li class="ee-status-message">
88 88
                     <?php printf(
89
-                        esc_html__(
90
-                            'The Message "Failed" status color has changed from %1$sRed%3$s to %2$sPink%3$s',
91
-                            'event_espresso'
92
-                        ),
93
-                        '<span class="red pill">',
94
-                        '<span class="pink pill">',
95
-                        '</span>'
96
-                    ); ?>
89
+						esc_html__(
90
+							'The Message "Failed" status color has changed from %1$sRed%3$s to %2$sPink%3$s',
91
+							'event_espresso'
92
+						),
93
+						'<span class="red pill">',
94
+						'<span class="pink pill">',
95
+						'</span>'
96
+					); ?>
97 97
                 </li>
98 98
                 <li class="ee-status-message">
99 99
                     <?php printf(
100
-                        esc_html__(
101
-                            'The Message "Debug only" status color has changed from %1$sYellow%3$s to %2$sRed%3$s',
102
-                            'event_espresso'
103
-                        ),
104
-                        '<span class="yellow pill">',
105
-                        '<span class="red pill">',
106
-                        '</span>'
107
-                    ); ?>
100
+						esc_html__(
101
+							'The Message "Debug only" status color has changed from %1$sYellow%3$s to %2$sRed%3$s',
102
+							'event_espresso'
103
+						),
104
+						'<span class="yellow pill">',
105
+						'<span class="red pill">',
106
+						'</span>'
107
+					); ?>
108 108
                 </li>
109 109
             </ul>
110 110
             <p>
111 111
                 <?php esc_html_e(
112
-                    'Please accept our sincere apologies for any inconvenience this might cause.',
113
-                    'event_espresso'
114
-                ); ?>
112
+					'Please accept our sincere apologies for any inconvenience this might cause.',
113
+					'event_espresso'
114
+				); ?>
115 115
             </p>
116 116
             <p class="ee-dismiss-notice-pg">
117 117
                 <button type="button"
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
                         id='ee-dismiss-notice-link'
121 121
                 >
122 122
                     <span class="pill pink"><?php
123
-                        esc_html_e('don\'t show this notice again please', 'event_espresso');
124
-                    ?></span>
123
+						esc_html_e('don\'t show this notice again please', 'event_espresso');
124
+					?></span>
125 125
                 </button>
126 126
             </p>
127 127
         </div>
Please login to merge, or discard this patch.
core/domain/services/admin/notices/status_change/StatusChangeNotice.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -20,112 +20,112 @@
 block discarded – undo
20 20
  */
21 21
 class StatusChangeNotice extends WordPressOption
22 22
 {
23
-    public function __construct()
24
-    {
25
-        parent::__construct('ee_hide_status_change_notices_for_users', [], false);
26
-    }
27
-
28
-
29
-    public static function loadAssets()
30
-    {
31
-        wp_enqueue_style(
32
-            'status_change_notice',
33
-            EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.css',
34
-            ['espresso_menu'],
35
-            EVENT_ESPRESSO_VERSION
36
-        );
37
-        wp_enqueue_script(
38
-            'status_change_notice',
39
-            EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.js',
40
-            ['jquery'],
41
-            EVENT_ESPRESSO_VERSION,
42
-            true
43
-        );
44
-        wp_localize_script(
45
-            'status_change_notice',
46
-            'eeStatusChangeNotice',
47
-            [
48
-                'failed_request_msg' => wp_strip_all_tags(
49
-                    __(
50
-                        'Request failed. The server returned status code: ',
51
-                        'event_espresso'
52
-                    )
53
-                ),
54
-                'unknown_error_msg' => wp_strip_all_tags(
55
-                    __(
56
-                        'Oops... an unknown error has occurred on the server and this notice could not be dismissed.',
57
-                        'event_espresso'
58
-                    )
59
-                ),
60
-            ]
61
-        );
62
-    }
63
-
64
-
65
-    public function display(string $context, string $page_slug): string
66
-    {
67
-        return $this->isNotDismissed()
68
-            ? EEH_Template::display_template(
69
-                __DIR__ . '/status_change_notice.template.php',
70
-                [
71
-                    'context'   => $context,
72
-                    'page_slug' => ! empty($page_slug) ? "{$page_slug}-page" : '',
73
-                ],
74
-                true
75
-            )
76
-            : '';
77
-    }
78
-
79
-
80
-    /**
81
-     * @return int
82
-     * @throws RuntimeException
83
-     */
84
-    public function dismiss(): int
85
-    {
86
-        $user      = $this->getCurrentUser();
87
-        $dismissed = (array) $this->loadOption();
88
-        if (! in_array($user, $dismissed)) {
89
-            $dismissed[] = $user;
90
-        }
91
-        return $this->updateOption($dismissed);
92
-    }
93
-
94
-
95
-    /**
96
-     * @return bool
97
-     * @throws RuntimeException
98
-     */
99
-    public function isDismissed(): bool
100
-    {
101
-        $user      = $this->getCurrentUser();
102
-        $dismissed = (array) $this->loadOption();
103
-        return in_array($user, $dismissed);
104
-    }
105
-
106
-
107
-    /**
108
-     * @return bool
109
-     * @throws RuntimeException
110
-     */
111
-    public function isNotDismissed(): bool
112
-    {
113
-        return ! $this->isDismissed();
114
-    }
115
-
116
-
117
-    /**
118
-     * @return string
119
-     * @throws RuntimeException
120
-     */
121
-    private function getCurrentUser(): string
122
-    {
123
-        $user = wp_get_current_user();
124
-        if (! $user instanceof WP_User || ! $user->exists()) {
125
-            throw new RuntimeException(
126
-                esc_html__('A valid WP User could not be retrieved.', 'event_espresso')
127
-            );
128
-        }
129
-        return $user->user_login;
130
-    }
23
+	public function __construct()
24
+	{
25
+		parent::__construct('ee_hide_status_change_notices_for_users', [], false);
26
+	}
27
+
28
+
29
+	public static function loadAssets()
30
+	{
31
+		wp_enqueue_style(
32
+			'status_change_notice',
33
+			EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.css',
34
+			['espresso_menu'],
35
+			EVENT_ESPRESSO_VERSION
36
+		);
37
+		wp_enqueue_script(
38
+			'status_change_notice',
39
+			EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.js',
40
+			['jquery'],
41
+			EVENT_ESPRESSO_VERSION,
42
+			true
43
+		);
44
+		wp_localize_script(
45
+			'status_change_notice',
46
+			'eeStatusChangeNotice',
47
+			[
48
+				'failed_request_msg' => wp_strip_all_tags(
49
+					__(
50
+						'Request failed. The server returned status code: ',
51
+						'event_espresso'
52
+					)
53
+				),
54
+				'unknown_error_msg' => wp_strip_all_tags(
55
+					__(
56
+						'Oops... an unknown error has occurred on the server and this notice could not be dismissed.',
57
+						'event_espresso'
58
+					)
59
+				),
60
+			]
61
+		);
62
+	}
63
+
64
+
65
+	public function display(string $context, string $page_slug): string
66
+	{
67
+		return $this->isNotDismissed()
68
+			? EEH_Template::display_template(
69
+				__DIR__ . '/status_change_notice.template.php',
70
+				[
71
+					'context'   => $context,
72
+					'page_slug' => ! empty($page_slug) ? "{$page_slug}-page" : '',
73
+				],
74
+				true
75
+			)
76
+			: '';
77
+	}
78
+
79
+
80
+	/**
81
+	 * @return int
82
+	 * @throws RuntimeException
83
+	 */
84
+	public function dismiss(): int
85
+	{
86
+		$user      = $this->getCurrentUser();
87
+		$dismissed = (array) $this->loadOption();
88
+		if (! in_array($user, $dismissed)) {
89
+			$dismissed[] = $user;
90
+		}
91
+		return $this->updateOption($dismissed);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return bool
97
+	 * @throws RuntimeException
98
+	 */
99
+	public function isDismissed(): bool
100
+	{
101
+		$user      = $this->getCurrentUser();
102
+		$dismissed = (array) $this->loadOption();
103
+		return in_array($user, $dismissed);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @return bool
109
+	 * @throws RuntimeException
110
+	 */
111
+	public function isNotDismissed(): bool
112
+	{
113
+		return ! $this->isDismissed();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @return string
119
+	 * @throws RuntimeException
120
+	 */
121
+	private function getCurrentUser(): string
122
+	{
123
+		$user = wp_get_current_user();
124
+		if (! $user instanceof WP_User || ! $user->exists()) {
125
+			throw new RuntimeException(
126
+				esc_html__('A valid WP User could not be retrieved.', 'event_espresso')
127
+			);
128
+		}
129
+		return $user->user_login;
130
+	}
131 131
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
     {
31 31
         wp_enqueue_style(
32 32
             'status_change_notice',
33
-            EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.css',
33
+            EE_PLUGIN_DIR_URL.'core/domain/services/admin/notices/status_change/status_change_notice.css',
34 34
             ['espresso_menu'],
35 35
             EVENT_ESPRESSO_VERSION
36 36
         );
37 37
         wp_enqueue_script(
38 38
             'status_change_notice',
39
-            EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.js',
39
+            EE_PLUGIN_DIR_URL.'core/domain/services/admin/notices/status_change/status_change_notice.js',
40 40
             ['jquery'],
41 41
             EVENT_ESPRESSO_VERSION,
42 42
             true
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     {
67 67
         return $this->isNotDismissed()
68 68
             ? EEH_Template::display_template(
69
-                __DIR__ . '/status_change_notice.template.php',
69
+                __DIR__.'/status_change_notice.template.php',
70 70
                 [
71 71
                     'context'   => $context,
72 72
                     'page_slug' => ! empty($page_slug) ? "{$page_slug}-page" : '',
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $user      = $this->getCurrentUser();
87 87
         $dismissed = (array) $this->loadOption();
88
-        if (! in_array($user, $dismissed)) {
88
+        if ( ! in_array($user, $dismissed)) {
89 89
             $dismissed[] = $user;
90 90
         }
91 91
         return $this->updateOption($dismissed);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     private function getCurrentUser(): string
122 122
     {
123 123
         $user = wp_get_current_user();
124
-        if (! $user instanceof WP_User || ! $user->exists()) {
124
+        if ( ! $user instanceof WP_User || ! $user->exists()) {
125 125
             throw new RuntimeException(
126 126
                 esc_html__('A valid WP User could not be retrieved.', 'event_espresso')
127 127
             );
Please login to merge, or discard this patch.
core/libraries/messages/EE_messenger.lib.php 2 patches
Indentation   +771 added lines, -771 removed lines patch added patch discarded remove patch
@@ -16,182 +16,182 @@  discard block
 block discarded – undo
16 16
  */
17 17
 abstract class EE_messenger extends EE_Messages_Base
18 18
 {
19
-    /**
20
-     * This property holds the default message types associated with this messenger when it is activated. The values of the array must match a valid message type.
21
-     * This property gets set by the _set_default_message_types() method.
22
-     *
23
-     * @var array
24
-     */
25
-    protected $_default_message_types = array();
19
+	/**
20
+	 * This property holds the default message types associated with this messenger when it is activated. The values of the array must match a valid message type.
21
+	 * This property gets set by the _set_default_message_types() method.
22
+	 *
23
+	 * @var array
24
+	 */
25
+	protected $_default_message_types = array();
26 26
 
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * This property holds the message types that are valid for use with this messenger.
32
-     * It gets set by the _set_valid_message_types() method.
33
-     *
34
-     * @var array
35
-     */
36
-    protected $_valid_message_types = array();
30
+	/**
31
+	 * This property holds the message types that are valid for use with this messenger.
32
+	 * It gets set by the _set_valid_message_types() method.
33
+	 *
34
+	 * @var array
35
+	 */
36
+	protected $_valid_message_types = array();
37 37
 
38 38
 
39 39
 
40
-    /**
41
-     * Holds the configuration for the EE_Messages_Validator class to know how to validated the different fields. Note that the Validator will match each field here with the allowed shortcodes set in the "valid_shortcodes" array for the matched message type context.  So message types don't need to set a $_validator_config property.
42
-     *
43
-     * Remember, ALL fields must be declared in this array.  However, an empty value for the field means that the field will accept all valid shortcodes set for the given context in the message type (by default).
44
-     *
45
-     * Array should be in this format:
46
-     *
47
-     * array(
48
-     *  'field_name(i.e.to)' => array(
49
-     *      'shortcodes' => array('email'), //an array of shortcode groups (correspond to EE_Shortcodes library class) that are allowed in the field. Typically you can just include $this->_valid_shortcodes['field_name'] as the value here (because they will match).
50
-     *      'specific_shortcodes' => array( array('[EVENT_AUTHOR_EMAIL]' => esc_html__('Admin Email', 'event_espresso')), //if this index is present you can further restrict the field to ONLY specific shortcodes if an entire group isn't sufficient. Specific shortcodes need to be listed as an array with the index the shortcode and the value = the label.
51
-     *      'type' => 'email' //this is the field type and should match one of the validator types (see EE_Messages_Validator::validator() for all the possible types).  If not required you can just leave empty.,
52
-     *      'required' => array'[SHORTCODE]') //this is used to indicate the shortcodes that MUST be in the assembled array of shortcodes by the validator in order for this field to be included in validation.  Otherwise the validator will always assign shortcodes for this field (regardless of whether the field settings for the given messenger/message_type/context use the field or not.).. please note, this does NOT mean that the shortcodes listed here MUST be in the given field.
53
-     *  )
54
-     * )
55
-     *
56
-     * @var array
57
-     */
58
-    protected $_validator_config = array();
40
+	/**
41
+	 * Holds the configuration for the EE_Messages_Validator class to know how to validated the different fields. Note that the Validator will match each field here with the allowed shortcodes set in the "valid_shortcodes" array for the matched message type context.  So message types don't need to set a $_validator_config property.
42
+	 *
43
+	 * Remember, ALL fields must be declared in this array.  However, an empty value for the field means that the field will accept all valid shortcodes set for the given context in the message type (by default).
44
+	 *
45
+	 * Array should be in this format:
46
+	 *
47
+	 * array(
48
+	 *  'field_name(i.e.to)' => array(
49
+	 *      'shortcodes' => array('email'), //an array of shortcode groups (correspond to EE_Shortcodes library class) that are allowed in the field. Typically you can just include $this->_valid_shortcodes['field_name'] as the value here (because they will match).
50
+	 *      'specific_shortcodes' => array( array('[EVENT_AUTHOR_EMAIL]' => esc_html__('Admin Email', 'event_espresso')), //if this index is present you can further restrict the field to ONLY specific shortcodes if an entire group isn't sufficient. Specific shortcodes need to be listed as an array with the index the shortcode and the value = the label.
51
+	 *      'type' => 'email' //this is the field type and should match one of the validator types (see EE_Messages_Validator::validator() for all the possible types).  If not required you can just leave empty.,
52
+	 *      'required' => array'[SHORTCODE]') //this is used to indicate the shortcodes that MUST be in the assembled array of shortcodes by the validator in order for this field to be included in validation.  Otherwise the validator will always assign shortcodes for this field (regardless of whether the field settings for the given messenger/message_type/context use the field or not.).. please note, this does NOT mean that the shortcodes listed here MUST be in the given field.
53
+	 *  )
54
+	 * )
55
+	 *
56
+	 * @var array
57
+	 */
58
+	protected $_validator_config = array();
59 59
 
60 60
 
61 61
 
62
-    /**
63
-     * This will hold the EEM_message_templates model for interacting with the database and retrieving active templates for the messenger
64
-     * @var object
65
-     */
66
-    protected $_EEM_data;
62
+	/**
63
+	 * This will hold the EEM_message_templates model for interacting with the database and retrieving active templates for the messenger
64
+	 * @var object
65
+	 */
66
+	protected $_EEM_data;
67 67
 
68 68
 
69 69
 
70
-    /**
71
-     * this property just holds an array of the various template refs.
72
-     * @var array
73
-     */
74
-    protected $_template_fields = array();
70
+	/**
71
+	 * this property just holds an array of the various template refs.
72
+	 * @var array
73
+	 */
74
+	protected $_template_fields = array();
75 75
 
76 76
 
77 77
 
78 78
 
79
-    /**
80
-     * This holds an array of the arguments used in parsing a template for the sender.
81
-     * @var array
82
-     */
83
-    protected $_template_args = array();
79
+	/**
80
+	 * This holds an array of the arguments used in parsing a template for the sender.
81
+	 * @var array
82
+	 */
83
+	protected $_template_args = array();
84 84
 
85 85
 
86 86
 
87 87
 
88 88
 
89 89
 
90
-    /**
91
-     * This property will hold the configuration for any test settings fields that are required for the "test" button that is used to trigger an actual test of this messenger
92
-     *
93
-     * @protected
94
-     * @var array
95
-     */
96
-    protected $_test_settings_fields = array();
90
+	/**
91
+	 * This property will hold the configuration for any test settings fields that are required for the "test" button that is used to trigger an actual test of this messenger
92
+	 *
93
+	 * @protected
94
+	 * @var array
95
+	 */
96
+	protected $_test_settings_fields = array();
97 97
 
98 98
 
99 99
 
100 100
 
101 101
 
102 102
 
103
-    /**
104
-     * This will hold the EE_Messages_Template_Pack object when set on the messenger.  This is set via the validate and setup method which grabs the template pack from the incoming messages object.
105
-     *
106
-     * @since 4.5.0
107
-     *
108
-     * @var EE_Messages_Template_Pack
109
-     */
110
-    protected $_tmp_pack;
103
+	/**
104
+	 * This will hold the EE_Messages_Template_Pack object when set on the messenger.  This is set via the validate and setup method which grabs the template pack from the incoming messages object.
105
+	 *
106
+	 * @since 4.5.0
107
+	 *
108
+	 * @var EE_Messages_Template_Pack
109
+	 */
110
+	protected $_tmp_pack;
111 111
 
112 112
 
113 113
 
114 114
 
115
-    /**
116
-     * This will hold the variation to use when performing a send.  It is set via the validate and setup method which grabs the variation from the incoming messages object on the send method.
117
-     *
118
-     * @since 4.5.0
119
-     *
120
-     * @var string
121
-     */
122
-    protected $_variation;
115
+	/**
116
+	 * This will hold the variation to use when performing a send.  It is set via the validate and setup method which grabs the variation from the incoming messages object on the send method.
117
+	 *
118
+	 * @since 4.5.0
119
+	 *
120
+	 * @var string
121
+	 */
122
+	protected $_variation;
123 123
 
124 124
 
125 125
 
126 126
 
127 127
 
128
-    /**
129
-     * This property is a stdClass that holds labels for all the various supporting properties for this messenger.  These labels are set via the _set_supports_labels() method in children classes. Initially this will include the label for:
130
-     *
131
-     *  - template pack
132
-     *  - template variation
133
-     *
134
-     * @since 4.5.0
135
-     *
136
-     * @var stdClass
137
-     */
138
-    protected $_supports_labels;
128
+	/**
129
+	 * This property is a stdClass that holds labels for all the various supporting properties for this messenger.  These labels are set via the _set_supports_labels() method in children classes. Initially this will include the label for:
130
+	 *
131
+	 *  - template pack
132
+	 *  - template variation
133
+	 *
134
+	 * @since 4.5.0
135
+	 *
136
+	 * @var stdClass
137
+	 */
138
+	protected $_supports_labels;
139 139
 
140 140
 
141 141
 
142 142
 
143 143
 
144
-    /**
145
-     * This property is set when the send_message() method is called and holds the Message Type used to generate templates with this messenger for the messages.
146
-     *
147
-     * @var EE_message_type
148
-     */
149
-    protected $_incoming_message_type;
144
+	/**
145
+	 * This property is set when the send_message() method is called and holds the Message Type used to generate templates with this messenger for the messages.
146
+	 *
147
+	 * @var EE_message_type
148
+	 */
149
+	protected $_incoming_message_type;
150 150
 
151 151
 
152 152
 
153
-    /**
154
-     * This flag sets whether a messenger is activated by default  on installation (or reactivation) of EE core or not.
155
-     *
156
-     * @var bool
157
-     */
158
-    public $activate_on_install = false;
153
+	/**
154
+	 * This flag sets whether a messenger is activated by default  on installation (or reactivation) of EE core or not.
155
+	 *
156
+	 * @var bool
157
+	 */
158
+	public $activate_on_install = false;
159 159
 
160 160
 
161 161
 
162 162
 
163 163
 
164
-    public function __construct()
165
-    {
166
-        $this->_EEM_data = EEM_Message_Template_Group::instance();
167
-        $this->_messages_item_type = 'messenger';
164
+	public function __construct()
165
+	{
166
+		$this->_EEM_data = EEM_Message_Template_Group::instance();
167
+		$this->_messages_item_type = 'messenger';
168 168
 
169
-        parent::__construct();
169
+		parent::__construct();
170 170
 
171
-        $this->_set_test_settings_fields();
172
-        $this->_set_template_fields();
173
-        $this->_set_default_message_types();
174
-        $this->_set_valid_message_types();
175
-        $this->_set_validator_config();
171
+		$this->_set_test_settings_fields();
172
+		$this->_set_template_fields();
173
+		$this->_set_default_message_types();
174
+		$this->_set_valid_message_types();
175
+		$this->_set_validator_config();
176 176
 
177 177
 
178
-        $this->_supports_labels = new stdClass();
179
-        $this->_set_supports_labels();
180
-    }
178
+		$this->_supports_labels = new stdClass();
179
+		$this->_set_supports_labels();
180
+	}
181 181
 
182 182
 
183 183
 
184 184
 
185 185
 
186
-    /**
187
-     * _set_template_fields
188
-     * This sets up the fields that a messenger requires for the message to go out.
189
-     *
190
-     * @abstract
191
-     * @access  protected
192
-     * @return void
193
-     */
194
-    abstract protected function _set_template_fields();
186
+	/**
187
+	 * _set_template_fields
188
+	 * This sets up the fields that a messenger requires for the message to go out.
189
+	 *
190
+	 * @abstract
191
+	 * @access  protected
192
+	 * @return void
193
+	 */
194
+	abstract protected function _set_template_fields();
195 195
 
196 196
 
197 197
 
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 
202 202
 
203 203
 
204
-    /**
205
-     * This method sets the _default_message_type property (see definition in docs attached to property)
206
-     *
207
-     * @abstract
208
-     * @access protected
209
-     * @return void
210
-     */
211
-    abstract protected function _set_default_message_types();
204
+	/**
205
+	 * This method sets the _default_message_type property (see definition in docs attached to property)
206
+	 *
207
+	 * @abstract
208
+	 * @access protected
209
+	 * @return void
210
+	 */
211
+	abstract protected function _set_default_message_types();
212 212
 
213 213
 
214 214
 
@@ -216,15 +216,15 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 
219
-    /**
220
-     * Sets the _valid_message_types property (see definition in cods attached to property)
221
-     *
222
-     * @since 4.5.0
223
-     *
224
-     * @abstract
225
-     * @return void
226
-     */
227
-    abstract protected function _set_valid_message_types();
219
+	/**
220
+	 * Sets the _valid_message_types property (see definition in cods attached to property)
221
+	 *
222
+	 * @since 4.5.0
223
+	 *
224
+	 * @abstract
225
+	 * @return void
226
+	 */
227
+	abstract protected function _set_valid_message_types();
228 228
 
229 229
 
230 230
 
@@ -232,171 +232,171 @@  discard block
 block discarded – undo
232 232
 
233 233
 
234 234
 
235
-    /**
236
-     * Child classes must declare the $_validator_config property using this method.
237
-     * See comments for $_validator_config for details on what it is used for.
238
-     *
239
-     * NOTE:  messengers should set an array of valid shortcodes for ALL scenarios.  The corresponding validator class (validators/{messenger}) can be used to restrict only certain shortcodes per template so users cannot add certain shortcodes.
240
-     *
241
-     * @access protected
242
-     * @return void
243
-     */
244
-    abstract protected function _set_validator_config();
235
+	/**
236
+	 * Child classes must declare the $_validator_config property using this method.
237
+	 * See comments for $_validator_config for details on what it is used for.
238
+	 *
239
+	 * NOTE:  messengers should set an array of valid shortcodes for ALL scenarios.  The corresponding validator class (validators/{messenger}) can be used to restrict only certain shortcodes per template so users cannot add certain shortcodes.
240
+	 *
241
+	 * @access protected
242
+	 * @return void
243
+	 */
244
+	abstract protected function _set_validator_config();
245 245
 
246 246
 
247 247
 
248 248
 
249 249
 
250 250
 
251
-    /**
252
-     * We just deliver the messages don't kill us!!  This method will need to be modified by child classes for whatever action is taken to actually send a message.
253
-     *
254
-     * @return bool|WP_Error
255
-     * @throw \Exception
256
-     */
257
-    abstract protected function _send_message();
251
+	/**
252
+	 * We just deliver the messages don't kill us!!  This method will need to be modified by child classes for whatever action is taken to actually send a message.
253
+	 *
254
+	 * @return bool|WP_Error
255
+	 * @throw \Exception
256
+	 */
257
+	abstract protected function _send_message();
258 258
 
259 259
 
260 260
 
261 261
 
262
-    /**
263
-     * We give you pretty previews of the messages!
264
-     * @return string html body for message content.
265
-     */
266
-    abstract protected function _preview();
262
+	/**
263
+	 * We give you pretty previews of the messages!
264
+	 * @return string html body for message content.
265
+	 */
266
+	abstract protected function _preview();
267 267
 
268 268
 
269 269
 
270 270
 
271
-    /**
272
-     * Used by messengers (or preview) for enqueueing any scripts or styles need in message generation.
273
-     *
274
-     * @since 4.5.0
275
-     *
276
-     * @return void
277
-     */
278
-    public function enqueue_scripts_styles()
279
-    {
280
-        do_action('AHEE__EE_messenger__enqueue_scripts_styles');
281
-    }
271
+	/**
272
+	 * Used by messengers (or preview) for enqueueing any scripts or styles need in message generation.
273
+	 *
274
+	 * @since 4.5.0
275
+	 *
276
+	 * @return void
277
+	 */
278
+	public function enqueue_scripts_styles()
279
+	{
280
+		do_action('AHEE__EE_messenger__enqueue_scripts_styles');
281
+	}
282 282
 
283 283
 
284 284
 
285 285
 
286 286
 
287
-    /**
288
-     * This is used to indicate whether a messenger must be sent immediately or not.
289
-     * eg. The HTML messenger will override this to return true because it should be displayed in user's browser right
290
-     * away.  The PDF messenger is similar.
291
-     *
292
-     * This flag thus overrides any priorities that may be set on the message type used to generate the message.
293
-     *
294
-     * Default for this is false.  So children classes must override this if they want a message to be executed immediately.
295
-     *
296
-     * @since  4.9.0
297
-     * @return bool
298
-     */
299
-    public function send_now()
300
-    {
301
-        return false;
302
-    }
287
+	/**
288
+	 * This is used to indicate whether a messenger must be sent immediately or not.
289
+	 * eg. The HTML messenger will override this to return true because it should be displayed in user's browser right
290
+	 * away.  The PDF messenger is similar.
291
+	 *
292
+	 * This flag thus overrides any priorities that may be set on the message type used to generate the message.
293
+	 *
294
+	 * Default for this is false.  So children classes must override this if they want a message to be executed immediately.
295
+	 *
296
+	 * @since  4.9.0
297
+	 * @return bool
298
+	 */
299
+	public function send_now()
300
+	{
301
+		return false;
302
+	}
303 303
 
304 304
 
305 305
 
306 306
 
307 307
 
308
-    /**
309
-     * This is a way for a messenger to indicate whether it allows an empty to field or not.
310
-     * Note: If the generated message is a for a preview, this value is ignored.
311
-     * @since 4.9.0
312
-     * @return bool
313
-     */
314
-    public function allow_empty_to_field()
315
-    {
316
-        return false;
317
-    }
308
+	/**
309
+	 * This is a way for a messenger to indicate whether it allows an empty to field or not.
310
+	 * Note: If the generated message is a for a preview, this value is ignored.
311
+	 * @since 4.9.0
312
+	 * @return bool
313
+	 */
314
+	public function allow_empty_to_field()
315
+	{
316
+		return false;
317
+	}
318 318
 
319 319
 
320 320
 
321 321
 
322 322
 
323
-    /**
324
-     * Sets the defaults for the _supports_labels property.  Can be overridden by child classes.
325
-     * @see property definition for info on how its formatted.
326
-     *
327
-     * @since 4.5.0;
328
-     * @return void
329
-     */
330
-    protected function _set_supports_labels()
331
-    {
332
-        $this->_set_supports_labels_defaults();
333
-    }
323
+	/**
324
+	 * Sets the defaults for the _supports_labels property.  Can be overridden by child classes.
325
+	 * @see property definition for info on how its formatted.
326
+	 *
327
+	 * @since 4.5.0;
328
+	 * @return void
329
+	 */
330
+	protected function _set_supports_labels()
331
+	{
332
+		$this->_set_supports_labels_defaults();
333
+	}
334 334
 
335 335
 
336 336
 
337 337
 
338 338
 
339
-    /**
340
-     * Sets the defaults for the _supports_labels property.
341
-     *
342
-     * @since 4.5.0
343
-     *
344
-     * @return void
345
-     */
346
-    private function _set_supports_labels_defaults()
347
-    {
348
-        $this->_supports_labels->template_pack = esc_html__('Template Structure', 'event_espresso');
349
-        $this->_supports_labels->template_variation = esc_html__('Template Style', 'event_espresso');
350
-        $this->_supports_labels->template_pack_description = esc_html__('Template Structure options are bundled structural changes for templates.', 'event_espresso');
339
+	/**
340
+	 * Sets the defaults for the _supports_labels property.
341
+	 *
342
+	 * @since 4.5.0
343
+	 *
344
+	 * @return void
345
+	 */
346
+	private function _set_supports_labels_defaults()
347
+	{
348
+		$this->_supports_labels->template_pack = esc_html__('Template Structure', 'event_espresso');
349
+		$this->_supports_labels->template_variation = esc_html__('Template Style', 'event_espresso');
350
+		$this->_supports_labels->template_pack_description = esc_html__('Template Structure options are bundled structural changes for templates.', 'event_espresso');
351 351
 
352
-        $this->_supports_labels->template_variation_description = esc_html__('These are different styles to choose from for the selected template structure.  Usually these affect things like font style, color, borders etc.  In some cases the styles will also make minor layout changes.', 'event_espresso');
352
+		$this->_supports_labels->template_variation_description = esc_html__('These are different styles to choose from for the selected template structure.  Usually these affect things like font style, color, borders etc.  In some cases the styles will also make minor layout changes.', 'event_espresso');
353 353
 
354
-        $this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this);
355
-    }
354
+		$this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this);
355
+	}
356 356
 
357 357
 
358 358
 
359 359
 
360 360
 
361
-    /**
362
-     * This returns the _supports_labels property.
363
-     *
364
-     * @since 4.5.0
365
-     *
366
-     * @return stdClass
367
-     */
368
-    public function get_supports_labels()
369
-    {
370
-        if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) {
371
-            $this->_set_supports_labels_defaults();
372
-        }
373
-        return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this);
374
-    }
361
+	/**
362
+	 * This returns the _supports_labels property.
363
+	 *
364
+	 * @since 4.5.0
365
+	 *
366
+	 * @return stdClass
367
+	 */
368
+	public function get_supports_labels()
369
+	{
370
+		if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) {
371
+			$this->_set_supports_labels_defaults();
372
+		}
373
+		return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this);
374
+	}
375 375
 
376 376
 
377 377
 
378 378
 
379
-    /**
380
-     * Used to retrieve a variation (typically the path/url to a css file)
381
-     *
382
-     * @since 4.5.0
383
-     *
384
-     * @param EE_Messages_Template_Pack $pack   The template pack used for retrieving the variation.
385
-     * @param string                    $message_type_name The name property of the message type that we need the variation for.
386
-     * @param bool                      $url   Whether to return url (true) or path (false). Default is false.
387
-     * @param string                    $type What variation type to return. Default is 'main'.
388
-     * @param string               $variation What variation for the template pack
389
-     * @param bool             $skip_filters This allows messengers to add a filter for another messengers get_variation but call skip filters on the callback so there is no recursion on apply_filters.
390
-     *
391
-     * @return string                    path or url for the requested variation.
392
-     */
393
-    public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = false, $type = 'main', $variation = 'default', $skip_filters = false)
394
-    {
395
-        $this->_tmp_pack = $pack;
396
-        $variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters);
397
-        $variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path;
398
-        return $variation_path;
399
-    }
379
+	/**
380
+	 * Used to retrieve a variation (typically the path/url to a css file)
381
+	 *
382
+	 * @since 4.5.0
383
+	 *
384
+	 * @param EE_Messages_Template_Pack $pack   The template pack used for retrieving the variation.
385
+	 * @param string                    $message_type_name The name property of the message type that we need the variation for.
386
+	 * @param bool                      $url   Whether to return url (true) or path (false). Default is false.
387
+	 * @param string                    $type What variation type to return. Default is 'main'.
388
+	 * @param string               $variation What variation for the template pack
389
+	 * @param bool             $skip_filters This allows messengers to add a filter for another messengers get_variation but call skip filters on the callback so there is no recursion on apply_filters.
390
+	 *
391
+	 * @return string                    path or url for the requested variation.
392
+	 */
393
+	public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = false, $type = 'main', $variation = 'default', $skip_filters = false)
394
+	{
395
+		$this->_tmp_pack = $pack;
396
+		$variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters);
397
+		$variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path;
398
+		return $variation_path;
399
+	}
400 400
 
401 401
 
402 402
 
@@ -404,200 +404,200 @@  discard block
 block discarded – undo
404 404
 
405 405
 
406 406
 
407
-    /**
408
-     * This just returns the default message types associated with this messenger when it is first activated.
409
-     *
410
-     * @access public
411
-     * @return array
412
-     */
413
-    public function get_default_message_types()
414
-    {
415
-        $class = get_class($this);
407
+	/**
408
+	 * This just returns the default message types associated with this messenger when it is first activated.
409
+	 *
410
+	 * @access public
411
+	 * @return array
412
+	 */
413
+	public function get_default_message_types()
414
+	{
415
+		$class = get_class($this);
416 416
 
417
-        // messenger specific filter
418
-        $default_types = apply_filters('FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this);
417
+		// messenger specific filter
418
+		$default_types = apply_filters('FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this);
419 419
 
420
-        // all messengers filter
421
-        $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
422
-        return $default_types;
423
-    }
420
+		// all messengers filter
421
+		$default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
422
+		return $default_types;
423
+	}
424 424
 
425 425
 
426 426
 
427 427
 
428
-    /**
429
-     * Returns the valid message types associated with this messenger.
430
-     *
431
-     * @since 4.5.0
432
-     *
433
-     * @return array
434
-     */
435
-    public function get_valid_message_types()
436
-    {
437
-        $class = get_class($this);
438
-
439
-        // messenger specific filter
440
-        // messenger specific filter
441
-        $valid_types = apply_filters('FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
442
-
443
-        // all messengers filter
444
-        $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
445
-        return $valid_types;
446
-    }
447
-
448
-
449
-
450
-
451
-
452
-    /**
453
-     * this is just used by the custom validators (EE_Messages_Validator classes) to modify the _validator_config for certain message_type/messenger combos where a context may only use certain shortcodes etc.
454
-     *
455
-     * @access public
456
-     * @param array $new_config Whatever is put in here will reset the _validator_config property
457
-     */
458
-    public function set_validator_config($new_config)
459
-    {
460
-        $this->_validator_config = $new_config;
461
-    }
462
-
463
-
464
-
465
-
466
-    /**
467
-     * This returns the _validator_config property
468
-     *
469
-     * @access public
470
-     * @return array
471
-     */
472
-    public function get_validator_config()
473
-    {
474
-        $class = get_class($this);
475
-
476
-        $config = apply_filters('FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this);
477
-        $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
478
-        return $config;
479
-    }
480
-
481
-
482
-
483
-
484
-    /**
485
-     * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class callback function if that page is registered via the `_admin_registered_page` property set by the child class.
486
-     *
487
-     * @param string $page the slug of the EE admin page
488
-     * @param array $message_types an array of active message type objects
489
-     * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages)
490
-     * @param array $extra  This is just an extra argument that can be used to pass additional data for setting up page content.
491
-     * @access public
492
-     * @return string content for page
493
-     */
494
-    public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array())
495
-    {
496
-        return $this->_get_admin_page_content($page, $action, $extra, $message_types);
497
-    }
498
-
499
-
500
-
501
-    /**
502
-     * @param $message_types
503
-     * @param array $extra
504
-     * @return mixed|string
505
-     */
506
-    protected function _get_admin_content_events_edit($message_types, $extra)
507
-    {
508
-        // defaults
509
-        $template_args = array();
510
-        $selector_rows = '';
511
-
512
-        // we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event.
513
-        $event_id = isset($extra['event']) ? $extra['event'] : null;
514
-
515
-        $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
516
-        $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
517
-
518
-        // array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
519
-        $global_templates = EEM_Message_Template_Group::instance()->get_all(
520
-            array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) )
521
-        );
522
-        $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event(
523
-            $event_id,
524
-            array(
525
-                'MTP_messenger' => $this->name,
526
-                'MTP_is_active' => true
527
-            )
528
-        );
529
-        $templates_for_event = !empty($templates_for_event) ? $templates_for_event : array();
530
-
531
-        $msg_type_status_map = [
532
-            'payment' => 'PAP',
533
-            'payment_refund' => 'PRF',
534
-            'payment_reminder' => 'PPN',
535
-            'registration' => 'RAP',
536
-            'not_approved_registration' => 'RNA',
537
-            'pending_approval' => 'RPP',
538
-            'payment_declined' => 'PDC',
539
-            'declined_registration' => 'RDC',
540
-            'cancelled_registration' => 'RCN',
541
-            'payment_failed' => 'PFL',
542
-            'payment_cancelled' => 'PCN',
543
-        ];
544
-
545
-        // so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups)
546
-        foreach ($global_templates as $mtpgID => $mtpg) {
547
-            if ($mtpg instanceof EE_Message_Template_Group) {
548
-                // verify this message type is supposed to show on this page
549
-                $mtp_obj = $mtpg->message_type_obj();
550
-                if (! $mtp_obj instanceof EE_message_type) {
551
-                    continue;
552
-                }
553
-                $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
554
-                if (! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
555
-                    continue;
556
-                }
557
-                $select_values = array();
558
-                $select_values[ $mtpgID ] = esc_html__('Global', 'event_espresso');
559
-                $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null;
560
-                // if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override.
561
-                if (! $mtpg->get('MTP_is_override')) {
562
-                    // any custom templates for this message type?
563
-                    $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
564
-                    foreach ($custom_templates as $cmtpgID => $cmtpg) {
565
-                        $select_values[ $cmtpgID ] = $cmtpg->name();
566
-                        $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
567
-                    }
568
-                }
569
-                // if there is no $default_value then we set it as the global
570
-                $default_value = empty($default_value) ? $mtpgID : $default_value;
571
-                $edit_url_query_args = [
572
-                    'page' => 'espresso_messages',
573
-                    'action' => 'edit_message_template',
574
-                    'id' => $default_value,
575
-                    'evt_id' => $event_id
576
-                ];
577
-                $edit_url = EEH_URL::add_query_args_and_nonce($edit_url_query_args, admin_url('admin.php'));
578
-                $create_url_query_args = [
579
-                    'page' => 'espresso_messages',
580
-                    'action' => 'add_new_message_template',
581
-                    'GRP_ID' => $default_value
582
-                ];
583
-                $mt_slug = $mtpg->message_type();
584
-                $create_url = EEH_URL::add_query_args_and_nonce($create_url_query_args, admin_url('admin.php'));
585
-                $st_args['mtpgID'] = $mtpgID;
586
-                $st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
587
-                $st_args['mt_slug'] = $mt_slug;
588
-                $st_args['messenger_slug'] = $this->name;
589
-                $st_args['status_code'] = $msg_type_status_map[ $mt_slug ] ?? '';
590
-                $st_args['selector'] = EEH_Form_Fields::select_input(
591
-                    'event_message_templates_relation[' . $mtpgID . ']',
592
-                    $select_values,
593
-                    $default_value,
594
-                    'data-messenger="' . $this->name . '" data-messagetype="' . $mt_slug . '"',
595
-                    'message-template-selector'
596
-                );
597
-                // note that  message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates).
598
-                $st_args['create_button'] = $mtpg->get('MTP_is_override')
599
-                    ? ''
600
-                    : '
428
+	/**
429
+	 * Returns the valid message types associated with this messenger.
430
+	 *
431
+	 * @since 4.5.0
432
+	 *
433
+	 * @return array
434
+	 */
435
+	public function get_valid_message_types()
436
+	{
437
+		$class = get_class($this);
438
+
439
+		// messenger specific filter
440
+		// messenger specific filter
441
+		$valid_types = apply_filters('FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
442
+
443
+		// all messengers filter
444
+		$valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
445
+		return $valid_types;
446
+	}
447
+
448
+
449
+
450
+
451
+
452
+	/**
453
+	 * this is just used by the custom validators (EE_Messages_Validator classes) to modify the _validator_config for certain message_type/messenger combos where a context may only use certain shortcodes etc.
454
+	 *
455
+	 * @access public
456
+	 * @param array $new_config Whatever is put in here will reset the _validator_config property
457
+	 */
458
+	public function set_validator_config($new_config)
459
+	{
460
+		$this->_validator_config = $new_config;
461
+	}
462
+
463
+
464
+
465
+
466
+	/**
467
+	 * This returns the _validator_config property
468
+	 *
469
+	 * @access public
470
+	 * @return array
471
+	 */
472
+	public function get_validator_config()
473
+	{
474
+		$class = get_class($this);
475
+
476
+		$config = apply_filters('FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this);
477
+		$config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
478
+		return $config;
479
+	}
480
+
481
+
482
+
483
+
484
+	/**
485
+	 * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class callback function if that page is registered via the `_admin_registered_page` property set by the child class.
486
+	 *
487
+	 * @param string $page the slug of the EE admin page
488
+	 * @param array $message_types an array of active message type objects
489
+	 * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages)
490
+	 * @param array $extra  This is just an extra argument that can be used to pass additional data for setting up page content.
491
+	 * @access public
492
+	 * @return string content for page
493
+	 */
494
+	public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array())
495
+	{
496
+		return $this->_get_admin_page_content($page, $action, $extra, $message_types);
497
+	}
498
+
499
+
500
+
501
+	/**
502
+	 * @param $message_types
503
+	 * @param array $extra
504
+	 * @return mixed|string
505
+	 */
506
+	protected function _get_admin_content_events_edit($message_types, $extra)
507
+	{
508
+		// defaults
509
+		$template_args = array();
510
+		$selector_rows = '';
511
+
512
+		// we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event.
513
+		$event_id = isset($extra['event']) ? $extra['event'] : null;
514
+
515
+		$template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
516
+		$template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
517
+
518
+		// array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
519
+		$global_templates = EEM_Message_Template_Group::instance()->get_all(
520
+			array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) )
521
+		);
522
+		$templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event(
523
+			$event_id,
524
+			array(
525
+				'MTP_messenger' => $this->name,
526
+				'MTP_is_active' => true
527
+			)
528
+		);
529
+		$templates_for_event = !empty($templates_for_event) ? $templates_for_event : array();
530
+
531
+		$msg_type_status_map = [
532
+			'payment' => 'PAP',
533
+			'payment_refund' => 'PRF',
534
+			'payment_reminder' => 'PPN',
535
+			'registration' => 'RAP',
536
+			'not_approved_registration' => 'RNA',
537
+			'pending_approval' => 'RPP',
538
+			'payment_declined' => 'PDC',
539
+			'declined_registration' => 'RDC',
540
+			'cancelled_registration' => 'RCN',
541
+			'payment_failed' => 'PFL',
542
+			'payment_cancelled' => 'PCN',
543
+		];
544
+
545
+		// so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups)
546
+		foreach ($global_templates as $mtpgID => $mtpg) {
547
+			if ($mtpg instanceof EE_Message_Template_Group) {
548
+				// verify this message type is supposed to show on this page
549
+				$mtp_obj = $mtpg->message_type_obj();
550
+				if (! $mtp_obj instanceof EE_message_type) {
551
+					continue;
552
+				}
553
+				$mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
554
+				if (! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
555
+					continue;
556
+				}
557
+				$select_values = array();
558
+				$select_values[ $mtpgID ] = esc_html__('Global', 'event_espresso');
559
+				$default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null;
560
+				// if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override.
561
+				if (! $mtpg->get('MTP_is_override')) {
562
+					// any custom templates for this message type?
563
+					$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
564
+					foreach ($custom_templates as $cmtpgID => $cmtpg) {
565
+						$select_values[ $cmtpgID ] = $cmtpg->name();
566
+						$default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
567
+					}
568
+				}
569
+				// if there is no $default_value then we set it as the global
570
+				$default_value = empty($default_value) ? $mtpgID : $default_value;
571
+				$edit_url_query_args = [
572
+					'page' => 'espresso_messages',
573
+					'action' => 'edit_message_template',
574
+					'id' => $default_value,
575
+					'evt_id' => $event_id
576
+				];
577
+				$edit_url = EEH_URL::add_query_args_and_nonce($edit_url_query_args, admin_url('admin.php'));
578
+				$create_url_query_args = [
579
+					'page' => 'espresso_messages',
580
+					'action' => 'add_new_message_template',
581
+					'GRP_ID' => $default_value
582
+				];
583
+				$mt_slug = $mtpg->message_type();
584
+				$create_url = EEH_URL::add_query_args_and_nonce($create_url_query_args, admin_url('admin.php'));
585
+				$st_args['mtpgID'] = $mtpgID;
586
+				$st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
587
+				$st_args['mt_slug'] = $mt_slug;
588
+				$st_args['messenger_slug'] = $this->name;
589
+				$st_args['status_code'] = $msg_type_status_map[ $mt_slug ] ?? '';
590
+				$st_args['selector'] = EEH_Form_Fields::select_input(
591
+					'event_message_templates_relation[' . $mtpgID . ']',
592
+					$select_values,
593
+					$default_value,
594
+					'data-messenger="' . $this->name . '" data-messagetype="' . $mt_slug . '"',
595
+					'message-template-selector'
596
+				);
597
+				// note that  message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates).
598
+				$st_args['create_button'] = $mtpg->get('MTP_is_override')
599
+					? ''
600
+					: '
601 601
                     <a data-messenger="' . $this->name . '"
602 602
                        data-messagetype="' . $mt_slug . '"
603 603
                        data-grpid="' . $default_value . '"
@@ -607,18 +607,18 @@  discard block
 block discarded – undo
607 607
                     >
608 608
                         ' . esc_html__('Create New Custom', 'event_espresso') . '
609 609
                     </a>';
610
-                $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can(
611
-                    'ee_edit_messages',
612
-                    'espresso_messages_add_new_message_template'
613
-                )
614
-                    ? $st_args['create_button']
615
-                    : '';
616
-                $st_args['edit_button']   = EE_Registry::instance()->CAP->current_user_can(
617
-                    'ee_edit_message',
618
-                    'espresso_messages_edit_message_template',
619
-                    $mtpgID
620
-                )
621
-                    ? '
610
+				$st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can(
611
+					'ee_edit_messages',
612
+					'espresso_messages_add_new_message_template'
613
+				)
614
+					? $st_args['create_button']
615
+					: '';
616
+				$st_args['edit_button']   = EE_Registry::instance()->CAP->current_user_can(
617
+					'ee_edit_message',
618
+					'espresso_messages_edit_message_template',
619
+					$mtpgID
620
+				)
621
+					? '
622 622
                     <a data-messagetype="' . $mt_slug . '"
623 623
                        data-grpid="' . $default_value . '"
624 624
                        target="_blank"
@@ -627,322 +627,322 @@  discard block
 block discarded – undo
627 627
                     >
628 628
                         ' . esc_html__('Edit', 'event_espresso') . '
629 629
                     </a>'
630
-                    : '';
631
-                $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true);
632
-            }
633
-        }
634
-
635
-        // if no selectors present then get out.
636
-        if (empty($selector_rows)) {
637
-            return '';
638
-        }
639
-
640
-        $template_args['selector_rows'] = $selector_rows;
641
-        return EEH_Template::display_template($template_wrapper_path, $template_args, true);
642
-    }
643
-
644
-
645
-
646
-
647
-
648
-
649
-    /**
650
-     * get_template_fields
651
-     *
652
-     * @access public
653
-     * @return array $this->_template_fields
654
-     */
655
-    public function get_template_fields()
656
-    {
657
-        $template_fields = apply_filters('FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this);
658
-        $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
659
-        return $template_fields;
660
-    }
661
-
662
-
663
-
664
-
665
-    /** SETUP METHODS **/
666
-    /**
667
-     * The following method doesn't NEED to be used by child classes but might be modified by the specific messenger
668
-     * @param string $item
669
-     * @param mixed $value
670
-     */
671
-    protected function _set_template_value($item, $value)
672
-    {
673
-        if (array_key_exists($item, $this->_template_fields)) {
674
-            $prop = '_' . $item;
675
-            $this->{$prop} = $value;
676
-        }
677
-    }
678
-
679
-    /**
680
-     * Sets up the message for sending.
681
-     *
682
-     * @param  EE_message $message the message object that contains details about the message.
683
-     * @param EE_message_type $message_type The message type object used in combination with this messenger to generate the provided message.
684
-     *
685
-     * @return bool Very important that all messengers return bool for successful send or not.  Error messages can be
686
-     *              added to EE_Error.
687
-     *              true = message sent successfully
688
-     *              false = message not sent but can be retried (i.e. the failure might be just due to communication issues at the time of send).
689
-     *              Throwing a SendMessageException means the message failed sending and cannot be retried.
690
-     *
691
-     * @throws SendMessageException
692
-     */
693
-    final public function send_message($message, EE_message_type $message_type)
694
-    {
695
-        try {
696
-            $this->_validate_and_setup($message);
697
-            $this->_incoming_message_type = $message_type;
698
-            $response = $this->_send_message();
699
-            if ($response instanceof WP_Error) {
700
-                EE_Error::add_error($response->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
701
-                $response = false;
702
-            }
703
-        } catch (\Exception $e) {
704
-            // convert to an instance of SendMessageException
705
-            throw new SendMessageException($e->getMessage());
706
-        }
707
-        return $response;
708
-    }
709
-
710
-
711
-
712
-    /**
713
-     * Sets up and returns message preview
714
-     * @param  EE_Message $message incoming message object
715
-     * @param EE_message_type $message_type This is whatever message type was used in combination with this messenger to generate the message.
716
-     * @param  bool   $send    true we will actually use the _send method (for test sends). FALSE we just return preview
717
-     * @return string          return the message html content
718
-     */
719
-    public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false)
720
-    {
721
-        $this->_validate_and_setup($message);
722
-
723
-        $this->_incoming_message_type = $message_type;
724
-
725
-        if ($send) {
726
-            // are we overriding any existing template fields?
727
-            $settings = apply_filters(
728
-                'FHEE__EE_messenger__get_preview__messenger_test_settings',
729
-                $this->get_existing_test_settings(),
730
-                $this,
731
-                $send,
732
-                $message,
733
-                $message_type
734
-            );
735
-            if (! empty($settings)) {
736
-                foreach ($settings as $field => $value) {
737
-                    $this->_set_template_value($field, $value);
738
-                }
739
-            }
740
-        }
741
-
742
-        // enqueue preview js so that any links/buttons on the page are disabled.
743
-        if (! $send) {
744
-            // the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
745
-            // it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
746
-            add_action('admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
747
-            add_action('wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
748
-            add_action('AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10);
749
-        }
750
-
751
-        return $send ? $this->_send_message() : $this->_preview();
752
-    }
753
-
754
-
755
-
756
-
757
-    /**
758
-     * Callback for enqueue_scripts so that we setup the preview script for all previews.
759
-     *
760
-     * @since 4.5.0
761
-     *
762
-     * @return void
763
-     */
764
-    public function add_preview_script()
765
-    {
766
-        // error message
767
-        EE_Registry::$i18n_js_strings['links_disabled'] = wp_strip_all_tags(
768
-            __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso')
769
-        );
770
-        wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true);
771
-        wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
772
-        wp_enqueue_script('ee-messages-preview-js');
773
-    }
774
-
775
-
776
-
777
-
778
-    /**
779
-     * simply validates the incoming message object and then sets up the properties for the messenger
780
-     * @param  EE_Message $message
781
-     * @throws EE_Error
782
-     */
783
-    protected function _validate_and_setup(EE_Message $message)
784
-    {
785
-        $template_pack = $message->get_template_pack();
786
-        $variation = $message->get_template_pack_variation();
787
-
788
-        // verify we have the required template pack value on the $message object.
789
-        if (! $template_pack instanceof EE_Messages_Template_Pack) {
790
-            throw new EE_Error(esc_html__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso'));
791
-        }
792
-
793
-        $this->_tmp_pack = $template_pack;
794
-
795
-        $this->_variation = $variation ? $variation : 'default';
796
-
797
-        $template_fields = $this->get_template_fields();
798
-
799
-        foreach ($template_fields as $template => $value) {
800
-            if ($template !== 'extra') {
801
-                $column_value = $message->get_field_or_extra_meta('MSG_' . $template);
802
-                $message_template_value = $column_value ? $column_value : null;
803
-                $this->_set_template_value($template, $message_template_value);
804
-            }
805
-        }
806
-    }
807
-
808
-
809
-
810
-    /**
811
-     * Utility method for child classes to get the contents of a template file and return
812
-     *
813
-     * We're assuming the child messenger class has already setup template args!
814
-     * @param  bool $preview if true we use the preview wrapper otherwise we use main wrapper.
815
-     * @return string
816
-     * @throws \EE_Error
817
-     */
818
-    protected function _get_main_template($preview = false)
819
-    {
820
-        $type = $preview ? 'preview' : 'main';
821
-
822
-        $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
823
-
824
-        // check file exists and is readable
825
-        if (!is_readable($wrapper_template)) {
826
-            throw new EE_Error(sprintf(esc_html__('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template));
827
-        }
828
-
829
-        // add message type to template args
830
-        $this->_template_args['message_type'] = $this->_incoming_message_type;
831
-
832
-        return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
833
-    }
834
-
835
-
836
-
837
-    /**
838
-     * set the _test_settings_fields property
839
-     *
840
-     * @access protected
841
-     * @return void
842
-     */
843
-    protected function _set_test_settings_fields()
844
-    {
845
-        $this->_test_settings_fields = array();
846
-    }
847
-
848
-
849
-
850
-    /**
851
-     * return the _test_settings_fields property
852
-     * @return array
853
-     */
854
-    public function get_test_settings_fields()
855
-    {
856
-        return $this->_test_settings_fields;
857
-    }
858
-
859
-
860
-
861
-
862
-    /**
863
-     * This just returns any existing test settings that might be saved in the database
864
-     *
865
-     * @access public
866
-     * @return array
867
-     */
868
-    public function get_existing_test_settings()
869
-    {
870
-        /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
871
-        $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
872
-        $settings = $Message_Resource_Manager->get_active_messengers_option();
873
-        return isset($settings[ $this->name ]['test_settings']) ? $settings[ $this->name ]['test_settings'] : array();
874
-    }
875
-
876
-
877
-
878
-    /**
879
-     * All this does is set the existing test settings (in the db) for the messenger
880
-     *
881
-     * @access public
882
-     * @param $settings
883
-     * @return bool success/fail
884
-     */
885
-    public function set_existing_test_settings($settings)
886
-    {
887
-        /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
888
-        $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
889
-        $existing = $Message_Resource_Manager->get_active_messengers_option();
890
-        $existing[ $this->name ]['test_settings'] = $settings;
891
-        return $Message_Resource_Manager->update_active_messengers_option($existing);
892
-    }
893
-
894
-
895
-
896
-    /**
897
-     * This just returns the field label for a given field setup in the _template_fields property.
898
-     *
899
-     * @since   4.3.0
900
-     *
901
-     * @param string $field The field to retrieve the label for
902
-     * @return string             The label
903
-     */
904
-    public function get_field_label($field)
905
-    {
906
-        // first let's see if the field requests is in the top level array.
907
-        if (isset($this->_template_fields[ $field ]) && !empty($this->_template_fields[ $field ]['label'])) {
908
-            return $this->_template[ $field ]['label'];
909
-        }
910
-
911
-        // nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
912
-        if (isset($this->_template_fields['extra']) && !empty($this->_template_fields['extra'][ $field ]) && !empty($this->_template_fields['extra'][ $field ]['main']['label'])) {
913
-            return $this->_template_fields['extra'][ $field ]['main']['label'];
914
-        }
915
-
916
-        // now it's possible this field may just be existing in any of the extra array items.
917
-        if (!empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
918
-            foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
919
-                if (!is_array($subfields)) {
920
-                    continue;
921
-                }
922
-                if (isset($subfields[ $field ]) && !empty($subfields[ $field ]['label'])) {
923
-                    return $subfields[ $field ]['label'];
924
-                }
925
-            }
926
-        }
927
-
928
-        // if we made it here then there's no label set so let's just return the $field.
929
-        return $field;
930
-    }
931
-
932
-
933
-
934
-
935
-    /**
936
-     * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger is a different messenger.  Child messengers can set hooks for the sending messenger to callback on if necessary (i.e. swap out css files or something else).
937
-     *
938
-     * @since 4.5.0
939
-     *
940
-     * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed.
941
-     *
942
-     * @return void
943
-     */
944
-    public function do_secondary_messenger_hooks($sending_messenger_name)
945
-    {
946
-        return;
947
-    }
630
+					: '';
631
+				$selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true);
632
+			}
633
+		}
634
+
635
+		// if no selectors present then get out.
636
+		if (empty($selector_rows)) {
637
+			return '';
638
+		}
639
+
640
+		$template_args['selector_rows'] = $selector_rows;
641
+		return EEH_Template::display_template($template_wrapper_path, $template_args, true);
642
+	}
643
+
644
+
645
+
646
+
647
+
648
+
649
+	/**
650
+	 * get_template_fields
651
+	 *
652
+	 * @access public
653
+	 * @return array $this->_template_fields
654
+	 */
655
+	public function get_template_fields()
656
+	{
657
+		$template_fields = apply_filters('FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this);
658
+		$template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
659
+		return $template_fields;
660
+	}
661
+
662
+
663
+
664
+
665
+	/** SETUP METHODS **/
666
+	/**
667
+	 * The following method doesn't NEED to be used by child classes but might be modified by the specific messenger
668
+	 * @param string $item
669
+	 * @param mixed $value
670
+	 */
671
+	protected function _set_template_value($item, $value)
672
+	{
673
+		if (array_key_exists($item, $this->_template_fields)) {
674
+			$prop = '_' . $item;
675
+			$this->{$prop} = $value;
676
+		}
677
+	}
678
+
679
+	/**
680
+	 * Sets up the message for sending.
681
+	 *
682
+	 * @param  EE_message $message the message object that contains details about the message.
683
+	 * @param EE_message_type $message_type The message type object used in combination with this messenger to generate the provided message.
684
+	 *
685
+	 * @return bool Very important that all messengers return bool for successful send or not.  Error messages can be
686
+	 *              added to EE_Error.
687
+	 *              true = message sent successfully
688
+	 *              false = message not sent but can be retried (i.e. the failure might be just due to communication issues at the time of send).
689
+	 *              Throwing a SendMessageException means the message failed sending and cannot be retried.
690
+	 *
691
+	 * @throws SendMessageException
692
+	 */
693
+	final public function send_message($message, EE_message_type $message_type)
694
+	{
695
+		try {
696
+			$this->_validate_and_setup($message);
697
+			$this->_incoming_message_type = $message_type;
698
+			$response = $this->_send_message();
699
+			if ($response instanceof WP_Error) {
700
+				EE_Error::add_error($response->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
701
+				$response = false;
702
+			}
703
+		} catch (\Exception $e) {
704
+			// convert to an instance of SendMessageException
705
+			throw new SendMessageException($e->getMessage());
706
+		}
707
+		return $response;
708
+	}
709
+
710
+
711
+
712
+	/**
713
+	 * Sets up and returns message preview
714
+	 * @param  EE_Message $message incoming message object
715
+	 * @param EE_message_type $message_type This is whatever message type was used in combination with this messenger to generate the message.
716
+	 * @param  bool   $send    true we will actually use the _send method (for test sends). FALSE we just return preview
717
+	 * @return string          return the message html content
718
+	 */
719
+	public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false)
720
+	{
721
+		$this->_validate_and_setup($message);
722
+
723
+		$this->_incoming_message_type = $message_type;
724
+
725
+		if ($send) {
726
+			// are we overriding any existing template fields?
727
+			$settings = apply_filters(
728
+				'FHEE__EE_messenger__get_preview__messenger_test_settings',
729
+				$this->get_existing_test_settings(),
730
+				$this,
731
+				$send,
732
+				$message,
733
+				$message_type
734
+			);
735
+			if (! empty($settings)) {
736
+				foreach ($settings as $field => $value) {
737
+					$this->_set_template_value($field, $value);
738
+				}
739
+			}
740
+		}
741
+
742
+		// enqueue preview js so that any links/buttons on the page are disabled.
743
+		if (! $send) {
744
+			// the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
745
+			// it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
746
+			add_action('admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
747
+			add_action('wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
748
+			add_action('AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10);
749
+		}
750
+
751
+		return $send ? $this->_send_message() : $this->_preview();
752
+	}
753
+
754
+
755
+
756
+
757
+	/**
758
+	 * Callback for enqueue_scripts so that we setup the preview script for all previews.
759
+	 *
760
+	 * @since 4.5.0
761
+	 *
762
+	 * @return void
763
+	 */
764
+	public function add_preview_script()
765
+	{
766
+		// error message
767
+		EE_Registry::$i18n_js_strings['links_disabled'] = wp_strip_all_tags(
768
+			__('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso')
769
+		);
770
+		wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true);
771
+		wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
772
+		wp_enqueue_script('ee-messages-preview-js');
773
+	}
774
+
775
+
776
+
777
+
778
+	/**
779
+	 * simply validates the incoming message object and then sets up the properties for the messenger
780
+	 * @param  EE_Message $message
781
+	 * @throws EE_Error
782
+	 */
783
+	protected function _validate_and_setup(EE_Message $message)
784
+	{
785
+		$template_pack = $message->get_template_pack();
786
+		$variation = $message->get_template_pack_variation();
787
+
788
+		// verify we have the required template pack value on the $message object.
789
+		if (! $template_pack instanceof EE_Messages_Template_Pack) {
790
+			throw new EE_Error(esc_html__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso'));
791
+		}
792
+
793
+		$this->_tmp_pack = $template_pack;
794
+
795
+		$this->_variation = $variation ? $variation : 'default';
796
+
797
+		$template_fields = $this->get_template_fields();
798
+
799
+		foreach ($template_fields as $template => $value) {
800
+			if ($template !== 'extra') {
801
+				$column_value = $message->get_field_or_extra_meta('MSG_' . $template);
802
+				$message_template_value = $column_value ? $column_value : null;
803
+				$this->_set_template_value($template, $message_template_value);
804
+			}
805
+		}
806
+	}
807
+
808
+
809
+
810
+	/**
811
+	 * Utility method for child classes to get the contents of a template file and return
812
+	 *
813
+	 * We're assuming the child messenger class has already setup template args!
814
+	 * @param  bool $preview if true we use the preview wrapper otherwise we use main wrapper.
815
+	 * @return string
816
+	 * @throws \EE_Error
817
+	 */
818
+	protected function _get_main_template($preview = false)
819
+	{
820
+		$type = $preview ? 'preview' : 'main';
821
+
822
+		$wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
823
+
824
+		// check file exists and is readable
825
+		if (!is_readable($wrapper_template)) {
826
+			throw new EE_Error(sprintf(esc_html__('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template));
827
+		}
828
+
829
+		// add message type to template args
830
+		$this->_template_args['message_type'] = $this->_incoming_message_type;
831
+
832
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
833
+	}
834
+
835
+
836
+
837
+	/**
838
+	 * set the _test_settings_fields property
839
+	 *
840
+	 * @access protected
841
+	 * @return void
842
+	 */
843
+	protected function _set_test_settings_fields()
844
+	{
845
+		$this->_test_settings_fields = array();
846
+	}
847
+
848
+
849
+
850
+	/**
851
+	 * return the _test_settings_fields property
852
+	 * @return array
853
+	 */
854
+	public function get_test_settings_fields()
855
+	{
856
+		return $this->_test_settings_fields;
857
+	}
858
+
859
+
860
+
861
+
862
+	/**
863
+	 * This just returns any existing test settings that might be saved in the database
864
+	 *
865
+	 * @access public
866
+	 * @return array
867
+	 */
868
+	public function get_existing_test_settings()
869
+	{
870
+		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
871
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
872
+		$settings = $Message_Resource_Manager->get_active_messengers_option();
873
+		return isset($settings[ $this->name ]['test_settings']) ? $settings[ $this->name ]['test_settings'] : array();
874
+	}
875
+
876
+
877
+
878
+	/**
879
+	 * All this does is set the existing test settings (in the db) for the messenger
880
+	 *
881
+	 * @access public
882
+	 * @param $settings
883
+	 * @return bool success/fail
884
+	 */
885
+	public function set_existing_test_settings($settings)
886
+	{
887
+		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
888
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
889
+		$existing = $Message_Resource_Manager->get_active_messengers_option();
890
+		$existing[ $this->name ]['test_settings'] = $settings;
891
+		return $Message_Resource_Manager->update_active_messengers_option($existing);
892
+	}
893
+
894
+
895
+
896
+	/**
897
+	 * This just returns the field label for a given field setup in the _template_fields property.
898
+	 *
899
+	 * @since   4.3.0
900
+	 *
901
+	 * @param string $field The field to retrieve the label for
902
+	 * @return string             The label
903
+	 */
904
+	public function get_field_label($field)
905
+	{
906
+		// first let's see if the field requests is in the top level array.
907
+		if (isset($this->_template_fields[ $field ]) && !empty($this->_template_fields[ $field ]['label'])) {
908
+			return $this->_template[ $field ]['label'];
909
+		}
910
+
911
+		// nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
912
+		if (isset($this->_template_fields['extra']) && !empty($this->_template_fields['extra'][ $field ]) && !empty($this->_template_fields['extra'][ $field ]['main']['label'])) {
913
+			return $this->_template_fields['extra'][ $field ]['main']['label'];
914
+		}
915
+
916
+		// now it's possible this field may just be existing in any of the extra array items.
917
+		if (!empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
918
+			foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
919
+				if (!is_array($subfields)) {
920
+					continue;
921
+				}
922
+				if (isset($subfields[ $field ]) && !empty($subfields[ $field ]['label'])) {
923
+					return $subfields[ $field ]['label'];
924
+				}
925
+			}
926
+		}
927
+
928
+		// if we made it here then there's no label set so let's just return the $field.
929
+		return $field;
930
+	}
931
+
932
+
933
+
934
+
935
+	/**
936
+	 * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger is a different messenger.  Child messengers can set hooks for the sending messenger to callback on if necessary (i.e. swap out css files or something else).
937
+	 *
938
+	 * @since 4.5.0
939
+	 *
940
+	 * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed.
941
+	 *
942
+	 * @return void
943
+	 */
944
+	public function do_secondary_messenger_hooks($sending_messenger_name)
945
+	{
946
+		return;
947
+	}
948 948
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
         $class = get_class($this);
416 416
 
417 417
         // messenger specific filter
418
-        $default_types = apply_filters('FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this);
418
+        $default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this);
419 419
 
420 420
         // all messengers filter
421 421
         $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 
439 439
         // messenger specific filter
440 440
         // messenger specific filter
441
-        $valid_types = apply_filters('FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
441
+        $valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
442 442
 
443 443
         // all messengers filter
444 444
         $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
     {
474 474
         $class = get_class($this);
475 475
 
476
-        $config = apply_filters('FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this);
476
+        $config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this);
477 477
         $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
478 478
         return $config;
479 479
     }
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
         // we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event.
513 513
         $event_id = isset($extra['event']) ? $extra['event'] : null;
514 514
 
515
-        $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
516
-        $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
515
+        $template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
516
+        $template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php';
517 517
 
518 518
         // array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
519 519
         $global_templates = EEM_Message_Template_Group::instance()->get_all(
520
-            array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) )
520
+            array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true))
521 521
         );
522 522
         $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event(
523 523
             $event_id,
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
                 'MTP_is_active' => true
527 527
             )
528 528
         );
529
-        $templates_for_event = !empty($templates_for_event) ? $templates_for_event : array();
529
+        $templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array();
530 530
 
531 531
         $msg_type_status_map = [
532 532
             'payment' => 'PAP',
@@ -547,22 +547,22 @@  discard block
 block discarded – undo
547 547
             if ($mtpg instanceof EE_Message_Template_Group) {
548 548
                 // verify this message type is supposed to show on this page
549 549
                 $mtp_obj = $mtpg->message_type_obj();
550
-                if (! $mtp_obj instanceof EE_message_type) {
550
+                if ( ! $mtp_obj instanceof EE_message_type) {
551 551
                     continue;
552 552
                 }
553 553
                 $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
554
-                if (! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
554
+                if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
555 555
                     continue;
556 556
                 }
557 557
                 $select_values = array();
558
-                $select_values[ $mtpgID ] = esc_html__('Global', 'event_espresso');
558
+                $select_values[$mtpgID] = esc_html__('Global', 'event_espresso');
559 559
                 $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null;
560 560
                 // if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override.
561
-                if (! $mtpg->get('MTP_is_override')) {
561
+                if ( ! $mtpg->get('MTP_is_override')) {
562 562
                     // any custom templates for this message type?
563 563
                     $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
564 564
                     foreach ($custom_templates as $cmtpgID => $cmtpg) {
565
-                        $select_values[ $cmtpgID ] = $cmtpg->name();
565
+                        $select_values[$cmtpgID] = $cmtpg->name();
566 566
                         $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
567 567
                     }
568 568
                 }
@@ -586,26 +586,26 @@  discard block
 block discarded – undo
586 586
                 $st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
587 587
                 $st_args['mt_slug'] = $mt_slug;
588 588
                 $st_args['messenger_slug'] = $this->name;
589
-                $st_args['status_code'] = $msg_type_status_map[ $mt_slug ] ?? '';
589
+                $st_args['status_code'] = $msg_type_status_map[$mt_slug] ?? '';
590 590
                 $st_args['selector'] = EEH_Form_Fields::select_input(
591
-                    'event_message_templates_relation[' . $mtpgID . ']',
591
+                    'event_message_templates_relation['.$mtpgID.']',
592 592
                     $select_values,
593 593
                     $default_value,
594
-                    'data-messenger="' . $this->name . '" data-messagetype="' . $mt_slug . '"',
594
+                    'data-messenger="'.$this->name.'" data-messagetype="'.$mt_slug.'"',
595 595
                     'message-template-selector'
596 596
                 );
597 597
                 // note that  message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates).
598 598
                 $st_args['create_button'] = $mtpg->get('MTP_is_override')
599 599
                     ? ''
600 600
                     : '
601
-                    <a data-messenger="' . $this->name . '"
602
-                       data-messagetype="' . $mt_slug . '"
603
-                       data-grpid="' . $default_value . '"
601
+                    <a data-messenger="' . $this->name.'"
602
+                       data-messagetype="' . $mt_slug.'"
603
+                       data-grpid="' . $default_value.'"
604 604
                        target="_blank"
605
-                       href="' . $create_url . '"
605
+                       href="' . $create_url.'"
606 606
                        class="button button--secondary button--tiny create-mtpg-button"
607 607
                     >
608
-                        ' . esc_html__('Create New Custom', 'event_espresso') . '
608
+                        ' . esc_html__('Create New Custom', 'event_espresso').'
609 609
                     </a>';
610 610
                 $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can(
611 611
                     'ee_edit_messages',
@@ -613,19 +613,19 @@  discard block
 block discarded – undo
613 613
                 )
614 614
                     ? $st_args['create_button']
615 615
                     : '';
616
-                $st_args['edit_button']   = EE_Registry::instance()->CAP->current_user_can(
616
+                $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can(
617 617
                     'ee_edit_message',
618 618
                     'espresso_messages_edit_message_template',
619 619
                     $mtpgID
620 620
                 )
621 621
                     ? '
622
-                    <a data-messagetype="' . $mt_slug . '"
623
-                       data-grpid="' . $default_value . '"
622
+                    <a data-messagetype="' . $mt_slug.'"
623
+                       data-grpid="' . $default_value.'"
624 624
                        target="_blank"
625
-                       href="' . $edit_url . '"
625
+                       href="' . $edit_url.'"
626 626
                        class="button button--secondary button--tiny edit-mtpg-button"
627 627
                     >
628
-                        ' . esc_html__('Edit', 'event_espresso') . '
628
+                        ' . esc_html__('Edit', 'event_espresso').'
629 629
                     </a>'
630 630
                     : '';
631 631
                 $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true);
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
      */
655 655
     public function get_template_fields()
656 656
     {
657
-        $template_fields = apply_filters('FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this);
657
+        $template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this);
658 658
         $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
659 659
         return $template_fields;
660 660
     }
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
     protected function _set_template_value($item, $value)
672 672
     {
673 673
         if (array_key_exists($item, $this->_template_fields)) {
674
-            $prop = '_' . $item;
674
+            $prop = '_'.$item;
675 675
             $this->{$prop} = $value;
676 676
         }
677 677
     }
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
                 $message,
733 733
                 $message_type
734 734
             );
735
-            if (! empty($settings)) {
735
+            if ( ! empty($settings)) {
736 736
                 foreach ($settings as $field => $value) {
737 737
                     $this->_set_template_value($field, $value);
738 738
                 }
@@ -740,12 +740,12 @@  discard block
 block discarded – undo
740 740
         }
741 741
 
742 742
         // enqueue preview js so that any links/buttons on the page are disabled.
743
-        if (! $send) {
743
+        if ( ! $send) {
744 744
             // the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
745 745
             // it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
746
-            add_action('admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
747
-            add_action('wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
748
-            add_action('AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10);
746
+            add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10);
747
+            add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10);
748
+            add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10);
749 749
         }
750 750
 
751 751
         return $send ? $this->_send_message() : $this->_preview();
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
         EE_Registry::$i18n_js_strings['links_disabled'] = wp_strip_all_tags(
768 768
             __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso')
769 769
         );
770
-        wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true);
770
+        wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
771 771
         wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
772 772
         wp_enqueue_script('ee-messages-preview-js');
773 773
     }
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
         $variation = $message->get_template_pack_variation();
787 787
 
788 788
         // verify we have the required template pack value on the $message object.
789
-        if (! $template_pack instanceof EE_Messages_Template_Pack) {
789
+        if ( ! $template_pack instanceof EE_Messages_Template_Pack) {
790 790
             throw new EE_Error(esc_html__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso'));
791 791
         }
792 792
 
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 
799 799
         foreach ($template_fields as $template => $value) {
800 800
             if ($template !== 'extra') {
801
-                $column_value = $message->get_field_or_extra_meta('MSG_' . $template);
801
+                $column_value = $message->get_field_or_extra_meta('MSG_'.$template);
802 802
                 $message_template_value = $column_value ? $column_value : null;
803 803
                 $this->_set_template_value($template, $message_template_value);
804 804
             }
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
         $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
823 823
 
824 824
         // check file exists and is readable
825
-        if (!is_readable($wrapper_template)) {
825
+        if ( ! is_readable($wrapper_template)) {
826 826
             throw new EE_Error(sprintf(esc_html__('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template));
827 827
         }
828 828
 
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
         /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
871 871
         $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
872 872
         $settings = $Message_Resource_Manager->get_active_messengers_option();
873
-        return isset($settings[ $this->name ]['test_settings']) ? $settings[ $this->name ]['test_settings'] : array();
873
+        return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array();
874 874
     }
875 875
 
876 876
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
         /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
888 888
         $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
889 889
         $existing = $Message_Resource_Manager->get_active_messengers_option();
890
-        $existing[ $this->name ]['test_settings'] = $settings;
890
+        $existing[$this->name]['test_settings'] = $settings;
891 891
         return $Message_Resource_Manager->update_active_messengers_option($existing);
892 892
     }
893 893
 
@@ -904,23 +904,23 @@  discard block
 block discarded – undo
904 904
     public function get_field_label($field)
905 905
     {
906 906
         // first let's see if the field requests is in the top level array.
907
-        if (isset($this->_template_fields[ $field ]) && !empty($this->_template_fields[ $field ]['label'])) {
908
-            return $this->_template[ $field ]['label'];
907
+        if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label'])) {
908
+            return $this->_template[$field]['label'];
909 909
         }
910 910
 
911 911
         // nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
912
-        if (isset($this->_template_fields['extra']) && !empty($this->_template_fields['extra'][ $field ]) && !empty($this->_template_fields['extra'][ $field ]['main']['label'])) {
913
-            return $this->_template_fields['extra'][ $field ]['main']['label'];
912
+        if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label'])) {
913
+            return $this->_template_fields['extra'][$field]['main']['label'];
914 914
         }
915 915
 
916 916
         // now it's possible this field may just be existing in any of the extra array items.
917
-        if (!empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
917
+        if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
918 918
             foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
919
-                if (!is_array($subfields)) {
919
+                if ( ! is_array($subfields)) {
920 920
                     continue;
921 921
                 }
922
-                if (isset($subfields[ $field ]) && !empty($subfields[ $field ]['label'])) {
923
-                    return $subfields[ $field ]['label'];
922
+                if (isset($subfields[$field]) && ! empty($subfields[$field]['label'])) {
923
+                    return $subfields[$field]['label'];
924 924
                 }
925 925
             }
926 926
         }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4180 added lines, -4180 removed lines patch added patch discarded remove patch
@@ -21,4264 +21,4264 @@
 block discarded – undo
21 21
  */
22 22
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
23 23
 {
24
-    /**
25
-     * @var EE_Admin_Config
26
-     */
27
-    protected $admin_config;
24
+	/**
25
+	 * @var EE_Admin_Config
26
+	 */
27
+	protected $admin_config;
28 28
 
29
-    /**
30
-     * @var LoaderInterface
31
-     */
32
-    protected $loader;
29
+	/**
30
+	 * @var LoaderInterface
31
+	 */
32
+	protected $loader;
33 33
 
34
-    /**
35
-     * @var RequestInterface
36
-     */
37
-    protected $request;
34
+	/**
35
+	 * @var RequestInterface
36
+	 */
37
+	protected $request;
38 38
 
39
-    // set in _init_page_props()
40
-    public $page_slug;
39
+	// set in _init_page_props()
40
+	public $page_slug;
41 41
 
42
-    public $page_label;
42
+	public $page_label;
43 43
 
44
-    public $page_folder;
44
+	public $page_folder;
45 45
 
46
-    // set in define_page_props()
47
-    protected $_admin_base_url;
46
+	// set in define_page_props()
47
+	protected $_admin_base_url;
48 48
 
49
-    protected $_admin_base_path;
49
+	protected $_admin_base_path;
50 50
 
51
-    protected $_admin_page_title;
51
+	protected $_admin_page_title;
52 52
 
53
-    protected $_labels;
53
+	protected $_labels;
54 54
 
55 55
 
56
-    // set early within EE_Admin_Init
57
-    protected $_wp_page_slug;
56
+	// set early within EE_Admin_Init
57
+	protected $_wp_page_slug;
58 58
 
59
-    // nav tabs
60
-    protected $_nav_tabs;
59
+	// nav tabs
60
+	protected $_nav_tabs;
61 61
 
62
-    protected $_default_nav_tab_name;
62
+	protected $_default_nav_tab_name;
63 63
 
64 64
 
65
-    // template variables (used by templates)
66
-    protected $_template_path;
65
+	// template variables (used by templates)
66
+	protected $_template_path;
67 67
 
68
-    protected $_column_template_path;
68
+	protected $_column_template_path;
69 69
 
70
-    /**
71
-     * @var array $_template_args
72
-     */
73
-    protected $_template_args = [];
70
+	/**
71
+	 * @var array $_template_args
72
+	 */
73
+	protected $_template_args = [];
74 74
 
75
-    /**
76
-     * this will hold the list table object for a given view.
77
-     *
78
-     * @var EE_Admin_List_Table $_list_table_object
79
-     */
80
-    protected $_list_table_object;
75
+	/**
76
+	 * this will hold the list table object for a given view.
77
+	 *
78
+	 * @var EE_Admin_List_Table $_list_table_object
79
+	 */
80
+	protected $_list_table_object;
81 81
 
82
-    // boolean
83
-    protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
82
+	// boolean
83
+	protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
84 84
 
85
-    protected $_routing;
85
+	protected $_routing;
86 86
 
87
-    // list table args
88
-    protected $_view;
87
+	// list table args
88
+	protected $_view;
89 89
 
90
-    protected $_views;
90
+	protected $_views;
91 91
 
92 92
 
93
-    // action => method pairs used for routing incoming requests
94
-    protected $_page_routes;
93
+	// action => method pairs used for routing incoming requests
94
+	protected $_page_routes;
95 95
 
96
-    /**
97
-     * @var array $_page_config
98
-     */
99
-    protected $_page_config;
96
+	/**
97
+	 * @var array $_page_config
98
+	 */
99
+	protected $_page_config;
100 100
 
101
-    /**
102
-     * the current page route and route config
103
-     *
104
-     * @var string $_route
105
-     */
106
-    protected $_route;
101
+	/**
102
+	 * the current page route and route config
103
+	 *
104
+	 * @var string $_route
105
+	 */
106
+	protected $_route;
107 107
 
108
-    /**
109
-     * @var string $_cpt_route
110
-     */
111
-    protected $_cpt_route;
108
+	/**
109
+	 * @var string $_cpt_route
110
+	 */
111
+	protected $_cpt_route;
112 112
 
113
-    /**
114
-     * @var array $_route_config
115
-     */
116
-    protected $_route_config;
113
+	/**
114
+	 * @var array $_route_config
115
+	 */
116
+	protected $_route_config;
117 117
 
118
-    /**
119
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
120
-     * actions.
121
-     *
122
-     * @since 4.6.x
123
-     * @var array.
124
-     */
125
-    protected $_default_route_query_args;
118
+	/**
119
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
120
+	 * actions.
121
+	 *
122
+	 * @since 4.6.x
123
+	 * @var array.
124
+	 */
125
+	protected $_default_route_query_args;
126 126
 
127
-    // set via request page and action args.
128
-    protected $_current_page;
127
+	// set via request page and action args.
128
+	protected $_current_page;
129 129
 
130
-    protected $_current_view;
130
+	protected $_current_view;
131 131
 
132
-    protected $_current_page_view_url;
132
+	protected $_current_page_view_url;
133 133
 
134
-    /**
135
-     * unprocessed value for the 'action' request param (default '')
136
-     *
137
-     * @var string
138
-     */
139
-    protected $raw_req_action = '';
134
+	/**
135
+	 * unprocessed value for the 'action' request param (default '')
136
+	 *
137
+	 * @var string
138
+	 */
139
+	protected $raw_req_action = '';
140 140
 
141
-    /**
142
-     * unprocessed value for the 'page' request param (default '')
143
-     *
144
-     * @var string
145
-     */
146
-    protected $raw_req_page = '';
147
-
148
-    /**
149
-     * sanitized request action (and nonce)
150
-     *
151
-     * @var string
152
-     */
153
-    protected $_req_action = '';
154
-
155
-    /**
156
-     * sanitized request action nonce
157
-     *
158
-     * @var string
159
-     */
160
-    protected $_req_nonce = '';
161
-
162
-    /**
163
-     * @var string
164
-     */
165
-    protected $_search_btn_label = '';
166
-
167
-    /**
168
-     * @var string
169
-     */
170
-    protected $_search_box_callback = '';
171
-
172
-    /**
173
-     * @var WP_Screen
174
-     */
175
-    protected $_current_screen;
176
-
177
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
178
-    protected $_hook_obj;
179
-
180
-    // for holding incoming request data
181
-    protected $_req_data = [];
182
-
183
-    // yes / no array for admin form fields
184
-    protected $_yes_no_values = [];
185
-
186
-    // some default things shared by all child classes
187
-    protected $_default_espresso_metaboxes = [
188
-        '_espresso_news_post_box',
189
-        '_espresso_links_post_box',
190
-        '_espresso_ratings_request',
191
-        '_espresso_sponsors_post_box',
192
-    ];
193
-
194
-    /**
195
-     * @var EE_Registry
196
-     */
197
-    protected $EE;
198
-
199
-
200
-    /**
201
-     * This is just a property that flags whether the given route is a caffeinated route or not.
202
-     *
203
-     * @var boolean
204
-     */
205
-    protected $_is_caf = false;
206
-
207
-    /**
208
-     * whether or not initializePage() has run
209
-     *
210
-     * @var boolean
211
-     */
212
-    protected $initialized = false;
213
-
214
-    /**
215
-     * @var FeatureFlags
216
-     */
217
-    protected $feature;
218
-
219
-
220
-    /**
221
-     * @var string
222
-     */
223
-    protected $class_name;
224
-
225
-    /**
226
-     * if the current class is an admin page extension, like: Extend_Events_Admin_Page,
227
-     * then this would be the parent classname: Events_Admin_Page
228
-     *
229
-     * @var string
230
-     */
231
-    protected $base_class_name;
232
-
233
-
234
-    /**
235
-     * @Constructor
236
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
237
-     * @throws InvalidArgumentException
238
-     * @throws InvalidDataTypeException
239
-     * @throws InvalidInterfaceException
240
-     * @throws ReflectionException
241
-     */
242
-    public function __construct($routing = true)
243
-    {
244
-        $this->loader = LoaderFactory::getLoader();
245
-        $this->admin_config = $this->loader->getShared('EE_Admin_Config');
246
-        $this->feature = $this->loader->getShared(FeatureFlags::class);
247
-        $this->request = $this->loader->getShared(RequestInterface::class);
248
-        // routing enabled?
249
-        $this->_routing = $routing;
250
-
251
-        $this->class_name = get_class($this);
252
-        $this->base_class_name = strpos($this->class_name, 'Extend_') === 0
253
-            ? str_replace('Extend_', '', $this->class_name)
254
-            : '';
255
-
256
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
257
-            $this->_is_caf = true;
258
-        }
259
-        $this->_yes_no_values = [
260
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
261
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
262
-        ];
263
-        // set the _req_data property.
264
-        $this->_req_data = $this->request->requestParams();
265
-    }
266
-
267
-
268
-    /**
269
-     * @return EE_Admin_Config
270
-     */
271
-    public function adminConfig(): EE_Admin_Config
272
-    {
273
-        return $this->admin_config;
274
-    }
275
-
276
-
277
-    /**
278
-     * @return FeatureFlags
279
-     */
280
-    public function feature(): FeatureFlags
281
-    {
282
-        return $this->feature;
283
-    }
284
-
285
-
286
-    /**
287
-     * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
288
-     * for child classes that needed to set properties prior to these methods getting called,
289
-     * but also needed the parent class to have its construction completed as well.
290
-     * Bottom line is that constructors should ONLY be used for setting initial properties
291
-     * and any complex initialization logic should only run after instantiation is complete.
292
-     *
293
-     * This method gets called immediately after construction from within
294
-     *      EE_Admin_Page_Init::_initialize_admin_page()
295
-     *
296
-     * @throws EE_Error
297
-     * @throws InvalidArgumentException
298
-     * @throws InvalidDataTypeException
299
-     * @throws InvalidInterfaceException
300
-     * @throws ReflectionException
301
-     * @since $VID:$
302
-     */
303
-    public function initializePage()
304
-    {
305
-        if ($this->initialized) {
306
-            return;
307
-        }
308
-        // set initial page props (child method)
309
-        $this->_init_page_props();
310
-        // set global defaults
311
-        $this->_set_defaults();
312
-        // set early because incoming requests could be ajax related and we need to register those hooks.
313
-        $this->_global_ajax_hooks();
314
-        $this->_ajax_hooks();
315
-        // other_page_hooks have to be early too.
316
-        $this->_do_other_page_hooks();
317
-        // set up page dependencies
318
-        $this->_before_page_setup();
319
-        $this->_page_setup();
320
-        $this->initialized = true;
321
-    }
322
-
323
-
324
-    /**
325
-     * _init_page_props
326
-     * Child classes use to set at least the following properties:
327
-     * $page_slug.
328
-     * $page_label.
329
-     *
330
-     * @abstract
331
-     * @return void
332
-     */
333
-    abstract protected function _init_page_props();
334
-
335
-
336
-    /**
337
-     * _ajax_hooks
338
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
339
-     * Note: within the ajax callback methods.
340
-     *
341
-     * @abstract
342
-     * @return void
343
-     */
344
-    abstract protected function _ajax_hooks();
345
-
346
-
347
-    /**
348
-     * _define_page_props
349
-     * child classes define page properties in here.  Must include at least:
350
-     * $_admin_base_url = base_url for all admin pages
351
-     * $_admin_page_title = default admin_page_title for admin pages
352
-     * $_labels = array of default labels for various automatically generated elements:
353
-     *    array(
354
-     *        'buttons' => array(
355
-     *            'add' => esc_html__('label for add new button'),
356
-     *            'edit' => esc_html__('label for edit button'),
357
-     *            'delete' => esc_html__('label for delete button')
358
-     *            )
359
-     *        )
360
-     *
361
-     * @abstract
362
-     * @return void
363
-     */
364
-    abstract protected function _define_page_props();
365
-
366
-
367
-    /**
368
-     * _set_page_routes
369
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
370
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
371
-     * have a 'default' route. Here's the format
372
-     * $this->_page_routes = array(
373
-     *        'default' => array(
374
-     *            'func' => '_default_method_handling_route',
375
-     *            'args' => array('array','of','args'),
376
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
377
-     *            ajax request, backend processing)
378
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
379
-     *            headers route after.  The string you enter here should match the defined route reference for a
380
-     *            headers sent route.
381
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
382
-     *            this route.
383
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
384
-     *            checks).
385
-     *        ),
386
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
387
-     *        handling method.
388
-     *        )
389
-     * )
390
-     *
391
-     * @abstract
392
-     * @return void
393
-     */
394
-    abstract protected function _set_page_routes();
395
-
396
-
397
-    /**
398
-     * _set_page_config
399
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
400
-     * array corresponds to the page_route for the loaded page. Format:
401
-     * $this->_page_config = array(
402
-     *        'default' => array(
403
-     *            'labels' => array(
404
-     *                'buttons' => array(
405
-     *                    'add' => esc_html__('label for adding item'),
406
-     *                    'edit' => esc_html__('label for editing item'),
407
-     *                    'delete' => esc_html__('label for deleting item')
408
-     *                ),
409
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
410
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
411
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
412
-     *            _define_page_props() method
413
-     *            'nav' => array(
414
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
415
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
416
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
417
-     *                'order' => 10, //required to indicate tab position.
418
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
419
-     *                displayed then add this parameter.
420
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
421
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
422
-     *            metaboxes set for eventespresso admin pages.
423
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
424
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
425
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
426
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
427
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
428
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
429
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
430
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
431
-     *            want to display.
432
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
433
-     *                'tab_id' => array(
434
-     *                    'title' => 'tab_title',
435
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
436
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
437
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
438
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
439
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
440
-     *                    attempt to use the callback which should match the name of a method in the class
441
-     *                    ),
442
-     *                'tab2_id' => array(
443
-     *                    'title' => 'tab2 title',
444
-     *                    'filename' => 'file_name_2'
445
-     *                    'callback' => 'callback_method_for_content',
446
-     *                 ),
447
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
448
-     *            help tab area on an admin page. @return void
449
-     *
450
-     * @abstract
451
-     */
452
-    abstract protected function _set_page_config();
453
-
454
-
455
-    /**
456
-     * _add_screen_options
457
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
458
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
459
-     * to a particular view.
460
-     *
461
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
462
-     *         see also WP_Screen object documents...
463
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
464
-     * @abstract
465
-     * @return void
466
-     */
467
-    abstract protected function _add_screen_options();
468
-
469
-
470
-    /**
471
-     * _add_feature_pointers
472
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
473
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
474
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
475
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
476
-     * extended) also see:
477
-     *
478
-     * @link   http://eamann.com/tech/wordpress-portland/
479
-     * @abstract
480
-     * @return void
481
-     */
482
-    abstract protected function _add_feature_pointers();
483
-
484
-
485
-    /**
486
-     * load_scripts_styles
487
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
488
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
489
-     * scripts/styles per view by putting them in a dynamic function in this format
490
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
491
-     *
492
-     * @abstract
493
-     * @return void
494
-     */
495
-    abstract public function load_scripts_styles();
496
-
497
-
498
-    /**
499
-     * admin_init
500
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
501
-     * all pages/views loaded by child class.
502
-     *
503
-     * @abstract
504
-     * @return void
505
-     */
506
-    abstract public function admin_init();
507
-
508
-
509
-    /**
510
-     * admin_notices
511
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
512
-     * all pages/views loaded by child class.
513
-     *
514
-     * @abstract
515
-     * @return void
516
-     */
517
-    abstract public function admin_notices();
518
-
519
-
520
-    /**
521
-     * admin_footer_scripts
522
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
523
-     * will apply to all pages/views loaded by child class.
524
-     *
525
-     * @return void
526
-     */
527
-    abstract public function admin_footer_scripts();
528
-
529
-
530
-    /**
531
-     * admin_footer
532
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
533
-     * apply to all pages/views loaded by child class.
534
-     *
535
-     * @return void
536
-     */
537
-    public function admin_footer()
538
-    {
539
-    }
540
-
541
-
542
-    /**
543
-     * _global_ajax_hooks
544
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
545
-     * Note: within the ajax callback methods.
546
-     *
547
-     * @abstract
548
-     * @return void
549
-     */
550
-    protected function _global_ajax_hooks()
551
-    {
552
-        // for lazy loading of metabox content
553
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
554
-
555
-        add_action(
556
-            'wp_ajax_espresso_hide_status_change_notice',
557
-            [$this, 'hideStatusChangeNotice']
558
-        );
559
-        add_action(
560
-            'wp_ajax_nopriv_espresso_hide_status_change_notice',
561
-            [$this, 'hideStatusChangeNotice']
562
-        );
563
-    }
564
-
565
-
566
-    public function ajax_metabox_content()
567
-    {
568
-        $content_id  = $this->request->getRequestParam('contentid', '');
569
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
570
-        EE_Admin_Page::cached_rss_display($content_id, $content_url);
571
-        wp_die();
572
-    }
573
-
574
-
575
-    public function hideStatusChangeNotice()
576
-    {
577
-        $response = [];
578
-        try {
579
-            /** @var StatusChangeNotice $status_change_notice */
580
-            $status_change_notice = $this->loader->getShared(
581
-                'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
582
-            );
583
-            $response['success'] = $status_change_notice->dismiss() > -1;
584
-        } catch (Exception $exception) {
585
-            $response['errors'] = $exception->getMessage();
586
-        }
587
-        echo wp_json_encode($response);
588
-        exit();
589
-    }
590
-
591
-
592
-    /**
593
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
594
-     *
595
-     * @return void
596
-     */
597
-    protected function _before_page_setup()
598
-    {
599
-        // default is to do nothing
600
-    }
601
-
602
-
603
-    /**
604
-     * Makes sure any things that need to be loaded early get handled.
605
-     * We also escape early here if the page requested doesn't match the object.
606
-     *
607
-     * @final
608
-     * @return void
609
-     * @throws EE_Error
610
-     * @throws InvalidArgumentException
611
-     * @throws ReflectionException
612
-     * @throws InvalidDataTypeException
613
-     * @throws InvalidInterfaceException
614
-     */
615
-    final protected function _page_setup()
616
-    {
617
-        // requires?
618
-        // admin_init stuff - global - we're setting this REALLY early
619
-        // so if EE_Admin pages have to hook into other WP pages they can.
620
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
621
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
622
-        // next verify if we need to load anything...
623
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
624
-        $this->page_folder   = strtolower(
625
-            str_replace(['_Admin_Page', 'Extend_'], '', $this->class_name)
626
-        );
627
-        global $ee_menu_slugs;
628
-        $ee_menu_slugs = (array) $ee_menu_slugs;
629
-        if (
630
-            ! $this->request->isAjax()
631
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
632
-        ) {
633
-            return;
634
-        }
635
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
636
-        // we need to copy the action from the second to the first
637
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
638
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
639
-        $action     = $action !== '-1' ? $action : $action2;
640
-        $req_action = $action !== '-1' ? $action : 'default';
641
-
642
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
643
-        // then let's use the route as the action.
644
-        // This covers cases where we're coming in from a list table that isn't on the default route.
645
-        $route = $this->request->getRequestParam('route');
646
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
647
-            ? $route
648
-            : $req_action;
649
-
650
-        $this->_current_view = $this->_req_action;
651
-        $this->_req_nonce    = $this->_req_action . '_nonce';
652
-        $this->_define_page_props();
653
-        $this->_current_page_view_url = add_query_arg(
654
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
655
-            $this->_admin_base_url
656
-        );
657
-        // set page configs
658
-        $this->_set_page_routes();
659
-        $this->_set_page_config();
660
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
661
-        if ($this->request->requestParamIsSet('wp_referer')) {
662
-            $wp_referer = $this->request->getRequestParam('wp_referer');
663
-            if ($wp_referer) {
664
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
665
-            }
666
-        }
667
-        // for caffeinated and other extended functionality.
668
-        //  If there is a _extend_page_config method
669
-        // then let's run that to modify the all the various page configuration arrays
670
-        if (method_exists($this, '_extend_page_config')) {
671
-            $this->_extend_page_config();
672
-        }
673
-        // for CPT and other extended functionality.
674
-        // If there is an _extend_page_config_for_cpt
675
-        // then let's run that to modify all the various page configuration arrays.
676
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
677
-            $this->_extend_page_config_for_cpt();
678
-        }
679
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
680
-        $this->_page_routes = apply_filters(
681
-            'FHEE__' . $this->class_name . '__page_setup__page_routes',
682
-            $this->_page_routes,
683
-            $this
684
-        );
685
-        $this->_page_config = apply_filters(
686
-            'FHEE__' . $this->class_name . '__page_setup__page_config',
687
-            $this->_page_config,
688
-            $this
689
-        );
690
-        if ($this->base_class_name !== '') {
691
-            $this->_page_routes = apply_filters(
692
-                'FHEE__' . $this->base_class_name . '__page_setup__page_routes',
693
-                $this->_page_routes,
694
-                $this
695
-            );
696
-            $this->_page_config = apply_filters(
697
-                'FHEE__' . $this->base_class_name . '__page_setup__page_config',
698
-                $this->_page_config,
699
-                $this
700
-            );
701
-        }
702
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
703
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
704
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
705
-            add_action(
706
-                'AHEE__EE_Admin_Page__route_admin_request',
707
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
708
-                10,
709
-                2
710
-            );
711
-        }
712
-        // next route only if routing enabled
713
-        if ($this->_routing && ! $this->request->isAjax()) {
714
-            $this->_verify_routes();
715
-            // next let's just check user_access and kill if no access
716
-            $this->check_user_access();
717
-            if ($this->_is_UI_request) {
718
-                // admin_init stuff - global, all views for this page class, specific view
719
-                add_action('admin_init', [$this, 'admin_init'], 10);
720
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
721
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
722
-                }
723
-            } else {
724
-                // hijack regular WP loading and route admin request immediately
725
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
726
-                $this->route_admin_request();
727
-            }
728
-        }
729
-    }
730
-
731
-
732
-    /**
733
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
734
-     *
735
-     * @return void
736
-     * @throws EE_Error
737
-     */
738
-    private function _do_other_page_hooks()
739
-    {
740
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
741
-        foreach ($registered_pages as $page) {
742
-            // now let's setup the file name and class that should be present
743
-            $classname = str_replace('.class.php', '', $page);
744
-            // autoloaders should take care of loading file
745
-            if (! class_exists($classname)) {
746
-                $error_msg[] = sprintf(
747
-                    esc_html__(
748
-                        'Something went wrong with loading the %s admin hooks page.',
749
-                        'event_espresso'
750
-                    ),
751
-                    $page
752
-                );
753
-                $error_msg[] = $error_msg[0]
754
-                               . "\r\n"
755
-                               . sprintf(
756
-                                   esc_html__(
757
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
758
-                                       'event_espresso'
759
-                                   ),
760
-                                   $page,
761
-                                   '<br />',
762
-                                   '<strong>' . $classname . '</strong>'
763
-                               );
764
-                throw new EE_Error(implode('||', $error_msg));
765
-            }
766
-            // notice we are passing the instance of this class to the hook object.
767
-            $this->loader->getShared($classname, [$this]);
768
-        }
769
-    }
770
-
771
-
772
-    /**
773
-     * @throws ReflectionException
774
-     * @throws EE_Error
775
-     */
776
-    public function load_page_dependencies()
777
-    {
778
-        try {
779
-            $this->_load_page_dependencies();
780
-        } catch (EE_Error $e) {
781
-            $e->get_error();
782
-        }
783
-    }
784
-
785
-
786
-    /**
787
-     * load_page_dependencies
788
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
789
-     *
790
-     * @return void
791
-     * @throws DomainException
792
-     * @throws EE_Error
793
-     * @throws InvalidArgumentException
794
-     * @throws InvalidDataTypeException
795
-     * @throws InvalidInterfaceException
796
-     */
797
-    protected function _load_page_dependencies()
798
-    {
799
-        // let's set the current_screen and screen options to override what WP set
800
-        $this->_current_screen = get_current_screen();
801
-        // load admin_notices - global, page class, and view specific
802
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
803
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
804
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
805
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
806
-        }
807
-        // load network admin_notices - global, page class, and view specific
808
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
809
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
810
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
811
-        }
812
-        // this will save any per_page screen options if they are present
813
-        $this->_set_per_page_screen_options();
814
-        // setup list table properties
815
-        $this->_set_list_table();
816
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
817
-        // However in some cases the metaboxes will need to be added within a route handling callback.
818
-        $this->_add_registered_meta_boxes();
819
-        $this->_add_screen_columns();
820
-        // add screen options - global, page child class, and view specific
821
-        $this->_add_global_screen_options();
822
-        $this->_add_screen_options();
823
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
824
-        if (method_exists($this, $add_screen_options)) {
825
-            $this->{$add_screen_options}();
826
-        }
827
-        // add help tab(s) - set via page_config and qtips.
828
-        $this->_add_help_tabs();
829
-        $this->_add_qtips();
830
-        // add feature_pointers - global, page child class, and view specific
831
-        $this->_add_feature_pointers();
832
-        $this->_add_global_feature_pointers();
833
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
834
-        if (method_exists($this, $add_feature_pointer)) {
835
-            $this->{$add_feature_pointer}();
836
-        }
837
-        // enqueue scripts/styles - global, page class, and view specific
838
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
839
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
840
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
841
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
842
-        }
843
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
844
-        // admin_print_footer_scripts - global, page child class, and view specific.
845
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
846
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
847
-        // is a good use case. Notice the late priority we're giving these
848
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
849
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
850
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
851
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
852
-        }
853
-        // admin footer scripts
854
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
855
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
856
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
857
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
858
-        }
859
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
860
-        // targeted hook
861
-        do_action(
862
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
863
-        );
864
-    }
865
-
866
-
867
-    /**
868
-     * _set_defaults
869
-     * This sets some global defaults for class properties.
870
-     */
871
-    private function _set_defaults()
872
-    {
873
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
874
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
875
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
876
-        $this->_page_config          = $this->_default_route_query_args = [];
877
-        $this->_default_nav_tab_name = 'overview';
878
-        // init template args
879
-        $this->_template_args = [
880
-            'admin_page_header'  => '',
881
-            'admin_page_content' => '',
882
-            'post_body_content'  => '',
883
-            'before_list_table'  => '',
884
-            'after_list_table'   => '',
885
-        ];
886
-    }
887
-
888
-
889
-    /**
890
-     * route_admin_request
891
-     *
892
-     * @return void
893
-     * @throws InvalidArgumentException
894
-     * @throws InvalidInterfaceException
895
-     * @throws InvalidDataTypeException
896
-     * @throws EE_Error
897
-     * @throws ReflectionException
898
-     * @see    _route_admin_request()
899
-     */
900
-    public function route_admin_request()
901
-    {
902
-        try {
903
-            $this->_route_admin_request();
904
-        } catch (EE_Error $e) {
905
-            $e->get_error();
906
-        }
907
-    }
908
-
909
-
910
-    public function set_wp_page_slug($wp_page_slug)
911
-    {
912
-        $this->_wp_page_slug = $wp_page_slug;
913
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
914
-        if (is_network_admin()) {
915
-            $this->_wp_page_slug .= '-network';
916
-        }
917
-    }
918
-
919
-
920
-    /**
921
-     * _verify_routes
922
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
923
-     * we know if we need to drop out.
924
-     *
925
-     * @return bool
926
-     * @throws EE_Error
927
-     */
928
-    protected function _verify_routes()
929
-    {
930
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
931
-        if (! $this->_current_page && ! $this->request->isAjax()) {
932
-            return false;
933
-        }
934
-        $this->_route = false;
935
-        // check that the page_routes array is not empty
936
-        if (empty($this->_page_routes)) {
937
-            // user error msg
938
-            $error_msg = sprintf(
939
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
940
-                $this->_admin_page_title
941
-            );
942
-            // developer error msg
943
-            $error_msg .= '||' . $error_msg
944
-                          . esc_html__(
945
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
946
-                              'event_espresso'
947
-                          );
948
-            throw new EE_Error($error_msg);
949
-        }
950
-        // and that the requested page route exists
951
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
952
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
953
-            $this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
954
-        } else {
955
-            // user error msg
956
-            $error_msg = sprintf(
957
-                esc_html__(
958
-                    'The requested page route does not exist for the %s admin page.',
959
-                    'event_espresso'
960
-                ),
961
-                $this->_admin_page_title
962
-            );
963
-            // developer error msg
964
-            $error_msg .= '||' . $error_msg
965
-                          . sprintf(
966
-                              esc_html__(
967
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
968
-                                  'event_espresso'
969
-                              ),
970
-                              $this->_req_action
971
-                          );
972
-            throw new EE_Error($error_msg);
973
-        }
974
-        // and that a default route exists
975
-        if (! array_key_exists('default', $this->_page_routes)) {
976
-            // user error msg
977
-            $error_msg = sprintf(
978
-                esc_html__(
979
-                    'A default page route has not been set for the % admin page.',
980
-                    'event_espresso'
981
-                ),
982
-                $this->_admin_page_title
983
-            );
984
-            // developer error msg
985
-            $error_msg .= '||' . $error_msg
986
-                          . esc_html__(
987
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
988
-                              'event_espresso'
989
-                          );
990
-            throw new EE_Error($error_msg);
991
-        }
992
-
993
-        // first lets' catch if the UI request has EVER been set.
994
-        if ($this->_is_UI_request === null) {
995
-            // lets set if this is a UI request or not.
996
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
997
-            // wait a minute... we might have a noheader in the route array
998
-            $this->_is_UI_request = ! (
999
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
1000
-            )
1001
-                ? $this->_is_UI_request
1002
-                : false;
1003
-        }
1004
-        $this->_set_current_labels();
1005
-        return true;
1006
-    }
1007
-
1008
-
1009
-    /**
1010
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
1011
-     *
1012
-     * @param string $route the route name we're verifying
1013
-     * @return bool we'll throw an exception if this isn't a valid route.
1014
-     * @throws EE_Error
1015
-     */
1016
-    protected function _verify_route($route)
1017
-    {
1018
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
1019
-            return true;
1020
-        }
1021
-        // user error msg
1022
-        $error_msg = sprintf(
1023
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
1024
-            $this->_admin_page_title
1025
-        );
1026
-        // developer error msg
1027
-        $error_msg .= '||' . $error_msg
1028
-                      . sprintf(
1029
-                          esc_html__(
1030
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
1031
-                              'event_espresso'
1032
-                          ),
1033
-                          $route
1034
-                      );
1035
-        throw new EE_Error($error_msg);
1036
-    }
1037
-
1038
-
1039
-    /**
1040
-     * perform nonce verification
1041
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
1042
-     * using this method (and save retyping!)
1043
-     *
1044
-     * @param string $nonce     The nonce sent
1045
-     * @param string $nonce_ref The nonce reference string (name0)
1046
-     * @return void
1047
-     * @throws EE_Error
1048
-     * @throws InvalidArgumentException
1049
-     * @throws InvalidDataTypeException
1050
-     * @throws InvalidInterfaceException
1051
-     */
1052
-    protected function _verify_nonce($nonce, $nonce_ref)
1053
-    {
1054
-        // verify nonce against expected value
1055
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
1056
-            // these are not the droids you are looking for !!!
1057
-            $msg = sprintf(
1058
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
1059
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
1060
-                '</a>'
1061
-            );
1062
-            if (WP_DEBUG) {
1063
-                $msg .= "\n  ";
1064
-                $msg .= sprintf(
1065
-                    esc_html__(
1066
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
1067
-                        'event_espresso'
1068
-                    ),
1069
-                    __CLASS__
1070
-                );
1071
-            }
1072
-            if (! $this->request->isAjax()) {
1073
-                wp_die($msg);
1074
-            }
1075
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1076
-            $this->_return_json();
1077
-        }
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * _route_admin_request()
1083
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1084
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1085
-     * in the page routes and then will try to load the corresponding method.
1086
-     *
1087
-     * @return void
1088
-     * @throws EE_Error
1089
-     * @throws InvalidArgumentException
1090
-     * @throws InvalidDataTypeException
1091
-     * @throws InvalidInterfaceException
1092
-     * @throws ReflectionException
1093
-     */
1094
-    protected function _route_admin_request()
1095
-    {
1096
-        if (! $this->_is_UI_request) {
1097
-            $this->_verify_routes();
1098
-        }
1099
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1100
-        if ($this->_req_action !== 'default' && $nonce_check) {
1101
-            // set nonce from post data
1102
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
1103
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1104
-        }
1105
-        // set the nav_tabs array but ONLY if this is  UI_request
1106
-        if ($this->_is_UI_request) {
1107
-            $this->_set_nav_tabs();
1108
-        }
1109
-        // grab callback function
1110
-        $func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1111
-        // check if callback has args
1112
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1113
-        $error_msg = '';
1114
-        // action right before calling route
1115
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1116
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1117
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1118
-        }
1119
-        // strip _wp_http_referer from the server REQUEST_URI
1120
-        // else it grows in length on every submission due to recursion,
1121
-        // ultimately causing a "Request-URI Too Large" error
1122
-        $request_uri = remove_query_arg(
1123
-            '_wp_http_referer',
1124
-            wp_unslash($this->request->getServerParam('REQUEST_URI'))
1125
-        );
1126
-        // set new value in both our Request object and the super global
1127
-        $this->request->setServerParam('REQUEST_URI', $request_uri, true);
1128
-        if (! empty($func)) {
1129
-            if (is_array($func)) {
1130
-                [$class, $method] = $func;
1131
-            } elseif (strpos($func, '::') !== false) {
1132
-                [$class, $method] = explode('::', $func);
1133
-            } else {
1134
-                $class  = $this;
1135
-                $method = $func;
1136
-            }
1137
-            if (! (is_object($class) && $class === $this)) {
1138
-                // send along this admin page object for access by addons.
1139
-                $args['admin_page_object'] = $this;
1140
-            }
1141
-            if (
1142
-                // is it a method on a class that doesn't work?
1143
-                (
1144
-                    (
1145
-                        method_exists($class, $method)
1146
-                        && call_user_func_array([$class, $method], $args) === false
1147
-                    )
1148
-                    && (
1149
-                        // is it a standalone function that doesn't work?
1150
-                        function_exists($method)
1151
-                        && call_user_func_array(
1152
-                            $func,
1153
-                            array_merge(['admin_page_object' => $this], $args)
1154
-                        ) === false
1155
-                    )
1156
-                )
1157
-                || (
1158
-                    // is it neither a class method NOR a standalone function?
1159
-                    ! method_exists($class, $method)
1160
-                    && ! function_exists($method)
1161
-                )
1162
-            ) {
1163
-                // user error msg
1164
-                $error_msg = esc_html__(
1165
-                    'An error occurred. The  requested page route could not be found.',
1166
-                    'event_espresso'
1167
-                );
1168
-                // developer error msg
1169
-                $error_msg .= '||';
1170
-                $error_msg .= sprintf(
1171
-                    esc_html__(
1172
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1173
-                        'event_espresso'
1174
-                    ),
1175
-                    $method
1176
-                );
1177
-            }
1178
-            if (! empty($error_msg)) {
1179
-                throw new EE_Error($error_msg);
1180
-            }
1181
-        }
1182
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1183
-        // then we need to reset the routing properties to the new route.
1184
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1185
-        if (
1186
-            $this->_is_UI_request === false
1187
-            && is_array($this->_route)
1188
-            && ! empty($this->_route['headers_sent_route'])
1189
-        ) {
1190
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1191
-        }
1192
-    }
1193
-
1194
-
1195
-    /**
1196
-     * This method just allows the resetting of page properties in the case where a no headers
1197
-     * route redirects to a headers route in its route config.
1198
-     *
1199
-     * @param string $new_route New (non header) route to redirect to.
1200
-     * @return   void
1201
-     * @throws ReflectionException
1202
-     * @throws InvalidArgumentException
1203
-     * @throws InvalidInterfaceException
1204
-     * @throws InvalidDataTypeException
1205
-     * @throws EE_Error
1206
-     * @since   4.3.0
1207
-     */
1208
-    protected function _reset_routing_properties($new_route)
1209
-    {
1210
-        $this->_is_UI_request = true;
1211
-        // now we set the current route to whatever the headers_sent_route is set at
1212
-        $this->request->setRequestParam('action', $new_route);
1213
-        // rerun page setup
1214
-        $this->_page_setup();
1215
-    }
1216
-
1217
-
1218
-    /**
1219
-     * _add_query_arg
1220
-     * adds nonce to array of arguments then calls WP add_query_arg function
1221
-     *(internally just uses EEH_URL's function with the same name)
1222
-     *
1223
-     * @param array  $args
1224
-     * @param string $url
1225
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1226
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1227
-     *                                        Example usage: If the current page is:
1228
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1229
-     *                                        &action=default&event_id=20&month_range=March%202015
1230
-     *                                        &_wpnonce=5467821
1231
-     *                                        and you call:
1232
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1233
-     *                                        array(
1234
-     *                                        'action' => 'resend_something',
1235
-     *                                        'page=>espresso_registrations'
1236
-     *                                        ),
1237
-     *                                        $some_url,
1238
-     *                                        true
1239
-     *                                        );
1240
-     *                                        It will produce a url in this structure:
1241
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1242
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1243
-     *                                        month_range]=March%202015
1244
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1245
-     * @return string
1246
-     */
1247
-    public static function add_query_args_and_nonce(
1248
-        $args = [],
1249
-        $url = '',
1250
-        $sticky = false,
1251
-        $exclude_nonce = false
1252
-    ) {
1253
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1254
-        if ($sticky) {
1255
-            /** @var RequestInterface $request */
1256
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1257
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1258
-            $request->unSetServerParam('_wp_http_referer', true);
1259
-            foreach ($request->requestParams() as $key => $value) {
1260
-                // do not add nonces
1261
-                if (strpos($key, 'nonce') !== false) {
1262
-                    continue;
1263
-                }
1264
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1265
-            }
1266
-        }
1267
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1268
-    }
1269
-
1270
-
1271
-    /**
1272
-     * This returns a generated link that will load the related help tab.
1273
-     *
1274
-     * @param string $help_tab_id the id for the connected help tab
1275
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1276
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1277
-     * @return string              generated link
1278
-     * @uses EEH_Template::get_help_tab_link()
1279
-     */
1280
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1281
-    {
1282
-        return EEH_Template::get_help_tab_link(
1283
-            $help_tab_id,
1284
-            $this->page_slug,
1285
-            $this->_req_action,
1286
-            $icon_style,
1287
-            $help_text
1288
-        );
1289
-    }
1290
-
1291
-
1292
-    /**
1293
-     * _add_help_tabs
1294
-     * Note child classes define their help tabs within the page_config array.
1295
-     *
1296
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1297
-     * @return void
1298
-     * @throws DomainException
1299
-     * @throws EE_Error
1300
-     * @throws ReflectionException
1301
-     */
1302
-    protected function _add_help_tabs()
1303
-    {
1304
-        if (isset($this->_page_config[ $this->_req_action ])) {
1305
-            $config = $this->_page_config[ $this->_req_action ];
1306
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1307
-            if (is_array($config) && isset($config['help_sidebar'])) {
1308
-                // check that the callback given is valid
1309
-                if (! method_exists($this, $config['help_sidebar'])) {
1310
-                    throw new EE_Error(
1311
-                        sprintf(
1312
-                            esc_html__(
1313
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1314
-                                'event_espresso'
1315
-                            ),
1316
-                            $config['help_sidebar'],
1317
-                            $this->class_name
1318
-                        )
1319
-                    );
1320
-                }
1321
-                $content = apply_filters(
1322
-                    'FHEE__' . $this->class_name . '__add_help_tabs__help_sidebar',
1323
-                    $this->{$config['help_sidebar']}()
1324
-                );
1325
-                $this->_current_screen->set_help_sidebar($content);
1326
-            }
1327
-            if (! isset($config['help_tabs'])) {
1328
-                return;
1329
-            } //no help tabs for this route
1330
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1331
-                // we're here so there ARE help tabs!
1332
-                // make sure we've got what we need
1333
-                if (! isset($cfg['title'])) {
1334
-                    throw new EE_Error(
1335
-                        esc_html__(
1336
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1337
-                            'event_espresso'
1338
-                        )
1339
-                    );
1340
-                }
1341
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1342
-                    throw new EE_Error(
1343
-                        esc_html__(
1344
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1345
-                            'event_espresso'
1346
-                        )
1347
-                    );
1348
-                }
1349
-                // first priority goes to content.
1350
-                if (! empty($cfg['content'])) {
1351
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1352
-                    // second priority goes to filename
1353
-                } elseif (! empty($cfg['filename'])) {
1354
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1355
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1356
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1357
-                                                             . basename($this->_get_dir())
1358
-                                                             . '/help_tabs/'
1359
-                                                             . $cfg['filename']
1360
-                                                             . '.help_tab.php' : $file_path;
1361
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1362
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1363
-                        EE_Error::add_error(
1364
-                            sprintf(
1365
-                                esc_html__(
1366
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1367
-                                    'event_espresso'
1368
-                                ),
1369
-                                $tab_id,
1370
-                                key($config),
1371
-                                $file_path
1372
-                            ),
1373
-                            __FILE__,
1374
-                            __FUNCTION__,
1375
-                            __LINE__
1376
-                        );
1377
-                        return;
1378
-                    }
1379
-                    $template_args['admin_page_obj'] = $this;
1380
-                    $content                         = EEH_Template::display_template(
1381
-                        $file_path,
1382
-                        $template_args,
1383
-                        true
1384
-                    );
1385
-                } else {
1386
-                    $content = '';
1387
-                }
1388
-                // check if callback is valid
1389
-                if (
1390
-                    empty($content)
1391
-                    && (
1392
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1393
-                    )
1394
-                ) {
1395
-                    EE_Error::add_error(
1396
-                        sprintf(
1397
-                            esc_html__(
1398
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1399
-                                'event_espresso'
1400
-                            ),
1401
-                            $cfg['title']
1402
-                        ),
1403
-                        __FILE__,
1404
-                        __FUNCTION__,
1405
-                        __LINE__
1406
-                    );
1407
-                    return;
1408
-                }
1409
-                // setup config array for help tab method
1410
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1411
-                $_ht = [
1412
-                    'id'       => $id,
1413
-                    'title'    => $cfg['title'],
1414
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1415
-                    'content'  => $content,
1416
-                ];
1417
-                $this->_current_screen->add_help_tab($_ht);
1418
-            }
1419
-        }
1420
-    }
1421
-
1422
-
1423
-    /**
1424
-     * This simply sets up any qtips that have been defined in the page config
1425
-     *
1426
-     * @return void
1427
-     * @throws ReflectionException
1428
-     * @throws EE_Error
1429
-     */
1430
-    protected function _add_qtips()
1431
-    {
1432
-        if (isset($this->_route_config['qtips'])) {
1433
-            $qtips = (array) $this->_route_config['qtips'];
1434
-            // load qtip loader
1435
-            $path = [
1436
-                $this->_get_dir() . '/qtips/',
1437
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1438
-            ];
1439
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1440
-        }
1441
-    }
1442
-
1443
-
1444
-    /**
1445
-     * _set_nav_tabs
1446
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1447
-     * wish to add additional tabs or modify accordingly.
1448
-     *
1449
-     * @return void
1450
-     * @throws InvalidArgumentException
1451
-     * @throws InvalidInterfaceException
1452
-     * @throws InvalidDataTypeException
1453
-     */
1454
-    protected function _set_nav_tabs()
1455
-    {
1456
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1457
-        $i = 0;
1458
-        foreach ($this->_page_config as $slug => $config) {
1459
-            if (! is_array($config) || empty($config['nav'])) {
1460
-                continue;
1461
-            }
1462
-            // no nav tab for this config
1463
-            // check for persistent flag
1464
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1465
-                // nav tab is only to appear when route requested.
1466
-                continue;
1467
-            }
1468
-            if (! $this->check_user_access($slug, true)) {
1469
-                // no nav tab because current user does not have access.
1470
-                continue;
1471
-            }
1472
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1473
-            $this->_nav_tabs[ $slug ] = [
1474
-                'url'       => isset($config['nav']['url'])
1475
-                    ? $config['nav']['url']
1476
-                    : EE_Admin_Page::add_query_args_and_nonce(
1477
-                        ['action' => $slug],
1478
-                        $this->_admin_base_url
1479
-                    ),
1480
-                'link_text' => isset($config['nav']['label'])
1481
-                    ? $config['nav']['label']
1482
-                    : ucwords(
1483
-                        str_replace('_', ' ', $slug)
1484
-                    ),
1485
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1486
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1487
-            ];
1488
-            $i++;
1489
-        }
1490
-        // if $this->_nav_tabs is empty then lets set the default
1491
-        if (empty($this->_nav_tabs)) {
1492
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1493
-                'url'       => $this->_admin_base_url,
1494
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1495
-                'css_class' => 'nav-tab-active',
1496
-                'order'     => 10,
1497
-            ];
1498
-        }
1499
-        // now let's sort the tabs according to order
1500
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1501
-    }
1502
-
1503
-
1504
-    /**
1505
-     * _set_current_labels
1506
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1507
-     * property array
1508
-     *
1509
-     * @return void
1510
-     */
1511
-    private function _set_current_labels()
1512
-    {
1513
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1514
-            foreach ($this->_route_config['labels'] as $label => $text) {
1515
-                if (is_array($text)) {
1516
-                    foreach ($text as $sublabel => $subtext) {
1517
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1518
-                    }
1519
-                } else {
1520
-                    $this->_labels[ $label ] = $text;
1521
-                }
1522
-            }
1523
-        }
1524
-    }
1525
-
1526
-
1527
-    /**
1528
-     *        verifies user access for this admin page
1529
-     *
1530
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1531
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1532
-     *                               return false if verify fail.
1533
-     * @return bool
1534
-     * @throws InvalidArgumentException
1535
-     * @throws InvalidDataTypeException
1536
-     * @throws InvalidInterfaceException
1537
-     */
1538
-    public function check_user_access($route_to_check = '', $verify_only = false)
1539
-    {
1540
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1541
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1542
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1543
-                          && is_array(
1544
-                              $this->_page_routes[ $route_to_check ]
1545
-                          )
1546
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1547
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1548
-        if (empty($capability) && empty($route_to_check)) {
1549
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1550
-                : $this->_route['capability'];
1551
-        } else {
1552
-            $capability = empty($capability) ? 'manage_options' : $capability;
1553
-        }
1554
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1555
-        if (
1556
-            ! $this->request->isAjax()
1557
-            && (
1558
-                ! function_exists('is_admin')
1559
-                || ! EE_Registry::instance()->CAP->current_user_can(
1560
-                    $capability,
1561
-                    $this->page_slug
1562
-                    . '_'
1563
-                    . $route_to_check,
1564
-                    $id
1565
-                )
1566
-            )
1567
-        ) {
1568
-            if ($verify_only) {
1569
-                return false;
1570
-            }
1571
-            if (is_user_logged_in()) {
1572
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1573
-            } else {
1574
-                return false;
1575
-            }
1576
-        }
1577
-        return true;
1578
-    }
1579
-
1580
-
1581
-    /**
1582
-     * @param string                 $box_id
1583
-     * @param string                 $title
1584
-     * @param callable|string|null   $callback
1585
-     * @param string|array|WP_Screen $screen
1586
-     * @param string                 $context
1587
-     * @param string                 $priority
1588
-     * @param array|null             $callback_args
1589
-     */
1590
-    protected function addMetaBox(
1591
-        string $box_id,
1592
-        string $title,
1593
-        $callback,
1594
-        $screen,
1595
-        string $context = 'normal',
1596
-        string $priority = 'default',
1597
-        ?array $callback_args = null
1598
-    ) {
1599
-        if (! is_callable($callback)) {
1600
-            return;
1601
-        }
1602
-
1603
-        add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1604
-        add_filter(
1605
-            "postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1606
-            function ($classes) {
1607
-                array_push($classes, 'ee-admin-container');
1608
-                return $classes;
1609
-            }
1610
-        );
1611
-    }
1612
-
1613
-
1614
-    /**
1615
-     * admin_init_global
1616
-     * This runs all the code that we want executed within the WP admin_init hook.
1617
-     * This method executes for ALL EE Admin pages.
1618
-     *
1619
-     * @return void
1620
-     */
1621
-    public function admin_init_global()
1622
-    {
1623
-    }
1624
-
1625
-
1626
-    /**
1627
-     * wp_loaded_global
1628
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1629
-     * EE_Admin page and will execute on every EE Admin Page load
1630
-     *
1631
-     * @return void
1632
-     */
1633
-    public function wp_loaded()
1634
-    {
1635
-    }
1636
-
1637
-
1638
-    /**
1639
-     * admin_notices
1640
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1641
-     * ALL EE_Admin pages.
1642
-     *
1643
-     * @return void
1644
-     */
1645
-    public function admin_notices_global()
1646
-    {
1647
-        $this->_display_no_javascript_warning();
1648
-        $this->_display_espresso_notices();
1649
-    }
1650
-
1651
-
1652
-    public function network_admin_notices_global()
1653
-    {
1654
-        $this->_display_no_javascript_warning();
1655
-        $this->_display_espresso_notices();
1656
-    }
1657
-
1658
-
1659
-    /**
1660
-     * admin_footer_scripts_global
1661
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1662
-     * will apply on ALL EE_Admin pages.
1663
-     *
1664
-     * @return void
1665
-     */
1666
-    public function admin_footer_scripts_global()
1667
-    {
1668
-        $this->_add_admin_page_ajax_loading_img();
1669
-        $this->_add_admin_page_overlay();
1670
-        // if metaboxes are present we need to add the nonce field
1671
-        if (
1672
-            isset($this->_route_config['metaboxes'])
1673
-            || isset($this->_route_config['list_table'])
1674
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1675
-        ) {
1676
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1677
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1678
-        }
1679
-    }
1680
-
1681
-
1682
-    /**
1683
-     * admin_footer_global
1684
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1685
-     * This particular method will apply on ALL EE_Admin Pages.
1686
-     *
1687
-     * @return void
1688
-     */
1689
-    public function admin_footer_global()
1690
-    {
1691
-        // dialog container for dialog helper
1692
-        echo '
141
+	/**
142
+	 * unprocessed value for the 'page' request param (default '')
143
+	 *
144
+	 * @var string
145
+	 */
146
+	protected $raw_req_page = '';
147
+
148
+	/**
149
+	 * sanitized request action (and nonce)
150
+	 *
151
+	 * @var string
152
+	 */
153
+	protected $_req_action = '';
154
+
155
+	/**
156
+	 * sanitized request action nonce
157
+	 *
158
+	 * @var string
159
+	 */
160
+	protected $_req_nonce = '';
161
+
162
+	/**
163
+	 * @var string
164
+	 */
165
+	protected $_search_btn_label = '';
166
+
167
+	/**
168
+	 * @var string
169
+	 */
170
+	protected $_search_box_callback = '';
171
+
172
+	/**
173
+	 * @var WP_Screen
174
+	 */
175
+	protected $_current_screen;
176
+
177
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
178
+	protected $_hook_obj;
179
+
180
+	// for holding incoming request data
181
+	protected $_req_data = [];
182
+
183
+	// yes / no array for admin form fields
184
+	protected $_yes_no_values = [];
185
+
186
+	// some default things shared by all child classes
187
+	protected $_default_espresso_metaboxes = [
188
+		'_espresso_news_post_box',
189
+		'_espresso_links_post_box',
190
+		'_espresso_ratings_request',
191
+		'_espresso_sponsors_post_box',
192
+	];
193
+
194
+	/**
195
+	 * @var EE_Registry
196
+	 */
197
+	protected $EE;
198
+
199
+
200
+	/**
201
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
202
+	 *
203
+	 * @var boolean
204
+	 */
205
+	protected $_is_caf = false;
206
+
207
+	/**
208
+	 * whether or not initializePage() has run
209
+	 *
210
+	 * @var boolean
211
+	 */
212
+	protected $initialized = false;
213
+
214
+	/**
215
+	 * @var FeatureFlags
216
+	 */
217
+	protected $feature;
218
+
219
+
220
+	/**
221
+	 * @var string
222
+	 */
223
+	protected $class_name;
224
+
225
+	/**
226
+	 * if the current class is an admin page extension, like: Extend_Events_Admin_Page,
227
+	 * then this would be the parent classname: Events_Admin_Page
228
+	 *
229
+	 * @var string
230
+	 */
231
+	protected $base_class_name;
232
+
233
+
234
+	/**
235
+	 * @Constructor
236
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
237
+	 * @throws InvalidArgumentException
238
+	 * @throws InvalidDataTypeException
239
+	 * @throws InvalidInterfaceException
240
+	 * @throws ReflectionException
241
+	 */
242
+	public function __construct($routing = true)
243
+	{
244
+		$this->loader = LoaderFactory::getLoader();
245
+		$this->admin_config = $this->loader->getShared('EE_Admin_Config');
246
+		$this->feature = $this->loader->getShared(FeatureFlags::class);
247
+		$this->request = $this->loader->getShared(RequestInterface::class);
248
+		// routing enabled?
249
+		$this->_routing = $routing;
250
+
251
+		$this->class_name = get_class($this);
252
+		$this->base_class_name = strpos($this->class_name, 'Extend_') === 0
253
+			? str_replace('Extend_', '', $this->class_name)
254
+			: '';
255
+
256
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
257
+			$this->_is_caf = true;
258
+		}
259
+		$this->_yes_no_values = [
260
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
261
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
262
+		];
263
+		// set the _req_data property.
264
+		$this->_req_data = $this->request->requestParams();
265
+	}
266
+
267
+
268
+	/**
269
+	 * @return EE_Admin_Config
270
+	 */
271
+	public function adminConfig(): EE_Admin_Config
272
+	{
273
+		return $this->admin_config;
274
+	}
275
+
276
+
277
+	/**
278
+	 * @return FeatureFlags
279
+	 */
280
+	public function feature(): FeatureFlags
281
+	{
282
+		return $this->feature;
283
+	}
284
+
285
+
286
+	/**
287
+	 * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
288
+	 * for child classes that needed to set properties prior to these methods getting called,
289
+	 * but also needed the parent class to have its construction completed as well.
290
+	 * Bottom line is that constructors should ONLY be used for setting initial properties
291
+	 * and any complex initialization logic should only run after instantiation is complete.
292
+	 *
293
+	 * This method gets called immediately after construction from within
294
+	 *      EE_Admin_Page_Init::_initialize_admin_page()
295
+	 *
296
+	 * @throws EE_Error
297
+	 * @throws InvalidArgumentException
298
+	 * @throws InvalidDataTypeException
299
+	 * @throws InvalidInterfaceException
300
+	 * @throws ReflectionException
301
+	 * @since $VID:$
302
+	 */
303
+	public function initializePage()
304
+	{
305
+		if ($this->initialized) {
306
+			return;
307
+		}
308
+		// set initial page props (child method)
309
+		$this->_init_page_props();
310
+		// set global defaults
311
+		$this->_set_defaults();
312
+		// set early because incoming requests could be ajax related and we need to register those hooks.
313
+		$this->_global_ajax_hooks();
314
+		$this->_ajax_hooks();
315
+		// other_page_hooks have to be early too.
316
+		$this->_do_other_page_hooks();
317
+		// set up page dependencies
318
+		$this->_before_page_setup();
319
+		$this->_page_setup();
320
+		$this->initialized = true;
321
+	}
322
+
323
+
324
+	/**
325
+	 * _init_page_props
326
+	 * Child classes use to set at least the following properties:
327
+	 * $page_slug.
328
+	 * $page_label.
329
+	 *
330
+	 * @abstract
331
+	 * @return void
332
+	 */
333
+	abstract protected function _init_page_props();
334
+
335
+
336
+	/**
337
+	 * _ajax_hooks
338
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
339
+	 * Note: within the ajax callback methods.
340
+	 *
341
+	 * @abstract
342
+	 * @return void
343
+	 */
344
+	abstract protected function _ajax_hooks();
345
+
346
+
347
+	/**
348
+	 * _define_page_props
349
+	 * child classes define page properties in here.  Must include at least:
350
+	 * $_admin_base_url = base_url for all admin pages
351
+	 * $_admin_page_title = default admin_page_title for admin pages
352
+	 * $_labels = array of default labels for various automatically generated elements:
353
+	 *    array(
354
+	 *        'buttons' => array(
355
+	 *            'add' => esc_html__('label for add new button'),
356
+	 *            'edit' => esc_html__('label for edit button'),
357
+	 *            'delete' => esc_html__('label for delete button')
358
+	 *            )
359
+	 *        )
360
+	 *
361
+	 * @abstract
362
+	 * @return void
363
+	 */
364
+	abstract protected function _define_page_props();
365
+
366
+
367
+	/**
368
+	 * _set_page_routes
369
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
370
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
371
+	 * have a 'default' route. Here's the format
372
+	 * $this->_page_routes = array(
373
+	 *        'default' => array(
374
+	 *            'func' => '_default_method_handling_route',
375
+	 *            'args' => array('array','of','args'),
376
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
377
+	 *            ajax request, backend processing)
378
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
379
+	 *            headers route after.  The string you enter here should match the defined route reference for a
380
+	 *            headers sent route.
381
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
382
+	 *            this route.
383
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
384
+	 *            checks).
385
+	 *        ),
386
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
387
+	 *        handling method.
388
+	 *        )
389
+	 * )
390
+	 *
391
+	 * @abstract
392
+	 * @return void
393
+	 */
394
+	abstract protected function _set_page_routes();
395
+
396
+
397
+	/**
398
+	 * _set_page_config
399
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
400
+	 * array corresponds to the page_route for the loaded page. Format:
401
+	 * $this->_page_config = array(
402
+	 *        'default' => array(
403
+	 *            'labels' => array(
404
+	 *                'buttons' => array(
405
+	 *                    'add' => esc_html__('label for adding item'),
406
+	 *                    'edit' => esc_html__('label for editing item'),
407
+	 *                    'delete' => esc_html__('label for deleting item')
408
+	 *                ),
409
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
410
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
411
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
412
+	 *            _define_page_props() method
413
+	 *            'nav' => array(
414
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
415
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
416
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
417
+	 *                'order' => 10, //required to indicate tab position.
418
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
419
+	 *                displayed then add this parameter.
420
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
421
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
422
+	 *            metaboxes set for eventespresso admin pages.
423
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
424
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
425
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
426
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
427
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
428
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
429
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
430
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
431
+	 *            want to display.
432
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
433
+	 *                'tab_id' => array(
434
+	 *                    'title' => 'tab_title',
435
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
436
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
437
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
438
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
439
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
440
+	 *                    attempt to use the callback which should match the name of a method in the class
441
+	 *                    ),
442
+	 *                'tab2_id' => array(
443
+	 *                    'title' => 'tab2 title',
444
+	 *                    'filename' => 'file_name_2'
445
+	 *                    'callback' => 'callback_method_for_content',
446
+	 *                 ),
447
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
448
+	 *            help tab area on an admin page. @return void
449
+	 *
450
+	 * @abstract
451
+	 */
452
+	abstract protected function _set_page_config();
453
+
454
+
455
+	/**
456
+	 * _add_screen_options
457
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
458
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
459
+	 * to a particular view.
460
+	 *
461
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
462
+	 *         see also WP_Screen object documents...
463
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
464
+	 * @abstract
465
+	 * @return void
466
+	 */
467
+	abstract protected function _add_screen_options();
468
+
469
+
470
+	/**
471
+	 * _add_feature_pointers
472
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
473
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
474
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
475
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
476
+	 * extended) also see:
477
+	 *
478
+	 * @link   http://eamann.com/tech/wordpress-portland/
479
+	 * @abstract
480
+	 * @return void
481
+	 */
482
+	abstract protected function _add_feature_pointers();
483
+
484
+
485
+	/**
486
+	 * load_scripts_styles
487
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
488
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
489
+	 * scripts/styles per view by putting them in a dynamic function in this format
490
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
491
+	 *
492
+	 * @abstract
493
+	 * @return void
494
+	 */
495
+	abstract public function load_scripts_styles();
496
+
497
+
498
+	/**
499
+	 * admin_init
500
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
501
+	 * all pages/views loaded by child class.
502
+	 *
503
+	 * @abstract
504
+	 * @return void
505
+	 */
506
+	abstract public function admin_init();
507
+
508
+
509
+	/**
510
+	 * admin_notices
511
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
512
+	 * all pages/views loaded by child class.
513
+	 *
514
+	 * @abstract
515
+	 * @return void
516
+	 */
517
+	abstract public function admin_notices();
518
+
519
+
520
+	/**
521
+	 * admin_footer_scripts
522
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
523
+	 * will apply to all pages/views loaded by child class.
524
+	 *
525
+	 * @return void
526
+	 */
527
+	abstract public function admin_footer_scripts();
528
+
529
+
530
+	/**
531
+	 * admin_footer
532
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
533
+	 * apply to all pages/views loaded by child class.
534
+	 *
535
+	 * @return void
536
+	 */
537
+	public function admin_footer()
538
+	{
539
+	}
540
+
541
+
542
+	/**
543
+	 * _global_ajax_hooks
544
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
545
+	 * Note: within the ajax callback methods.
546
+	 *
547
+	 * @abstract
548
+	 * @return void
549
+	 */
550
+	protected function _global_ajax_hooks()
551
+	{
552
+		// for lazy loading of metabox content
553
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
554
+
555
+		add_action(
556
+			'wp_ajax_espresso_hide_status_change_notice',
557
+			[$this, 'hideStatusChangeNotice']
558
+		);
559
+		add_action(
560
+			'wp_ajax_nopriv_espresso_hide_status_change_notice',
561
+			[$this, 'hideStatusChangeNotice']
562
+		);
563
+	}
564
+
565
+
566
+	public function ajax_metabox_content()
567
+	{
568
+		$content_id  = $this->request->getRequestParam('contentid', '');
569
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
570
+		EE_Admin_Page::cached_rss_display($content_id, $content_url);
571
+		wp_die();
572
+	}
573
+
574
+
575
+	public function hideStatusChangeNotice()
576
+	{
577
+		$response = [];
578
+		try {
579
+			/** @var StatusChangeNotice $status_change_notice */
580
+			$status_change_notice = $this->loader->getShared(
581
+				'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
582
+			);
583
+			$response['success'] = $status_change_notice->dismiss() > -1;
584
+		} catch (Exception $exception) {
585
+			$response['errors'] = $exception->getMessage();
586
+		}
587
+		echo wp_json_encode($response);
588
+		exit();
589
+	}
590
+
591
+
592
+	/**
593
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
594
+	 *
595
+	 * @return void
596
+	 */
597
+	protected function _before_page_setup()
598
+	{
599
+		// default is to do nothing
600
+	}
601
+
602
+
603
+	/**
604
+	 * Makes sure any things that need to be loaded early get handled.
605
+	 * We also escape early here if the page requested doesn't match the object.
606
+	 *
607
+	 * @final
608
+	 * @return void
609
+	 * @throws EE_Error
610
+	 * @throws InvalidArgumentException
611
+	 * @throws ReflectionException
612
+	 * @throws InvalidDataTypeException
613
+	 * @throws InvalidInterfaceException
614
+	 */
615
+	final protected function _page_setup()
616
+	{
617
+		// requires?
618
+		// admin_init stuff - global - we're setting this REALLY early
619
+		// so if EE_Admin pages have to hook into other WP pages they can.
620
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
621
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
622
+		// next verify if we need to load anything...
623
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
624
+		$this->page_folder   = strtolower(
625
+			str_replace(['_Admin_Page', 'Extend_'], '', $this->class_name)
626
+		);
627
+		global $ee_menu_slugs;
628
+		$ee_menu_slugs = (array) $ee_menu_slugs;
629
+		if (
630
+			! $this->request->isAjax()
631
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
632
+		) {
633
+			return;
634
+		}
635
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
636
+		// we need to copy the action from the second to the first
637
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
638
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
639
+		$action     = $action !== '-1' ? $action : $action2;
640
+		$req_action = $action !== '-1' ? $action : 'default';
641
+
642
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
643
+		// then let's use the route as the action.
644
+		// This covers cases where we're coming in from a list table that isn't on the default route.
645
+		$route = $this->request->getRequestParam('route');
646
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
647
+			? $route
648
+			: $req_action;
649
+
650
+		$this->_current_view = $this->_req_action;
651
+		$this->_req_nonce    = $this->_req_action . '_nonce';
652
+		$this->_define_page_props();
653
+		$this->_current_page_view_url = add_query_arg(
654
+			['page' => $this->_current_page, 'action' => $this->_current_view],
655
+			$this->_admin_base_url
656
+		);
657
+		// set page configs
658
+		$this->_set_page_routes();
659
+		$this->_set_page_config();
660
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
661
+		if ($this->request->requestParamIsSet('wp_referer')) {
662
+			$wp_referer = $this->request->getRequestParam('wp_referer');
663
+			if ($wp_referer) {
664
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
665
+			}
666
+		}
667
+		// for caffeinated and other extended functionality.
668
+		//  If there is a _extend_page_config method
669
+		// then let's run that to modify the all the various page configuration arrays
670
+		if (method_exists($this, '_extend_page_config')) {
671
+			$this->_extend_page_config();
672
+		}
673
+		// for CPT and other extended functionality.
674
+		// If there is an _extend_page_config_for_cpt
675
+		// then let's run that to modify all the various page configuration arrays.
676
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
677
+			$this->_extend_page_config_for_cpt();
678
+		}
679
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
680
+		$this->_page_routes = apply_filters(
681
+			'FHEE__' . $this->class_name . '__page_setup__page_routes',
682
+			$this->_page_routes,
683
+			$this
684
+		);
685
+		$this->_page_config = apply_filters(
686
+			'FHEE__' . $this->class_name . '__page_setup__page_config',
687
+			$this->_page_config,
688
+			$this
689
+		);
690
+		if ($this->base_class_name !== '') {
691
+			$this->_page_routes = apply_filters(
692
+				'FHEE__' . $this->base_class_name . '__page_setup__page_routes',
693
+				$this->_page_routes,
694
+				$this
695
+			);
696
+			$this->_page_config = apply_filters(
697
+				'FHEE__' . $this->base_class_name . '__page_setup__page_config',
698
+				$this->_page_config,
699
+				$this
700
+			);
701
+		}
702
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
703
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
704
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
705
+			add_action(
706
+				'AHEE__EE_Admin_Page__route_admin_request',
707
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
708
+				10,
709
+				2
710
+			);
711
+		}
712
+		// next route only if routing enabled
713
+		if ($this->_routing && ! $this->request->isAjax()) {
714
+			$this->_verify_routes();
715
+			// next let's just check user_access and kill if no access
716
+			$this->check_user_access();
717
+			if ($this->_is_UI_request) {
718
+				// admin_init stuff - global, all views for this page class, specific view
719
+				add_action('admin_init', [$this, 'admin_init'], 10);
720
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
721
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
722
+				}
723
+			} else {
724
+				// hijack regular WP loading and route admin request immediately
725
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
726
+				$this->route_admin_request();
727
+			}
728
+		}
729
+	}
730
+
731
+
732
+	/**
733
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
734
+	 *
735
+	 * @return void
736
+	 * @throws EE_Error
737
+	 */
738
+	private function _do_other_page_hooks()
739
+	{
740
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
741
+		foreach ($registered_pages as $page) {
742
+			// now let's setup the file name and class that should be present
743
+			$classname = str_replace('.class.php', '', $page);
744
+			// autoloaders should take care of loading file
745
+			if (! class_exists($classname)) {
746
+				$error_msg[] = sprintf(
747
+					esc_html__(
748
+						'Something went wrong with loading the %s admin hooks page.',
749
+						'event_espresso'
750
+					),
751
+					$page
752
+				);
753
+				$error_msg[] = $error_msg[0]
754
+							   . "\r\n"
755
+							   . sprintf(
756
+								   esc_html__(
757
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
758
+									   'event_espresso'
759
+								   ),
760
+								   $page,
761
+								   '<br />',
762
+								   '<strong>' . $classname . '</strong>'
763
+							   );
764
+				throw new EE_Error(implode('||', $error_msg));
765
+			}
766
+			// notice we are passing the instance of this class to the hook object.
767
+			$this->loader->getShared($classname, [$this]);
768
+		}
769
+	}
770
+
771
+
772
+	/**
773
+	 * @throws ReflectionException
774
+	 * @throws EE_Error
775
+	 */
776
+	public function load_page_dependencies()
777
+	{
778
+		try {
779
+			$this->_load_page_dependencies();
780
+		} catch (EE_Error $e) {
781
+			$e->get_error();
782
+		}
783
+	}
784
+
785
+
786
+	/**
787
+	 * load_page_dependencies
788
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
789
+	 *
790
+	 * @return void
791
+	 * @throws DomainException
792
+	 * @throws EE_Error
793
+	 * @throws InvalidArgumentException
794
+	 * @throws InvalidDataTypeException
795
+	 * @throws InvalidInterfaceException
796
+	 */
797
+	protected function _load_page_dependencies()
798
+	{
799
+		// let's set the current_screen and screen options to override what WP set
800
+		$this->_current_screen = get_current_screen();
801
+		// load admin_notices - global, page class, and view specific
802
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
803
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
804
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
805
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
806
+		}
807
+		// load network admin_notices - global, page class, and view specific
808
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
809
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
810
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
811
+		}
812
+		// this will save any per_page screen options if they are present
813
+		$this->_set_per_page_screen_options();
814
+		// setup list table properties
815
+		$this->_set_list_table();
816
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
817
+		// However in some cases the metaboxes will need to be added within a route handling callback.
818
+		$this->_add_registered_meta_boxes();
819
+		$this->_add_screen_columns();
820
+		// add screen options - global, page child class, and view specific
821
+		$this->_add_global_screen_options();
822
+		$this->_add_screen_options();
823
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
824
+		if (method_exists($this, $add_screen_options)) {
825
+			$this->{$add_screen_options}();
826
+		}
827
+		// add help tab(s) - set via page_config and qtips.
828
+		$this->_add_help_tabs();
829
+		$this->_add_qtips();
830
+		// add feature_pointers - global, page child class, and view specific
831
+		$this->_add_feature_pointers();
832
+		$this->_add_global_feature_pointers();
833
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
834
+		if (method_exists($this, $add_feature_pointer)) {
835
+			$this->{$add_feature_pointer}();
836
+		}
837
+		// enqueue scripts/styles - global, page class, and view specific
838
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
839
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
840
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
841
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
842
+		}
843
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
844
+		// admin_print_footer_scripts - global, page child class, and view specific.
845
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
846
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
847
+		// is a good use case. Notice the late priority we're giving these
848
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
849
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
850
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
851
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
852
+		}
853
+		// admin footer scripts
854
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
855
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
856
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
857
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
858
+		}
859
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
860
+		// targeted hook
861
+		do_action(
862
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
863
+		);
864
+	}
865
+
866
+
867
+	/**
868
+	 * _set_defaults
869
+	 * This sets some global defaults for class properties.
870
+	 */
871
+	private function _set_defaults()
872
+	{
873
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
874
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
875
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
876
+		$this->_page_config          = $this->_default_route_query_args = [];
877
+		$this->_default_nav_tab_name = 'overview';
878
+		// init template args
879
+		$this->_template_args = [
880
+			'admin_page_header'  => '',
881
+			'admin_page_content' => '',
882
+			'post_body_content'  => '',
883
+			'before_list_table'  => '',
884
+			'after_list_table'   => '',
885
+		];
886
+	}
887
+
888
+
889
+	/**
890
+	 * route_admin_request
891
+	 *
892
+	 * @return void
893
+	 * @throws InvalidArgumentException
894
+	 * @throws InvalidInterfaceException
895
+	 * @throws InvalidDataTypeException
896
+	 * @throws EE_Error
897
+	 * @throws ReflectionException
898
+	 * @see    _route_admin_request()
899
+	 */
900
+	public function route_admin_request()
901
+	{
902
+		try {
903
+			$this->_route_admin_request();
904
+		} catch (EE_Error $e) {
905
+			$e->get_error();
906
+		}
907
+	}
908
+
909
+
910
+	public function set_wp_page_slug($wp_page_slug)
911
+	{
912
+		$this->_wp_page_slug = $wp_page_slug;
913
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
914
+		if (is_network_admin()) {
915
+			$this->_wp_page_slug .= '-network';
916
+		}
917
+	}
918
+
919
+
920
+	/**
921
+	 * _verify_routes
922
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
923
+	 * we know if we need to drop out.
924
+	 *
925
+	 * @return bool
926
+	 * @throws EE_Error
927
+	 */
928
+	protected function _verify_routes()
929
+	{
930
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
931
+		if (! $this->_current_page && ! $this->request->isAjax()) {
932
+			return false;
933
+		}
934
+		$this->_route = false;
935
+		// check that the page_routes array is not empty
936
+		if (empty($this->_page_routes)) {
937
+			// user error msg
938
+			$error_msg = sprintf(
939
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
940
+				$this->_admin_page_title
941
+			);
942
+			// developer error msg
943
+			$error_msg .= '||' . $error_msg
944
+						  . esc_html__(
945
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
946
+							  'event_espresso'
947
+						  );
948
+			throw new EE_Error($error_msg);
949
+		}
950
+		// and that the requested page route exists
951
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
952
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
953
+			$this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
954
+		} else {
955
+			// user error msg
956
+			$error_msg = sprintf(
957
+				esc_html__(
958
+					'The requested page route does not exist for the %s admin page.',
959
+					'event_espresso'
960
+				),
961
+				$this->_admin_page_title
962
+			);
963
+			// developer error msg
964
+			$error_msg .= '||' . $error_msg
965
+						  . sprintf(
966
+							  esc_html__(
967
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
968
+								  'event_espresso'
969
+							  ),
970
+							  $this->_req_action
971
+						  );
972
+			throw new EE_Error($error_msg);
973
+		}
974
+		// and that a default route exists
975
+		if (! array_key_exists('default', $this->_page_routes)) {
976
+			// user error msg
977
+			$error_msg = sprintf(
978
+				esc_html__(
979
+					'A default page route has not been set for the % admin page.',
980
+					'event_espresso'
981
+				),
982
+				$this->_admin_page_title
983
+			);
984
+			// developer error msg
985
+			$error_msg .= '||' . $error_msg
986
+						  . esc_html__(
987
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
988
+							  'event_espresso'
989
+						  );
990
+			throw new EE_Error($error_msg);
991
+		}
992
+
993
+		// first lets' catch if the UI request has EVER been set.
994
+		if ($this->_is_UI_request === null) {
995
+			// lets set if this is a UI request or not.
996
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
997
+			// wait a minute... we might have a noheader in the route array
998
+			$this->_is_UI_request = ! (
999
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
1000
+			)
1001
+				? $this->_is_UI_request
1002
+				: false;
1003
+		}
1004
+		$this->_set_current_labels();
1005
+		return true;
1006
+	}
1007
+
1008
+
1009
+	/**
1010
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
1011
+	 *
1012
+	 * @param string $route the route name we're verifying
1013
+	 * @return bool we'll throw an exception if this isn't a valid route.
1014
+	 * @throws EE_Error
1015
+	 */
1016
+	protected function _verify_route($route)
1017
+	{
1018
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
1019
+			return true;
1020
+		}
1021
+		// user error msg
1022
+		$error_msg = sprintf(
1023
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
1024
+			$this->_admin_page_title
1025
+		);
1026
+		// developer error msg
1027
+		$error_msg .= '||' . $error_msg
1028
+					  . sprintf(
1029
+						  esc_html__(
1030
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
1031
+							  'event_espresso'
1032
+						  ),
1033
+						  $route
1034
+					  );
1035
+		throw new EE_Error($error_msg);
1036
+	}
1037
+
1038
+
1039
+	/**
1040
+	 * perform nonce verification
1041
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
1042
+	 * using this method (and save retyping!)
1043
+	 *
1044
+	 * @param string $nonce     The nonce sent
1045
+	 * @param string $nonce_ref The nonce reference string (name0)
1046
+	 * @return void
1047
+	 * @throws EE_Error
1048
+	 * @throws InvalidArgumentException
1049
+	 * @throws InvalidDataTypeException
1050
+	 * @throws InvalidInterfaceException
1051
+	 */
1052
+	protected function _verify_nonce($nonce, $nonce_ref)
1053
+	{
1054
+		// verify nonce against expected value
1055
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
1056
+			// these are not the droids you are looking for !!!
1057
+			$msg = sprintf(
1058
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
1059
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
1060
+				'</a>'
1061
+			);
1062
+			if (WP_DEBUG) {
1063
+				$msg .= "\n  ";
1064
+				$msg .= sprintf(
1065
+					esc_html__(
1066
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
1067
+						'event_espresso'
1068
+					),
1069
+					__CLASS__
1070
+				);
1071
+			}
1072
+			if (! $this->request->isAjax()) {
1073
+				wp_die($msg);
1074
+			}
1075
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1076
+			$this->_return_json();
1077
+		}
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * _route_admin_request()
1083
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1084
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1085
+	 * in the page routes and then will try to load the corresponding method.
1086
+	 *
1087
+	 * @return void
1088
+	 * @throws EE_Error
1089
+	 * @throws InvalidArgumentException
1090
+	 * @throws InvalidDataTypeException
1091
+	 * @throws InvalidInterfaceException
1092
+	 * @throws ReflectionException
1093
+	 */
1094
+	protected function _route_admin_request()
1095
+	{
1096
+		if (! $this->_is_UI_request) {
1097
+			$this->_verify_routes();
1098
+		}
1099
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1100
+		if ($this->_req_action !== 'default' && $nonce_check) {
1101
+			// set nonce from post data
1102
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
1103
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1104
+		}
1105
+		// set the nav_tabs array but ONLY if this is  UI_request
1106
+		if ($this->_is_UI_request) {
1107
+			$this->_set_nav_tabs();
1108
+		}
1109
+		// grab callback function
1110
+		$func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1111
+		// check if callback has args
1112
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1113
+		$error_msg = '';
1114
+		// action right before calling route
1115
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1116
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1117
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1118
+		}
1119
+		// strip _wp_http_referer from the server REQUEST_URI
1120
+		// else it grows in length on every submission due to recursion,
1121
+		// ultimately causing a "Request-URI Too Large" error
1122
+		$request_uri = remove_query_arg(
1123
+			'_wp_http_referer',
1124
+			wp_unslash($this->request->getServerParam('REQUEST_URI'))
1125
+		);
1126
+		// set new value in both our Request object and the super global
1127
+		$this->request->setServerParam('REQUEST_URI', $request_uri, true);
1128
+		if (! empty($func)) {
1129
+			if (is_array($func)) {
1130
+				[$class, $method] = $func;
1131
+			} elseif (strpos($func, '::') !== false) {
1132
+				[$class, $method] = explode('::', $func);
1133
+			} else {
1134
+				$class  = $this;
1135
+				$method = $func;
1136
+			}
1137
+			if (! (is_object($class) && $class === $this)) {
1138
+				// send along this admin page object for access by addons.
1139
+				$args['admin_page_object'] = $this;
1140
+			}
1141
+			if (
1142
+				// is it a method on a class that doesn't work?
1143
+				(
1144
+					(
1145
+						method_exists($class, $method)
1146
+						&& call_user_func_array([$class, $method], $args) === false
1147
+					)
1148
+					&& (
1149
+						// is it a standalone function that doesn't work?
1150
+						function_exists($method)
1151
+						&& call_user_func_array(
1152
+							$func,
1153
+							array_merge(['admin_page_object' => $this], $args)
1154
+						) === false
1155
+					)
1156
+				)
1157
+				|| (
1158
+					// is it neither a class method NOR a standalone function?
1159
+					! method_exists($class, $method)
1160
+					&& ! function_exists($method)
1161
+				)
1162
+			) {
1163
+				// user error msg
1164
+				$error_msg = esc_html__(
1165
+					'An error occurred. The  requested page route could not be found.',
1166
+					'event_espresso'
1167
+				);
1168
+				// developer error msg
1169
+				$error_msg .= '||';
1170
+				$error_msg .= sprintf(
1171
+					esc_html__(
1172
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1173
+						'event_espresso'
1174
+					),
1175
+					$method
1176
+				);
1177
+			}
1178
+			if (! empty($error_msg)) {
1179
+				throw new EE_Error($error_msg);
1180
+			}
1181
+		}
1182
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1183
+		// then we need to reset the routing properties to the new route.
1184
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1185
+		if (
1186
+			$this->_is_UI_request === false
1187
+			&& is_array($this->_route)
1188
+			&& ! empty($this->_route['headers_sent_route'])
1189
+		) {
1190
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1191
+		}
1192
+	}
1193
+
1194
+
1195
+	/**
1196
+	 * This method just allows the resetting of page properties in the case where a no headers
1197
+	 * route redirects to a headers route in its route config.
1198
+	 *
1199
+	 * @param string $new_route New (non header) route to redirect to.
1200
+	 * @return   void
1201
+	 * @throws ReflectionException
1202
+	 * @throws InvalidArgumentException
1203
+	 * @throws InvalidInterfaceException
1204
+	 * @throws InvalidDataTypeException
1205
+	 * @throws EE_Error
1206
+	 * @since   4.3.0
1207
+	 */
1208
+	protected function _reset_routing_properties($new_route)
1209
+	{
1210
+		$this->_is_UI_request = true;
1211
+		// now we set the current route to whatever the headers_sent_route is set at
1212
+		$this->request->setRequestParam('action', $new_route);
1213
+		// rerun page setup
1214
+		$this->_page_setup();
1215
+	}
1216
+
1217
+
1218
+	/**
1219
+	 * _add_query_arg
1220
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1221
+	 *(internally just uses EEH_URL's function with the same name)
1222
+	 *
1223
+	 * @param array  $args
1224
+	 * @param string $url
1225
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1226
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1227
+	 *                                        Example usage: If the current page is:
1228
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1229
+	 *                                        &action=default&event_id=20&month_range=March%202015
1230
+	 *                                        &_wpnonce=5467821
1231
+	 *                                        and you call:
1232
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1233
+	 *                                        array(
1234
+	 *                                        'action' => 'resend_something',
1235
+	 *                                        'page=>espresso_registrations'
1236
+	 *                                        ),
1237
+	 *                                        $some_url,
1238
+	 *                                        true
1239
+	 *                                        );
1240
+	 *                                        It will produce a url in this structure:
1241
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1242
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1243
+	 *                                        month_range]=March%202015
1244
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1245
+	 * @return string
1246
+	 */
1247
+	public static function add_query_args_and_nonce(
1248
+		$args = [],
1249
+		$url = '',
1250
+		$sticky = false,
1251
+		$exclude_nonce = false
1252
+	) {
1253
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1254
+		if ($sticky) {
1255
+			/** @var RequestInterface $request */
1256
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1257
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1258
+			$request->unSetServerParam('_wp_http_referer', true);
1259
+			foreach ($request->requestParams() as $key => $value) {
1260
+				// do not add nonces
1261
+				if (strpos($key, 'nonce') !== false) {
1262
+					continue;
1263
+				}
1264
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1265
+			}
1266
+		}
1267
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1268
+	}
1269
+
1270
+
1271
+	/**
1272
+	 * This returns a generated link that will load the related help tab.
1273
+	 *
1274
+	 * @param string $help_tab_id the id for the connected help tab
1275
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1276
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1277
+	 * @return string              generated link
1278
+	 * @uses EEH_Template::get_help_tab_link()
1279
+	 */
1280
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1281
+	{
1282
+		return EEH_Template::get_help_tab_link(
1283
+			$help_tab_id,
1284
+			$this->page_slug,
1285
+			$this->_req_action,
1286
+			$icon_style,
1287
+			$help_text
1288
+		);
1289
+	}
1290
+
1291
+
1292
+	/**
1293
+	 * _add_help_tabs
1294
+	 * Note child classes define their help tabs within the page_config array.
1295
+	 *
1296
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1297
+	 * @return void
1298
+	 * @throws DomainException
1299
+	 * @throws EE_Error
1300
+	 * @throws ReflectionException
1301
+	 */
1302
+	protected function _add_help_tabs()
1303
+	{
1304
+		if (isset($this->_page_config[ $this->_req_action ])) {
1305
+			$config = $this->_page_config[ $this->_req_action ];
1306
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1307
+			if (is_array($config) && isset($config['help_sidebar'])) {
1308
+				// check that the callback given is valid
1309
+				if (! method_exists($this, $config['help_sidebar'])) {
1310
+					throw new EE_Error(
1311
+						sprintf(
1312
+							esc_html__(
1313
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1314
+								'event_espresso'
1315
+							),
1316
+							$config['help_sidebar'],
1317
+							$this->class_name
1318
+						)
1319
+					);
1320
+				}
1321
+				$content = apply_filters(
1322
+					'FHEE__' . $this->class_name . '__add_help_tabs__help_sidebar',
1323
+					$this->{$config['help_sidebar']}()
1324
+				);
1325
+				$this->_current_screen->set_help_sidebar($content);
1326
+			}
1327
+			if (! isset($config['help_tabs'])) {
1328
+				return;
1329
+			} //no help tabs for this route
1330
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1331
+				// we're here so there ARE help tabs!
1332
+				// make sure we've got what we need
1333
+				if (! isset($cfg['title'])) {
1334
+					throw new EE_Error(
1335
+						esc_html__(
1336
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1337
+							'event_espresso'
1338
+						)
1339
+					);
1340
+				}
1341
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1342
+					throw new EE_Error(
1343
+						esc_html__(
1344
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1345
+							'event_espresso'
1346
+						)
1347
+					);
1348
+				}
1349
+				// first priority goes to content.
1350
+				if (! empty($cfg['content'])) {
1351
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1352
+					// second priority goes to filename
1353
+				} elseif (! empty($cfg['filename'])) {
1354
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1355
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1356
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1357
+															 . basename($this->_get_dir())
1358
+															 . '/help_tabs/'
1359
+															 . $cfg['filename']
1360
+															 . '.help_tab.php' : $file_path;
1361
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1362
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1363
+						EE_Error::add_error(
1364
+							sprintf(
1365
+								esc_html__(
1366
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1367
+									'event_espresso'
1368
+								),
1369
+								$tab_id,
1370
+								key($config),
1371
+								$file_path
1372
+							),
1373
+							__FILE__,
1374
+							__FUNCTION__,
1375
+							__LINE__
1376
+						);
1377
+						return;
1378
+					}
1379
+					$template_args['admin_page_obj'] = $this;
1380
+					$content                         = EEH_Template::display_template(
1381
+						$file_path,
1382
+						$template_args,
1383
+						true
1384
+					);
1385
+				} else {
1386
+					$content = '';
1387
+				}
1388
+				// check if callback is valid
1389
+				if (
1390
+					empty($content)
1391
+					&& (
1392
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1393
+					)
1394
+				) {
1395
+					EE_Error::add_error(
1396
+						sprintf(
1397
+							esc_html__(
1398
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1399
+								'event_espresso'
1400
+							),
1401
+							$cfg['title']
1402
+						),
1403
+						__FILE__,
1404
+						__FUNCTION__,
1405
+						__LINE__
1406
+					);
1407
+					return;
1408
+				}
1409
+				// setup config array for help tab method
1410
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1411
+				$_ht = [
1412
+					'id'       => $id,
1413
+					'title'    => $cfg['title'],
1414
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1415
+					'content'  => $content,
1416
+				];
1417
+				$this->_current_screen->add_help_tab($_ht);
1418
+			}
1419
+		}
1420
+	}
1421
+
1422
+
1423
+	/**
1424
+	 * This simply sets up any qtips that have been defined in the page config
1425
+	 *
1426
+	 * @return void
1427
+	 * @throws ReflectionException
1428
+	 * @throws EE_Error
1429
+	 */
1430
+	protected function _add_qtips()
1431
+	{
1432
+		if (isset($this->_route_config['qtips'])) {
1433
+			$qtips = (array) $this->_route_config['qtips'];
1434
+			// load qtip loader
1435
+			$path = [
1436
+				$this->_get_dir() . '/qtips/',
1437
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1438
+			];
1439
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1440
+		}
1441
+	}
1442
+
1443
+
1444
+	/**
1445
+	 * _set_nav_tabs
1446
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1447
+	 * wish to add additional tabs or modify accordingly.
1448
+	 *
1449
+	 * @return void
1450
+	 * @throws InvalidArgumentException
1451
+	 * @throws InvalidInterfaceException
1452
+	 * @throws InvalidDataTypeException
1453
+	 */
1454
+	protected function _set_nav_tabs()
1455
+	{
1456
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1457
+		$i = 0;
1458
+		foreach ($this->_page_config as $slug => $config) {
1459
+			if (! is_array($config) || empty($config['nav'])) {
1460
+				continue;
1461
+			}
1462
+			// no nav tab for this config
1463
+			// check for persistent flag
1464
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1465
+				// nav tab is only to appear when route requested.
1466
+				continue;
1467
+			}
1468
+			if (! $this->check_user_access($slug, true)) {
1469
+				// no nav tab because current user does not have access.
1470
+				continue;
1471
+			}
1472
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1473
+			$this->_nav_tabs[ $slug ] = [
1474
+				'url'       => isset($config['nav']['url'])
1475
+					? $config['nav']['url']
1476
+					: EE_Admin_Page::add_query_args_and_nonce(
1477
+						['action' => $slug],
1478
+						$this->_admin_base_url
1479
+					),
1480
+				'link_text' => isset($config['nav']['label'])
1481
+					? $config['nav']['label']
1482
+					: ucwords(
1483
+						str_replace('_', ' ', $slug)
1484
+					),
1485
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1486
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1487
+			];
1488
+			$i++;
1489
+		}
1490
+		// if $this->_nav_tabs is empty then lets set the default
1491
+		if (empty($this->_nav_tabs)) {
1492
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1493
+				'url'       => $this->_admin_base_url,
1494
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1495
+				'css_class' => 'nav-tab-active',
1496
+				'order'     => 10,
1497
+			];
1498
+		}
1499
+		// now let's sort the tabs according to order
1500
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1501
+	}
1502
+
1503
+
1504
+	/**
1505
+	 * _set_current_labels
1506
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1507
+	 * property array
1508
+	 *
1509
+	 * @return void
1510
+	 */
1511
+	private function _set_current_labels()
1512
+	{
1513
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1514
+			foreach ($this->_route_config['labels'] as $label => $text) {
1515
+				if (is_array($text)) {
1516
+					foreach ($text as $sublabel => $subtext) {
1517
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1518
+					}
1519
+				} else {
1520
+					$this->_labels[ $label ] = $text;
1521
+				}
1522
+			}
1523
+		}
1524
+	}
1525
+
1526
+
1527
+	/**
1528
+	 *        verifies user access for this admin page
1529
+	 *
1530
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1531
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1532
+	 *                               return false if verify fail.
1533
+	 * @return bool
1534
+	 * @throws InvalidArgumentException
1535
+	 * @throws InvalidDataTypeException
1536
+	 * @throws InvalidInterfaceException
1537
+	 */
1538
+	public function check_user_access($route_to_check = '', $verify_only = false)
1539
+	{
1540
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1541
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1542
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1543
+						  && is_array(
1544
+							  $this->_page_routes[ $route_to_check ]
1545
+						  )
1546
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1547
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1548
+		if (empty($capability) && empty($route_to_check)) {
1549
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1550
+				: $this->_route['capability'];
1551
+		} else {
1552
+			$capability = empty($capability) ? 'manage_options' : $capability;
1553
+		}
1554
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1555
+		if (
1556
+			! $this->request->isAjax()
1557
+			&& (
1558
+				! function_exists('is_admin')
1559
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1560
+					$capability,
1561
+					$this->page_slug
1562
+					. '_'
1563
+					. $route_to_check,
1564
+					$id
1565
+				)
1566
+			)
1567
+		) {
1568
+			if ($verify_only) {
1569
+				return false;
1570
+			}
1571
+			if (is_user_logged_in()) {
1572
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1573
+			} else {
1574
+				return false;
1575
+			}
1576
+		}
1577
+		return true;
1578
+	}
1579
+
1580
+
1581
+	/**
1582
+	 * @param string                 $box_id
1583
+	 * @param string                 $title
1584
+	 * @param callable|string|null   $callback
1585
+	 * @param string|array|WP_Screen $screen
1586
+	 * @param string                 $context
1587
+	 * @param string                 $priority
1588
+	 * @param array|null             $callback_args
1589
+	 */
1590
+	protected function addMetaBox(
1591
+		string $box_id,
1592
+		string $title,
1593
+		$callback,
1594
+		$screen,
1595
+		string $context = 'normal',
1596
+		string $priority = 'default',
1597
+		?array $callback_args = null
1598
+	) {
1599
+		if (! is_callable($callback)) {
1600
+			return;
1601
+		}
1602
+
1603
+		add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1604
+		add_filter(
1605
+			"postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1606
+			function ($classes) {
1607
+				array_push($classes, 'ee-admin-container');
1608
+				return $classes;
1609
+			}
1610
+		);
1611
+	}
1612
+
1613
+
1614
+	/**
1615
+	 * admin_init_global
1616
+	 * This runs all the code that we want executed within the WP admin_init hook.
1617
+	 * This method executes for ALL EE Admin pages.
1618
+	 *
1619
+	 * @return void
1620
+	 */
1621
+	public function admin_init_global()
1622
+	{
1623
+	}
1624
+
1625
+
1626
+	/**
1627
+	 * wp_loaded_global
1628
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1629
+	 * EE_Admin page and will execute on every EE Admin Page load
1630
+	 *
1631
+	 * @return void
1632
+	 */
1633
+	public function wp_loaded()
1634
+	{
1635
+	}
1636
+
1637
+
1638
+	/**
1639
+	 * admin_notices
1640
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1641
+	 * ALL EE_Admin pages.
1642
+	 *
1643
+	 * @return void
1644
+	 */
1645
+	public function admin_notices_global()
1646
+	{
1647
+		$this->_display_no_javascript_warning();
1648
+		$this->_display_espresso_notices();
1649
+	}
1650
+
1651
+
1652
+	public function network_admin_notices_global()
1653
+	{
1654
+		$this->_display_no_javascript_warning();
1655
+		$this->_display_espresso_notices();
1656
+	}
1657
+
1658
+
1659
+	/**
1660
+	 * admin_footer_scripts_global
1661
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1662
+	 * will apply on ALL EE_Admin pages.
1663
+	 *
1664
+	 * @return void
1665
+	 */
1666
+	public function admin_footer_scripts_global()
1667
+	{
1668
+		$this->_add_admin_page_ajax_loading_img();
1669
+		$this->_add_admin_page_overlay();
1670
+		// if metaboxes are present we need to add the nonce field
1671
+		if (
1672
+			isset($this->_route_config['metaboxes'])
1673
+			|| isset($this->_route_config['list_table'])
1674
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1675
+		) {
1676
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1677
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1678
+		}
1679
+	}
1680
+
1681
+
1682
+	/**
1683
+	 * admin_footer_global
1684
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1685
+	 * This particular method will apply on ALL EE_Admin Pages.
1686
+	 *
1687
+	 * @return void
1688
+	 */
1689
+	public function admin_footer_global()
1690
+	{
1691
+		// dialog container for dialog helper
1692
+		echo '
1693 1693
         <div class="ee-admin-dialog-container auto-hide hidden">
1694 1694
             <div class="ee-notices"></div>
1695 1695
             <div class="ee-admin-dialog-container-inner-content"></div>
1696 1696
         </div>
1697 1697
         ';
1698 1698
 
1699
-        // current set timezone for timezone js
1700
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1701
-    }
1702
-
1703
-
1704
-    /**
1705
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1706
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1707
-     * help popups then in your templates or your content you set "triggers" for the content using the
1708
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1709
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1710
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1711
-     * for the
1712
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1713
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1714
-     *    'help_trigger_id' => array(
1715
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1716
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1717
-     *    )
1718
-     * );
1719
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1720
-     *
1721
-     * @param array $help_array
1722
-     * @param bool  $display
1723
-     * @return string content
1724
-     * @throws DomainException
1725
-     * @throws EE_Error
1726
-     */
1727
-    protected function _set_help_popup_content($help_array = [], $display = false)
1728
-    {
1729
-        $content    = '';
1730
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1731
-        // loop through the array and setup content
1732
-        foreach ($help_array as $trigger => $help) {
1733
-            // make sure the array is setup properly
1734
-            if (! isset($help['title'], $help['content'])) {
1735
-                throw new EE_Error(
1736
-                    esc_html__(
1737
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1738
-                        'event_espresso'
1739
-                    )
1740
-                );
1741
-            }
1742
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1743
-            $template_args = [
1744
-                'help_popup_id'      => $trigger,
1745
-                'help_popup_title'   => $help['title'],
1746
-                'help_popup_content' => $help['content'],
1747
-            ];
1748
-            $content       .= EEH_Template::display_template(
1749
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1750
-                $template_args,
1751
-                true
1752
-            );
1753
-        }
1754
-        if ($display) {
1755
-            echo $content; // already escaped
1756
-            return '';
1757
-        }
1758
-        return $content;
1759
-    }
1760
-
1761
-
1762
-    /**
1763
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1764
-     *
1765
-     * @return array properly formatted array for help popup content
1766
-     * @throws EE_Error
1767
-     */
1768
-    private function _get_help_content()
1769
-    {
1770
-        // what is the method we're looking for?
1771
-        $method_name = '_help_popup_content_' . $this->_req_action;
1772
-        // if method doesn't exist let's get out.
1773
-        if (! method_exists($this, $method_name)) {
1774
-            return [];
1775
-        }
1776
-        // k we're good to go let's retrieve the help array
1777
-        $help_array = $this->{$method_name}();
1778
-        // make sure we've got an array!
1779
-        if (! is_array($help_array)) {
1780
-            throw new EE_Error(
1781
-                esc_html__(
1782
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1783
-                    'event_espresso'
1784
-                )
1785
-            );
1786
-        }
1787
-        return $help_array;
1788
-    }
1789
-
1790
-
1791
-    /**
1792
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1793
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1794
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1795
-     *
1796
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1797
-     * @param boolean $display    if false then we return the trigger string
1798
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1799
-     * @return string
1800
-     * @throws DomainException
1801
-     * @throws EE_Error
1802
-     */
1803
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1804
-    {
1805
-        if ($this->request->isAjax()) {
1806
-            return '';
1807
-        }
1808
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1809
-        $help_array   = $this->_get_help_content();
1810
-        $help_content = '';
1811
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1812
-            $help_array[ $trigger_id ] = [
1813
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1814
-                'content' => esc_html__(
1815
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1816
-                    'event_espresso'
1817
-                ),
1818
-            ];
1819
-            $help_content = $this->_set_help_popup_content($help_array);
1820
-        }
1821
-        // let's setup the trigger
1822
-        $content = '<a class="ee-dialog" href="?height='
1823
-                   . esc_attr($dimensions[0])
1824
-                   . '&width='
1825
-                   . esc_attr($dimensions[1])
1826
-                   . '&inlineId='
1827
-                   . esc_attr($trigger_id)
1828
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1829
-        $content .= $help_content;
1830
-        if ($display) {
1831
-            echo $content; // already escaped
1832
-            return '';
1833
-        }
1834
-        return $content;
1835
-    }
1836
-
1837
-
1838
-    /**
1839
-     * _add_global_screen_options
1840
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1841
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1842
-     *
1843
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1844
-     *         see also WP_Screen object documents...
1845
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1846
-     * @abstract
1847
-     * @return void
1848
-     */
1849
-    private function _add_global_screen_options()
1850
-    {
1851
-    }
1852
-
1853
-
1854
-    /**
1855
-     * _add_global_feature_pointers
1856
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1857
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1858
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1859
-     *
1860
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1861
-     *         extended) also see:
1862
-     * @link   http://eamann.com/tech/wordpress-portland/
1863
-     * @abstract
1864
-     * @return void
1865
-     */
1866
-    private function _add_global_feature_pointers()
1867
-    {
1868
-    }
1869
-
1870
-
1871
-    /**
1872
-     * load_global_scripts_styles
1873
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1874
-     *
1875
-     * @return void
1876
-     */
1877
-    public function load_global_scripts_styles()
1878
-    {
1879
-        // add debugging styles
1880
-        if (WP_DEBUG) {
1881
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1882
-        }
1883
-        // taking care of metaboxes
1884
-        if (
1885
-            empty($this->_cpt_route)
1886
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1887
-        ) {
1888
-            wp_enqueue_script('dashboard');
1889
-        }
1890
-
1891
-        wp_enqueue_script(JqueryAssetManager::JS_HANDLE_JQUERY_UI_TOUCH_PUNCH);
1892
-        wp_enqueue_script(EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN);
1893
-        // LOCALIZED DATA
1894
-        // localize script for ajax lazy loading
1895
-        wp_localize_script(
1896
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
1897
-            'eeLazyLoadingContainers',
1898
-            apply_filters(
1899
-                'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1900
-                ['espresso_news_post_box_content']
1901
-            )
1902
-        );
1903
-        StatusChangeNotice::loadAssets();
1904
-
1905
-        add_filter(
1906
-            'admin_body_class',
1907
-            function ($classes) {
1908
-                if (strpos($classes, 'espresso-admin') === false) {
1909
-                    $classes .= ' espresso-admin';
1910
-                }
1911
-                return $classes;
1912
-            }
1913
-        );
1914
-    }
1915
-
1916
-
1917
-    /**
1918
-     *        admin_footer_scripts_eei18n_js_strings
1919
-     *
1920
-     * @return        void
1921
-     */
1922
-    public function admin_footer_scripts_eei18n_js_strings()
1923
-    {
1924
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1925
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1926
-            __(
1927
-                'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
1928
-                'event_espresso'
1929
-            )
1930
-        );
1931
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1932
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1933
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1934
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1935
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1936
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1937
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1938
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1939
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1940
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1941
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1942
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1943
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1944
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1945
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1946
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1947
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1948
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1949
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1950
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1951
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1952
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1953
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1954
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1955
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1956
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1957
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1958
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1959
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1960
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1961
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1962
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1963
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1964
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1965
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1966
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1967
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1968
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1969
-    }
1970
-
1971
-
1972
-    /**
1973
-     *        load enhanced xdebug styles for ppl with failing eyesight
1974
-     *
1975
-     * @return        void
1976
-     */
1977
-    public function add_xdebug_style()
1978
-    {
1979
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1980
-    }
1981
-
1982
-
1983
-    /************************/
1984
-    /** LIST TABLE METHODS **/
1985
-    /************************/
1986
-    /**
1987
-     * this sets up the list table if the current view requires it.
1988
-     *
1989
-     * @return void
1990
-     * @throws EE_Error
1991
-     * @throws InvalidArgumentException
1992
-     * @throws InvalidDataTypeException
1993
-     * @throws InvalidInterfaceException
1994
-     */
1995
-    protected function _set_list_table()
1996
-    {
1997
-        // first is this a list_table view?
1998
-        if (! isset($this->_route_config['list_table'])) {
1999
-            return;
2000
-        } //not a list_table view so get out.
2001
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2002
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2003
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2004
-            // user error msg
2005
-            $error_msg = esc_html__(
2006
-                'An error occurred. The requested list table views could not be found.',
2007
-                'event_espresso'
2008
-            );
2009
-            // developer error msg
2010
-            $error_msg .= '||'
2011
-                          . sprintf(
2012
-                              esc_html__(
2013
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2014
-                                  'event_espresso'
2015
-                              ),
2016
-                              $this->_req_action,
2017
-                              $list_table_view
2018
-                          );
2019
-            throw new EE_Error($error_msg);
2020
-        }
2021
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2022
-        $this->_views = apply_filters(
2023
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2024
-            $this->_views
2025
-        );
2026
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2027
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2028
-        $this->_set_list_table_view();
2029
-        $this->_set_list_table_object();
2030
-    }
2031
-
2032
-
2033
-    /**
2034
-     * set current view for List Table
2035
-     *
2036
-     * @return void
2037
-     */
2038
-    protected function _set_list_table_view()
2039
-    {
2040
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2041
-        $status = $this->request->getRequestParam('status', null, 'key');
2042
-        $this->_view = $status && array_key_exists($status, $this->_views)
2043
-            ? $status
2044
-            : $this->_view;
2045
-    }
2046
-
2047
-
2048
-    /**
2049
-     * _set_list_table_object
2050
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2051
-     *
2052
-     * @throws InvalidInterfaceException
2053
-     * @throws InvalidArgumentException
2054
-     * @throws InvalidDataTypeException
2055
-     * @throws EE_Error
2056
-     * @throws InvalidInterfaceException
2057
-     */
2058
-    protected function _set_list_table_object()
2059
-    {
2060
-        if (isset($this->_route_config['list_table'])) {
2061
-            if (! class_exists($this->_route_config['list_table'])) {
2062
-                throw new EE_Error(
2063
-                    sprintf(
2064
-                        esc_html__(
2065
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2066
-                            'event_espresso'
2067
-                        ),
2068
-                        $this->_route_config['list_table'],
2069
-                        $this->class_name
2070
-                    )
2071
-                );
2072
-            }
2073
-            $this->_list_table_object = $this->loader->getShared(
2074
-                $this->_route_config['list_table'],
2075
-                [$this]
2076
-            );
2077
-        }
2078
-    }
2079
-
2080
-
2081
-    /**
2082
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2083
-     *
2084
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2085
-     *                                                    urls.  The array should be indexed by the view it is being
2086
-     *                                                    added to.
2087
-     * @return array
2088
-     */
2089
-    public function get_list_table_view_RLs($extra_query_args = [])
2090
-    {
2091
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2092
-        if (empty($this->_views)) {
2093
-            $this->_views = [];
2094
-        }
2095
-        // cycle thru views
2096
-        foreach ($this->_views as $key => $view) {
2097
-            $query_args = [];
2098
-            // check for current view
2099
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2100
-            $query_args['action']                        = $this->_req_action;
2101
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2102
-            $query_args['status']                        = $view['slug'];
2103
-            // merge any other arguments sent in.
2104
-            if (isset($extra_query_args[ $view['slug'] ])) {
2105
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2106
-                    $query_args[] = $extra_query_arg;
2107
-                }
2108
-            }
2109
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2110
-        }
2111
-        return $this->_views;
2112
-    }
2113
-
2114
-
2115
-    /**
2116
-     * _entries_per_page_dropdown
2117
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2118
-     *
2119
-     * @param int $max_entries total number of rows in the table
2120
-     * @return string
2121
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2122
-     *         WP does it.
2123
-     */
2124
-    protected function _entries_per_page_dropdown($max_entries = 0)
2125
-    {
2126
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2127
-        $values   = [10, 25, 50, 100];
2128
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2129
-        if ($max_entries) {
2130
-            $values[] = $max_entries;
2131
-            sort($values);
2132
-        }
2133
-        $entries_per_page_dropdown = '
1699
+		// current set timezone for timezone js
1700
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1701
+	}
1702
+
1703
+
1704
+	/**
1705
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1706
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1707
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1708
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1709
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1710
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1711
+	 * for the
1712
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1713
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1714
+	 *    'help_trigger_id' => array(
1715
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1716
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1717
+	 *    )
1718
+	 * );
1719
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1720
+	 *
1721
+	 * @param array $help_array
1722
+	 * @param bool  $display
1723
+	 * @return string content
1724
+	 * @throws DomainException
1725
+	 * @throws EE_Error
1726
+	 */
1727
+	protected function _set_help_popup_content($help_array = [], $display = false)
1728
+	{
1729
+		$content    = '';
1730
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1731
+		// loop through the array and setup content
1732
+		foreach ($help_array as $trigger => $help) {
1733
+			// make sure the array is setup properly
1734
+			if (! isset($help['title'], $help['content'])) {
1735
+				throw new EE_Error(
1736
+					esc_html__(
1737
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1738
+						'event_espresso'
1739
+					)
1740
+				);
1741
+			}
1742
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1743
+			$template_args = [
1744
+				'help_popup_id'      => $trigger,
1745
+				'help_popup_title'   => $help['title'],
1746
+				'help_popup_content' => $help['content'],
1747
+			];
1748
+			$content       .= EEH_Template::display_template(
1749
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1750
+				$template_args,
1751
+				true
1752
+			);
1753
+		}
1754
+		if ($display) {
1755
+			echo $content; // already escaped
1756
+			return '';
1757
+		}
1758
+		return $content;
1759
+	}
1760
+
1761
+
1762
+	/**
1763
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1764
+	 *
1765
+	 * @return array properly formatted array for help popup content
1766
+	 * @throws EE_Error
1767
+	 */
1768
+	private function _get_help_content()
1769
+	{
1770
+		// what is the method we're looking for?
1771
+		$method_name = '_help_popup_content_' . $this->_req_action;
1772
+		// if method doesn't exist let's get out.
1773
+		if (! method_exists($this, $method_name)) {
1774
+			return [];
1775
+		}
1776
+		// k we're good to go let's retrieve the help array
1777
+		$help_array = $this->{$method_name}();
1778
+		// make sure we've got an array!
1779
+		if (! is_array($help_array)) {
1780
+			throw new EE_Error(
1781
+				esc_html__(
1782
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1783
+					'event_espresso'
1784
+				)
1785
+			);
1786
+		}
1787
+		return $help_array;
1788
+	}
1789
+
1790
+
1791
+	/**
1792
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1793
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1794
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1795
+	 *
1796
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1797
+	 * @param boolean $display    if false then we return the trigger string
1798
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1799
+	 * @return string
1800
+	 * @throws DomainException
1801
+	 * @throws EE_Error
1802
+	 */
1803
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1804
+	{
1805
+		if ($this->request->isAjax()) {
1806
+			return '';
1807
+		}
1808
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1809
+		$help_array   = $this->_get_help_content();
1810
+		$help_content = '';
1811
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1812
+			$help_array[ $trigger_id ] = [
1813
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1814
+				'content' => esc_html__(
1815
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1816
+					'event_espresso'
1817
+				),
1818
+			];
1819
+			$help_content = $this->_set_help_popup_content($help_array);
1820
+		}
1821
+		// let's setup the trigger
1822
+		$content = '<a class="ee-dialog" href="?height='
1823
+				   . esc_attr($dimensions[0])
1824
+				   . '&width='
1825
+				   . esc_attr($dimensions[1])
1826
+				   . '&inlineId='
1827
+				   . esc_attr($trigger_id)
1828
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1829
+		$content .= $help_content;
1830
+		if ($display) {
1831
+			echo $content; // already escaped
1832
+			return '';
1833
+		}
1834
+		return $content;
1835
+	}
1836
+
1837
+
1838
+	/**
1839
+	 * _add_global_screen_options
1840
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1841
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1842
+	 *
1843
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1844
+	 *         see also WP_Screen object documents...
1845
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1846
+	 * @abstract
1847
+	 * @return void
1848
+	 */
1849
+	private function _add_global_screen_options()
1850
+	{
1851
+	}
1852
+
1853
+
1854
+	/**
1855
+	 * _add_global_feature_pointers
1856
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1857
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1858
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1859
+	 *
1860
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1861
+	 *         extended) also see:
1862
+	 * @link   http://eamann.com/tech/wordpress-portland/
1863
+	 * @abstract
1864
+	 * @return void
1865
+	 */
1866
+	private function _add_global_feature_pointers()
1867
+	{
1868
+	}
1869
+
1870
+
1871
+	/**
1872
+	 * load_global_scripts_styles
1873
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1874
+	 *
1875
+	 * @return void
1876
+	 */
1877
+	public function load_global_scripts_styles()
1878
+	{
1879
+		// add debugging styles
1880
+		if (WP_DEBUG) {
1881
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1882
+		}
1883
+		// taking care of metaboxes
1884
+		if (
1885
+			empty($this->_cpt_route)
1886
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1887
+		) {
1888
+			wp_enqueue_script('dashboard');
1889
+		}
1890
+
1891
+		wp_enqueue_script(JqueryAssetManager::JS_HANDLE_JQUERY_UI_TOUCH_PUNCH);
1892
+		wp_enqueue_script(EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN);
1893
+		// LOCALIZED DATA
1894
+		// localize script for ajax lazy loading
1895
+		wp_localize_script(
1896
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
1897
+			'eeLazyLoadingContainers',
1898
+			apply_filters(
1899
+				'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1900
+				['espresso_news_post_box_content']
1901
+			)
1902
+		);
1903
+		StatusChangeNotice::loadAssets();
1904
+
1905
+		add_filter(
1906
+			'admin_body_class',
1907
+			function ($classes) {
1908
+				if (strpos($classes, 'espresso-admin') === false) {
1909
+					$classes .= ' espresso-admin';
1910
+				}
1911
+				return $classes;
1912
+			}
1913
+		);
1914
+	}
1915
+
1916
+
1917
+	/**
1918
+	 *        admin_footer_scripts_eei18n_js_strings
1919
+	 *
1920
+	 * @return        void
1921
+	 */
1922
+	public function admin_footer_scripts_eei18n_js_strings()
1923
+	{
1924
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1925
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1926
+			__(
1927
+				'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
1928
+				'event_espresso'
1929
+			)
1930
+		);
1931
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1932
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1933
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1934
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1935
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1936
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1937
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1938
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1939
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1940
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1941
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1942
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1943
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1944
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1945
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1946
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1947
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1948
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1949
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1950
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1951
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1952
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1953
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1954
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1955
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1956
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1957
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1958
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1959
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1960
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1961
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1962
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1963
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1964
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1965
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1966
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1967
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1968
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1969
+	}
1970
+
1971
+
1972
+	/**
1973
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1974
+	 *
1975
+	 * @return        void
1976
+	 */
1977
+	public function add_xdebug_style()
1978
+	{
1979
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1980
+	}
1981
+
1982
+
1983
+	/************************/
1984
+	/** LIST TABLE METHODS **/
1985
+	/************************/
1986
+	/**
1987
+	 * this sets up the list table if the current view requires it.
1988
+	 *
1989
+	 * @return void
1990
+	 * @throws EE_Error
1991
+	 * @throws InvalidArgumentException
1992
+	 * @throws InvalidDataTypeException
1993
+	 * @throws InvalidInterfaceException
1994
+	 */
1995
+	protected function _set_list_table()
1996
+	{
1997
+		// first is this a list_table view?
1998
+		if (! isset($this->_route_config['list_table'])) {
1999
+			return;
2000
+		} //not a list_table view so get out.
2001
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2002
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2003
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2004
+			// user error msg
2005
+			$error_msg = esc_html__(
2006
+				'An error occurred. The requested list table views could not be found.',
2007
+				'event_espresso'
2008
+			);
2009
+			// developer error msg
2010
+			$error_msg .= '||'
2011
+						  . sprintf(
2012
+							  esc_html__(
2013
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2014
+								  'event_espresso'
2015
+							  ),
2016
+							  $this->_req_action,
2017
+							  $list_table_view
2018
+						  );
2019
+			throw new EE_Error($error_msg);
2020
+		}
2021
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2022
+		$this->_views = apply_filters(
2023
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2024
+			$this->_views
2025
+		);
2026
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2027
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2028
+		$this->_set_list_table_view();
2029
+		$this->_set_list_table_object();
2030
+	}
2031
+
2032
+
2033
+	/**
2034
+	 * set current view for List Table
2035
+	 *
2036
+	 * @return void
2037
+	 */
2038
+	protected function _set_list_table_view()
2039
+	{
2040
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2041
+		$status = $this->request->getRequestParam('status', null, 'key');
2042
+		$this->_view = $status && array_key_exists($status, $this->_views)
2043
+			? $status
2044
+			: $this->_view;
2045
+	}
2046
+
2047
+
2048
+	/**
2049
+	 * _set_list_table_object
2050
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2051
+	 *
2052
+	 * @throws InvalidInterfaceException
2053
+	 * @throws InvalidArgumentException
2054
+	 * @throws InvalidDataTypeException
2055
+	 * @throws EE_Error
2056
+	 * @throws InvalidInterfaceException
2057
+	 */
2058
+	protected function _set_list_table_object()
2059
+	{
2060
+		if (isset($this->_route_config['list_table'])) {
2061
+			if (! class_exists($this->_route_config['list_table'])) {
2062
+				throw new EE_Error(
2063
+					sprintf(
2064
+						esc_html__(
2065
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2066
+							'event_espresso'
2067
+						),
2068
+						$this->_route_config['list_table'],
2069
+						$this->class_name
2070
+					)
2071
+				);
2072
+			}
2073
+			$this->_list_table_object = $this->loader->getShared(
2074
+				$this->_route_config['list_table'],
2075
+				[$this]
2076
+			);
2077
+		}
2078
+	}
2079
+
2080
+
2081
+	/**
2082
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2083
+	 *
2084
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2085
+	 *                                                    urls.  The array should be indexed by the view it is being
2086
+	 *                                                    added to.
2087
+	 * @return array
2088
+	 */
2089
+	public function get_list_table_view_RLs($extra_query_args = [])
2090
+	{
2091
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2092
+		if (empty($this->_views)) {
2093
+			$this->_views = [];
2094
+		}
2095
+		// cycle thru views
2096
+		foreach ($this->_views as $key => $view) {
2097
+			$query_args = [];
2098
+			// check for current view
2099
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2100
+			$query_args['action']                        = $this->_req_action;
2101
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2102
+			$query_args['status']                        = $view['slug'];
2103
+			// merge any other arguments sent in.
2104
+			if (isset($extra_query_args[ $view['slug'] ])) {
2105
+				foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2106
+					$query_args[] = $extra_query_arg;
2107
+				}
2108
+			}
2109
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2110
+		}
2111
+		return $this->_views;
2112
+	}
2113
+
2114
+
2115
+	/**
2116
+	 * _entries_per_page_dropdown
2117
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2118
+	 *
2119
+	 * @param int $max_entries total number of rows in the table
2120
+	 * @return string
2121
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2122
+	 *         WP does it.
2123
+	 */
2124
+	protected function _entries_per_page_dropdown($max_entries = 0)
2125
+	{
2126
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2127
+		$values   = [10, 25, 50, 100];
2128
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2129
+		if ($max_entries) {
2130
+			$values[] = $max_entries;
2131
+			sort($values);
2132
+		}
2133
+		$entries_per_page_dropdown = '
2134 2134
 			<div id="entries-per-page-dv" class="alignleft actions">
2135 2135
 				<label class="hide-if-no-js">
2136 2136
 					Show
2137 2137
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2138
-        foreach ($values as $value) {
2139
-            if ($value < $max_entries) {
2140
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2141
-                $entries_per_page_dropdown .= '
2138
+		foreach ($values as $value) {
2139
+			if ($value < $max_entries) {
2140
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2141
+				$entries_per_page_dropdown .= '
2142 2142
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2143
-            }
2144
-        }
2145
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2146
-        $entries_per_page_dropdown .= '
2143
+			}
2144
+		}
2145
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2146
+		$entries_per_page_dropdown .= '
2147 2147
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2148
-        $entries_per_page_dropdown .= '
2148
+		$entries_per_page_dropdown .= '
2149 2149
 					</select>
2150 2150
 					entries
2151 2151
 				</label>
2152 2152
 				<input id="entries-per-page-btn" class="button button--secondary" type="submit" value="Go" >
2153 2153
 			</div>
2154 2154
 		';
2155
-        return $entries_per_page_dropdown;
2156
-    }
2157
-
2158
-
2159
-    /**
2160
-     *        _set_search_attributes
2161
-     *
2162
-     * @return        void
2163
-     */
2164
-    public function _set_search_attributes()
2165
-    {
2166
-        $this->_template_args['search']['btn_label'] = sprintf(
2167
-            esc_html__('Search %s', 'event_espresso'),
2168
-            empty($this->_search_btn_label) ? $this->page_label
2169
-                : $this->_search_btn_label
2170
-        );
2171
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2172
-    }
2173
-
2174
-
2175
-
2176
-    /*** END LIST TABLE METHODS **/
2177
-
2178
-
2179
-    /**
2180
-     * _add_registered_metaboxes
2181
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2182
-     *
2183
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2184
-     * @return void
2185
-     * @throws EE_Error
2186
-     */
2187
-    private function _add_registered_meta_boxes()
2188
-    {
2189
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2190
-        // we only add meta boxes if the page_route calls for it
2191
-        if (
2192
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2193
-            && is_array(
2194
-                $this->_route_config['metaboxes']
2195
-            )
2196
-        ) {
2197
-            // this simply loops through the callbacks provided
2198
-            // and checks if there is a corresponding callback registered by the child
2199
-            // if there is then we go ahead and process the metabox loader.
2200
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2201
-                // first check for Closures
2202
-                if ($metabox_callback instanceof Closure) {
2203
-                    $result = $metabox_callback();
2204
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2205
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2206
-                } else {
2207
-                    $result = $this->{$metabox_callback}();
2208
-                }
2209
-                if ($result === false) {
2210
-                    // user error msg
2211
-                    $error_msg = esc_html__(
2212
-                        'An error occurred. The  requested metabox could not be found.',
2213
-                        'event_espresso'
2214
-                    );
2215
-                    // developer error msg
2216
-                    $error_msg .= '||'
2217
-                                  . sprintf(
2218
-                                      esc_html__(
2219
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2220
-                                          'event_espresso'
2221
-                                      ),
2222
-                                      $metabox_callback
2223
-                                  );
2224
-                    throw new EE_Error($error_msg);
2225
-                }
2226
-            }
2227
-        }
2228
-    }
2229
-
2230
-
2231
-    /**
2232
-     * _add_screen_columns
2233
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2234
-     * the dynamic column template and we'll setup the column options for the page.
2235
-     *
2236
-     * @return void
2237
-     */
2238
-    private function _add_screen_columns()
2239
-    {
2240
-        if (
2241
-            is_array($this->_route_config)
2242
-            && isset($this->_route_config['columns'])
2243
-            && is_array($this->_route_config['columns'])
2244
-            && count($this->_route_config['columns']) === 2
2245
-        ) {
2246
-            add_screen_option(
2247
-                'layout_columns',
2248
-                [
2249
-                    'max'     => (int) $this->_route_config['columns'][0],
2250
-                    'default' => (int) $this->_route_config['columns'][1],
2251
-                ]
2252
-            );
2253
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2254
-            $screen_id                                           = $this->_current_screen->id;
2255
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2256
-            $total_columns                                       = ! empty($screen_columns)
2257
-                ? $screen_columns
2258
-                : $this->_route_config['columns'][1];
2259
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2260
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2261
-            $this->_template_args['screen']                      = $this->_current_screen;
2262
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2263
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2264
-            // finally if we don't have has_metaboxes set in the route config
2265
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2266
-            $this->_route_config['has_metaboxes'] = true;
2267
-        }
2268
-    }
2269
-
2270
-
2271
-
2272
-    /** GLOBALLY AVAILABLE METABOXES **/
2273
-
2274
-
2275
-    /**
2276
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2277
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2278
-     * these get loaded on.
2279
-     */
2280
-    private function _espresso_news_post_box()
2281
-    {
2282
-        $news_box_title = apply_filters(
2283
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2284
-            esc_html__('New @ Event Espresso', 'event_espresso')
2285
-        );
2286
-        $this->addMetaBox(
2287
-            'espresso_news_post_box',
2288
-            $news_box_title,
2289
-            [
2290
-                $this,
2291
-                'espresso_news_post_box',
2292
-            ],
2293
-            $this->_wp_page_slug,
2294
-            'side',
2295
-            'low'
2296
-        );
2297
-    }
2298
-
2299
-
2300
-    /**
2301
-     * Code for setting up espresso ratings request metabox.
2302
-     */
2303
-    protected function _espresso_ratings_request()
2304
-    {
2305
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2306
-            return;
2307
-        }
2308
-        $ratings_box_title = apply_filters(
2309
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2310
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2311
-        );
2312
-        $this->addMetaBox(
2313
-            'espresso_ratings_request',
2314
-            $ratings_box_title,
2315
-            [
2316
-                $this,
2317
-                'espresso_ratings_request',
2318
-            ],
2319
-            $this->_wp_page_slug,
2320
-            'side'
2321
-        );
2322
-    }
2323
-
2324
-
2325
-    /**
2326
-     * Code for setting up espresso ratings request metabox content.
2327
-     *
2328
-     * @throws DomainException
2329
-     */
2330
-    public function espresso_ratings_request()
2331
-    {
2332
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2333
-    }
2334
-
2335
-
2336
-    public static function cached_rss_display($rss_id, $url)
2337
-    {
2338
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2339
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2340
-                     . '</p><p class="hide-if-js">'
2341
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2342
-                     . '</p>';
2343
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2344
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2345
-        $post      = '</div>' . "\n";
2346
-        $cache_key = 'ee_rss_' . md5($rss_id);
2347
-        $output    = get_transient($cache_key);
2348
-        if ($output !== false) {
2349
-            echo $pre . $output . $post; // already escaped
2350
-            return true;
2351
-        }
2352
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2353
-            echo $pre . $loading . $post; // already escaped
2354
-            return false;
2355
-        }
2356
-        ob_start();
2357
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2358
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2359
-        return true;
2360
-    }
2361
-
2362
-
2363
-    public function espresso_news_post_box()
2364
-    {
2365
-        ?>
2155
+		return $entries_per_page_dropdown;
2156
+	}
2157
+
2158
+
2159
+	/**
2160
+	 *        _set_search_attributes
2161
+	 *
2162
+	 * @return        void
2163
+	 */
2164
+	public function _set_search_attributes()
2165
+	{
2166
+		$this->_template_args['search']['btn_label'] = sprintf(
2167
+			esc_html__('Search %s', 'event_espresso'),
2168
+			empty($this->_search_btn_label) ? $this->page_label
2169
+				: $this->_search_btn_label
2170
+		);
2171
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2172
+	}
2173
+
2174
+
2175
+
2176
+	/*** END LIST TABLE METHODS **/
2177
+
2178
+
2179
+	/**
2180
+	 * _add_registered_metaboxes
2181
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2182
+	 *
2183
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2184
+	 * @return void
2185
+	 * @throws EE_Error
2186
+	 */
2187
+	private function _add_registered_meta_boxes()
2188
+	{
2189
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2190
+		// we only add meta boxes if the page_route calls for it
2191
+		if (
2192
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2193
+			&& is_array(
2194
+				$this->_route_config['metaboxes']
2195
+			)
2196
+		) {
2197
+			// this simply loops through the callbacks provided
2198
+			// and checks if there is a corresponding callback registered by the child
2199
+			// if there is then we go ahead and process the metabox loader.
2200
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2201
+				// first check for Closures
2202
+				if ($metabox_callback instanceof Closure) {
2203
+					$result = $metabox_callback();
2204
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2205
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2206
+				} else {
2207
+					$result = $this->{$metabox_callback}();
2208
+				}
2209
+				if ($result === false) {
2210
+					// user error msg
2211
+					$error_msg = esc_html__(
2212
+						'An error occurred. The  requested metabox could not be found.',
2213
+						'event_espresso'
2214
+					);
2215
+					// developer error msg
2216
+					$error_msg .= '||'
2217
+								  . sprintf(
2218
+									  esc_html__(
2219
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2220
+										  'event_espresso'
2221
+									  ),
2222
+									  $metabox_callback
2223
+								  );
2224
+					throw new EE_Error($error_msg);
2225
+				}
2226
+			}
2227
+		}
2228
+	}
2229
+
2230
+
2231
+	/**
2232
+	 * _add_screen_columns
2233
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2234
+	 * the dynamic column template and we'll setup the column options for the page.
2235
+	 *
2236
+	 * @return void
2237
+	 */
2238
+	private function _add_screen_columns()
2239
+	{
2240
+		if (
2241
+			is_array($this->_route_config)
2242
+			&& isset($this->_route_config['columns'])
2243
+			&& is_array($this->_route_config['columns'])
2244
+			&& count($this->_route_config['columns']) === 2
2245
+		) {
2246
+			add_screen_option(
2247
+				'layout_columns',
2248
+				[
2249
+					'max'     => (int) $this->_route_config['columns'][0],
2250
+					'default' => (int) $this->_route_config['columns'][1],
2251
+				]
2252
+			);
2253
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2254
+			$screen_id                                           = $this->_current_screen->id;
2255
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2256
+			$total_columns                                       = ! empty($screen_columns)
2257
+				? $screen_columns
2258
+				: $this->_route_config['columns'][1];
2259
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2260
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2261
+			$this->_template_args['screen']                      = $this->_current_screen;
2262
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2263
+																   . 'admin_details_metabox_column_wrapper.template.php';
2264
+			// finally if we don't have has_metaboxes set in the route config
2265
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2266
+			$this->_route_config['has_metaboxes'] = true;
2267
+		}
2268
+	}
2269
+
2270
+
2271
+
2272
+	/** GLOBALLY AVAILABLE METABOXES **/
2273
+
2274
+
2275
+	/**
2276
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2277
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2278
+	 * these get loaded on.
2279
+	 */
2280
+	private function _espresso_news_post_box()
2281
+	{
2282
+		$news_box_title = apply_filters(
2283
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2284
+			esc_html__('New @ Event Espresso', 'event_espresso')
2285
+		);
2286
+		$this->addMetaBox(
2287
+			'espresso_news_post_box',
2288
+			$news_box_title,
2289
+			[
2290
+				$this,
2291
+				'espresso_news_post_box',
2292
+			],
2293
+			$this->_wp_page_slug,
2294
+			'side',
2295
+			'low'
2296
+		);
2297
+	}
2298
+
2299
+
2300
+	/**
2301
+	 * Code for setting up espresso ratings request metabox.
2302
+	 */
2303
+	protected function _espresso_ratings_request()
2304
+	{
2305
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2306
+			return;
2307
+		}
2308
+		$ratings_box_title = apply_filters(
2309
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2310
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2311
+		);
2312
+		$this->addMetaBox(
2313
+			'espresso_ratings_request',
2314
+			$ratings_box_title,
2315
+			[
2316
+				$this,
2317
+				'espresso_ratings_request',
2318
+			],
2319
+			$this->_wp_page_slug,
2320
+			'side'
2321
+		);
2322
+	}
2323
+
2324
+
2325
+	/**
2326
+	 * Code for setting up espresso ratings request metabox content.
2327
+	 *
2328
+	 * @throws DomainException
2329
+	 */
2330
+	public function espresso_ratings_request()
2331
+	{
2332
+		EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2333
+	}
2334
+
2335
+
2336
+	public static function cached_rss_display($rss_id, $url)
2337
+	{
2338
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2339
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2340
+					 . '</p><p class="hide-if-js">'
2341
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2342
+					 . '</p>';
2343
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2344
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2345
+		$post      = '</div>' . "\n";
2346
+		$cache_key = 'ee_rss_' . md5($rss_id);
2347
+		$output    = get_transient($cache_key);
2348
+		if ($output !== false) {
2349
+			echo $pre . $output . $post; // already escaped
2350
+			return true;
2351
+		}
2352
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2353
+			echo $pre . $loading . $post; // already escaped
2354
+			return false;
2355
+		}
2356
+		ob_start();
2357
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2358
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2359
+		return true;
2360
+	}
2361
+
2362
+
2363
+	public function espresso_news_post_box()
2364
+	{
2365
+		?>
2366 2366
         <div class="padding">
2367 2367
             <div id="espresso_news_post_box_content" class="infolinks">
2368 2368
                 <?php
2369
-                // Get RSS Feed(s)
2370
-                EE_Admin_Page::cached_rss_display(
2371
-                    'espresso_news_post_box_content',
2372
-                    esc_url_raw(
2373
-                        apply_filters(
2374
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2375
-                            'https://eventespresso.com/feed/'
2376
-                        )
2377
-                    )
2378
-                );
2379
-                ?>
2369
+				// Get RSS Feed(s)
2370
+				EE_Admin_Page::cached_rss_display(
2371
+					'espresso_news_post_box_content',
2372
+					esc_url_raw(
2373
+						apply_filters(
2374
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2375
+							'https://eventespresso.com/feed/'
2376
+						)
2377
+					)
2378
+				);
2379
+				?>
2380 2380
             </div>
2381 2381
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2382 2382
         </div>
2383 2383
         <?php
2384
-    }
2385
-
2386
-
2387
-    private function _espresso_links_post_box()
2388
-    {
2389
-        // Hiding until we actually have content to put in here...
2390
-        // $this->addMetaBox('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2391
-    }
2392
-
2393
-
2394
-    public function espresso_links_post_box()
2395
-    {
2396
-        // Hiding until we actually have content to put in here...
2397
-        // EEH_Template::display_template(
2398
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2399
-        // );
2400
-    }
2401
-
2402
-
2403
-    protected function _espresso_sponsors_post_box()
2404
-    {
2405
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2406
-            $this->addMetaBox(
2407
-                'espresso_sponsors_post_box',
2408
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2409
-                [$this, 'espresso_sponsors_post_box'],
2410
-                $this->_wp_page_slug,
2411
-                'side'
2412
-            );
2413
-        }
2414
-    }
2415
-
2416
-
2417
-    public function espresso_sponsors_post_box()
2418
-    {
2419
-        EEH_Template::display_template(
2420
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2421
-        );
2422
-    }
2423
-
2424
-
2425
-    private function _publish_post_box()
2426
-    {
2427
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2428
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2429
-        // then we'll use that for the metabox label.
2430
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2431
-        if (! empty($this->_labels['publishbox'])) {
2432
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2433
-                : $this->_labels['publishbox'];
2434
-        } else {
2435
-            $box_label = esc_html__('Publish', 'event_espresso');
2436
-        }
2437
-        $box_label = apply_filters(
2438
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2439
-            $box_label,
2440
-            $this->_req_action,
2441
-            $this
2442
-        );
2443
-        $this->addMetaBox(
2444
-            $meta_box_ref,
2445
-            $box_label,
2446
-            [$this, 'editor_overview'],
2447
-            $this->_current_screen->id,
2448
-            'side',
2449
-            'high'
2450
-        );
2451
-    }
2452
-
2453
-
2454
-    public function editor_overview()
2455
-    {
2456
-        // if we have extra content set let's add it in if not make sure its empty
2457
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2458
-            ? $this->_template_args['publish_box_extra_content']
2459
-            : '';
2460
-        echo EEH_Template::display_template(
2461
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2462
-            $this->_template_args,
2463
-            true
2464
-        );
2465
-    }
2466
-
2467
-
2468
-    /** end of globally available metaboxes section **/
2469
-
2470
-
2471
-    /**
2472
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2473
-     * protected method.
2474
-     *
2475
-     * @param string $name
2476
-     * @param int    $id
2477
-     * @param bool   $delete
2478
-     * @param string $save_close_redirect_URL
2479
-     * @param bool   $both_btns
2480
-     * @throws EE_Error
2481
-     * @throws InvalidArgumentException
2482
-     * @throws InvalidDataTypeException
2483
-     * @throws InvalidInterfaceException
2484
-     * @see   $this->_set_publish_post_box_vars for param details
2485
-     * @since 4.6.0
2486
-     */
2487
-    public function set_publish_post_box_vars(
2488
-        $name = '',
2489
-        $id = 0,
2490
-        $delete = false,
2491
-        $save_close_redirect_URL = '',
2492
-        $both_btns = true
2493
-    ) {
2494
-        $this->_set_publish_post_box_vars(
2495
-            $name,
2496
-            $id,
2497
-            $delete,
2498
-            $save_close_redirect_URL,
2499
-            $both_btns
2500
-        );
2501
-    }
2502
-
2503
-
2504
-    /**
2505
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2506
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2507
-     * save, and save and close buttons to work properly, then you will want to include a
2508
-     * values for the name and id arguments.
2509
-     *
2510
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2511
-     * @param int     $id                         id attached to the item published
2512
-     * @param string  $delete                     page route callback for the delete action
2513
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2514
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2515
-     *                                            the Save button
2516
-     * @throws EE_Error
2517
-     * @throws InvalidArgumentException
2518
-     * @throws InvalidDataTypeException
2519
-     * @throws InvalidInterfaceException
2520
-     * @todo  Add in validation for name/id arguments.
2521
-     */
2522
-    protected function _set_publish_post_box_vars(
2523
-        $name = '',
2524
-        $id = 0,
2525
-        $delete = '',
2526
-        $save_close_redirect_URL = '',
2527
-        $both_btns = true
2528
-    ) {
2529
-        // if Save & Close, use a custom redirect URL or default to the main page?
2530
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2531
-            ? $save_close_redirect_URL
2532
-            : $this->_admin_base_url;
2533
-        // create the Save & Close and Save buttons
2534
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2535
-        // if we have extra content set let's add it in if not make sure its empty
2536
-        $this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2537
-        $delete_link = '';
2538
-        if ($delete && ! empty($id)) {
2539
-            // make sure we have a default if just true is sent.
2540
-            $delete           = ! empty($delete) ? $delete : 'delete';
2541
-            $delete_link      = $this->get_action_link_or_button(
2542
-                $delete,
2543
-                $delete,
2544
-                [$name => $id],
2545
-                'submitdelete deletion button button--outline button--caution'
2546
-            );
2547
-        }
2548
-        $this->_template_args['publish_delete_link'] = $delete_link;
2549
-        if (! empty($name) && ! empty($id)) {
2550
-            $hidden_field_arr[ $name ] = [
2551
-                'type'  => 'hidden',
2552
-                'value' => $id,
2553
-            ];
2554
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2555
-        } else {
2556
-            $hf = '';
2557
-        }
2558
-        // add hidden field
2559
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2560
-            ? $hf[ $name ]['field']
2561
-            : $hf;
2562
-    }
2563
-
2564
-
2565
-    /**
2566
-     * displays an error message to ppl who have javascript disabled
2567
-     *
2568
-     * @return void
2569
-     */
2570
-    private function _display_no_javascript_warning()
2571
-    {
2572
-        ?>
2384
+	}
2385
+
2386
+
2387
+	private function _espresso_links_post_box()
2388
+	{
2389
+		// Hiding until we actually have content to put in here...
2390
+		// $this->addMetaBox('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2391
+	}
2392
+
2393
+
2394
+	public function espresso_links_post_box()
2395
+	{
2396
+		// Hiding until we actually have content to put in here...
2397
+		// EEH_Template::display_template(
2398
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2399
+		// );
2400
+	}
2401
+
2402
+
2403
+	protected function _espresso_sponsors_post_box()
2404
+	{
2405
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2406
+			$this->addMetaBox(
2407
+				'espresso_sponsors_post_box',
2408
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2409
+				[$this, 'espresso_sponsors_post_box'],
2410
+				$this->_wp_page_slug,
2411
+				'side'
2412
+			);
2413
+		}
2414
+	}
2415
+
2416
+
2417
+	public function espresso_sponsors_post_box()
2418
+	{
2419
+		EEH_Template::display_template(
2420
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2421
+		);
2422
+	}
2423
+
2424
+
2425
+	private function _publish_post_box()
2426
+	{
2427
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2428
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2429
+		// then we'll use that for the metabox label.
2430
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2431
+		if (! empty($this->_labels['publishbox'])) {
2432
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2433
+				: $this->_labels['publishbox'];
2434
+		} else {
2435
+			$box_label = esc_html__('Publish', 'event_espresso');
2436
+		}
2437
+		$box_label = apply_filters(
2438
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2439
+			$box_label,
2440
+			$this->_req_action,
2441
+			$this
2442
+		);
2443
+		$this->addMetaBox(
2444
+			$meta_box_ref,
2445
+			$box_label,
2446
+			[$this, 'editor_overview'],
2447
+			$this->_current_screen->id,
2448
+			'side',
2449
+			'high'
2450
+		);
2451
+	}
2452
+
2453
+
2454
+	public function editor_overview()
2455
+	{
2456
+		// if we have extra content set let's add it in if not make sure its empty
2457
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2458
+			? $this->_template_args['publish_box_extra_content']
2459
+			: '';
2460
+		echo EEH_Template::display_template(
2461
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2462
+			$this->_template_args,
2463
+			true
2464
+		);
2465
+	}
2466
+
2467
+
2468
+	/** end of globally available metaboxes section **/
2469
+
2470
+
2471
+	/**
2472
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2473
+	 * protected method.
2474
+	 *
2475
+	 * @param string $name
2476
+	 * @param int    $id
2477
+	 * @param bool   $delete
2478
+	 * @param string $save_close_redirect_URL
2479
+	 * @param bool   $both_btns
2480
+	 * @throws EE_Error
2481
+	 * @throws InvalidArgumentException
2482
+	 * @throws InvalidDataTypeException
2483
+	 * @throws InvalidInterfaceException
2484
+	 * @see   $this->_set_publish_post_box_vars for param details
2485
+	 * @since 4.6.0
2486
+	 */
2487
+	public function set_publish_post_box_vars(
2488
+		$name = '',
2489
+		$id = 0,
2490
+		$delete = false,
2491
+		$save_close_redirect_URL = '',
2492
+		$both_btns = true
2493
+	) {
2494
+		$this->_set_publish_post_box_vars(
2495
+			$name,
2496
+			$id,
2497
+			$delete,
2498
+			$save_close_redirect_URL,
2499
+			$both_btns
2500
+		);
2501
+	}
2502
+
2503
+
2504
+	/**
2505
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2506
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2507
+	 * save, and save and close buttons to work properly, then you will want to include a
2508
+	 * values for the name and id arguments.
2509
+	 *
2510
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2511
+	 * @param int     $id                         id attached to the item published
2512
+	 * @param string  $delete                     page route callback for the delete action
2513
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2514
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2515
+	 *                                            the Save button
2516
+	 * @throws EE_Error
2517
+	 * @throws InvalidArgumentException
2518
+	 * @throws InvalidDataTypeException
2519
+	 * @throws InvalidInterfaceException
2520
+	 * @todo  Add in validation for name/id arguments.
2521
+	 */
2522
+	protected function _set_publish_post_box_vars(
2523
+		$name = '',
2524
+		$id = 0,
2525
+		$delete = '',
2526
+		$save_close_redirect_URL = '',
2527
+		$both_btns = true
2528
+	) {
2529
+		// if Save & Close, use a custom redirect URL or default to the main page?
2530
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2531
+			? $save_close_redirect_URL
2532
+			: $this->_admin_base_url;
2533
+		// create the Save & Close and Save buttons
2534
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2535
+		// if we have extra content set let's add it in if not make sure its empty
2536
+		$this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2537
+		$delete_link = '';
2538
+		if ($delete && ! empty($id)) {
2539
+			// make sure we have a default if just true is sent.
2540
+			$delete           = ! empty($delete) ? $delete : 'delete';
2541
+			$delete_link      = $this->get_action_link_or_button(
2542
+				$delete,
2543
+				$delete,
2544
+				[$name => $id],
2545
+				'submitdelete deletion button button--outline button--caution'
2546
+			);
2547
+		}
2548
+		$this->_template_args['publish_delete_link'] = $delete_link;
2549
+		if (! empty($name) && ! empty($id)) {
2550
+			$hidden_field_arr[ $name ] = [
2551
+				'type'  => 'hidden',
2552
+				'value' => $id,
2553
+			];
2554
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2555
+		} else {
2556
+			$hf = '';
2557
+		}
2558
+		// add hidden field
2559
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2560
+			? $hf[ $name ]['field']
2561
+			: $hf;
2562
+	}
2563
+
2564
+
2565
+	/**
2566
+	 * displays an error message to ppl who have javascript disabled
2567
+	 *
2568
+	 * @return void
2569
+	 */
2570
+	private function _display_no_javascript_warning()
2571
+	{
2572
+		?>
2573 2573
         <noscript>
2574 2574
             <div id="no-js-message" class="error">
2575 2575
                 <p style="font-size:1.3em;">
2576 2576
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2577 2577
                     <?php esc_html_e(
2578
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2579
-                        'event_espresso'
2580
-                    ); ?>
2578
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2579
+						'event_espresso'
2580
+					); ?>
2581 2581
                 </p>
2582 2582
             </div>
2583 2583
         </noscript>
2584 2584
         <?php
2585
-    }
2586
-
2587
-
2588
-    /**
2589
-     * displays espresso success and/or error notices
2590
-     *
2591
-     * @return void
2592
-     */
2593
-    protected function _display_espresso_notices()
2594
-    {
2595
-        $notices = $this->_get_transient(true);
2596
-        echo stripslashes($notices);
2597
-    }
2598
-
2599
-
2600
-    /**
2601
-     * spinny things pacify the masses
2602
-     *
2603
-     * @return void
2604
-     */
2605
-    protected function _add_admin_page_ajax_loading_img()
2606
-    {
2607
-        ?>
2585
+	}
2586
+
2587
+
2588
+	/**
2589
+	 * displays espresso success and/or error notices
2590
+	 *
2591
+	 * @return void
2592
+	 */
2593
+	protected function _display_espresso_notices()
2594
+	{
2595
+		$notices = $this->_get_transient(true);
2596
+		echo stripslashes($notices);
2597
+	}
2598
+
2599
+
2600
+	/**
2601
+	 * spinny things pacify the masses
2602
+	 *
2603
+	 * @return void
2604
+	 */
2605
+	protected function _add_admin_page_ajax_loading_img()
2606
+	{
2607
+		?>
2608 2608
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2609 2609
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2610
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2610
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2611 2611
         </div>
2612 2612
         <?php
2613
-    }
2613
+	}
2614 2614
 
2615 2615
 
2616
-    /**
2617
-     * add admin page overlay for modal boxes
2618
-     *
2619
-     * @return void
2620
-     */
2621
-    protected function _add_admin_page_overlay()
2622
-    {
2623
-        ?>
2616
+	/**
2617
+	 * add admin page overlay for modal boxes
2618
+	 *
2619
+	 * @return void
2620
+	 */
2621
+	protected function _add_admin_page_overlay()
2622
+	{
2623
+		?>
2624 2624
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2625 2625
         <?php
2626
-    }
2627
-
2628
-
2629
-    /**
2630
-     * facade for $this->addMetaBox()
2631
-     *
2632
-     * @param string  $action        where the metabox gets displayed
2633
-     * @param string  $title         Title of Metabox (output in metabox header)
2634
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2635
-     *                               instead of the one created in here.
2636
-     * @param array   $callback_args an array of args supplied for the metabox
2637
-     * @param string  $column        what metabox column
2638
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2639
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2640
-     *                               created but just set our own callback for wp's add_meta_box.
2641
-     * @throws DomainException
2642
-     */
2643
-    public function _add_admin_page_meta_box(
2644
-        $action,
2645
-        $title,
2646
-        $callback,
2647
-        $callback_args,
2648
-        $column = 'normal',
2649
-        $priority = 'high',
2650
-        $create_func = true
2651
-    ) {
2652
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2653
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2654
-        if (empty($callback_args) && $create_func) {
2655
-            $callback_args = [
2656
-                'template_path' => $this->_template_path,
2657
-                'template_args' => $this->_template_args,
2658
-            ];
2659
-        }
2660
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2661
-        $call_back_func = $create_func
2662
-            ? static function ($post, $metabox) {
2663
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2664
-                echo EEH_Template::display_template(
2665
-                    $metabox['args']['template_path'],
2666
-                    $metabox['args']['template_args'],
2667
-                    true
2668
-                );
2669
-            }
2670
-            : $callback;
2671
-        $this->addMetaBox(
2672
-            str_replace('_', '-', $action) . '-mbox',
2673
-            $title,
2674
-            $call_back_func,
2675
-            $this->_wp_page_slug,
2676
-            $column,
2677
-            $priority,
2678
-            $callback_args
2679
-        );
2680
-    }
2681
-
2682
-
2683
-    /**
2684
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2685
-     *
2686
-     * @throws DomainException
2687
-     * @throws EE_Error
2688
-     * @throws InvalidArgumentException
2689
-     * @throws InvalidDataTypeException
2690
-     * @throws InvalidInterfaceException
2691
-     */
2692
-    public function display_admin_page_with_metabox_columns()
2693
-    {
2694
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2695
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2696
-            $this->_column_template_path,
2697
-            $this->_template_args,
2698
-            true
2699
-        );
2700
-        // the final wrapper
2701
-        $this->admin_page_wrapper();
2702
-    }
2703
-
2704
-
2705
-    /**
2706
-     * generates  HTML wrapper for an admin details page
2707
-     *
2708
-     * @return void
2709
-     * @throws DomainException
2710
-     * @throws EE_Error
2711
-     * @throws InvalidArgumentException
2712
-     * @throws InvalidDataTypeException
2713
-     * @throws InvalidInterfaceException
2714
-     */
2715
-    public function display_admin_page_with_sidebar()
2716
-    {
2717
-        $this->_display_admin_page(true);
2718
-    }
2719
-
2720
-
2721
-    /**
2722
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2723
-     *
2724
-     * @return void
2725
-     * @throws DomainException
2726
-     * @throws EE_Error
2727
-     * @throws InvalidArgumentException
2728
-     * @throws InvalidDataTypeException
2729
-     * @throws InvalidInterfaceException
2730
-     */
2731
-    public function display_admin_page_with_no_sidebar()
2732
-    {
2733
-        $this->_display_admin_page();
2734
-    }
2735
-
2736
-
2737
-    /**
2738
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2739
-     *
2740
-     * @return void
2741
-     * @throws DomainException
2742
-     * @throws EE_Error
2743
-     * @throws InvalidArgumentException
2744
-     * @throws InvalidDataTypeException
2745
-     * @throws InvalidInterfaceException
2746
-     */
2747
-    public function display_about_admin_page()
2748
-    {
2749
-        $this->_display_admin_page(false, true);
2750
-    }
2751
-
2752
-
2753
-    /**
2754
-     * display_admin_page
2755
-     * contains the code for actually displaying an admin page
2756
-     *
2757
-     * @param boolean $sidebar true with sidebar, false without
2758
-     * @param boolean $about   use the about admin wrapper instead of the default.
2759
-     * @return void
2760
-     * @throws DomainException
2761
-     * @throws EE_Error
2762
-     * @throws InvalidArgumentException
2763
-     * @throws InvalidDataTypeException
2764
-     * @throws InvalidInterfaceException
2765
-     */
2766
-    private function _display_admin_page($sidebar = false, $about = false)
2767
-    {
2768
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2769
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2770
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2771
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2772
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2773
-
2774
-        $post_body_content = $this->_template_args['before_admin_page_content'] ?? '';
2775
-
2776
-        $this->_template_args['add_page_frame'] = $this->_req_action !== 'system_status'
2777
-                                                 && $this->_req_action !== 'data_reset'
2778
-                                                 && $this->_wp_page_slug !== 'event-espresso_page_espresso_packages'
2779
-                                                 && strpos($post_body_content, 'wp-list-table') === false;
2780
-
2781
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2782
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2783
-            ? 'poststuff'
2784
-            : 'espresso-default-admin';
2785
-        $this->_template_args['admin_page_wrapper_div_class'] = str_replace(
2786
-            'event-espresso_page_espresso_',
2787
-            '',
2788
-            $this->_wp_page_slug
2789
-        ) . ' ' . $this->_req_action . '-route';
2790
-
2791
-        $template_path = $sidebar
2792
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2793
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2794
-        if ($this->request->isAjax()) {
2795
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2796
-        }
2797
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2798
-
2799
-        $this->_template_args['post_body_content']         = $this->_template_args['admin_page_content'] ?? '';
2800
-        $this->_template_args['before_admin_page_content'] = $post_body_content;
2801
-        $this->_template_args['after_admin_page_content']  = $this->_template_args['after_admin_page_content'] ?? '';
2802
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2803
-            $template_path,
2804
-            $this->_template_args,
2805
-            true
2806
-        );
2807
-        // the final template wrapper
2808
-        $this->admin_page_wrapper($about);
2809
-    }
2810
-
2811
-
2812
-    /**
2813
-     * This is used to display caf preview pages.
2814
-     *
2815
-     * @param string $utm_campaign_source what is the key used for google analytics link
2816
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2817
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2818
-     * @return void
2819
-     * @throws DomainException
2820
-     * @throws EE_Error
2821
-     * @throws InvalidArgumentException
2822
-     * @throws InvalidDataTypeException
2823
-     * @throws InvalidInterfaceException
2824
-     * @since 4.3.2
2825
-     */
2826
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2827
-    {
2828
-        // let's generate a default preview action button if there isn't one already present.
2829
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2830
-            'Upgrade to Event Espresso 4 Right Now',
2831
-            'event_espresso'
2832
-        );
2833
-        $buy_now_url                                   = add_query_arg(
2834
-            [
2835
-                'ee_ver'       => 'ee4',
2836
-                'utm_source'   => 'ee4_plugin_admin',
2837
-                'utm_medium'   => 'link',
2838
-                'utm_campaign' => $utm_campaign_source,
2839
-                'utm_content'  => 'buy_now_button',
2840
-            ],
2841
-            'https://eventespresso.com/pricing/'
2842
-        );
2843
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2844
-            ? $this->get_action_link_or_button(
2845
-                '',
2846
-                'buy_now',
2847
-                [],
2848
-                'button button--primary button--big',
2849
-                esc_url_raw($buy_now_url),
2850
-                true
2851
-            )
2852
-            : $this->_template_args['preview_action_button'];
2853
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2854
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2855
-            $this->_template_args,
2856
-            true
2857
-        );
2858
-        $this->_display_admin_page($display_sidebar);
2859
-    }
2860
-
2861
-
2862
-    /**
2863
-     * display_admin_list_table_page_with_sidebar
2864
-     * generates HTML wrapper for an admin_page with list_table
2865
-     *
2866
-     * @return void
2867
-     * @throws DomainException
2868
-     * @throws EE_Error
2869
-     * @throws InvalidArgumentException
2870
-     * @throws InvalidDataTypeException
2871
-     * @throws InvalidInterfaceException
2872
-     */
2873
-    public function display_admin_list_table_page_with_sidebar()
2874
-    {
2875
-        $this->_display_admin_list_table_page(true);
2876
-    }
2877
-
2878
-
2879
-    /**
2880
-     * display_admin_list_table_page_with_no_sidebar
2881
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2882
-     *
2883
-     * @return void
2884
-     * @throws DomainException
2885
-     * @throws EE_Error
2886
-     * @throws InvalidArgumentException
2887
-     * @throws InvalidDataTypeException
2888
-     * @throws InvalidInterfaceException
2889
-     */
2890
-    public function display_admin_list_table_page_with_no_sidebar()
2891
-    {
2892
-        $this->_display_admin_list_table_page();
2893
-    }
2894
-
2895
-
2896
-    /**
2897
-     * generates html wrapper for an admin_list_table page
2898
-     *
2899
-     * @param boolean $sidebar whether to display with sidebar or not.
2900
-     * @return void
2901
-     * @throws DomainException
2902
-     * @throws EE_Error
2903
-     * @throws InvalidArgumentException
2904
-     * @throws InvalidDataTypeException
2905
-     * @throws InvalidInterfaceException
2906
-     */
2907
-    private function _display_admin_list_table_page($sidebar = false)
2908
-    {
2909
-        // setup search attributes
2910
-        $this->_set_search_attributes();
2911
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2912
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2913
-        $this->_template_args['table_url']        = $this->request->isAjax()
2914
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2915
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2916
-        $this->_template_args['list_table']       = $this->_list_table_object;
2917
-        $this->_template_args['current_route']    = $this->_req_action;
2918
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2919
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2920
-        if (! empty($ajax_sorting_callback)) {
2921
-            $sortable_list_table_form_fields = wp_nonce_field(
2922
-                $ajax_sorting_callback . '_nonce',
2923
-                $ajax_sorting_callback . '_nonce',
2924
-                false,
2925
-                false
2926
-            );
2927
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2928
-                                                . $this->page_slug
2929
-                                                . '" />';
2930
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2931
-                                                . $ajax_sorting_callback
2932
-                                                . '" />';
2933
-        } else {
2934
-            $sortable_list_table_form_fields = '';
2935
-        }
2936
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2937
-
2938
-        $hidden_form_fields = $this->_template_args['list_table_hidden_fields'] ?? '';
2939
-
2940
-        $nonce_ref          = $this->_req_action . '_nonce';
2941
-        $hidden_form_fields .= '
2626
+	}
2627
+
2628
+
2629
+	/**
2630
+	 * facade for $this->addMetaBox()
2631
+	 *
2632
+	 * @param string  $action        where the metabox gets displayed
2633
+	 * @param string  $title         Title of Metabox (output in metabox header)
2634
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2635
+	 *                               instead of the one created in here.
2636
+	 * @param array   $callback_args an array of args supplied for the metabox
2637
+	 * @param string  $column        what metabox column
2638
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2639
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2640
+	 *                               created but just set our own callback for wp's add_meta_box.
2641
+	 * @throws DomainException
2642
+	 */
2643
+	public function _add_admin_page_meta_box(
2644
+		$action,
2645
+		$title,
2646
+		$callback,
2647
+		$callback_args,
2648
+		$column = 'normal',
2649
+		$priority = 'high',
2650
+		$create_func = true
2651
+	) {
2652
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2653
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2654
+		if (empty($callback_args) && $create_func) {
2655
+			$callback_args = [
2656
+				'template_path' => $this->_template_path,
2657
+				'template_args' => $this->_template_args,
2658
+			];
2659
+		}
2660
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2661
+		$call_back_func = $create_func
2662
+			? static function ($post, $metabox) {
2663
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2664
+				echo EEH_Template::display_template(
2665
+					$metabox['args']['template_path'],
2666
+					$metabox['args']['template_args'],
2667
+					true
2668
+				);
2669
+			}
2670
+			: $callback;
2671
+		$this->addMetaBox(
2672
+			str_replace('_', '-', $action) . '-mbox',
2673
+			$title,
2674
+			$call_back_func,
2675
+			$this->_wp_page_slug,
2676
+			$column,
2677
+			$priority,
2678
+			$callback_args
2679
+		);
2680
+	}
2681
+
2682
+
2683
+	/**
2684
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2685
+	 *
2686
+	 * @throws DomainException
2687
+	 * @throws EE_Error
2688
+	 * @throws InvalidArgumentException
2689
+	 * @throws InvalidDataTypeException
2690
+	 * @throws InvalidInterfaceException
2691
+	 */
2692
+	public function display_admin_page_with_metabox_columns()
2693
+	{
2694
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2695
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2696
+			$this->_column_template_path,
2697
+			$this->_template_args,
2698
+			true
2699
+		);
2700
+		// the final wrapper
2701
+		$this->admin_page_wrapper();
2702
+	}
2703
+
2704
+
2705
+	/**
2706
+	 * generates  HTML wrapper for an admin details page
2707
+	 *
2708
+	 * @return void
2709
+	 * @throws DomainException
2710
+	 * @throws EE_Error
2711
+	 * @throws InvalidArgumentException
2712
+	 * @throws InvalidDataTypeException
2713
+	 * @throws InvalidInterfaceException
2714
+	 */
2715
+	public function display_admin_page_with_sidebar()
2716
+	{
2717
+		$this->_display_admin_page(true);
2718
+	}
2719
+
2720
+
2721
+	/**
2722
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2723
+	 *
2724
+	 * @return void
2725
+	 * @throws DomainException
2726
+	 * @throws EE_Error
2727
+	 * @throws InvalidArgumentException
2728
+	 * @throws InvalidDataTypeException
2729
+	 * @throws InvalidInterfaceException
2730
+	 */
2731
+	public function display_admin_page_with_no_sidebar()
2732
+	{
2733
+		$this->_display_admin_page();
2734
+	}
2735
+
2736
+
2737
+	/**
2738
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2739
+	 *
2740
+	 * @return void
2741
+	 * @throws DomainException
2742
+	 * @throws EE_Error
2743
+	 * @throws InvalidArgumentException
2744
+	 * @throws InvalidDataTypeException
2745
+	 * @throws InvalidInterfaceException
2746
+	 */
2747
+	public function display_about_admin_page()
2748
+	{
2749
+		$this->_display_admin_page(false, true);
2750
+	}
2751
+
2752
+
2753
+	/**
2754
+	 * display_admin_page
2755
+	 * contains the code for actually displaying an admin page
2756
+	 *
2757
+	 * @param boolean $sidebar true with sidebar, false without
2758
+	 * @param boolean $about   use the about admin wrapper instead of the default.
2759
+	 * @return void
2760
+	 * @throws DomainException
2761
+	 * @throws EE_Error
2762
+	 * @throws InvalidArgumentException
2763
+	 * @throws InvalidDataTypeException
2764
+	 * @throws InvalidInterfaceException
2765
+	 */
2766
+	private function _display_admin_page($sidebar = false, $about = false)
2767
+	{
2768
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2769
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2770
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2771
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2772
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2773
+
2774
+		$post_body_content = $this->_template_args['before_admin_page_content'] ?? '';
2775
+
2776
+		$this->_template_args['add_page_frame'] = $this->_req_action !== 'system_status'
2777
+												 && $this->_req_action !== 'data_reset'
2778
+												 && $this->_wp_page_slug !== 'event-espresso_page_espresso_packages'
2779
+												 && strpos($post_body_content, 'wp-list-table') === false;
2780
+
2781
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2782
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2783
+			? 'poststuff'
2784
+			: 'espresso-default-admin';
2785
+		$this->_template_args['admin_page_wrapper_div_class'] = str_replace(
2786
+			'event-espresso_page_espresso_',
2787
+			'',
2788
+			$this->_wp_page_slug
2789
+		) . ' ' . $this->_req_action . '-route';
2790
+
2791
+		$template_path = $sidebar
2792
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2793
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2794
+		if ($this->request->isAjax()) {
2795
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2796
+		}
2797
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2798
+
2799
+		$this->_template_args['post_body_content']         = $this->_template_args['admin_page_content'] ?? '';
2800
+		$this->_template_args['before_admin_page_content'] = $post_body_content;
2801
+		$this->_template_args['after_admin_page_content']  = $this->_template_args['after_admin_page_content'] ?? '';
2802
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2803
+			$template_path,
2804
+			$this->_template_args,
2805
+			true
2806
+		);
2807
+		// the final template wrapper
2808
+		$this->admin_page_wrapper($about);
2809
+	}
2810
+
2811
+
2812
+	/**
2813
+	 * This is used to display caf preview pages.
2814
+	 *
2815
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2816
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2817
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2818
+	 * @return void
2819
+	 * @throws DomainException
2820
+	 * @throws EE_Error
2821
+	 * @throws InvalidArgumentException
2822
+	 * @throws InvalidDataTypeException
2823
+	 * @throws InvalidInterfaceException
2824
+	 * @since 4.3.2
2825
+	 */
2826
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2827
+	{
2828
+		// let's generate a default preview action button if there isn't one already present.
2829
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2830
+			'Upgrade to Event Espresso 4 Right Now',
2831
+			'event_espresso'
2832
+		);
2833
+		$buy_now_url                                   = add_query_arg(
2834
+			[
2835
+				'ee_ver'       => 'ee4',
2836
+				'utm_source'   => 'ee4_plugin_admin',
2837
+				'utm_medium'   => 'link',
2838
+				'utm_campaign' => $utm_campaign_source,
2839
+				'utm_content'  => 'buy_now_button',
2840
+			],
2841
+			'https://eventespresso.com/pricing/'
2842
+		);
2843
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2844
+			? $this->get_action_link_or_button(
2845
+				'',
2846
+				'buy_now',
2847
+				[],
2848
+				'button button--primary button--big',
2849
+				esc_url_raw($buy_now_url),
2850
+				true
2851
+			)
2852
+			: $this->_template_args['preview_action_button'];
2853
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2854
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2855
+			$this->_template_args,
2856
+			true
2857
+		);
2858
+		$this->_display_admin_page($display_sidebar);
2859
+	}
2860
+
2861
+
2862
+	/**
2863
+	 * display_admin_list_table_page_with_sidebar
2864
+	 * generates HTML wrapper for an admin_page with list_table
2865
+	 *
2866
+	 * @return void
2867
+	 * @throws DomainException
2868
+	 * @throws EE_Error
2869
+	 * @throws InvalidArgumentException
2870
+	 * @throws InvalidDataTypeException
2871
+	 * @throws InvalidInterfaceException
2872
+	 */
2873
+	public function display_admin_list_table_page_with_sidebar()
2874
+	{
2875
+		$this->_display_admin_list_table_page(true);
2876
+	}
2877
+
2878
+
2879
+	/**
2880
+	 * display_admin_list_table_page_with_no_sidebar
2881
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2882
+	 *
2883
+	 * @return void
2884
+	 * @throws DomainException
2885
+	 * @throws EE_Error
2886
+	 * @throws InvalidArgumentException
2887
+	 * @throws InvalidDataTypeException
2888
+	 * @throws InvalidInterfaceException
2889
+	 */
2890
+	public function display_admin_list_table_page_with_no_sidebar()
2891
+	{
2892
+		$this->_display_admin_list_table_page();
2893
+	}
2894
+
2895
+
2896
+	/**
2897
+	 * generates html wrapper for an admin_list_table page
2898
+	 *
2899
+	 * @param boolean $sidebar whether to display with sidebar or not.
2900
+	 * @return void
2901
+	 * @throws DomainException
2902
+	 * @throws EE_Error
2903
+	 * @throws InvalidArgumentException
2904
+	 * @throws InvalidDataTypeException
2905
+	 * @throws InvalidInterfaceException
2906
+	 */
2907
+	private function _display_admin_list_table_page($sidebar = false)
2908
+	{
2909
+		// setup search attributes
2910
+		$this->_set_search_attributes();
2911
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2912
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2913
+		$this->_template_args['table_url']        = $this->request->isAjax()
2914
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2915
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2916
+		$this->_template_args['list_table']       = $this->_list_table_object;
2917
+		$this->_template_args['current_route']    = $this->_req_action;
2918
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2919
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2920
+		if (! empty($ajax_sorting_callback)) {
2921
+			$sortable_list_table_form_fields = wp_nonce_field(
2922
+				$ajax_sorting_callback . '_nonce',
2923
+				$ajax_sorting_callback . '_nonce',
2924
+				false,
2925
+				false
2926
+			);
2927
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2928
+												. $this->page_slug
2929
+												. '" />';
2930
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2931
+												. $ajax_sorting_callback
2932
+												. '" />';
2933
+		} else {
2934
+			$sortable_list_table_form_fields = '';
2935
+		}
2936
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2937
+
2938
+		$hidden_form_fields = $this->_template_args['list_table_hidden_fields'] ?? '';
2939
+
2940
+		$nonce_ref          = $this->_req_action . '_nonce';
2941
+		$hidden_form_fields .= '
2942 2942
             <input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2943 2943
 
2944
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2945
-        // display message about search results?
2946
-        $search = $this->request->getRequestParam('s');
2947
-        $this->_template_args['before_list_table'] .= ! empty($search)
2948
-            ? '<p class="ee-search-results">' . sprintf(
2949
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2950
-                trim($search, '%')
2951
-            ) . '</p>'
2952
-            : '';
2953
-        // filter before_list_table template arg
2954
-        $this->_template_args['before_list_table'] = apply_filters(
2955
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2956
-            $this->_template_args['before_list_table'],
2957
-            $this->page_slug,
2958
-            $this->request->requestParams(),
2959
-            $this->_req_action
2960
-        );
2961
-        // convert to array and filter again
2962
-        // arrays are easier to inject new items in a specific location,
2963
-        // but would not be backwards compatible, so we have to add a new filter
2964
-        $this->_template_args['before_list_table'] = implode(
2965
-            " \n",
2966
-            (array) apply_filters(
2967
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2968
-                (array) $this->_template_args['before_list_table'],
2969
-                $this->page_slug,
2970
-                $this->request->requestParams(),
2971
-                $this->_req_action
2972
-            )
2973
-        );
2974
-        // filter after_list_table template arg
2975
-        $this->_template_args['after_list_table'] = apply_filters(
2976
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2977
-            $this->_template_args['after_list_table'],
2978
-            $this->page_slug,
2979
-            $this->request->requestParams(),
2980
-            $this->_req_action
2981
-        );
2982
-        // convert to array and filter again
2983
-        // arrays are easier to inject new items in a specific location,
2984
-        // but would not be backwards compatible, so we have to add a new filter
2985
-        $this->_template_args['after_list_table']   = implode(
2986
-            " \n",
2987
-            (array) apply_filters(
2988
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2989
-                (array) $this->_template_args['after_list_table'],
2990
-                $this->page_slug,
2991
-                $this->request->requestParams(),
2992
-                $this->_req_action
2993
-            )
2994
-        );
2995
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2996
-            $template_path,
2997
-            $this->_template_args,
2998
-            true
2999
-        );
3000
-        // the final template wrapper
3001
-        if ($sidebar) {
3002
-            $this->display_admin_page_with_sidebar();
3003
-        } else {
3004
-            $this->display_admin_page_with_no_sidebar();
3005
-        }
3006
-    }
3007
-
3008
-
3009
-    /**
3010
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3011
-     * html string for the legend.
3012
-     * $items are expected in an array in the following format:
3013
-     * $legend_items = array(
3014
-     *        'item_id' => array(
3015
-     *            'icon' => 'http://url_to_icon_being_described.png',
3016
-     *            'desc' => esc_html__('localized description of item');
3017
-     *        )
3018
-     * );
3019
-     *
3020
-     * @param array $items see above for format of array
3021
-     * @return string html string of legend
3022
-     * @throws DomainException
3023
-     */
3024
-    protected function _display_legend($items)
3025
-    {
3026
-        $this->_template_args['items'] = apply_filters(
3027
-            'FHEE__EE_Admin_Page___display_legend__items',
3028
-            (array) $items,
3029
-            $this
3030
-        );
3031
-        /** @var StatusChangeNotice $status_change_notice */
3032
-        $status_change_notice = $this->loader->getShared(
3033
-            'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
3034
-        );
3035
-        $this->_template_args['status_change_notice'] = $status_change_notice->display(
3036
-            '__admin-legend',
3037
-            $this->page_slug
3038
-        );
3039
-        return EEH_Template::display_template(
3040
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3041
-            $this->_template_args,
3042
-            true
3043
-        );
3044
-    }
3045
-
3046
-
3047
-    /**
3048
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3049
-     * The returned json object is created from an array in the following format:
3050
-     * array(
3051
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3052
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3053
-     *  'notices' => '', // - contains any EE_Error formatted notices
3054
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3055
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3056
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3057
-     *  that might be included in here)
3058
-     * )
3059
-     * The json object is populated by whatever is set in the $_template_args property.
3060
-     *
3061
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3062
-     *                                 instead of displayed.
3063
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3064
-     * @return void
3065
-     * @throws EE_Error
3066
-     * @throws InvalidArgumentException
3067
-     * @throws InvalidDataTypeException
3068
-     * @throws InvalidInterfaceException
3069
-     */
3070
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3071
-    {
3072
-        // make sure any EE_Error notices have been handled.
3073
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3074
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3075
-        unset($this->_template_args['data']);
3076
-        $json = [
3077
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3078
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3079
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3080
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3081
-            'notices'   => EE_Error::get_notices(),
3082
-            'content'   => isset($this->_template_args['admin_page_content'])
3083
-                ? $this->_template_args['admin_page_content'] : '',
3084
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3085
-            'isEEajax'  => true
3086
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3087
-        ];
3088
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3089
-        if (null === error_get_last() || ! headers_sent()) {
3090
-            header('Content-Type: application/json; charset=UTF-8');
3091
-        }
3092
-        echo wp_json_encode($json);
3093
-        exit();
3094
-    }
3095
-
3096
-
3097
-    /**
3098
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3099
-     *
3100
-     * @return void
3101
-     * @throws EE_Error
3102
-     * @throws InvalidArgumentException
3103
-     * @throws InvalidDataTypeException
3104
-     * @throws InvalidInterfaceException
3105
-     */
3106
-    public function return_json()
3107
-    {
3108
-        if ($this->request->isAjax()) {
3109
-            $this->_return_json();
3110
-        } else {
3111
-            throw new EE_Error(
3112
-                sprintf(
3113
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3114
-                    __FUNCTION__
3115
-                )
3116
-            );
3117
-        }
3118
-    }
3119
-
3120
-
3121
-    /**
3122
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3123
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3124
-     *
3125
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3126
-     */
3127
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3128
-    {
3129
-        $this->_hook_obj = $hook_obj;
3130
-    }
3131
-
3132
-
3133
-    /**
3134
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3135
-     *
3136
-     * @param boolean $about whether to use the special about page wrapper or default.
3137
-     * @return void
3138
-     * @throws DomainException
3139
-     * @throws EE_Error
3140
-     * @throws InvalidArgumentException
3141
-     * @throws InvalidDataTypeException
3142
-     * @throws InvalidInterfaceException
3143
-     */
3144
-    public function admin_page_wrapper($about = false)
3145
-    {
3146
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3147
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3148
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3149
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3150
-
3151
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3152
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3153
-            $this->_template_args['before_admin_page_content'] ?? ''
3154
-        );
3155
-
3156
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3157
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3158
-            $this->_template_args['after_admin_page_content'] ?? ''
3159
-        );
3160
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3161
-
3162
-        if ($this->request->isAjax()) {
3163
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3164
-                // $template_path,
3165
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3166
-                $this->_template_args,
3167
-                true
3168
-            );
3169
-            $this->_return_json();
3170
-        }
3171
-        // load settings page wrapper template
3172
-        $template_path = $about
3173
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3174
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3175
-
3176
-        EEH_Template::display_template($template_path, $this->_template_args);
3177
-    }
3178
-
3179
-
3180
-    /**
3181
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3182
-     *
3183
-     * @return string html
3184
-     * @throws EE_Error
3185
-     */
3186
-    protected function _get_main_nav_tabs()
3187
-    {
3188
-        // let's generate the html using the EEH_Tabbed_Content helper.
3189
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3190
-        // (rather than setting in the page_routes array)
3191
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3192
-    }
3193
-
3194
-
3195
-    /**
3196
-     *        sort nav tabs
3197
-     *
3198
-     * @param $a
3199
-     * @param $b
3200
-     * @return int
3201
-     */
3202
-    private function _sort_nav_tabs($a, $b)
3203
-    {
3204
-        if ($a['order'] === $b['order']) {
3205
-            return 0;
3206
-        }
3207
-        return ($a['order'] < $b['order']) ? -1 : 1;
3208
-    }
3209
-
3210
-
3211
-    /**
3212
-     * generates HTML for the forms used on admin pages
3213
-     *
3214
-     * @param array  $input_vars - array of input field details
3215
-     * @param string $generator  indicates which generator to use: options are 'string' or 'array'
3216
-     * @param bool   $id
3217
-     * @return array|string
3218
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3219
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3220
-     */
3221
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3222
-    {
3223
-        return $generator === 'string'
3224
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3225
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3226
-    }
3227
-
3228
-
3229
-    /**
3230
-     * generates the "Save" and "Save & Close" buttons for edit forms
3231
-     *
3232
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3233
-     *                                   Close" button.
3234
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3235
-     *                                   'Save', [1] => 'save & close')
3236
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3237
-     *                                   via the "name" value in the button).  We can also use this to just dump
3238
-     *                                   default actions by submitting some other value.
3239
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3240
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3241
-     *                                   close (normal form handling).
3242
-     */
3243
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3244
-    {
3245
-        // make sure $text and $actions are in an array
3246
-        $text          = (array) $text;
3247
-        $actions       = (array) $actions;
3248
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3249
-        $button_text   = ! empty($text)
3250
-            ? $text
3251
-            : [
3252
-                esc_html__('Save', 'event_espresso'),
3253
-                esc_html__('Save and Close', 'event_espresso'),
3254
-            ];
3255
-        $default_names = ['save', 'save_and_close'];
3256
-        $buttons = '';
3257
-        foreach ($button_text as $key => $button) {
3258
-            $ref     = $default_names[ $key ];
3259
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3260
-            $buttons .= '<input type="submit" class="button button--primary ' . $ref . '" '
3261
-                        . 'value="' . $button . '" name="' . $name . '" '
3262
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3263
-            if (! $both) {
3264
-                break;
3265
-            }
3266
-        }
3267
-        // add in a hidden index for the current page (so save and close redirects properly)
3268
-        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3269
-                   . $referrer_url
3270
-                   . '" />';
3271
-        $this->_template_args['save_buttons'] = $buttons;
3272
-    }
3273
-
3274
-
3275
-    /**
3276
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3277
-     *
3278
-     * @param string $route
3279
-     * @param array  $additional_hidden_fields
3280
-     * @see   $this->_set_add_edit_form_tags() for details on params
3281
-     * @since 4.6.0
3282
-     */
3283
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3284
-    {
3285
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3286
-    }
3287
-
3288
-
3289
-    /**
3290
-     * set form open and close tags on add/edit pages.
3291
-     *
3292
-     * @param string $route                    the route you want the form to direct to
3293
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3294
-     * @return void
3295
-     */
3296
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3297
-    {
3298
-        if (empty($route)) {
3299
-            $user_msg = esc_html__(
3300
-                'An error occurred. No action was set for this page\'s form.',
3301
-                'event_espresso'
3302
-            );
3303
-            $dev_msg  = $user_msg . "\n"
3304
-                        . sprintf(
3305
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3306
-                            __FUNCTION__,
3307
-                            __CLASS__
3308
-                        );
3309
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3310
-        }
3311
-        // open form
3312
-        $action = $this->_admin_base_url;
3313
-        $this->_template_args['before_admin_page_content'] = "
2944
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2945
+		// display message about search results?
2946
+		$search = $this->request->getRequestParam('s');
2947
+		$this->_template_args['before_list_table'] .= ! empty($search)
2948
+			? '<p class="ee-search-results">' . sprintf(
2949
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2950
+				trim($search, '%')
2951
+			) . '</p>'
2952
+			: '';
2953
+		// filter before_list_table template arg
2954
+		$this->_template_args['before_list_table'] = apply_filters(
2955
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2956
+			$this->_template_args['before_list_table'],
2957
+			$this->page_slug,
2958
+			$this->request->requestParams(),
2959
+			$this->_req_action
2960
+		);
2961
+		// convert to array and filter again
2962
+		// arrays are easier to inject new items in a specific location,
2963
+		// but would not be backwards compatible, so we have to add a new filter
2964
+		$this->_template_args['before_list_table'] = implode(
2965
+			" \n",
2966
+			(array) apply_filters(
2967
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2968
+				(array) $this->_template_args['before_list_table'],
2969
+				$this->page_slug,
2970
+				$this->request->requestParams(),
2971
+				$this->_req_action
2972
+			)
2973
+		);
2974
+		// filter after_list_table template arg
2975
+		$this->_template_args['after_list_table'] = apply_filters(
2976
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2977
+			$this->_template_args['after_list_table'],
2978
+			$this->page_slug,
2979
+			$this->request->requestParams(),
2980
+			$this->_req_action
2981
+		);
2982
+		// convert to array and filter again
2983
+		// arrays are easier to inject new items in a specific location,
2984
+		// but would not be backwards compatible, so we have to add a new filter
2985
+		$this->_template_args['after_list_table']   = implode(
2986
+			" \n",
2987
+			(array) apply_filters(
2988
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2989
+				(array) $this->_template_args['after_list_table'],
2990
+				$this->page_slug,
2991
+				$this->request->requestParams(),
2992
+				$this->_req_action
2993
+			)
2994
+		);
2995
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2996
+			$template_path,
2997
+			$this->_template_args,
2998
+			true
2999
+		);
3000
+		// the final template wrapper
3001
+		if ($sidebar) {
3002
+			$this->display_admin_page_with_sidebar();
3003
+		} else {
3004
+			$this->display_admin_page_with_no_sidebar();
3005
+		}
3006
+	}
3007
+
3008
+
3009
+	/**
3010
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3011
+	 * html string for the legend.
3012
+	 * $items are expected in an array in the following format:
3013
+	 * $legend_items = array(
3014
+	 *        'item_id' => array(
3015
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3016
+	 *            'desc' => esc_html__('localized description of item');
3017
+	 *        )
3018
+	 * );
3019
+	 *
3020
+	 * @param array $items see above for format of array
3021
+	 * @return string html string of legend
3022
+	 * @throws DomainException
3023
+	 */
3024
+	protected function _display_legend($items)
3025
+	{
3026
+		$this->_template_args['items'] = apply_filters(
3027
+			'FHEE__EE_Admin_Page___display_legend__items',
3028
+			(array) $items,
3029
+			$this
3030
+		);
3031
+		/** @var StatusChangeNotice $status_change_notice */
3032
+		$status_change_notice = $this->loader->getShared(
3033
+			'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
3034
+		);
3035
+		$this->_template_args['status_change_notice'] = $status_change_notice->display(
3036
+			'__admin-legend',
3037
+			$this->page_slug
3038
+		);
3039
+		return EEH_Template::display_template(
3040
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3041
+			$this->_template_args,
3042
+			true
3043
+		);
3044
+	}
3045
+
3046
+
3047
+	/**
3048
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3049
+	 * The returned json object is created from an array in the following format:
3050
+	 * array(
3051
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3052
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3053
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3054
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3055
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3056
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3057
+	 *  that might be included in here)
3058
+	 * )
3059
+	 * The json object is populated by whatever is set in the $_template_args property.
3060
+	 *
3061
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3062
+	 *                                 instead of displayed.
3063
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3064
+	 * @return void
3065
+	 * @throws EE_Error
3066
+	 * @throws InvalidArgumentException
3067
+	 * @throws InvalidDataTypeException
3068
+	 * @throws InvalidInterfaceException
3069
+	 */
3070
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3071
+	{
3072
+		// make sure any EE_Error notices have been handled.
3073
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3074
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3075
+		unset($this->_template_args['data']);
3076
+		$json = [
3077
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3078
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3079
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3080
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3081
+			'notices'   => EE_Error::get_notices(),
3082
+			'content'   => isset($this->_template_args['admin_page_content'])
3083
+				? $this->_template_args['admin_page_content'] : '',
3084
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3085
+			'isEEajax'  => true
3086
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3087
+		];
3088
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3089
+		if (null === error_get_last() || ! headers_sent()) {
3090
+			header('Content-Type: application/json; charset=UTF-8');
3091
+		}
3092
+		echo wp_json_encode($json);
3093
+		exit();
3094
+	}
3095
+
3096
+
3097
+	/**
3098
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3099
+	 *
3100
+	 * @return void
3101
+	 * @throws EE_Error
3102
+	 * @throws InvalidArgumentException
3103
+	 * @throws InvalidDataTypeException
3104
+	 * @throws InvalidInterfaceException
3105
+	 */
3106
+	public function return_json()
3107
+	{
3108
+		if ($this->request->isAjax()) {
3109
+			$this->_return_json();
3110
+		} else {
3111
+			throw new EE_Error(
3112
+				sprintf(
3113
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3114
+					__FUNCTION__
3115
+				)
3116
+			);
3117
+		}
3118
+	}
3119
+
3120
+
3121
+	/**
3122
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3123
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3124
+	 *
3125
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3126
+	 */
3127
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3128
+	{
3129
+		$this->_hook_obj = $hook_obj;
3130
+	}
3131
+
3132
+
3133
+	/**
3134
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3135
+	 *
3136
+	 * @param boolean $about whether to use the special about page wrapper or default.
3137
+	 * @return void
3138
+	 * @throws DomainException
3139
+	 * @throws EE_Error
3140
+	 * @throws InvalidArgumentException
3141
+	 * @throws InvalidDataTypeException
3142
+	 * @throws InvalidInterfaceException
3143
+	 */
3144
+	public function admin_page_wrapper($about = false)
3145
+	{
3146
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3147
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3148
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3149
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3150
+
3151
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3152
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3153
+			$this->_template_args['before_admin_page_content'] ?? ''
3154
+		);
3155
+
3156
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3157
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3158
+			$this->_template_args['after_admin_page_content'] ?? ''
3159
+		);
3160
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3161
+
3162
+		if ($this->request->isAjax()) {
3163
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3164
+				// $template_path,
3165
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3166
+				$this->_template_args,
3167
+				true
3168
+			);
3169
+			$this->_return_json();
3170
+		}
3171
+		// load settings page wrapper template
3172
+		$template_path = $about
3173
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3174
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3175
+
3176
+		EEH_Template::display_template($template_path, $this->_template_args);
3177
+	}
3178
+
3179
+
3180
+	/**
3181
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3182
+	 *
3183
+	 * @return string html
3184
+	 * @throws EE_Error
3185
+	 */
3186
+	protected function _get_main_nav_tabs()
3187
+	{
3188
+		// let's generate the html using the EEH_Tabbed_Content helper.
3189
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3190
+		// (rather than setting in the page_routes array)
3191
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3192
+	}
3193
+
3194
+
3195
+	/**
3196
+	 *        sort nav tabs
3197
+	 *
3198
+	 * @param $a
3199
+	 * @param $b
3200
+	 * @return int
3201
+	 */
3202
+	private function _sort_nav_tabs($a, $b)
3203
+	{
3204
+		if ($a['order'] === $b['order']) {
3205
+			return 0;
3206
+		}
3207
+		return ($a['order'] < $b['order']) ? -1 : 1;
3208
+	}
3209
+
3210
+
3211
+	/**
3212
+	 * generates HTML for the forms used on admin pages
3213
+	 *
3214
+	 * @param array  $input_vars - array of input field details
3215
+	 * @param string $generator  indicates which generator to use: options are 'string' or 'array'
3216
+	 * @param bool   $id
3217
+	 * @return array|string
3218
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3219
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3220
+	 */
3221
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3222
+	{
3223
+		return $generator === 'string'
3224
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3225
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3226
+	}
3227
+
3228
+
3229
+	/**
3230
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3231
+	 *
3232
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3233
+	 *                                   Close" button.
3234
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3235
+	 *                                   'Save', [1] => 'save & close')
3236
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3237
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3238
+	 *                                   default actions by submitting some other value.
3239
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3240
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3241
+	 *                                   close (normal form handling).
3242
+	 */
3243
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3244
+	{
3245
+		// make sure $text and $actions are in an array
3246
+		$text          = (array) $text;
3247
+		$actions       = (array) $actions;
3248
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3249
+		$button_text   = ! empty($text)
3250
+			? $text
3251
+			: [
3252
+				esc_html__('Save', 'event_espresso'),
3253
+				esc_html__('Save and Close', 'event_espresso'),
3254
+			];
3255
+		$default_names = ['save', 'save_and_close'];
3256
+		$buttons = '';
3257
+		foreach ($button_text as $key => $button) {
3258
+			$ref     = $default_names[ $key ];
3259
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3260
+			$buttons .= '<input type="submit" class="button button--primary ' . $ref . '" '
3261
+						. 'value="' . $button . '" name="' . $name . '" '
3262
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3263
+			if (! $both) {
3264
+				break;
3265
+			}
3266
+		}
3267
+		// add in a hidden index for the current page (so save and close redirects properly)
3268
+		$buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3269
+				   . $referrer_url
3270
+				   . '" />';
3271
+		$this->_template_args['save_buttons'] = $buttons;
3272
+	}
3273
+
3274
+
3275
+	/**
3276
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3277
+	 *
3278
+	 * @param string $route
3279
+	 * @param array  $additional_hidden_fields
3280
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3281
+	 * @since 4.6.0
3282
+	 */
3283
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3284
+	{
3285
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3286
+	}
3287
+
3288
+
3289
+	/**
3290
+	 * set form open and close tags on add/edit pages.
3291
+	 *
3292
+	 * @param string $route                    the route you want the form to direct to
3293
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3294
+	 * @return void
3295
+	 */
3296
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3297
+	{
3298
+		if (empty($route)) {
3299
+			$user_msg = esc_html__(
3300
+				'An error occurred. No action was set for this page\'s form.',
3301
+				'event_espresso'
3302
+			);
3303
+			$dev_msg  = $user_msg . "\n"
3304
+						. sprintf(
3305
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3306
+							__FUNCTION__,
3307
+							__CLASS__
3308
+						);
3309
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3310
+		}
3311
+		// open form
3312
+		$action = $this->_admin_base_url;
3313
+		$this->_template_args['before_admin_page_content'] = "
3314 3314
             <form name='form' method='post' action='{$action}' id='{$route}_event_form' class='ee-admin-page-form' >
3315 3315
             ";
3316
-        // add nonce
3317
-        $nonce                                             =
3318
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3319
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3320
-        // add REQUIRED form action
3321
-        $hidden_fields = [
3322
-            'action' => ['type' => 'hidden', 'value' => $route],
3323
-        ];
3324
-        // merge arrays
3325
-        $hidden_fields = is_array($additional_hidden_fields)
3326
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3327
-            : $hidden_fields;
3328
-        // generate form fields
3329
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3330
-        // add fields to form
3331
-        foreach ((array) $form_fields as $form_field) {
3332
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3333
-        }
3334
-        // close form
3335
-        $this->_template_args['after_admin_page_content'] = '</form>';
3336
-    }
3337
-
3338
-
3339
-    /**
3340
-     * Public Wrapper for _redirect_after_action() method since its
3341
-     * discovered it would be useful for external code to have access.
3342
-     *
3343
-     * @param bool   $success
3344
-     * @param string $what
3345
-     * @param string $action_desc
3346
-     * @param array  $query_args
3347
-     * @param bool   $override_overwrite
3348
-     * @throws EE_Error
3349
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3350
-     * @since 4.5.0
3351
-     */
3352
-    public function redirect_after_action(
3353
-        $success = false,
3354
-        $what = 'item',
3355
-        $action_desc = 'processed',
3356
-        $query_args = [],
3357
-        $override_overwrite = false
3358
-    ) {
3359
-        $this->_redirect_after_action(
3360
-            $success,
3361
-            $what,
3362
-            $action_desc,
3363
-            $query_args,
3364
-            $override_overwrite
3365
-        );
3366
-    }
3367
-
3368
-
3369
-    /**
3370
-     * Helper method for merging existing request data with the returned redirect url.
3371
-     *
3372
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3373
-     * filters are still applied.
3374
-     *
3375
-     * @param array $new_route_data
3376
-     * @return array
3377
-     */
3378
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3379
-    {
3380
-        foreach ($this->request->requestParams() as $ref => $value) {
3381
-            // unset nonces
3382
-            if (strpos($ref, 'nonce') !== false) {
3383
-                $this->request->unSetRequestParam($ref);
3384
-                continue;
3385
-            }
3386
-            // urlencode values.
3387
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3388
-            $this->request->setRequestParam($ref, $value);
3389
-        }
3390
-        return array_merge($this->request->requestParams(), $new_route_data);
3391
-    }
3392
-
3393
-
3394
-    /**
3395
-     * @param int|float|string $success      - whether success was for two or more records, or just one, or none
3396
-     * @param string           $what         - what the action was performed on
3397
-     * @param string           $action_desc  - what was done ie: updated, deleted, etc
3398
-     * @param array $query_args              - an array of query_args to be added to the URL to redirect to
3399
-     * @param BOOL $override_overwrite       - by default all EE_Error::success messages are overwritten,
3400
-     *                                         this allows you to override this so that they show.
3401
-     * @return void
3402
-     * @throws EE_Error
3403
-     * @throws InvalidArgumentException
3404
-     * @throws InvalidDataTypeException
3405
-     * @throws InvalidInterfaceException
3406
-     */
3407
-    protected function _redirect_after_action(
3408
-        $success = 0,
3409
-        string $what = 'item',
3410
-        string $action_desc = 'processed',
3411
-        array $query_args = [],
3412
-        bool $override_overwrite = false
3413
-    ) {
3414
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3415
-        $notices      = EE_Error::get_notices(false);
3416
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3417
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3418
-            EE_Error::overwrite_success();
3419
-        }
3420
-        if (! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3421
-            // how many records affected ? more than one record ? or just one ?
3422
-            EE_Error::add_success(
3423
-                sprintf(
3424
-                    esc_html(
3425
-                        _n(
3426
-                            'The "%1$s" has been successfully %2$s.',
3427
-                            'The "%1$s" have been successfully %2$s.',
3428
-                            $success,
3429
-                            'event_espresso'
3430
-                        )
3431
-                    ),
3432
-                    $what,
3433
-                    $action_desc
3434
-                ),
3435
-                __FILE__,
3436
-                __FUNCTION__,
3437
-                __LINE__
3438
-            );
3439
-        }
3440
-        // check that $query_args isn't something crazy
3441
-        if (! is_array($query_args)) {
3442
-            $query_args = [];
3443
-        }
3444
-        /**
3445
-         * Allow injecting actions before the query_args are modified for possible different
3446
-         * redirections on save and close actions
3447
-         *
3448
-         * @param array $query_args       The original query_args array coming into the
3449
-         *                                method.
3450
-         * @since 4.2.0
3451
-         */
3452
-        do_action(
3453
-            "AHEE__{$this->class_name}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3454
-            $query_args
3455
-        );
3456
-        // set redirect url.
3457
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3458
-        // otherwise we go with whatever is set as the _admin_base_url
3459
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3460
-        // calculate where we're going (if we have a "save and close" button pushed)
3461
-        if (
3462
-            $this->request->requestParamIsSet('save_and_close')
3463
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3464
-        ) {
3465
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3466
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3467
-            // regenerate query args array from referrer URL
3468
-            parse_str($parsed_url['query'], $query_args);
3469
-            // correct page and action will be in the query args now
3470
-            $redirect_url = admin_url('admin.php');
3471
-        }
3472
-        // merge any default query_args set in _default_route_query_args property
3473
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3474
-            $args_to_merge = [];
3475
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3476
-                // is there a wp_referer array in our _default_route_query_args property?
3477
-                if ($query_param === 'wp_referer') {
3478
-                    $query_value = (array) $query_value;
3479
-                    foreach ($query_value as $reference => $value) {
3480
-                        if (strpos($reference, 'nonce') !== false) {
3481
-                            continue;
3482
-                        }
3483
-                        // finally we will override any arguments in the referer with
3484
-                        // what might be set on the _default_route_query_args array.
3485
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3486
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3487
-                        } else {
3488
-                            $args_to_merge[ $reference ] = urlencode($value);
3489
-                        }
3490
-                    }
3491
-                    continue;
3492
-                }
3493
-                $args_to_merge[ $query_param ] = $query_value;
3494
-            }
3495
-            // now let's merge these arguments but override with what was specifically sent in to the
3496
-            // redirect.
3497
-            $query_args = array_merge($args_to_merge, $query_args);
3498
-        }
3499
-        $this->_process_notices($query_args);
3500
-        // generate redirect url
3501
-        // if redirecting to anything other than the main page, add a nonce
3502
-        if (isset($query_args['action'])) {
3503
-            // manually generate wp_nonce and merge that with the query vars
3504
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3505
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3506
-        }
3507
-        // we're adding some hooks and filters in here for processing any things just before redirects
3508
-        // (example: an admin page has done an insert or update and we want to run something after that).
3509
-        do_action('AHEE_redirect_' . $this->class_name . $this->_req_action, $query_args);
3510
-        $redirect_url = apply_filters(
3511
-            'FHEE_redirect_' . $this->class_name . $this->_req_action,
3512
-            EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3513
-            $query_args
3514
-        );
3515
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3516
-        if ($this->request->isAjax()) {
3517
-            $default_data                    = [
3518
-                'close'        => true,
3519
-                'redirect_url' => $redirect_url,
3520
-                'where'        => 'main',
3521
-                'what'         => 'append',
3522
-            ];
3523
-            $this->_template_args['success'] = $success;
3524
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3525
-                $default_data,
3526
-                $this->_template_args['data']
3527
-            ) : $default_data;
3528
-            $this->_return_json();
3529
-        }
3530
-        wp_safe_redirect($redirect_url);
3531
-        exit();
3532
-    }
3533
-
3534
-
3535
-    /**
3536
-     * process any notices before redirecting (or returning ajax request)
3537
-     * This method sets the $this->_template_args['notices'] attribute;
3538
-     *
3539
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3540
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3541
-     *                                  page_routes haven't been defined yet.
3542
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3543
-     *                                  still save a transient for the notice.
3544
-     * @return void
3545
-     * @throws EE_Error
3546
-     * @throws InvalidArgumentException
3547
-     * @throws InvalidDataTypeException
3548
-     * @throws InvalidInterfaceException
3549
-     */
3550
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3551
-    {
3552
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3553
-        if ($this->request->isAjax()) {
3554
-            $notices = EE_Error::get_notices(false);
3555
-            if (empty($this->_template_args['success'])) {
3556
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3557
-            }
3558
-            if (empty($this->_template_args['errors'])) {
3559
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3560
-            }
3561
-            if (empty($this->_template_args['attention'])) {
3562
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3563
-            }
3564
-        }
3565
-        $this->_template_args['notices'] = EE_Error::get_notices();
3566
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3567
-        if (! $this->request->isAjax() || $sticky_notices) {
3568
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3569
-            $this->_add_transient(
3570
-                $route,
3571
-                $this->_template_args['notices'],
3572
-                true,
3573
-                $skip_route_verify
3574
-            );
3575
-        }
3576
-    }
3577
-
3578
-
3579
-    /**
3580
-     * get_action_link_or_button
3581
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3582
-     *
3583
-     * @param string $action        use this to indicate which action the url is generated with.
3584
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3585
-     *                              property.
3586
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3587
-     * @param string $class         Use this to give the class for the button. Defaults to 'button--primary'
3588
-     * @param string $base_url      If this is not provided
3589
-     *                              the _admin_base_url will be used as the default for the button base_url.
3590
-     *                              Otherwise this value will be used.
3591
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3592
-     * @return string
3593
-     * @throws InvalidArgumentException
3594
-     * @throws InvalidInterfaceException
3595
-     * @throws InvalidDataTypeException
3596
-     * @throws EE_Error
3597
-     */
3598
-    public function get_action_link_or_button(
3599
-        $action,
3600
-        $type = 'add',
3601
-        $extra_request = [],
3602
-        $class = 'button--primary',
3603
-        $base_url = '',
3604
-        $exclude_nonce = false
3605
-    ) {
3606
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3607
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3608
-            throw new EE_Error(
3609
-                sprintf(
3610
-                    esc_html__(
3611
-                        'There is no page route for given action for the button.  This action was given: %s',
3612
-                        'event_espresso'
3613
-                    ),
3614
-                    $action
3615
-                )
3616
-            );
3617
-        }
3618
-        if (! isset($this->_labels['buttons'][ $type ])) {
3619
-            throw new EE_Error(
3620
-                sprintf(
3621
-                    esc_html__(
3622
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3623
-                        'event_espresso'
3624
-                    ),
3625
-                    $type
3626
-                )
3627
-            );
3628
-        }
3629
-        // finally check user access for this button.
3630
-        $has_access = $this->check_user_access($action, true);
3631
-        if (! $has_access) {
3632
-            return '';
3633
-        }
3634
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3635
-        $query_args = [
3636
-            'action' => $action,
3637
-        ];
3638
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3639
-        if (! empty($extra_request)) {
3640
-            $query_args = array_merge($extra_request, $query_args);
3641
-        }
3642
-        $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3643
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3644
-    }
3645
-
3646
-
3647
-    /**
3648
-     * _per_page_screen_option
3649
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3650
-     *
3651
-     * @return void
3652
-     * @throws InvalidArgumentException
3653
-     * @throws InvalidInterfaceException
3654
-     * @throws InvalidDataTypeException
3655
-     */
3656
-    protected function _per_page_screen_option()
3657
-    {
3658
-        $option = 'per_page';
3659
-        $args   = [
3660
-            'label'   => apply_filters(
3661
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3662
-                $this->_admin_page_title,
3663
-                $this
3664
-            ),
3665
-            'default' => (int) apply_filters(
3666
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3667
-                20
3668
-            ),
3669
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3670
-        ];
3671
-        // ONLY add the screen option if the user has access to it.
3672
-        if ($this->check_user_access($this->_current_view, true)) {
3673
-            add_screen_option($option, $args);
3674
-        }
3675
-    }
3676
-
3677
-
3678
-    /**
3679
-     * set_per_page_screen_option
3680
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3681
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3682
-     * admin_menu.
3683
-     *
3684
-     * @return void
3685
-     */
3686
-    private function _set_per_page_screen_options()
3687
-    {
3688
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3689
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3690
-            if (! $user = wp_get_current_user()) {
3691
-                return;
3692
-            }
3693
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3694
-            if (! $option) {
3695
-                return;
3696
-            }
3697
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3698
-            $map_option = $option;
3699
-            $option     = str_replace('-', '_', $option);
3700
-            switch ($map_option) {
3701
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3702
-                    $max_value = apply_filters(
3703
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3704
-                        999,
3705
-                        $this->_current_page,
3706
-                        $this->_current_view
3707
-                    );
3708
-                    if ($value < 1) {
3709
-                        return;
3710
-                    }
3711
-                    $value = min($value, $max_value);
3712
-                    break;
3713
-                default:
3714
-                    $value = apply_filters(
3715
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3716
-                        false,
3717
-                        $option,
3718
-                        $value
3719
-                    );
3720
-                    if (false === $value) {
3721
-                        return;
3722
-                    }
3723
-                    break;
3724
-            }
3725
-            update_user_meta($user->ID, $option, $value);
3726
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3727
-            exit;
3728
-        }
3729
-    }
3730
-
3731
-
3732
-    /**
3733
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3734
-     *
3735
-     * @param array $data array that will be assigned to template args.
3736
-     */
3737
-    public function set_template_args($data)
3738
-    {
3739
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3740
-    }
3741
-
3742
-
3743
-    /**
3744
-     * This makes available the WP transient system for temporarily moving data between routes
3745
-     *
3746
-     * @param string $route             the route that should receive the transient
3747
-     * @param array  $data              the data that gets sent
3748
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3749
-     *                                  normal route transient.
3750
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3751
-     *                                  when we are adding a transient before page_routes have been defined.
3752
-     * @return void
3753
-     * @throws EE_Error
3754
-     */
3755
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3756
-    {
3757
-        $user_id = get_current_user_id();
3758
-        if (! $skip_route_verify) {
3759
-            $this->_verify_route($route);
3760
-        }
3761
-        // now let's set the string for what kind of transient we're setting
3762
-        $transient = $notices
3763
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3764
-            : 'rte_tx_' . $route . '_' . $user_id;
3765
-        $data      = $notices ? ['notices' => $data] : $data;
3766
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3767
-        $existing = is_multisite() && is_network_admin()
3768
-            ? get_site_transient($transient)
3769
-            : get_transient($transient);
3770
-        if ($existing) {
3771
-            $data = array_merge((array) $data, (array) $existing);
3772
-        }
3773
-        if (is_multisite() && is_network_admin()) {
3774
-            set_site_transient($transient, $data, 8);
3775
-        } else {
3776
-            set_transient($transient, $data, 8);
3777
-        }
3778
-    }
3779
-
3780
-
3781
-    /**
3782
-     * this retrieves the temporary transient that has been set for moving data between routes.
3783
-     *
3784
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3785
-     * @param string $route
3786
-     * @return mixed data
3787
-     */
3788
-    protected function _get_transient($notices = false, $route = '')
3789
-    {
3790
-        $user_id   = get_current_user_id();
3791
-        $route     = ! $route ? $this->_req_action : $route;
3792
-        $transient = $notices
3793
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3794
-            : 'rte_tx_' . $route . '_' . $user_id;
3795
-        $data      = is_multisite() && is_network_admin()
3796
-            ? get_site_transient($transient)
3797
-            : get_transient($transient);
3798
-        // delete transient after retrieval (just in case it hasn't expired);
3799
-        if (is_multisite() && is_network_admin()) {
3800
-            delete_site_transient($transient);
3801
-        } else {
3802
-            delete_transient($transient);
3803
-        }
3804
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3805
-    }
3806
-
3807
-
3808
-    /**
3809
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3810
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3811
-     * default route callback on the EE_Admin page you want it run.)
3812
-     *
3813
-     * @return void
3814
-     */
3815
-    protected function _transient_garbage_collection()
3816
-    {
3817
-        global $wpdb;
3818
-        // retrieve all existing transients
3819
-        $query =
3820
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3821
-        if ($results = $wpdb->get_results($query)) {
3822
-            foreach ($results as $result) {
3823
-                $transient = str_replace('_transient_', '', $result->option_name);
3824
-                get_transient($transient);
3825
-                if (is_multisite() && is_network_admin()) {
3826
-                    get_site_transient($transient);
3827
-                }
3828
-            }
3829
-        }
3830
-    }
3831
-
3832
-
3833
-    /**
3834
-     * get_view
3835
-     *
3836
-     * @return string content of _view property
3837
-     */
3838
-    public function get_view()
3839
-    {
3840
-        return $this->_view;
3841
-    }
3842
-
3843
-
3844
-    /**
3845
-     * getter for the protected $_views property
3846
-     *
3847
-     * @return array
3848
-     */
3849
-    public function get_views()
3850
-    {
3851
-        return $this->_views;
3852
-    }
3853
-
3854
-
3855
-    /**
3856
-     * get_current_page
3857
-     *
3858
-     * @return string _current_page property value
3859
-     */
3860
-    public function get_current_page()
3861
-    {
3862
-        return $this->_current_page;
3863
-    }
3864
-
3865
-
3866
-    /**
3867
-     * get_current_view
3868
-     *
3869
-     * @return string _current_view property value
3870
-     */
3871
-    public function get_current_view()
3872
-    {
3873
-        return $this->_current_view;
3874
-    }
3875
-
3876
-
3877
-    /**
3878
-     * get_current_screen
3879
-     *
3880
-     * @return object The current WP_Screen object
3881
-     */
3882
-    public function get_current_screen()
3883
-    {
3884
-        return $this->_current_screen;
3885
-    }
3886
-
3887
-
3888
-    /**
3889
-     * get_current_page_view_url
3890
-     *
3891
-     * @return string This returns the url for the current_page_view.
3892
-     */
3893
-    public function get_current_page_view_url()
3894
-    {
3895
-        return $this->_current_page_view_url;
3896
-    }
3897
-
3898
-
3899
-    /**
3900
-     * just returns the Request
3901
-     *
3902
-     * @return RequestInterface
3903
-     */
3904
-    public function get_request()
3905
-    {
3906
-        return $this->request;
3907
-    }
3908
-
3909
-
3910
-    /**
3911
-     * just returns the _req_data property
3912
-     *
3913
-     * @return array
3914
-     */
3915
-    public function get_request_data()
3916
-    {
3917
-        return $this->request->requestParams();
3918
-    }
3919
-
3920
-
3921
-    /**
3922
-     * returns the _req_data protected property
3923
-     *
3924
-     * @return string
3925
-     */
3926
-    public function get_req_action()
3927
-    {
3928
-        return $this->_req_action;
3929
-    }
3930
-
3931
-
3932
-    /**
3933
-     * @return bool  value of $_is_caf property
3934
-     */
3935
-    public function is_caf()
3936
-    {
3937
-        return $this->_is_caf;
3938
-    }
3939
-
3940
-
3941
-    /**
3942
-     * @return mixed
3943
-     */
3944
-    public function default_espresso_metaboxes()
3945
-    {
3946
-        return $this->_default_espresso_metaboxes;
3947
-    }
3948
-
3949
-
3950
-    /**
3951
-     * @return mixed
3952
-     */
3953
-    public function admin_base_url()
3954
-    {
3955
-        return $this->_admin_base_url;
3956
-    }
3957
-
3958
-
3959
-    /**
3960
-     * @return mixed
3961
-     */
3962
-    public function wp_page_slug()
3963
-    {
3964
-        return $this->_wp_page_slug;
3965
-    }
3966
-
3967
-
3968
-    /**
3969
-     * updates  espresso configuration settings
3970
-     *
3971
-     * @param string                   $tab
3972
-     * @param EE_Config_Base|EE_Config $config
3973
-     * @param string                   $file file where error occurred
3974
-     * @param string                   $func function  where error occurred
3975
-     * @param string                   $line line no where error occurred
3976
-     * @return boolean
3977
-     */
3978
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3979
-    {
3980
-        // remove any options that are NOT going to be saved with the config settings.
3981
-        if (isset($config->core->ee_ueip_optin)) {
3982
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3983
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3984
-            update_option('ee_ueip_has_notified', true);
3985
-        }
3986
-        // and save it (note we're also doing the network save here)
3987
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3988
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3989
-        if ($config_saved && $net_saved) {
3990
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3991
-            return true;
3992
-        }
3993
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3994
-        return false;
3995
-    }
3996
-
3997
-
3998
-    /**
3999
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4000
-     *
4001
-     * @return array
4002
-     */
4003
-    public function get_yes_no_values()
4004
-    {
4005
-        return $this->_yes_no_values;
4006
-    }
4007
-
4008
-
4009
-    /**
4010
-     * @return string
4011
-     * @throws ReflectionException
4012
-     * @since $VID:$
4013
-     */
4014
-    protected function _get_dir()
4015
-    {
4016
-        $reflector = new ReflectionClass($this->class_name);
4017
-        return dirname($reflector->getFileName());
4018
-    }
4019
-
4020
-
4021
-    /**
4022
-     * A helper for getting a "next link".
4023
-     *
4024
-     * @param string $url   The url to link to
4025
-     * @param string $class The class to use.
4026
-     * @return string
4027
-     */
4028
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4029
-    {
4030
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4031
-    }
4032
-
4033
-
4034
-    /**
4035
-     * A helper for getting a "previous link".
4036
-     *
4037
-     * @param string $url   The url to link to
4038
-     * @param string $class The class to use.
4039
-     * @return string
4040
-     */
4041
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4042
-    {
4043
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4044
-    }
4045
-
4046
-
4047
-
4048
-
4049
-
4050
-
4051
-
4052
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4053
-
4054
-
4055
-    /**
4056
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4057
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4058
-     * _req_data array.
4059
-     *
4060
-     * @return bool success/fail
4061
-     * @throws EE_Error
4062
-     * @throws InvalidArgumentException
4063
-     * @throws ReflectionException
4064
-     * @throws InvalidDataTypeException
4065
-     * @throws InvalidInterfaceException
4066
-     */
4067
-    protected function _process_resend_registration()
4068
-    {
4069
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4070
-        do_action(
4071
-            'AHEE__EE_Admin_Page___process_resend_registration',
4072
-            $this->_template_args['success'],
4073
-            $this->request->requestParams()
4074
-        );
4075
-        return $this->_template_args['success'];
4076
-    }
4077
-
4078
-
4079
-    /**
4080
-     * This automatically processes any payment message notifications when manual payment has been applied.
4081
-     *
4082
-     * @param EE_Payment $payment
4083
-     * @return bool success/fail
4084
-     */
4085
-    protected function _process_payment_notification(EE_Payment $payment)
4086
-    {
4087
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4088
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4089
-        $this->_template_args['success'] = apply_filters(
4090
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4091
-            false,
4092
-            $payment
4093
-        );
4094
-        return $this->_template_args['success'];
4095
-    }
4096
-
4097
-
4098
-    /**
4099
-     * @param EEM_Base      $entity_model
4100
-     * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4101
-     * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4102
-     * @param string        $delete_column  name of the field that denotes whether entity is trashed
4103
-     * @param callable|null $callback       called after entity is trashed, restored, or deleted
4104
-     * @return int|float
4105
-     * @throws EE_Error
4106
-     */
4107
-    protected function trashRestoreDeleteEntities(
4108
-        EEM_Base $entity_model,
4109
-        string $entity_PK_name,
4110
-        string $action = EE_Admin_List_Table::ACTION_DELETE,
4111
-        string $delete_column = '',
4112
-        callable $callback = null
4113
-    ) {
4114
-        $entity_PK      = $entity_model->get_primary_key_field();
4115
-        $entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4116
-        $entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4117
-        // grab ID if deleting a single entity
4118
-        if ($this->request->requestParamIsSet($entity_PK_name)) {
4119
-            $ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4120
-            return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4121
-        }
4122
-        // or grab checkbox array if bulk deleting
4123
-        $checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4124
-        if (empty($checkboxes)) {
4125
-            return 0;
4126
-        }
4127
-        $success = 0;
4128
-        $IDs     = array_keys($checkboxes);
4129
-        // cycle thru bulk action checkboxes
4130
-        foreach ($IDs as $ID) {
4131
-            // increment $success
4132
-            if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4133
-                $success++;
4134
-            }
4135
-        }
4136
-        $count = (int) count($checkboxes);
4137
-        // if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4138
-        // otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4139
-        return $success === $count ? $count : $success / $count;
4140
-    }
4141
-
4142
-
4143
-    /**
4144
-     * @param EE_Primary_Key_Field_Base $entity_PK
4145
-     * @return string
4146
-     * @throws EE_Error
4147
-     * @since   $VID:$
4148
-     */
4149
-    private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4150
-    {
4151
-        $entity_PK_type = $entity_PK->getSchemaType();
4152
-        switch ($entity_PK_type) {
4153
-            case 'boolean':
4154
-                return 'bool';
4155
-            case 'integer':
4156
-                return 'int';
4157
-            case 'number':
4158
-                return 'float';
4159
-            case 'string':
4160
-                return 'string';
4161
-        }
4162
-        throw new RuntimeException(
4163
-            sprintf(
4164
-                esc_html__(
4165
-                    '"%1$s" is an invalid schema type for the %2$s primary key.',
4166
-                    'event_espresso'
4167
-                ),
4168
-                $entity_PK_type,
4169
-                $entity_PK->get_name()
4170
-            )
4171
-        );
4172
-    }
4173
-
4174
-
4175
-    /**
4176
-     * @param EEM_Base      $entity_model
4177
-     * @param int|string    $entity_ID
4178
-     * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4179
-     * @param string        $delete_column name of the field that denotes whether entity is trashed
4180
-     * @param callable|null $callback      called after entity is trashed, restored, or deleted
4181
-     * @return bool
4182
-     */
4183
-    protected function trashRestoreDeleteEntity(
4184
-        EEM_Base $entity_model,
4185
-        $entity_ID,
4186
-        string $action,
4187
-        string $delete_column,
4188
-        ?callable $callback = null
4189
-    ): bool {
4190
-        $entity_ID = absint($entity_ID);
4191
-        if (! $entity_ID) {
4192
-            $this->trashRestoreDeleteError($action, $entity_model);
4193
-        }
4194
-        $result = 0;
4195
-        try {
4196
-            switch ($action) {
4197
-                case EE_Admin_List_Table::ACTION_DELETE:
4198
-                    $result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4199
-                    break;
4200
-                case EE_Admin_List_Table::ACTION_RESTORE:
4201
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4202
-                    $result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4203
-                    break;
4204
-                case EE_Admin_List_Table::ACTION_TRASH:
4205
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4206
-                    $result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4207
-                    break;
4208
-            }
4209
-        } catch (Exception $exception) {
4210
-            $this->trashRestoreDeleteError($action, $entity_model, $exception);
4211
-        }
4212
-        if (is_callable($callback)) {
4213
-            call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4214
-        }
4215
-        return $result;
4216
-    }
4217
-
4218
-
4219
-    /**
4220
-     * @param EEM_Base $entity_model
4221
-     * @param string   $delete_column
4222
-     * @since $VID:$
4223
-     */
4224
-    private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4225
-    {
4226
-        if (empty($delete_column)) {
4227
-            throw new DomainException(
4228
-                sprintf(
4229
-                    esc_html__(
4230
-                        'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4231
-                        'event_espresso'
4232
-                    ),
4233
-                    $entity_model->get_this_model_name()
4234
-                )
4235
-            );
4236
-        }
4237
-        if (! $entity_model->has_field($delete_column)) {
4238
-            throw new DomainException(
4239
-                sprintf(
4240
-                    esc_html__(
4241
-                        'The %1$s field does not exist on the %2$s model.',
4242
-                        'event_espresso'
4243
-                    ),
4244
-                    $delete_column,
4245
-                    $entity_model->get_this_model_name()
4246
-                )
4247
-            );
4248
-        }
4249
-    }
4250
-
4251
-
4252
-    /**
4253
-     * @param EEM_Base       $entity_model
4254
-     * @param Exception|null $exception
4255
-     * @param string         $action
4256
-     * @since $VID:$
4257
-     */
4258
-    private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4259
-    {
4260
-        if ($exception instanceof Exception) {
4261
-            throw new RuntimeException(
4262
-                sprintf(
4263
-                    esc_html__(
4264
-                        'Could not %1$s the %2$s because the following error occurred: %3$s',
4265
-                        'event_espresso'
4266
-                    ),
4267
-                    $action,
4268
-                    $entity_model->get_this_model_name(),
4269
-                    $exception->getMessage()
4270
-                )
4271
-            );
4272
-        }
4273
-        throw new RuntimeException(
4274
-            sprintf(
4275
-                esc_html__(
4276
-                    'Could not %1$s the %2$s because an invalid ID was received.',
4277
-                    'event_espresso'
4278
-                ),
4279
-                $action,
4280
-                $entity_model->get_this_model_name()
4281
-            )
4282
-        );
4283
-    }
3316
+		// add nonce
3317
+		$nonce                                             =
3318
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3319
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3320
+		// add REQUIRED form action
3321
+		$hidden_fields = [
3322
+			'action' => ['type' => 'hidden', 'value' => $route],
3323
+		];
3324
+		// merge arrays
3325
+		$hidden_fields = is_array($additional_hidden_fields)
3326
+			? array_merge($hidden_fields, $additional_hidden_fields)
3327
+			: $hidden_fields;
3328
+		// generate form fields
3329
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3330
+		// add fields to form
3331
+		foreach ((array) $form_fields as $form_field) {
3332
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3333
+		}
3334
+		// close form
3335
+		$this->_template_args['after_admin_page_content'] = '</form>';
3336
+	}
3337
+
3338
+
3339
+	/**
3340
+	 * Public Wrapper for _redirect_after_action() method since its
3341
+	 * discovered it would be useful for external code to have access.
3342
+	 *
3343
+	 * @param bool   $success
3344
+	 * @param string $what
3345
+	 * @param string $action_desc
3346
+	 * @param array  $query_args
3347
+	 * @param bool   $override_overwrite
3348
+	 * @throws EE_Error
3349
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3350
+	 * @since 4.5.0
3351
+	 */
3352
+	public function redirect_after_action(
3353
+		$success = false,
3354
+		$what = 'item',
3355
+		$action_desc = 'processed',
3356
+		$query_args = [],
3357
+		$override_overwrite = false
3358
+	) {
3359
+		$this->_redirect_after_action(
3360
+			$success,
3361
+			$what,
3362
+			$action_desc,
3363
+			$query_args,
3364
+			$override_overwrite
3365
+		);
3366
+	}
3367
+
3368
+
3369
+	/**
3370
+	 * Helper method for merging existing request data with the returned redirect url.
3371
+	 *
3372
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3373
+	 * filters are still applied.
3374
+	 *
3375
+	 * @param array $new_route_data
3376
+	 * @return array
3377
+	 */
3378
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3379
+	{
3380
+		foreach ($this->request->requestParams() as $ref => $value) {
3381
+			// unset nonces
3382
+			if (strpos($ref, 'nonce') !== false) {
3383
+				$this->request->unSetRequestParam($ref);
3384
+				continue;
3385
+			}
3386
+			// urlencode values.
3387
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3388
+			$this->request->setRequestParam($ref, $value);
3389
+		}
3390
+		return array_merge($this->request->requestParams(), $new_route_data);
3391
+	}
3392
+
3393
+
3394
+	/**
3395
+	 * @param int|float|string $success      - whether success was for two or more records, or just one, or none
3396
+	 * @param string           $what         - what the action was performed on
3397
+	 * @param string           $action_desc  - what was done ie: updated, deleted, etc
3398
+	 * @param array $query_args              - an array of query_args to be added to the URL to redirect to
3399
+	 * @param BOOL $override_overwrite       - by default all EE_Error::success messages are overwritten,
3400
+	 *                                         this allows you to override this so that they show.
3401
+	 * @return void
3402
+	 * @throws EE_Error
3403
+	 * @throws InvalidArgumentException
3404
+	 * @throws InvalidDataTypeException
3405
+	 * @throws InvalidInterfaceException
3406
+	 */
3407
+	protected function _redirect_after_action(
3408
+		$success = 0,
3409
+		string $what = 'item',
3410
+		string $action_desc = 'processed',
3411
+		array $query_args = [],
3412
+		bool $override_overwrite = false
3413
+	) {
3414
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3415
+		$notices      = EE_Error::get_notices(false);
3416
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3417
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3418
+			EE_Error::overwrite_success();
3419
+		}
3420
+		if (! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3421
+			// how many records affected ? more than one record ? or just one ?
3422
+			EE_Error::add_success(
3423
+				sprintf(
3424
+					esc_html(
3425
+						_n(
3426
+							'The "%1$s" has been successfully %2$s.',
3427
+							'The "%1$s" have been successfully %2$s.',
3428
+							$success,
3429
+							'event_espresso'
3430
+						)
3431
+					),
3432
+					$what,
3433
+					$action_desc
3434
+				),
3435
+				__FILE__,
3436
+				__FUNCTION__,
3437
+				__LINE__
3438
+			);
3439
+		}
3440
+		// check that $query_args isn't something crazy
3441
+		if (! is_array($query_args)) {
3442
+			$query_args = [];
3443
+		}
3444
+		/**
3445
+		 * Allow injecting actions before the query_args are modified for possible different
3446
+		 * redirections on save and close actions
3447
+		 *
3448
+		 * @param array $query_args       The original query_args array coming into the
3449
+		 *                                method.
3450
+		 * @since 4.2.0
3451
+		 */
3452
+		do_action(
3453
+			"AHEE__{$this->class_name}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3454
+			$query_args
3455
+		);
3456
+		// set redirect url.
3457
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3458
+		// otherwise we go with whatever is set as the _admin_base_url
3459
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3460
+		// calculate where we're going (if we have a "save and close" button pushed)
3461
+		if (
3462
+			$this->request->requestParamIsSet('save_and_close')
3463
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3464
+		) {
3465
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3466
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3467
+			// regenerate query args array from referrer URL
3468
+			parse_str($parsed_url['query'], $query_args);
3469
+			// correct page and action will be in the query args now
3470
+			$redirect_url = admin_url('admin.php');
3471
+		}
3472
+		// merge any default query_args set in _default_route_query_args property
3473
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3474
+			$args_to_merge = [];
3475
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3476
+				// is there a wp_referer array in our _default_route_query_args property?
3477
+				if ($query_param === 'wp_referer') {
3478
+					$query_value = (array) $query_value;
3479
+					foreach ($query_value as $reference => $value) {
3480
+						if (strpos($reference, 'nonce') !== false) {
3481
+							continue;
3482
+						}
3483
+						// finally we will override any arguments in the referer with
3484
+						// what might be set on the _default_route_query_args array.
3485
+						if (isset($this->_default_route_query_args[ $reference ])) {
3486
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3487
+						} else {
3488
+							$args_to_merge[ $reference ] = urlencode($value);
3489
+						}
3490
+					}
3491
+					continue;
3492
+				}
3493
+				$args_to_merge[ $query_param ] = $query_value;
3494
+			}
3495
+			// now let's merge these arguments but override with what was specifically sent in to the
3496
+			// redirect.
3497
+			$query_args = array_merge($args_to_merge, $query_args);
3498
+		}
3499
+		$this->_process_notices($query_args);
3500
+		// generate redirect url
3501
+		// if redirecting to anything other than the main page, add a nonce
3502
+		if (isset($query_args['action'])) {
3503
+			// manually generate wp_nonce and merge that with the query vars
3504
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3505
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3506
+		}
3507
+		// we're adding some hooks and filters in here for processing any things just before redirects
3508
+		// (example: an admin page has done an insert or update and we want to run something after that).
3509
+		do_action('AHEE_redirect_' . $this->class_name . $this->_req_action, $query_args);
3510
+		$redirect_url = apply_filters(
3511
+			'FHEE_redirect_' . $this->class_name . $this->_req_action,
3512
+			EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3513
+			$query_args
3514
+		);
3515
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3516
+		if ($this->request->isAjax()) {
3517
+			$default_data                    = [
3518
+				'close'        => true,
3519
+				'redirect_url' => $redirect_url,
3520
+				'where'        => 'main',
3521
+				'what'         => 'append',
3522
+			];
3523
+			$this->_template_args['success'] = $success;
3524
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3525
+				$default_data,
3526
+				$this->_template_args['data']
3527
+			) : $default_data;
3528
+			$this->_return_json();
3529
+		}
3530
+		wp_safe_redirect($redirect_url);
3531
+		exit();
3532
+	}
3533
+
3534
+
3535
+	/**
3536
+	 * process any notices before redirecting (or returning ajax request)
3537
+	 * This method sets the $this->_template_args['notices'] attribute;
3538
+	 *
3539
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3540
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3541
+	 *                                  page_routes haven't been defined yet.
3542
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3543
+	 *                                  still save a transient for the notice.
3544
+	 * @return void
3545
+	 * @throws EE_Error
3546
+	 * @throws InvalidArgumentException
3547
+	 * @throws InvalidDataTypeException
3548
+	 * @throws InvalidInterfaceException
3549
+	 */
3550
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3551
+	{
3552
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3553
+		if ($this->request->isAjax()) {
3554
+			$notices = EE_Error::get_notices(false);
3555
+			if (empty($this->_template_args['success'])) {
3556
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3557
+			}
3558
+			if (empty($this->_template_args['errors'])) {
3559
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3560
+			}
3561
+			if (empty($this->_template_args['attention'])) {
3562
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3563
+			}
3564
+		}
3565
+		$this->_template_args['notices'] = EE_Error::get_notices();
3566
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3567
+		if (! $this->request->isAjax() || $sticky_notices) {
3568
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3569
+			$this->_add_transient(
3570
+				$route,
3571
+				$this->_template_args['notices'],
3572
+				true,
3573
+				$skip_route_verify
3574
+			);
3575
+		}
3576
+	}
3577
+
3578
+
3579
+	/**
3580
+	 * get_action_link_or_button
3581
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3582
+	 *
3583
+	 * @param string $action        use this to indicate which action the url is generated with.
3584
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3585
+	 *                              property.
3586
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3587
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button--primary'
3588
+	 * @param string $base_url      If this is not provided
3589
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3590
+	 *                              Otherwise this value will be used.
3591
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3592
+	 * @return string
3593
+	 * @throws InvalidArgumentException
3594
+	 * @throws InvalidInterfaceException
3595
+	 * @throws InvalidDataTypeException
3596
+	 * @throws EE_Error
3597
+	 */
3598
+	public function get_action_link_or_button(
3599
+		$action,
3600
+		$type = 'add',
3601
+		$extra_request = [],
3602
+		$class = 'button--primary',
3603
+		$base_url = '',
3604
+		$exclude_nonce = false
3605
+	) {
3606
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3607
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3608
+			throw new EE_Error(
3609
+				sprintf(
3610
+					esc_html__(
3611
+						'There is no page route for given action for the button.  This action was given: %s',
3612
+						'event_espresso'
3613
+					),
3614
+					$action
3615
+				)
3616
+			);
3617
+		}
3618
+		if (! isset($this->_labels['buttons'][ $type ])) {
3619
+			throw new EE_Error(
3620
+				sprintf(
3621
+					esc_html__(
3622
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3623
+						'event_espresso'
3624
+					),
3625
+					$type
3626
+				)
3627
+			);
3628
+		}
3629
+		// finally check user access for this button.
3630
+		$has_access = $this->check_user_access($action, true);
3631
+		if (! $has_access) {
3632
+			return '';
3633
+		}
3634
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3635
+		$query_args = [
3636
+			'action' => $action,
3637
+		];
3638
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3639
+		if (! empty($extra_request)) {
3640
+			$query_args = array_merge($extra_request, $query_args);
3641
+		}
3642
+		$url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3643
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3644
+	}
3645
+
3646
+
3647
+	/**
3648
+	 * _per_page_screen_option
3649
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3650
+	 *
3651
+	 * @return void
3652
+	 * @throws InvalidArgumentException
3653
+	 * @throws InvalidInterfaceException
3654
+	 * @throws InvalidDataTypeException
3655
+	 */
3656
+	protected function _per_page_screen_option()
3657
+	{
3658
+		$option = 'per_page';
3659
+		$args   = [
3660
+			'label'   => apply_filters(
3661
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3662
+				$this->_admin_page_title,
3663
+				$this
3664
+			),
3665
+			'default' => (int) apply_filters(
3666
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3667
+				20
3668
+			),
3669
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3670
+		];
3671
+		// ONLY add the screen option if the user has access to it.
3672
+		if ($this->check_user_access($this->_current_view, true)) {
3673
+			add_screen_option($option, $args);
3674
+		}
3675
+	}
3676
+
3677
+
3678
+	/**
3679
+	 * set_per_page_screen_option
3680
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3681
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3682
+	 * admin_menu.
3683
+	 *
3684
+	 * @return void
3685
+	 */
3686
+	private function _set_per_page_screen_options()
3687
+	{
3688
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3689
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3690
+			if (! $user = wp_get_current_user()) {
3691
+				return;
3692
+			}
3693
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3694
+			if (! $option) {
3695
+				return;
3696
+			}
3697
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3698
+			$map_option = $option;
3699
+			$option     = str_replace('-', '_', $option);
3700
+			switch ($map_option) {
3701
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3702
+					$max_value = apply_filters(
3703
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3704
+						999,
3705
+						$this->_current_page,
3706
+						$this->_current_view
3707
+					);
3708
+					if ($value < 1) {
3709
+						return;
3710
+					}
3711
+					$value = min($value, $max_value);
3712
+					break;
3713
+				default:
3714
+					$value = apply_filters(
3715
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3716
+						false,
3717
+						$option,
3718
+						$value
3719
+					);
3720
+					if (false === $value) {
3721
+						return;
3722
+					}
3723
+					break;
3724
+			}
3725
+			update_user_meta($user->ID, $option, $value);
3726
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3727
+			exit;
3728
+		}
3729
+	}
3730
+
3731
+
3732
+	/**
3733
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3734
+	 *
3735
+	 * @param array $data array that will be assigned to template args.
3736
+	 */
3737
+	public function set_template_args($data)
3738
+	{
3739
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3740
+	}
3741
+
3742
+
3743
+	/**
3744
+	 * This makes available the WP transient system for temporarily moving data between routes
3745
+	 *
3746
+	 * @param string $route             the route that should receive the transient
3747
+	 * @param array  $data              the data that gets sent
3748
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3749
+	 *                                  normal route transient.
3750
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3751
+	 *                                  when we are adding a transient before page_routes have been defined.
3752
+	 * @return void
3753
+	 * @throws EE_Error
3754
+	 */
3755
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3756
+	{
3757
+		$user_id = get_current_user_id();
3758
+		if (! $skip_route_verify) {
3759
+			$this->_verify_route($route);
3760
+		}
3761
+		// now let's set the string for what kind of transient we're setting
3762
+		$transient = $notices
3763
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3764
+			: 'rte_tx_' . $route . '_' . $user_id;
3765
+		$data      = $notices ? ['notices' => $data] : $data;
3766
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3767
+		$existing = is_multisite() && is_network_admin()
3768
+			? get_site_transient($transient)
3769
+			: get_transient($transient);
3770
+		if ($existing) {
3771
+			$data = array_merge((array) $data, (array) $existing);
3772
+		}
3773
+		if (is_multisite() && is_network_admin()) {
3774
+			set_site_transient($transient, $data, 8);
3775
+		} else {
3776
+			set_transient($transient, $data, 8);
3777
+		}
3778
+	}
3779
+
3780
+
3781
+	/**
3782
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3783
+	 *
3784
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3785
+	 * @param string $route
3786
+	 * @return mixed data
3787
+	 */
3788
+	protected function _get_transient($notices = false, $route = '')
3789
+	{
3790
+		$user_id   = get_current_user_id();
3791
+		$route     = ! $route ? $this->_req_action : $route;
3792
+		$transient = $notices
3793
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3794
+			: 'rte_tx_' . $route . '_' . $user_id;
3795
+		$data      = is_multisite() && is_network_admin()
3796
+			? get_site_transient($transient)
3797
+			: get_transient($transient);
3798
+		// delete transient after retrieval (just in case it hasn't expired);
3799
+		if (is_multisite() && is_network_admin()) {
3800
+			delete_site_transient($transient);
3801
+		} else {
3802
+			delete_transient($transient);
3803
+		}
3804
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3805
+	}
3806
+
3807
+
3808
+	/**
3809
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3810
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3811
+	 * default route callback on the EE_Admin page you want it run.)
3812
+	 *
3813
+	 * @return void
3814
+	 */
3815
+	protected function _transient_garbage_collection()
3816
+	{
3817
+		global $wpdb;
3818
+		// retrieve all existing transients
3819
+		$query =
3820
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3821
+		if ($results = $wpdb->get_results($query)) {
3822
+			foreach ($results as $result) {
3823
+				$transient = str_replace('_transient_', '', $result->option_name);
3824
+				get_transient($transient);
3825
+				if (is_multisite() && is_network_admin()) {
3826
+					get_site_transient($transient);
3827
+				}
3828
+			}
3829
+		}
3830
+	}
3831
+
3832
+
3833
+	/**
3834
+	 * get_view
3835
+	 *
3836
+	 * @return string content of _view property
3837
+	 */
3838
+	public function get_view()
3839
+	{
3840
+		return $this->_view;
3841
+	}
3842
+
3843
+
3844
+	/**
3845
+	 * getter for the protected $_views property
3846
+	 *
3847
+	 * @return array
3848
+	 */
3849
+	public function get_views()
3850
+	{
3851
+		return $this->_views;
3852
+	}
3853
+
3854
+
3855
+	/**
3856
+	 * get_current_page
3857
+	 *
3858
+	 * @return string _current_page property value
3859
+	 */
3860
+	public function get_current_page()
3861
+	{
3862
+		return $this->_current_page;
3863
+	}
3864
+
3865
+
3866
+	/**
3867
+	 * get_current_view
3868
+	 *
3869
+	 * @return string _current_view property value
3870
+	 */
3871
+	public function get_current_view()
3872
+	{
3873
+		return $this->_current_view;
3874
+	}
3875
+
3876
+
3877
+	/**
3878
+	 * get_current_screen
3879
+	 *
3880
+	 * @return object The current WP_Screen object
3881
+	 */
3882
+	public function get_current_screen()
3883
+	{
3884
+		return $this->_current_screen;
3885
+	}
3886
+
3887
+
3888
+	/**
3889
+	 * get_current_page_view_url
3890
+	 *
3891
+	 * @return string This returns the url for the current_page_view.
3892
+	 */
3893
+	public function get_current_page_view_url()
3894
+	{
3895
+		return $this->_current_page_view_url;
3896
+	}
3897
+
3898
+
3899
+	/**
3900
+	 * just returns the Request
3901
+	 *
3902
+	 * @return RequestInterface
3903
+	 */
3904
+	public function get_request()
3905
+	{
3906
+		return $this->request;
3907
+	}
3908
+
3909
+
3910
+	/**
3911
+	 * just returns the _req_data property
3912
+	 *
3913
+	 * @return array
3914
+	 */
3915
+	public function get_request_data()
3916
+	{
3917
+		return $this->request->requestParams();
3918
+	}
3919
+
3920
+
3921
+	/**
3922
+	 * returns the _req_data protected property
3923
+	 *
3924
+	 * @return string
3925
+	 */
3926
+	public function get_req_action()
3927
+	{
3928
+		return $this->_req_action;
3929
+	}
3930
+
3931
+
3932
+	/**
3933
+	 * @return bool  value of $_is_caf property
3934
+	 */
3935
+	public function is_caf()
3936
+	{
3937
+		return $this->_is_caf;
3938
+	}
3939
+
3940
+
3941
+	/**
3942
+	 * @return mixed
3943
+	 */
3944
+	public function default_espresso_metaboxes()
3945
+	{
3946
+		return $this->_default_espresso_metaboxes;
3947
+	}
3948
+
3949
+
3950
+	/**
3951
+	 * @return mixed
3952
+	 */
3953
+	public function admin_base_url()
3954
+	{
3955
+		return $this->_admin_base_url;
3956
+	}
3957
+
3958
+
3959
+	/**
3960
+	 * @return mixed
3961
+	 */
3962
+	public function wp_page_slug()
3963
+	{
3964
+		return $this->_wp_page_slug;
3965
+	}
3966
+
3967
+
3968
+	/**
3969
+	 * updates  espresso configuration settings
3970
+	 *
3971
+	 * @param string                   $tab
3972
+	 * @param EE_Config_Base|EE_Config $config
3973
+	 * @param string                   $file file where error occurred
3974
+	 * @param string                   $func function  where error occurred
3975
+	 * @param string                   $line line no where error occurred
3976
+	 * @return boolean
3977
+	 */
3978
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3979
+	{
3980
+		// remove any options that are NOT going to be saved with the config settings.
3981
+		if (isset($config->core->ee_ueip_optin)) {
3982
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3983
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3984
+			update_option('ee_ueip_has_notified', true);
3985
+		}
3986
+		// and save it (note we're also doing the network save here)
3987
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3988
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3989
+		if ($config_saved && $net_saved) {
3990
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3991
+			return true;
3992
+		}
3993
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3994
+		return false;
3995
+	}
3996
+
3997
+
3998
+	/**
3999
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4000
+	 *
4001
+	 * @return array
4002
+	 */
4003
+	public function get_yes_no_values()
4004
+	{
4005
+		return $this->_yes_no_values;
4006
+	}
4007
+
4008
+
4009
+	/**
4010
+	 * @return string
4011
+	 * @throws ReflectionException
4012
+	 * @since $VID:$
4013
+	 */
4014
+	protected function _get_dir()
4015
+	{
4016
+		$reflector = new ReflectionClass($this->class_name);
4017
+		return dirname($reflector->getFileName());
4018
+	}
4019
+
4020
+
4021
+	/**
4022
+	 * A helper for getting a "next link".
4023
+	 *
4024
+	 * @param string $url   The url to link to
4025
+	 * @param string $class The class to use.
4026
+	 * @return string
4027
+	 */
4028
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4029
+	{
4030
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4031
+	}
4032
+
4033
+
4034
+	/**
4035
+	 * A helper for getting a "previous link".
4036
+	 *
4037
+	 * @param string $url   The url to link to
4038
+	 * @param string $class The class to use.
4039
+	 * @return string
4040
+	 */
4041
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4042
+	{
4043
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4044
+	}
4045
+
4046
+
4047
+
4048
+
4049
+
4050
+
4051
+
4052
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4053
+
4054
+
4055
+	/**
4056
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4057
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4058
+	 * _req_data array.
4059
+	 *
4060
+	 * @return bool success/fail
4061
+	 * @throws EE_Error
4062
+	 * @throws InvalidArgumentException
4063
+	 * @throws ReflectionException
4064
+	 * @throws InvalidDataTypeException
4065
+	 * @throws InvalidInterfaceException
4066
+	 */
4067
+	protected function _process_resend_registration()
4068
+	{
4069
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4070
+		do_action(
4071
+			'AHEE__EE_Admin_Page___process_resend_registration',
4072
+			$this->_template_args['success'],
4073
+			$this->request->requestParams()
4074
+		);
4075
+		return $this->_template_args['success'];
4076
+	}
4077
+
4078
+
4079
+	/**
4080
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4081
+	 *
4082
+	 * @param EE_Payment $payment
4083
+	 * @return bool success/fail
4084
+	 */
4085
+	protected function _process_payment_notification(EE_Payment $payment)
4086
+	{
4087
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4088
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4089
+		$this->_template_args['success'] = apply_filters(
4090
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4091
+			false,
4092
+			$payment
4093
+		);
4094
+		return $this->_template_args['success'];
4095
+	}
4096
+
4097
+
4098
+	/**
4099
+	 * @param EEM_Base      $entity_model
4100
+	 * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4101
+	 * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4102
+	 * @param string        $delete_column  name of the field that denotes whether entity is trashed
4103
+	 * @param callable|null $callback       called after entity is trashed, restored, or deleted
4104
+	 * @return int|float
4105
+	 * @throws EE_Error
4106
+	 */
4107
+	protected function trashRestoreDeleteEntities(
4108
+		EEM_Base $entity_model,
4109
+		string $entity_PK_name,
4110
+		string $action = EE_Admin_List_Table::ACTION_DELETE,
4111
+		string $delete_column = '',
4112
+		callable $callback = null
4113
+	) {
4114
+		$entity_PK      = $entity_model->get_primary_key_field();
4115
+		$entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4116
+		$entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4117
+		// grab ID if deleting a single entity
4118
+		if ($this->request->requestParamIsSet($entity_PK_name)) {
4119
+			$ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4120
+			return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4121
+		}
4122
+		// or grab checkbox array if bulk deleting
4123
+		$checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4124
+		if (empty($checkboxes)) {
4125
+			return 0;
4126
+		}
4127
+		$success = 0;
4128
+		$IDs     = array_keys($checkboxes);
4129
+		// cycle thru bulk action checkboxes
4130
+		foreach ($IDs as $ID) {
4131
+			// increment $success
4132
+			if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4133
+				$success++;
4134
+			}
4135
+		}
4136
+		$count = (int) count($checkboxes);
4137
+		// if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4138
+		// otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4139
+		return $success === $count ? $count : $success / $count;
4140
+	}
4141
+
4142
+
4143
+	/**
4144
+	 * @param EE_Primary_Key_Field_Base $entity_PK
4145
+	 * @return string
4146
+	 * @throws EE_Error
4147
+	 * @since   $VID:$
4148
+	 */
4149
+	private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4150
+	{
4151
+		$entity_PK_type = $entity_PK->getSchemaType();
4152
+		switch ($entity_PK_type) {
4153
+			case 'boolean':
4154
+				return 'bool';
4155
+			case 'integer':
4156
+				return 'int';
4157
+			case 'number':
4158
+				return 'float';
4159
+			case 'string':
4160
+				return 'string';
4161
+		}
4162
+		throw new RuntimeException(
4163
+			sprintf(
4164
+				esc_html__(
4165
+					'"%1$s" is an invalid schema type for the %2$s primary key.',
4166
+					'event_espresso'
4167
+				),
4168
+				$entity_PK_type,
4169
+				$entity_PK->get_name()
4170
+			)
4171
+		);
4172
+	}
4173
+
4174
+
4175
+	/**
4176
+	 * @param EEM_Base      $entity_model
4177
+	 * @param int|string    $entity_ID
4178
+	 * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4179
+	 * @param string        $delete_column name of the field that denotes whether entity is trashed
4180
+	 * @param callable|null $callback      called after entity is trashed, restored, or deleted
4181
+	 * @return bool
4182
+	 */
4183
+	protected function trashRestoreDeleteEntity(
4184
+		EEM_Base $entity_model,
4185
+		$entity_ID,
4186
+		string $action,
4187
+		string $delete_column,
4188
+		?callable $callback = null
4189
+	): bool {
4190
+		$entity_ID = absint($entity_ID);
4191
+		if (! $entity_ID) {
4192
+			$this->trashRestoreDeleteError($action, $entity_model);
4193
+		}
4194
+		$result = 0;
4195
+		try {
4196
+			switch ($action) {
4197
+				case EE_Admin_List_Table::ACTION_DELETE:
4198
+					$result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4199
+					break;
4200
+				case EE_Admin_List_Table::ACTION_RESTORE:
4201
+					$this->validateDeleteColumn($entity_model, $delete_column);
4202
+					$result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4203
+					break;
4204
+				case EE_Admin_List_Table::ACTION_TRASH:
4205
+					$this->validateDeleteColumn($entity_model, $delete_column);
4206
+					$result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4207
+					break;
4208
+			}
4209
+		} catch (Exception $exception) {
4210
+			$this->trashRestoreDeleteError($action, $entity_model, $exception);
4211
+		}
4212
+		if (is_callable($callback)) {
4213
+			call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4214
+		}
4215
+		return $result;
4216
+	}
4217
+
4218
+
4219
+	/**
4220
+	 * @param EEM_Base $entity_model
4221
+	 * @param string   $delete_column
4222
+	 * @since $VID:$
4223
+	 */
4224
+	private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4225
+	{
4226
+		if (empty($delete_column)) {
4227
+			throw new DomainException(
4228
+				sprintf(
4229
+					esc_html__(
4230
+						'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4231
+						'event_espresso'
4232
+					),
4233
+					$entity_model->get_this_model_name()
4234
+				)
4235
+			);
4236
+		}
4237
+		if (! $entity_model->has_field($delete_column)) {
4238
+			throw new DomainException(
4239
+				sprintf(
4240
+					esc_html__(
4241
+						'The %1$s field does not exist on the %2$s model.',
4242
+						'event_espresso'
4243
+					),
4244
+					$delete_column,
4245
+					$entity_model->get_this_model_name()
4246
+				)
4247
+			);
4248
+		}
4249
+	}
4250
+
4251
+
4252
+	/**
4253
+	 * @param EEM_Base       $entity_model
4254
+	 * @param Exception|null $exception
4255
+	 * @param string         $action
4256
+	 * @since $VID:$
4257
+	 */
4258
+	private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4259
+	{
4260
+		if ($exception instanceof Exception) {
4261
+			throw new RuntimeException(
4262
+				sprintf(
4263
+					esc_html__(
4264
+						'Could not %1$s the %2$s because the following error occurred: %3$s',
4265
+						'event_espresso'
4266
+					),
4267
+					$action,
4268
+					$entity_model->get_this_model_name(),
4269
+					$exception->getMessage()
4270
+				)
4271
+			);
4272
+		}
4273
+		throw new RuntimeException(
4274
+			sprintf(
4275
+				esc_html__(
4276
+					'Could not %1$s the %2$s because an invalid ID was received.',
4277
+					'event_espresso'
4278
+				),
4279
+				$action,
4280
+				$entity_model->get_this_model_name()
4281
+			)
4282
+		);
4283
+	}
4284 4284
 }
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
         $ee_menu_slugs = (array) $ee_menu_slugs;
629 629
         if (
630 630
             ! $this->request->isAjax()
631
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
631
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
632 632
         ) {
633 633
             return;
634 634
         }
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
             : $req_action;
649 649
 
650 650
         $this->_current_view = $this->_req_action;
651
-        $this->_req_nonce    = $this->_req_action . '_nonce';
651
+        $this->_req_nonce    = $this->_req_action.'_nonce';
652 652
         $this->_define_page_props();
653 653
         $this->_current_page_view_url = add_query_arg(
654 654
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -678,33 +678,33 @@  discard block
 block discarded – undo
678 678
         }
679 679
         // filter routes and page_config so addons can add their stuff. Filtering done per class
680 680
         $this->_page_routes = apply_filters(
681
-            'FHEE__' . $this->class_name . '__page_setup__page_routes',
681
+            'FHEE__'.$this->class_name.'__page_setup__page_routes',
682 682
             $this->_page_routes,
683 683
             $this
684 684
         );
685 685
         $this->_page_config = apply_filters(
686
-            'FHEE__' . $this->class_name . '__page_setup__page_config',
686
+            'FHEE__'.$this->class_name.'__page_setup__page_config',
687 687
             $this->_page_config,
688 688
             $this
689 689
         );
690 690
         if ($this->base_class_name !== '') {
691 691
             $this->_page_routes = apply_filters(
692
-                'FHEE__' . $this->base_class_name . '__page_setup__page_routes',
692
+                'FHEE__'.$this->base_class_name.'__page_setup__page_routes',
693 693
                 $this->_page_routes,
694 694
                 $this
695 695
             );
696 696
             $this->_page_config = apply_filters(
697
-                'FHEE__' . $this->base_class_name . '__page_setup__page_config',
697
+                'FHEE__'.$this->base_class_name.'__page_setup__page_config',
698 698
                 $this->_page_config,
699 699
                 $this
700 700
             );
701 701
         }
702 702
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
703 703
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
704
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
704
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
705 705
             add_action(
706 706
                 'AHEE__EE_Admin_Page__route_admin_request',
707
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
707
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
708 708
                 10,
709 709
                 2
710 710
             );
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
             if ($this->_is_UI_request) {
718 718
                 // admin_init stuff - global, all views for this page class, specific view
719 719
                 add_action('admin_init', [$this, 'admin_init'], 10);
720
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
721
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
720
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
721
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
722 722
                 }
723 723
             } else {
724 724
                 // hijack regular WP loading and route admin request immediately
@@ -737,12 +737,12 @@  discard block
 block discarded – undo
737 737
      */
738 738
     private function _do_other_page_hooks()
739 739
     {
740
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
740
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
741 741
         foreach ($registered_pages as $page) {
742 742
             // now let's setup the file name and class that should be present
743 743
             $classname = str_replace('.class.php', '', $page);
744 744
             // autoloaders should take care of loading file
745
-            if (! class_exists($classname)) {
745
+            if ( ! class_exists($classname)) {
746 746
                 $error_msg[] = sprintf(
747 747
                     esc_html__(
748 748
                         'Something went wrong with loading the %s admin hooks page.',
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
                                    ),
760 760
                                    $page,
761 761
                                    '<br />',
762
-                                   '<strong>' . $classname . '</strong>'
762
+                                   '<strong>'.$classname.'</strong>'
763 763
                                );
764 764
                 throw new EE_Error(implode('||', $error_msg));
765 765
             }
@@ -801,13 +801,13 @@  discard block
 block discarded – undo
801 801
         // load admin_notices - global, page class, and view specific
802 802
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
803 803
         add_action('admin_notices', [$this, 'admin_notices'], 10);
804
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
805
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
804
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
805
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
806 806
         }
807 807
         // load network admin_notices - global, page class, and view specific
808 808
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
809
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
810
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
809
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
810
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
811 811
         }
812 812
         // this will save any per_page screen options if they are present
813 813
         $this->_set_per_page_screen_options();
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
     protected function _verify_routes()
929 929
     {
930 930
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
931
-        if (! $this->_current_page && ! $this->request->isAjax()) {
931
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
932 932
             return false;
933 933
         }
934 934
         $this->_route = false;
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
                 $this->_admin_page_title
941 941
             );
942 942
             // developer error msg
943
-            $error_msg .= '||' . $error_msg
943
+            $error_msg .= '||'.$error_msg
944 944
                           . esc_html__(
945 945
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
946 946
                               'event_espresso'
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
         }
950 950
         // and that the requested page route exists
951 951
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
952
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
953
-            $this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
952
+            $this->_route        = $this->_page_routes[$this->_req_action];
953
+            $this->_route_config = $this->_page_config[$this->_req_action] ?? [];
954 954
         } else {
955 955
             // user error msg
956 956
             $error_msg = sprintf(
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
                 $this->_admin_page_title
962 962
             );
963 963
             // developer error msg
964
-            $error_msg .= '||' . $error_msg
964
+            $error_msg .= '||'.$error_msg
965 965
                           . sprintf(
966 966
                               esc_html__(
967 967
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
             throw new EE_Error($error_msg);
973 973
         }
974 974
         // and that a default route exists
975
-        if (! array_key_exists('default', $this->_page_routes)) {
975
+        if ( ! array_key_exists('default', $this->_page_routes)) {
976 976
             // user error msg
977 977
             $error_msg = sprintf(
978 978
                 esc_html__(
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
                 $this->_admin_page_title
983 983
             );
984 984
             // developer error msg
985
-            $error_msg .= '||' . $error_msg
985
+            $error_msg .= '||'.$error_msg
986 986
                           . esc_html__(
987 987
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
988 988
                               'event_espresso'
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
             $this->_admin_page_title
1025 1025
         );
1026 1026
         // developer error msg
1027
-        $error_msg .= '||' . $error_msg
1027
+        $error_msg .= '||'.$error_msg
1028 1028
                       . sprintf(
1029 1029
                           esc_html__(
1030 1030
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
     protected function _verify_nonce($nonce, $nonce_ref)
1053 1053
     {
1054 1054
         // verify nonce against expected value
1055
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
1055
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
1056 1056
             // these are not the droids you are looking for !!!
1057 1057
             $msg = sprintf(
1058 1058
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
                     __CLASS__
1070 1070
                 );
1071 1071
             }
1072
-            if (! $this->request->isAjax()) {
1072
+            if ( ! $this->request->isAjax()) {
1073 1073
                 wp_die($msg);
1074 1074
             }
1075 1075
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
      */
1094 1094
     protected function _route_admin_request()
1095 1095
     {
1096
-        if (! $this->_is_UI_request) {
1096
+        if ( ! $this->_is_UI_request) {
1097 1097
             $this->_verify_routes();
1098 1098
         }
1099 1099
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
         $error_msg = '';
1114 1114
         // action right before calling route
1115 1115
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1116
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1116
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1117 1117
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1118 1118
         }
1119 1119
         // strip _wp_http_referer from the server REQUEST_URI
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
         );
1126 1126
         // set new value in both our Request object and the super global
1127 1127
         $this->request->setServerParam('REQUEST_URI', $request_uri, true);
1128
-        if (! empty($func)) {
1128
+        if ( ! empty($func)) {
1129 1129
             if (is_array($func)) {
1130 1130
                 [$class, $method] = $func;
1131 1131
             } elseif (strpos($func, '::') !== false) {
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
                 $class  = $this;
1135 1135
                 $method = $func;
1136 1136
             }
1137
-            if (! (is_object($class) && $class === $this)) {
1137
+            if ( ! (is_object($class) && $class === $this)) {
1138 1138
                 // send along this admin page object for access by addons.
1139 1139
                 $args['admin_page_object'] = $this;
1140 1140
             }
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
                     $method
1176 1176
                 );
1177 1177
             }
1178
-            if (! empty($error_msg)) {
1178
+            if ( ! empty($error_msg)) {
1179 1179
                 throw new EE_Error($error_msg);
1180 1180
             }
1181 1181
         }
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
                 if (strpos($key, 'nonce') !== false) {
1262 1262
                     continue;
1263 1263
                 }
1264
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1264
+                $args['wp_referer['.$key.']'] = is_string($value) ? htmlspecialchars($value) : $value;
1265 1265
             }
1266 1266
         }
1267 1267
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1301,12 +1301,12 @@  discard block
 block discarded – undo
1301 1301
      */
1302 1302
     protected function _add_help_tabs()
1303 1303
     {
1304
-        if (isset($this->_page_config[ $this->_req_action ])) {
1305
-            $config = $this->_page_config[ $this->_req_action ];
1304
+        if (isset($this->_page_config[$this->_req_action])) {
1305
+            $config = $this->_page_config[$this->_req_action];
1306 1306
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1307 1307
             if (is_array($config) && isset($config['help_sidebar'])) {
1308 1308
                 // check that the callback given is valid
1309
-                if (! method_exists($this, $config['help_sidebar'])) {
1309
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1310 1310
                     throw new EE_Error(
1311 1311
                         sprintf(
1312 1312
                             esc_html__(
@@ -1319,18 +1319,18 @@  discard block
 block discarded – undo
1319 1319
                     );
1320 1320
                 }
1321 1321
                 $content = apply_filters(
1322
-                    'FHEE__' . $this->class_name . '__add_help_tabs__help_sidebar',
1322
+                    'FHEE__'.$this->class_name.'__add_help_tabs__help_sidebar',
1323 1323
                     $this->{$config['help_sidebar']}()
1324 1324
                 );
1325 1325
                 $this->_current_screen->set_help_sidebar($content);
1326 1326
             }
1327
-            if (! isset($config['help_tabs'])) {
1327
+            if ( ! isset($config['help_tabs'])) {
1328 1328
                 return;
1329 1329
             } //no help tabs for this route
1330 1330
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1331 1331
                 // we're here so there ARE help tabs!
1332 1332
                 // make sure we've got what we need
1333
-                if (! isset($cfg['title'])) {
1333
+                if ( ! isset($cfg['title'])) {
1334 1334
                     throw new EE_Error(
1335 1335
                         esc_html__(
1336 1336
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
                         )
1339 1339
                     );
1340 1340
                 }
1341
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1341
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1342 1342
                     throw new EE_Error(
1343 1343
                         esc_html__(
1344 1344
                             'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
@@ -1347,11 +1347,11 @@  discard block
 block discarded – undo
1347 1347
                     );
1348 1348
                 }
1349 1349
                 // first priority goes to content.
1350
-                if (! empty($cfg['content'])) {
1350
+                if ( ! empty($cfg['content'])) {
1351 1351
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1352 1352
                     // second priority goes to filename
1353
-                } elseif (! empty($cfg['filename'])) {
1354
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1353
+                } elseif ( ! empty($cfg['filename'])) {
1354
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1355 1355
                     // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1356 1356
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1357 1357
                                                              . basename($this->_get_dir())
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
                                                              . $cfg['filename']
1360 1360
                                                              . '.help_tab.php' : $file_path;
1361 1361
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1362
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1362
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1363 1363
                         EE_Error::add_error(
1364 1364
                             sprintf(
1365 1365
                                 esc_html__(
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
                     return;
1408 1408
                 }
1409 1409
                 // setup config array for help tab method
1410
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1410
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1411 1411
                 $_ht = [
1412 1412
                     'id'       => $id,
1413 1413
                     'title'    => $cfg['title'],
@@ -1433,8 +1433,8 @@  discard block
 block discarded – undo
1433 1433
             $qtips = (array) $this->_route_config['qtips'];
1434 1434
             // load qtip loader
1435 1435
             $path = [
1436
-                $this->_get_dir() . '/qtips/',
1437
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1436
+                $this->_get_dir().'/qtips/',
1437
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1438 1438
             ];
1439 1439
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1440 1440
         }
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1457 1457
         $i = 0;
1458 1458
         foreach ($this->_page_config as $slug => $config) {
1459
-            if (! is_array($config) || empty($config['nav'])) {
1459
+            if ( ! is_array($config) || empty($config['nav'])) {
1460 1460
                 continue;
1461 1461
             }
1462 1462
             // no nav tab for this config
@@ -1465,12 +1465,12 @@  discard block
 block discarded – undo
1465 1465
                 // nav tab is only to appear when route requested.
1466 1466
                 continue;
1467 1467
             }
1468
-            if (! $this->check_user_access($slug, true)) {
1468
+            if ( ! $this->check_user_access($slug, true)) {
1469 1469
                 // no nav tab because current user does not have access.
1470 1470
                 continue;
1471 1471
             }
1472
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1473
-            $this->_nav_tabs[ $slug ] = [
1472
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1473
+            $this->_nav_tabs[$slug] = [
1474 1474
                 'url'       => isset($config['nav']['url'])
1475 1475
                     ? $config['nav']['url']
1476 1476
                     : EE_Admin_Page::add_query_args_and_nonce(
@@ -1482,14 +1482,14 @@  discard block
 block discarded – undo
1482 1482
                     : ucwords(
1483 1483
                         str_replace('_', ' ', $slug)
1484 1484
                     ),
1485
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1485
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1486 1486
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1487 1487
             ];
1488 1488
             $i++;
1489 1489
         }
1490 1490
         // if $this->_nav_tabs is empty then lets set the default
1491 1491
         if (empty($this->_nav_tabs)) {
1492
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1492
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1493 1493
                 'url'       => $this->_admin_base_url,
1494 1494
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1495 1495
                 'css_class' => 'nav-tab-active',
@@ -1514,10 +1514,10 @@  discard block
 block discarded – undo
1514 1514
             foreach ($this->_route_config['labels'] as $label => $text) {
1515 1515
                 if (is_array($text)) {
1516 1516
                     foreach ($text as $sublabel => $subtext) {
1517
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1517
+                        $this->_labels[$label][$sublabel] = $subtext;
1518 1518
                     }
1519 1519
                 } else {
1520
-                    $this->_labels[ $label ] = $text;
1520
+                    $this->_labels[$label] = $text;
1521 1521
                 }
1522 1522
             }
1523 1523
         }
@@ -1539,12 +1539,12 @@  discard block
 block discarded – undo
1539 1539
     {
1540 1540
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1541 1541
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1542
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1542
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1543 1543
                           && is_array(
1544
-                              $this->_page_routes[ $route_to_check ]
1544
+                              $this->_page_routes[$route_to_check]
1545 1545
                           )
1546
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1547
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1546
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1547
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1548 1548
         if (empty($capability) && empty($route_to_check)) {
1549 1549
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1550 1550
                 : $this->_route['capability'];
@@ -1596,14 +1596,14 @@  discard block
 block discarded – undo
1596 1596
         string $priority = 'default',
1597 1597
         ?array $callback_args = null
1598 1598
     ) {
1599
-        if (! is_callable($callback)) {
1599
+        if ( ! is_callable($callback)) {
1600 1600
             return;
1601 1601
         }
1602 1602
 
1603 1603
         add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1604 1604
         add_filter(
1605 1605
             "postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1606
-            function ($classes) {
1606
+            function($classes) {
1607 1607
                 array_push($classes, 'ee-admin-container');
1608 1608
                 return $classes;
1609 1609
             }
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
         ';
1698 1698
 
1699 1699
         // current set timezone for timezone js
1700
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1700
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1701 1701
     }
1702 1702
 
1703 1703
 
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
         // loop through the array and setup content
1732 1732
         foreach ($help_array as $trigger => $help) {
1733 1733
             // make sure the array is setup properly
1734
-            if (! isset($help['title'], $help['content'])) {
1734
+            if ( ! isset($help['title'], $help['content'])) {
1735 1735
                 throw new EE_Error(
1736 1736
                     esc_html__(
1737 1737
                         'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
@@ -1745,8 +1745,8 @@  discard block
 block discarded – undo
1745 1745
                 'help_popup_title'   => $help['title'],
1746 1746
                 'help_popup_content' => $help['content'],
1747 1747
             ];
1748
-            $content       .= EEH_Template::display_template(
1749
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1748
+            $content .= EEH_Template::display_template(
1749
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1750 1750
                 $template_args,
1751 1751
                 true
1752 1752
             );
@@ -1768,15 +1768,15 @@  discard block
 block discarded – undo
1768 1768
     private function _get_help_content()
1769 1769
     {
1770 1770
         // what is the method we're looking for?
1771
-        $method_name = '_help_popup_content_' . $this->_req_action;
1771
+        $method_name = '_help_popup_content_'.$this->_req_action;
1772 1772
         // if method doesn't exist let's get out.
1773
-        if (! method_exists($this, $method_name)) {
1773
+        if ( ! method_exists($this, $method_name)) {
1774 1774
             return [];
1775 1775
         }
1776 1776
         // k we're good to go let's retrieve the help array
1777 1777
         $help_array = $this->{$method_name}();
1778 1778
         // make sure we've got an array!
1779
-        if (! is_array($help_array)) {
1779
+        if ( ! is_array($help_array)) {
1780 1780
             throw new EE_Error(
1781 1781
                 esc_html__(
1782 1782
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1808,8 +1808,8 @@  discard block
 block discarded – undo
1808 1808
         // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1809 1809
         $help_array   = $this->_get_help_content();
1810 1810
         $help_content = '';
1811
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1812
-            $help_array[ $trigger_id ] = [
1811
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1812
+            $help_array[$trigger_id] = [
1813 1813
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1814 1814
                 'content' => esc_html__(
1815 1815
                     'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 
1905 1905
         add_filter(
1906 1906
             'admin_body_class',
1907
-            function ($classes) {
1907
+            function($classes) {
1908 1908
                 if (strpos($classes, 'espresso-admin') === false) {
1909 1909
                     $classes .= ' espresso-admin';
1910 1910
                 }
@@ -1995,12 +1995,12 @@  discard block
 block discarded – undo
1995 1995
     protected function _set_list_table()
1996 1996
     {
1997 1997
         // first is this a list_table view?
1998
-        if (! isset($this->_route_config['list_table'])) {
1998
+        if ( ! isset($this->_route_config['list_table'])) {
1999 1999
             return;
2000 2000
         } //not a list_table view so get out.
2001 2001
         // list table functions are per view specific (because some admin pages might have more than one list table!)
2002
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2003
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2002
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
2003
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2004 2004
             // user error msg
2005 2005
             $error_msg = esc_html__(
2006 2006
                 'An error occurred. The requested list table views could not be found.',
@@ -2020,10 +2020,10 @@  discard block
 block discarded – undo
2020 2020
         }
2021 2021
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2022 2022
         $this->_views = apply_filters(
2023
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2023
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2024 2024
             $this->_views
2025 2025
         );
2026
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2026
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2027 2027
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2028 2028
         $this->_set_list_table_view();
2029 2029
         $this->_set_list_table_object();
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
     protected function _set_list_table_object()
2059 2059
     {
2060 2060
         if (isset($this->_route_config['list_table'])) {
2061
-            if (! class_exists($this->_route_config['list_table'])) {
2061
+            if ( ! class_exists($this->_route_config['list_table'])) {
2062 2062
                 throw new EE_Error(
2063 2063
                     sprintf(
2064 2064
                         esc_html__(
@@ -2096,17 +2096,17 @@  discard block
 block discarded – undo
2096 2096
         foreach ($this->_views as $key => $view) {
2097 2097
             $query_args = [];
2098 2098
             // check for current view
2099
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2099
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2100 2100
             $query_args['action']                        = $this->_req_action;
2101
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2101
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2102 2102
             $query_args['status']                        = $view['slug'];
2103 2103
             // merge any other arguments sent in.
2104
-            if (isset($extra_query_args[ $view['slug'] ])) {
2105
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2104
+            if (isset($extra_query_args[$view['slug']])) {
2105
+                foreach ($extra_query_args[$view['slug']] as $extra_query_arg) {
2106 2106
                     $query_args[] = $extra_query_arg;
2107 2107
                 }
2108 2108
             }
2109
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2109
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2110 2110
         }
2111 2111
         return $this->_views;
2112 2112
     }
@@ -2137,14 +2137,14 @@  discard block
 block discarded – undo
2137 2137
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2138 2138
         foreach ($values as $value) {
2139 2139
             if ($value < $max_entries) {
2140
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2140
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2141 2141
                 $entries_per_page_dropdown .= '
2142
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2142
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2143 2143
             }
2144 2144
         }
2145
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2145
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2146 2146
         $entries_per_page_dropdown .= '
2147
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2147
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2148 2148
         $entries_per_page_dropdown .= '
2149 2149
 					</select>
2150 2150
 					entries
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
             empty($this->_search_btn_label) ? $this->page_label
2169 2169
                 : $this->_search_btn_label
2170 2170
         );
2171
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2171
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2172 2172
     }
2173 2173
 
2174 2174
 
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
             $total_columns                                       = ! empty($screen_columns)
2257 2257
                 ? $screen_columns
2258 2258
                 : $this->_route_config['columns'][1];
2259
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2259
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2260 2260
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2261 2261
             $this->_template_args['screen']                      = $this->_current_screen;
2262 2262
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
      */
2303 2303
     protected function _espresso_ratings_request()
2304 2304
     {
2305
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2305
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2306 2306
             return;
2307 2307
         }
2308 2308
         $ratings_box_title = apply_filters(
@@ -2329,28 +2329,28 @@  discard block
 block discarded – undo
2329 2329
      */
2330 2330
     public function espresso_ratings_request()
2331 2331
     {
2332
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2332
+        EEH_Template::display_template(EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php');
2333 2333
     }
2334 2334
 
2335 2335
 
2336 2336
     public static function cached_rss_display($rss_id, $url)
2337 2337
     {
2338
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2338
+        $loading = '<p class="widget-loading hide-if-no-js">'
2339 2339
                      . esc_html__('Loading&#8230;', 'event_espresso')
2340 2340
                      . '</p><p class="hide-if-js">'
2341 2341
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2342 2342
                      . '</p>';
2343
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2344
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2345
-        $post      = '</div>' . "\n";
2346
-        $cache_key = 'ee_rss_' . md5($rss_id);
2343
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2344
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2345
+        $post      = '</div>'."\n";
2346
+        $cache_key = 'ee_rss_'.md5($rss_id);
2347 2347
         $output    = get_transient($cache_key);
2348 2348
         if ($output !== false) {
2349
-            echo $pre . $output . $post; // already escaped
2349
+            echo $pre.$output.$post; // already escaped
2350 2350
             return true;
2351 2351
         }
2352
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2353
-            echo $pre . $loading . $post; // already escaped
2352
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2353
+            echo $pre.$loading.$post; // already escaped
2354 2354
             return false;
2355 2355
         }
2356 2356
         ob_start();
@@ -2417,19 +2417,19 @@  discard block
 block discarded – undo
2417 2417
     public function espresso_sponsors_post_box()
2418 2418
     {
2419 2419
         EEH_Template::display_template(
2420
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2420
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2421 2421
         );
2422 2422
     }
2423 2423
 
2424 2424
 
2425 2425
     private function _publish_post_box()
2426 2426
     {
2427
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2427
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2428 2428
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2429 2429
         // then we'll use that for the metabox label.
2430 2430
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2431
-        if (! empty($this->_labels['publishbox'])) {
2432
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2431
+        if ( ! empty($this->_labels['publishbox'])) {
2432
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2433 2433
                 : $this->_labels['publishbox'];
2434 2434
         } else {
2435 2435
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2458,7 +2458,7 @@  discard block
 block discarded – undo
2458 2458
             ? $this->_template_args['publish_box_extra_content']
2459 2459
             : '';
2460 2460
         echo EEH_Template::display_template(
2461
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2461
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2462 2462
             $this->_template_args,
2463 2463
             true
2464 2464
         );
@@ -2546,18 +2546,18 @@  discard block
 block discarded – undo
2546 2546
             );
2547 2547
         }
2548 2548
         $this->_template_args['publish_delete_link'] = $delete_link;
2549
-        if (! empty($name) && ! empty($id)) {
2550
-            $hidden_field_arr[ $name ] = [
2549
+        if ( ! empty($name) && ! empty($id)) {
2550
+            $hidden_field_arr[$name] = [
2551 2551
                 'type'  => 'hidden',
2552 2552
                 'value' => $id,
2553 2553
             ];
2554
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2554
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2555 2555
         } else {
2556 2556
             $hf = '';
2557 2557
         }
2558 2558
         // add hidden field
2559 2559
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2560
-            ? $hf[ $name ]['field']
2560
+            ? $hf[$name]['field']
2561 2561
             : $hf;
2562 2562
     }
2563 2563
 
@@ -2659,7 +2659,7 @@  discard block
 block discarded – undo
2659 2659
         }
2660 2660
         // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2661 2661
         $call_back_func = $create_func
2662
-            ? static function ($post, $metabox) {
2662
+            ? static function($post, $metabox) {
2663 2663
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2664 2664
                 echo EEH_Template::display_template(
2665 2665
                     $metabox['args']['template_path'],
@@ -2669,7 +2669,7 @@  discard block
 block discarded – undo
2669 2669
             }
2670 2670
             : $callback;
2671 2671
         $this->addMetaBox(
2672
-            str_replace('_', '-', $action) . '-mbox',
2672
+            str_replace('_', '-', $action).'-mbox',
2673 2673
             $title,
2674 2674
             $call_back_func,
2675 2675
             $this->_wp_page_slug,
@@ -2786,13 +2786,13 @@  discard block
 block discarded – undo
2786 2786
             'event-espresso_page_espresso_',
2787 2787
             '',
2788 2788
             $this->_wp_page_slug
2789
-        ) . ' ' . $this->_req_action . '-route';
2789
+        ).' '.$this->_req_action.'-route';
2790 2790
 
2791 2791
         $template_path = $sidebar
2792 2792
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2793
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2793
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2794 2794
         if ($this->request->isAjax()) {
2795
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2795
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2796 2796
         }
2797 2797
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2798 2798
 
@@ -2826,11 +2826,11 @@  discard block
 block discarded – undo
2826 2826
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2827 2827
     {
2828 2828
         // let's generate a default preview action button if there isn't one already present.
2829
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2829
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2830 2830
             'Upgrade to Event Espresso 4 Right Now',
2831 2831
             'event_espresso'
2832 2832
         );
2833
-        $buy_now_url                                   = add_query_arg(
2833
+        $buy_now_url = add_query_arg(
2834 2834
             [
2835 2835
                 'ee_ver'       => 'ee4',
2836 2836
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2850,8 +2850,8 @@  discard block
 block discarded – undo
2850 2850
                 true
2851 2851
             )
2852 2852
             : $this->_template_args['preview_action_button'];
2853
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2854
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2853
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2854
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2855 2855
             $this->_template_args,
2856 2856
             true
2857 2857
         );
@@ -2909,7 +2909,7 @@  discard block
 block discarded – undo
2909 2909
         // setup search attributes
2910 2910
         $this->_set_search_attributes();
2911 2911
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2912
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2912
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2913 2913
         $this->_template_args['table_url']        = $this->request->isAjax()
2914 2914
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2915 2915
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -2917,10 +2917,10 @@  discard block
 block discarded – undo
2917 2917
         $this->_template_args['current_route']    = $this->_req_action;
2918 2918
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2919 2919
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2920
-        if (! empty($ajax_sorting_callback)) {
2920
+        if ( ! empty($ajax_sorting_callback)) {
2921 2921
             $sortable_list_table_form_fields = wp_nonce_field(
2922
-                $ajax_sorting_callback . '_nonce',
2923
-                $ajax_sorting_callback . '_nonce',
2922
+                $ajax_sorting_callback.'_nonce',
2923
+                $ajax_sorting_callback.'_nonce',
2924 2924
                 false,
2925 2925
                 false
2926 2926
             );
@@ -2937,18 +2937,18 @@  discard block
 block discarded – undo
2937 2937
 
2938 2938
         $hidden_form_fields = $this->_template_args['list_table_hidden_fields'] ?? '';
2939 2939
 
2940
-        $nonce_ref          = $this->_req_action . '_nonce';
2940
+        $nonce_ref          = $this->_req_action.'_nonce';
2941 2941
         $hidden_form_fields .= '
2942
-            <input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2942
+            <input type="hidden" name="' . $nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2943 2943
 
2944
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2944
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2945 2945
         // display message about search results?
2946 2946
         $search = $this->request->getRequestParam('s');
2947 2947
         $this->_template_args['before_list_table'] .= ! empty($search)
2948
-            ? '<p class="ee-search-results">' . sprintf(
2948
+            ? '<p class="ee-search-results">'.sprintf(
2949 2949
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2950 2950
                 trim($search, '%')
2951
-            ) . '</p>'
2951
+            ).'</p>'
2952 2952
             : '';
2953 2953
         // filter before_list_table template arg
2954 2954
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2982,7 +2982,7 @@  discard block
 block discarded – undo
2982 2982
         // convert to array and filter again
2983 2983
         // arrays are easier to inject new items in a specific location,
2984 2984
         // but would not be backwards compatible, so we have to add a new filter
2985
-        $this->_template_args['after_list_table']   = implode(
2985
+        $this->_template_args['after_list_table'] = implode(
2986 2986
             " \n",
2987 2987
             (array) apply_filters(
2988 2988
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -3037,7 +3037,7 @@  discard block
 block discarded – undo
3037 3037
             $this->page_slug
3038 3038
         );
3039 3039
         return EEH_Template::display_template(
3040
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3040
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
3041 3041
             $this->_template_args,
3042 3042
             true
3043 3043
         );
@@ -3153,16 +3153,16 @@  discard block
 block discarded – undo
3153 3153
             $this->_template_args['before_admin_page_content'] ?? ''
3154 3154
         );
3155 3155
 
3156
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3156
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3157 3157
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3158 3158
             $this->_template_args['after_admin_page_content'] ?? ''
3159 3159
         );
3160
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3160
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3161 3161
 
3162 3162
         if ($this->request->isAjax()) {
3163 3163
             $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3164 3164
                 // $template_path,
3165
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3165
+                EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php',
3166 3166
                 $this->_template_args,
3167 3167
                 true
3168 3168
             );
@@ -3171,7 +3171,7 @@  discard block
 block discarded – undo
3171 3171
         // load settings page wrapper template
3172 3172
         $template_path = $about
3173 3173
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3174
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3174
+            : EE_ADMIN_TEMPLATE.'admin_wrapper.template.php';
3175 3175
 
3176 3176
         EEH_Template::display_template($template_path, $this->_template_args);
3177 3177
     }
@@ -3255,12 +3255,12 @@  discard block
 block discarded – undo
3255 3255
         $default_names = ['save', 'save_and_close'];
3256 3256
         $buttons = '';
3257 3257
         foreach ($button_text as $key => $button) {
3258
-            $ref     = $default_names[ $key ];
3259
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3260
-            $buttons .= '<input type="submit" class="button button--primary ' . $ref . '" '
3261
-                        . 'value="' . $button . '" name="' . $name . '" '
3262
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3263
-            if (! $both) {
3258
+            $ref     = $default_names[$key];
3259
+            $name    = ! empty($actions) ? $actions[$key] : $ref;
3260
+            $buttons .= '<input type="submit" class="button button--primary '.$ref.'" '
3261
+                        . 'value="'.$button.'" name="'.$name.'" '
3262
+                        . 'id="'.$this->_current_view.'_'.$ref.'" />';
3263
+            if ( ! $both) {
3264 3264
                 break;
3265 3265
             }
3266 3266
         }
@@ -3300,13 +3300,13 @@  discard block
 block discarded – undo
3300 3300
                 'An error occurred. No action was set for this page\'s form.',
3301 3301
                 'event_espresso'
3302 3302
             );
3303
-            $dev_msg  = $user_msg . "\n"
3303
+            $dev_msg = $user_msg."\n"
3304 3304
                         . sprintf(
3305 3305
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3306 3306
                             __FUNCTION__,
3307 3307
                             __CLASS__
3308 3308
                         );
3309
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3309
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3310 3310
         }
3311 3311
         // open form
3312 3312
         $action = $this->_admin_base_url;
@@ -3314,9 +3314,9 @@  discard block
 block discarded – undo
3314 3314
             <form name='form' method='post' action='{$action}' id='{$route}_event_form' class='ee-admin-page-form' >
3315 3315
             ";
3316 3316
         // add nonce
3317
-        $nonce                                             =
3318
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3319
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3317
+        $nonce =
3318
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3319
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3320 3320
         // add REQUIRED form action
3321 3321
         $hidden_fields = [
3322 3322
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3329,7 +3329,7 @@  discard block
 block discarded – undo
3329 3329
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3330 3330
         // add fields to form
3331 3331
         foreach ((array) $form_fields as $form_field) {
3332
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3332
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3333 3333
         }
3334 3334
         // close form
3335 3335
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3412,12 +3412,12 @@  discard block
 block discarded – undo
3412 3412
         bool $override_overwrite = false
3413 3413
     ) {
3414 3414
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3415
-        $notices      = EE_Error::get_notices(false);
3415
+        $notices = EE_Error::get_notices(false);
3416 3416
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3417
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3417
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3418 3418
             EE_Error::overwrite_success();
3419 3419
         }
3420
-        if (! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3420
+        if ( ! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3421 3421
             // how many records affected ? more than one record ? or just one ?
3422 3422
             EE_Error::add_success(
3423 3423
                 sprintf(
@@ -3438,7 +3438,7 @@  discard block
 block discarded – undo
3438 3438
             );
3439 3439
         }
3440 3440
         // check that $query_args isn't something crazy
3441
-        if (! is_array($query_args)) {
3441
+        if ( ! is_array($query_args)) {
3442 3442
             $query_args = [];
3443 3443
         }
3444 3444
         /**
@@ -3470,7 +3470,7 @@  discard block
 block discarded – undo
3470 3470
             $redirect_url = admin_url('admin.php');
3471 3471
         }
3472 3472
         // merge any default query_args set in _default_route_query_args property
3473
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3473
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3474 3474
             $args_to_merge = [];
3475 3475
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3476 3476
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3482,15 +3482,15 @@  discard block
 block discarded – undo
3482 3482
                         }
3483 3483
                         // finally we will override any arguments in the referer with
3484 3484
                         // what might be set on the _default_route_query_args array.
3485
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3486
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3485
+                        if (isset($this->_default_route_query_args[$reference])) {
3486
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3487 3487
                         } else {
3488
-                            $args_to_merge[ $reference ] = urlencode($value);
3488
+                            $args_to_merge[$reference] = urlencode($value);
3489 3489
                         }
3490 3490
                     }
3491 3491
                     continue;
3492 3492
                 }
3493
-                $args_to_merge[ $query_param ] = $query_value;
3493
+                $args_to_merge[$query_param] = $query_value;
3494 3494
             }
3495 3495
             // now let's merge these arguments but override with what was specifically sent in to the
3496 3496
             // redirect.
@@ -3502,19 +3502,19 @@  discard block
 block discarded – undo
3502 3502
         if (isset($query_args['action'])) {
3503 3503
             // manually generate wp_nonce and merge that with the query vars
3504 3504
             // becuz the wp_nonce_url function wrecks havoc on some vars
3505
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3505
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3506 3506
         }
3507 3507
         // we're adding some hooks and filters in here for processing any things just before redirects
3508 3508
         // (example: an admin page has done an insert or update and we want to run something after that).
3509
-        do_action('AHEE_redirect_' . $this->class_name . $this->_req_action, $query_args);
3509
+        do_action('AHEE_redirect_'.$this->class_name.$this->_req_action, $query_args);
3510 3510
         $redirect_url = apply_filters(
3511
-            'FHEE_redirect_' . $this->class_name . $this->_req_action,
3511
+            'FHEE_redirect_'.$this->class_name.$this->_req_action,
3512 3512
             EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3513 3513
             $query_args
3514 3514
         );
3515 3515
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3516 3516
         if ($this->request->isAjax()) {
3517
-            $default_data                    = [
3517
+            $default_data = [
3518 3518
                 'close'        => true,
3519 3519
                 'redirect_url' => $redirect_url,
3520 3520
                 'where'        => 'main',
@@ -3564,7 +3564,7 @@  discard block
 block discarded – undo
3564 3564
         }
3565 3565
         $this->_template_args['notices'] = EE_Error::get_notices();
3566 3566
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3567
-        if (! $this->request->isAjax() || $sticky_notices) {
3567
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3568 3568
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3569 3569
             $this->_add_transient(
3570 3570
                 $route,
@@ -3604,7 +3604,7 @@  discard block
 block discarded – undo
3604 3604
         $exclude_nonce = false
3605 3605
     ) {
3606 3606
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3607
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3607
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3608 3608
             throw new EE_Error(
3609 3609
                 sprintf(
3610 3610
                     esc_html__(
@@ -3615,7 +3615,7 @@  discard block
 block discarded – undo
3615 3615
                 )
3616 3616
             );
3617 3617
         }
3618
-        if (! isset($this->_labels['buttons'][ $type ])) {
3618
+        if ( ! isset($this->_labels['buttons'][$type])) {
3619 3619
             throw new EE_Error(
3620 3620
                 sprintf(
3621 3621
                     esc_html__(
@@ -3628,7 +3628,7 @@  discard block
 block discarded – undo
3628 3628
         }
3629 3629
         // finally check user access for this button.
3630 3630
         $has_access = $this->check_user_access($action, true);
3631
-        if (! $has_access) {
3631
+        if ( ! $has_access) {
3632 3632
             return '';
3633 3633
         }
3634 3634
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3636,11 +3636,11 @@  discard block
 block discarded – undo
3636 3636
             'action' => $action,
3637 3637
         ];
3638 3638
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3639
-        if (! empty($extra_request)) {
3639
+        if ( ! empty($extra_request)) {
3640 3640
             $query_args = array_merge($extra_request, $query_args);
3641 3641
         }
3642 3642
         $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3643
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3643
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3644 3644
     }
3645 3645
 
3646 3646
 
@@ -3666,7 +3666,7 @@  discard block
 block discarded – undo
3666 3666
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3667 3667
                 20
3668 3668
             ),
3669
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3669
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3670 3670
         ];
3671 3671
         // ONLY add the screen option if the user has access to it.
3672 3672
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3687,18 +3687,18 @@  discard block
 block discarded – undo
3687 3687
     {
3688 3688
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3689 3689
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3690
-            if (! $user = wp_get_current_user()) {
3690
+            if ( ! $user = wp_get_current_user()) {
3691 3691
                 return;
3692 3692
             }
3693 3693
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3694
-            if (! $option) {
3694
+            if ( ! $option) {
3695 3695
                 return;
3696 3696
             }
3697
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3697
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3698 3698
             $map_option = $option;
3699 3699
             $option     = str_replace('-', '_', $option);
3700 3700
             switch ($map_option) {
3701
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3701
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3702 3702
                     $max_value = apply_filters(
3703 3703
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3704 3704
                         999,
@@ -3755,13 +3755,13 @@  discard block
 block discarded – undo
3755 3755
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3756 3756
     {
3757 3757
         $user_id = get_current_user_id();
3758
-        if (! $skip_route_verify) {
3758
+        if ( ! $skip_route_verify) {
3759 3759
             $this->_verify_route($route);
3760 3760
         }
3761 3761
         // now let's set the string for what kind of transient we're setting
3762 3762
         $transient = $notices
3763
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3764
-            : 'rte_tx_' . $route . '_' . $user_id;
3763
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3764
+            : 'rte_tx_'.$route.'_'.$user_id;
3765 3765
         $data      = $notices ? ['notices' => $data] : $data;
3766 3766
         // is there already a transient for this route?  If there is then let's ADD to that transient
3767 3767
         $existing = is_multisite() && is_network_admin()
@@ -3790,8 +3790,8 @@  discard block
 block discarded – undo
3790 3790
         $user_id   = get_current_user_id();
3791 3791
         $route     = ! $route ? $this->_req_action : $route;
3792 3792
         $transient = $notices
3793
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3794
-            : 'rte_tx_' . $route . '_' . $user_id;
3793
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3794
+            : 'rte_tx_'.$route.'_'.$user_id;
3795 3795
         $data      = is_multisite() && is_network_admin()
3796 3796
             ? get_site_transient($transient)
3797 3797
             : get_transient($transient);
@@ -4027,7 +4027,7 @@  discard block
 block discarded – undo
4027 4027
      */
4028 4028
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4029 4029
     {
4030
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4030
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4031 4031
     }
4032 4032
 
4033 4033
 
@@ -4040,7 +4040,7 @@  discard block
 block discarded – undo
4040 4040
      */
4041 4041
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4042 4042
     {
4043
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4043
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4044 4044
     }
4045 4045
 
4046 4046
 
@@ -4188,7 +4188,7 @@  discard block
 block discarded – undo
4188 4188
         ?callable $callback = null
4189 4189
     ): bool {
4190 4190
         $entity_ID = absint($entity_ID);
4191
-        if (! $entity_ID) {
4191
+        if ( ! $entity_ID) {
4192 4192
             $this->trashRestoreDeleteError($action, $entity_model);
4193 4193
         }
4194 4194
         $result = 0;
@@ -4234,7 +4234,7 @@  discard block
 block discarded – undo
4234 4234
                 )
4235 4235
             );
4236 4236
         }
4237
-        if (! $entity_model->has_field($delete_column)) {
4237
+        if ( ! $entity_model->has_field($delete_column)) {
4238 4238
             throw new DomainException(
4239 4239
                 sprintf(
4240 4240
                     esc_html__(
Please login to merge, or discard this patch.
ticket_selector_caff/templates/ticket_selector_price_details.template.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 if (! function_exists('espressoSubtotalRow')) {
13
-    function espressoSubtotalRow(float $running_total, bool $show = true): string
14
-    {
15
-        return $show
16
-            ? '
13
+	function espressoSubtotalRow(float $running_total, bool $show = true): string
14
+	{
15
+		return $show
16
+			? '
17 17
                 <tr>
18 18
                     <td colspan="2" class="jst-rght small-text sbttl">
19 19
                         <b>' . esc_html__('subtotal', 'event_espresso') . '</b>
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
                     </td>
24 24
                 </tr>
25 25
             '
26
-            : '';
27
-    }
26
+			: '';
27
+	}
28 28
 }
29 29
 
30 30
 if ($display_ticket_price) { ?>
31 31
     <section class="tckt-slctr-tkt-price-sctn">
32 32
         <h5><?php echo esc_html(
33
-            apply_filters(
34
-                'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
35
-                __('Price', 'event_espresso')
36
-            )
37
-        ); ?></h5>
33
+			apply_filters(
34
+				'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
35
+				__('Price', 'event_espresso')
36
+			)
37
+		); ?></h5>
38 38
         <div class="tckt-slctr-tkt-details-tbl-wrap-dv">
39 39
             <table class="tckt-slctr-tkt-details-tbl">
40 40
                 <thead>
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                 </thead>
55 55
                 <tbody>
56 56
                     <?php
57
-                    if ($ticket->base_price() instanceof EE_Price) { ?>
57
+					if ($ticket->base_price() instanceof EE_Price) { ?>
58 58
                         <tr>
59 59
                             <td data-th="<?php esc_html_e('Name', 'event_espresso'); ?>" class="small-text" colspan="2">
60 60
                                 <b>
@@ -66,31 +66,31 @@  discard block
 block discarded – undo
66 66
                             </td>
67 67
                         </tr>
68 68
                         <?php
69
-                        $running_total = $ticket->base_price()->amount();
70
-                    } else {
71
-                        $running_total = 0;
72
-                    }
73
-                    $pretax_total     = $running_total;
74
-                    $display_subtotal = true;
75
-                    // now add price modifiers
76
-                    foreach ($ticket->price_modifiers() as $price_mod) {
77
-                        if ($price_mod->is_tax()) {
78
-                            echo espressoSubtotalRow($running_total, $display_subtotal);
79
-                            $display_subtotal = false;
80
-                            $new_sub_total    = $pretax_total * ($price_mod->amount() / 100);
81
-                        } elseif ($price_mod->is_percent()) {
82
-                            $new_sub_total = $running_total * ($price_mod->amount() / 100);
83
-                        } else {
84
-                            $new_sub_total = $price_mod->amount();
85
-                        }
86
-                        $new_sub_total = $price_mod->is_discount()
87
-                            ? $new_sub_total * -1
88
-                            : $new_sub_total;
89
-                        $description   = $price_mod->desc() . ' ';
90
-                        $description   .= $price_mod->is_percent()
91
-                            ? $price_mod->amount() . '%'
92
-                            : EEH_Template::format_currency($price_mod->amount());
93
-                        ?>
69
+						$running_total = $ticket->base_price()->amount();
70
+					} else {
71
+						$running_total = 0;
72
+					}
73
+					$pretax_total     = $running_total;
74
+					$display_subtotal = true;
75
+					// now add price modifiers
76
+					foreach ($ticket->price_modifiers() as $price_mod) {
77
+						if ($price_mod->is_tax()) {
78
+							echo espressoSubtotalRow($running_total, $display_subtotal);
79
+							$display_subtotal = false;
80
+							$new_sub_total    = $pretax_total * ($price_mod->amount() / 100);
81
+						} elseif ($price_mod->is_percent()) {
82
+							$new_sub_total = $running_total * ($price_mod->amount() / 100);
83
+						} else {
84
+							$new_sub_total = $price_mod->amount();
85
+						}
86
+						$new_sub_total = $price_mod->is_discount()
87
+							? $new_sub_total * -1
88
+							: $new_sub_total;
89
+						$description   = $price_mod->desc() . ' ';
90
+						$description   .= $price_mod->is_percent()
91
+							? $price_mod->amount() . '%'
92
+							: EEH_Template::format_currency($price_mod->amount());
93
+						?>
94 94
                         <tr>
95 95
                             <td data-th="<?php esc_html_e('Name', 'event_espresso'); ?>"
96 96
                                 class="jst-rght small-text"
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
                             </td>
103 103
                             <td data-th="<?php esc_html_e('Amount', 'event_espresso'); ?>" class="jst-rght small-text">
104 104
                                 <?php echo wp_kses(
105
-                                    EEH_Template::format_currency($new_sub_total),
106
-                                    AllowedTags::getAllowedTags()
107
-                                ); ?>
105
+									EEH_Template::format_currency($new_sub_total),
106
+									AllowedTags::getAllowedTags()
107
+								); ?>
108 108
                             </td>
109 109
                             <?php $pretax_total += ! $price_mod->is_tax() ? $new_sub_total : 0; ?>
110 110
                             <?php $running_total += $new_sub_total; ?>
111 111
                         </tr>
112 112
                     <?php } ?>
113 113
                     <?php if ($ticket->taxable()) {
114
-                        echo espressoSubtotalRow($running_total);
115
-                        foreach ($ticket->get_ticket_taxes_for_admin() as $tax) { ?>
114
+						echo espressoSubtotalRow($running_total);
115
+						foreach ($ticket->get_ticket_taxes_for_admin() as $tax) { ?>
116 116
                             <tr>
117 117
                                 <td data-th="<?php esc_html_e('Name', 'event_espresso'); ?>"
118 118
                                     class="jst-rght small-text"
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
                                     class="jst-rght small-text"
130 130
                                 >
131 131
                                     <?php echo wp_kses(
132
-                                        EEH_Template::format_currency($tax_amount),
133
-                                        AllowedTags::getAllowedTags()
134
-                                    ); ?>
132
+										EEH_Template::format_currency($tax_amount),
133
+										AllowedTags::getAllowedTags()
134
+									); ?>
135 135
                                 </td>
136 136
                                 <?php $running_total += $tax_amount; ?>
137 137
                             </tr>
@@ -141,24 +141,24 @@  discard block
 block discarded – undo
141 141
                         <td colspan="2" class="jst-rght small-text ttl-lbl-td">
142 142
                             <b>
143 143
                                 <?php echo esc_html(
144
-                                    apply_filters(
145
-                                        'FHEE__ticket_selector_chart_template__ticket_details_total_price',
146
-                                        __('Total', 'event_espresso')
147
-                                    )
148
-                                ); ?>
144
+									apply_filters(
145
+										'FHEE__ticket_selector_chart_template__ticket_details_total_price',
146
+										__('Total', 'event_espresso')
147
+									)
148
+								); ?>
149 149
                             </b>
150 150
                         </td>
151 151
                         <td data-th="<?php echo esc_html(
152
-                            apply_filters(
153
-                                'FHEE__ticket_selector_chart_template__ticket_details_total_price',
154
-                                __('Total', 'event_espresso')
155
-                            )
156
-                        ); ?>" class="jst-rght small-text"
152
+							apply_filters(
153
+								'FHEE__ticket_selector_chart_template__ticket_details_total_price',
154
+								__('Total', 'event_espresso')
155
+							)
156
+						); ?>" class="jst-rght small-text"
157 157
                         >
158 158
                             <b><?php  wp_kses(
159
-                                EEH_Template::format_currency($running_total),
160
-                                AllowedTags::getAllowedTags()
161
-                            ); ?></b>
159
+								EEH_Template::format_currency($running_total),
160
+								AllowedTags::getAllowedTags()
161
+							); ?></b>
162 162
                         </td>
163 163
                     </tr>
164 164
                 </tbody>
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 2 patches
Indentation   +663 added lines, -663 removed lines patch added patch discarded remove patch
@@ -15,711 +15,711 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Event_Registrations_List_Table extends EE_Admin_List_Table
17 17
 {
18
-    /**
19
-     * @var RequestInterface
20
-     */
21
-    protected $request;
22
-
23
-    /**
24
-     * @var Extend_Registrations_Admin_Page
25
-     */
26
-    protected $_admin_page;
27
-
28
-    /**
29
-     * The event ID if one is specified in the request
30
-     *
31
-     * @var int
32
-     */
33
-    protected $event_id = 0;
34
-
35
-    /**
36
-     * This property will hold the related Datetimes on an event IF the event id is included in the request.
37
-     *
38
-     * @var DatetimesForEventCheckIn
39
-     */
40
-    protected $datetimes_for_event = [];
41
-
42
-    /**
43
-     * The DTT_ID if the current view has a specified datetime.
44
-     *
45
-     * @var int
46
-     */
47
-    protected $datetime_id = 0;
48
-
49
-    /**
50
-     * @var EE_Datetime
51
-     */
52
-    protected $datetime;
53
-
54
-    /**
55
-     * @var EE_Event
56
-     */
57
-    protected $event;
58
-
59
-    /**
60
-     * @var DatetimesForEventCheckIn
61
-     */
62
-    protected $datetimes_for_current_row;
63
-
64
-    /**
65
-     * @var bool
66
-     */
67
-    protected $hide_expired;
68
-
69
-    /**
70
-     * @var bool
71
-     */
72
-    protected $hide_upcoming;
73
-
74
-
75
-    /**
76
-     * EE_Event_Registrations_List_Table constructor.
77
-     *
78
-     * @param Registrations_Admin_Page $admin_page
79
-     * @throws EE_Error
80
-     * @throws ReflectionException
81
-     */
82
-    public function __construct($admin_page)
83
-    {
84
-        $this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
85
-        $this->resolveRequestVars();
86
-        parent::__construct($admin_page);
87
-    }
88
-
89
-
90
-    /**
91
-     * @throws EE_Error
92
-     * @throws ReflectionException
93
-     * @since $VID:$
94
-     */
95
-    private function resolveRequestVars()
96
-    {
97
-        $this->event_id = $this->request->getRequestParam('event_id', 0, 'int');
98
-        $this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id);
99
-        // if we're filtering for a specific event and it only has one datetime, then grab its ID
100
-        $datetime          = $this->datetimes_for_event->getOneActiveDatetimeForEvent();
101
-        $this->datetime_id = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
102
-        // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ)
103
-        $this->datetime_id = $this->request->getRequestParam(
104
-            'DTT_ID',
105
-            $this->datetime_id,
106
-            'int'
107
-        );
108
-    }
109
-
110
-
111
-    /**
112
-     * @throws EE_Error
113
-     */
114
-    protected function _setup_data()
115
-    {
116
-        $this->_data = $this->_view !== 'trash'
117
-            ? $this->_admin_page->get_event_attendees($this->_per_page)
118
-            : $this->_admin_page->get_event_attendees($this->_per_page, false, true);
119
-
120
-        $this->_all_data_count = $this->_view !== 'trash'
121
-            ? $this->_admin_page->get_event_attendees($this->_per_page, true)
122
-            : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
123
-    }
124
-
125
-
126
-    protected function _set_properties()
127
-    {
128
-        $this->_wp_list_args = [
129
-            'singular' => esc_html__('registrant', 'event_espresso'),
130
-            'plural'   => esc_html__('registrants', 'event_espresso'),
131
-            'ajax'     => true,
132
-            'screen'   => $this->_admin_page->get_current_screen()->id,
133
-        ];
134
-
135
-        $this->_columns      = [
136
-            'cb' => '<input type="checkbox" />', // Render a checkbox instead of text
137
-            '_REG_att_checked_in' => esc_html__('Check In', 'event_espresso'),
138
-            'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
139
-            'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
140
-            'Event'               => esc_html__('Event', 'event_espresso'),
141
-            'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
142
-            '_REG_final_price'    => esc_html__('Price', 'event_espresso'),
143
-            'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
144
-            'TXN_total'           => esc_html__('Total', 'event_espresso'),
145
-        ];
146
-        $this->_primary_column = '_REG_att_checked_in';
147
-
148
-        // Add/remove columns when an event has been selected
149
-        if ($this->event_id) {
150
-            // Render a checkbox column
151
-            $this->_columns['cb'] = '<input type="checkbox" />';
152
-            $this->_has_checkbox_column = true;
153
-            // Remove the 'Event' column
154
-            unset($this->_columns['Event']);
155
-            $this->setBottomButtons();
156
-        }
157
-
158
-        $this->_sortable_columns = [
159
-            /**
160
-             * Allows users to change the default sort if they wish.
161
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
162
-             *
163
-             * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
164
-             * change the sorts on any list table involving registration contacts.  If you want to only change the filter
165
-             * for a specific list table you can use the provided reference to this object instance.
166
-             */
167
-            'ATT_name' => [
168
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
169
-                true,
170
-                $this,
171
-            ]
172
-                ? ['ATT_lname' => true]
173
-                : ['ATT_fname' => true],
174
-            'Event'    => ['Event.EVT_name' => false],
175
-        ];
176
-
177
-        $this->_hidden_columns = [];
178
-    }
179
-
180
-
181
-    private function setBottomButtons()
182
-    {
183
-        if (
184
-            ! EE_Registry::instance()->CAP->current_user_can(
185
-                'ee_read_registrations',
186
-                'espresso_registrations_registrations_reports',
187
-                $this->event_id
188
-            )
189
-        ) {
190
-            return;
191
-        }
192
-
193
-        $return_url = $this->getReturnUrl();
194
-        $this->_bottom_buttons = [
195
-            'report' => [
196
-                'route'         => 'registrations_report',
197
-                'extra_request' =>
198
-                    [
199
-                        'EVT_ID'     => $this->event_id,
200
-                        'return_url' => $return_url,
201
-                    ],
202
-            ],
203
-        ];
204
-
205
-        $request_params = $this->request->requestParams();
206
-
207
-        $this->_bottom_buttons['report_filtered'] = [
208
-            'route'         => 'registrations_checkin_report',
209
-            'extra_request' => [
210
-                'use_filters' => true,
211
-                'filters'     => array_merge(
212
-                    [
213
-                        'EVT_ID' => $this->event_id,
214
-                    ],
215
-                    array_diff_key(
216
-                        $request_params,
217
-                        array_flip(
218
-                            [
219
-                                'page',
220
-                                'action',
221
-                                'default_nonce',
222
-                            ]
223
-                        )
224
-                    )
225
-                ),
226
-                'return_url'  => $return_url,
227
-            ],
228
-        ];
229
-    }
230
-
231
-
232
-    /**
233
-     * @param EE_Registration $item
234
-     * @return string
235
-     */
236
-    protected function _get_row_class($item): string
237
-    {
238
-        $class = parent::_get_row_class($item);
239
-        if ($this->_has_checkbox_column) {
240
-            $class .= ' has-checkbox-column';
241
-        }
242
-        return $class;
243
-    }
244
-
245
-
246
-    /**
247
-     * @return array
248
-     * @throws EE_Error
249
-     * @throws ReflectionException
250
-     */
251
-    protected function _get_table_filters(): array
252
-    {
253
-        $filters = [];
254
-        $this->hide_expired = $this->request->getRequestParam('hide_expired', false, 'bool');
255
-        $this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, 'bool');
256
-        $hide_expired_checked = $this->hide_expired ? 'checked' : '';
257
-        $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : '';
258
-        // get datetimes for ALL active events (note possible capability restrictions)
259
-        $events   = $this->datetimes_for_event->getAllActiveDatetimesForAllEvents();
260
-        $event_options[] = [
261
-            'id'   => 0,
262
-            'text' => esc_html__(' - select an event - ', 'event_espresso'),
263
-        ];
264
-        /** @var EE_Event $event */
265
-        foreach ($events as $event) {
266
-            // any registrations for this event?
267
-            if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
268
-                continue;
269
-            }
270
-            $expired_class = $event->is_expired() ? 'ee-expired-event' : '';
271
-            $upcoming_class  = $event->is_upcoming() ? ' ee-upcoming-event' : '';
272
-            $event_options[] = [
273
-                'id'    => $event->ID(),
274
-                'text'  => apply_filters(
275
-                    'FHEE__EE_Event_Registrations___get_table_filters__event_name',
276
-                    $event->name(),
277
-                    $event
278
-                ),
279
-                'class' => $expired_class . $upcoming_class,
280
-            ];
281
-            if ($event->ID() === $this->event_id) {
282
-                $this->hide_expired = $expired_class === '';
283
-                $hide_expired_checked  = $expired_class === '' ? $hide_expired_checked : '';
284
-                $this->hide_upcoming = $upcoming_class === '';
285
-                $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : '';
286
-            }
287
-        }
288
-
289
-        $select_class = $this->hide_expired ? 'ee-hide-expired-events' : '';
290
-        $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : '';
291
-
292
-        $filters[] = '
18
+	/**
19
+	 * @var RequestInterface
20
+	 */
21
+	protected $request;
22
+
23
+	/**
24
+	 * @var Extend_Registrations_Admin_Page
25
+	 */
26
+	protected $_admin_page;
27
+
28
+	/**
29
+	 * The event ID if one is specified in the request
30
+	 *
31
+	 * @var int
32
+	 */
33
+	protected $event_id = 0;
34
+
35
+	/**
36
+	 * This property will hold the related Datetimes on an event IF the event id is included in the request.
37
+	 *
38
+	 * @var DatetimesForEventCheckIn
39
+	 */
40
+	protected $datetimes_for_event = [];
41
+
42
+	/**
43
+	 * The DTT_ID if the current view has a specified datetime.
44
+	 *
45
+	 * @var int
46
+	 */
47
+	protected $datetime_id = 0;
48
+
49
+	/**
50
+	 * @var EE_Datetime
51
+	 */
52
+	protected $datetime;
53
+
54
+	/**
55
+	 * @var EE_Event
56
+	 */
57
+	protected $event;
58
+
59
+	/**
60
+	 * @var DatetimesForEventCheckIn
61
+	 */
62
+	protected $datetimes_for_current_row;
63
+
64
+	/**
65
+	 * @var bool
66
+	 */
67
+	protected $hide_expired;
68
+
69
+	/**
70
+	 * @var bool
71
+	 */
72
+	protected $hide_upcoming;
73
+
74
+
75
+	/**
76
+	 * EE_Event_Registrations_List_Table constructor.
77
+	 *
78
+	 * @param Registrations_Admin_Page $admin_page
79
+	 * @throws EE_Error
80
+	 * @throws ReflectionException
81
+	 */
82
+	public function __construct($admin_page)
83
+	{
84
+		$this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
85
+		$this->resolveRequestVars();
86
+		parent::__construct($admin_page);
87
+	}
88
+
89
+
90
+	/**
91
+	 * @throws EE_Error
92
+	 * @throws ReflectionException
93
+	 * @since $VID:$
94
+	 */
95
+	private function resolveRequestVars()
96
+	{
97
+		$this->event_id = $this->request->getRequestParam('event_id', 0, 'int');
98
+		$this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id);
99
+		// if we're filtering for a specific event and it only has one datetime, then grab its ID
100
+		$datetime          = $this->datetimes_for_event->getOneActiveDatetimeForEvent();
101
+		$this->datetime_id = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
102
+		// else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ)
103
+		$this->datetime_id = $this->request->getRequestParam(
104
+			'DTT_ID',
105
+			$this->datetime_id,
106
+			'int'
107
+		);
108
+	}
109
+
110
+
111
+	/**
112
+	 * @throws EE_Error
113
+	 */
114
+	protected function _setup_data()
115
+	{
116
+		$this->_data = $this->_view !== 'trash'
117
+			? $this->_admin_page->get_event_attendees($this->_per_page)
118
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
119
+
120
+		$this->_all_data_count = $this->_view !== 'trash'
121
+			? $this->_admin_page->get_event_attendees($this->_per_page, true)
122
+			: $this->_admin_page->get_event_attendees($this->_per_page, true, true);
123
+	}
124
+
125
+
126
+	protected function _set_properties()
127
+	{
128
+		$this->_wp_list_args = [
129
+			'singular' => esc_html__('registrant', 'event_espresso'),
130
+			'plural'   => esc_html__('registrants', 'event_espresso'),
131
+			'ajax'     => true,
132
+			'screen'   => $this->_admin_page->get_current_screen()->id,
133
+		];
134
+
135
+		$this->_columns      = [
136
+			'cb' => '<input type="checkbox" />', // Render a checkbox instead of text
137
+			'_REG_att_checked_in' => esc_html__('Check In', 'event_espresso'),
138
+			'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
139
+			'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
140
+			'Event'               => esc_html__('Event', 'event_espresso'),
141
+			'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
142
+			'_REG_final_price'    => esc_html__('Price', 'event_espresso'),
143
+			'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
144
+			'TXN_total'           => esc_html__('Total', 'event_espresso'),
145
+		];
146
+		$this->_primary_column = '_REG_att_checked_in';
147
+
148
+		// Add/remove columns when an event has been selected
149
+		if ($this->event_id) {
150
+			// Render a checkbox column
151
+			$this->_columns['cb'] = '<input type="checkbox" />';
152
+			$this->_has_checkbox_column = true;
153
+			// Remove the 'Event' column
154
+			unset($this->_columns['Event']);
155
+			$this->setBottomButtons();
156
+		}
157
+
158
+		$this->_sortable_columns = [
159
+			/**
160
+			 * Allows users to change the default sort if they wish.
161
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
162
+			 *
163
+			 * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
164
+			 * change the sorts on any list table involving registration contacts.  If you want to only change the filter
165
+			 * for a specific list table you can use the provided reference to this object instance.
166
+			 */
167
+			'ATT_name' => [
168
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
169
+				true,
170
+				$this,
171
+			]
172
+				? ['ATT_lname' => true]
173
+				: ['ATT_fname' => true],
174
+			'Event'    => ['Event.EVT_name' => false],
175
+		];
176
+
177
+		$this->_hidden_columns = [];
178
+	}
179
+
180
+
181
+	private function setBottomButtons()
182
+	{
183
+		if (
184
+			! EE_Registry::instance()->CAP->current_user_can(
185
+				'ee_read_registrations',
186
+				'espresso_registrations_registrations_reports',
187
+				$this->event_id
188
+			)
189
+		) {
190
+			return;
191
+		}
192
+
193
+		$return_url = $this->getReturnUrl();
194
+		$this->_bottom_buttons = [
195
+			'report' => [
196
+				'route'         => 'registrations_report',
197
+				'extra_request' =>
198
+					[
199
+						'EVT_ID'     => $this->event_id,
200
+						'return_url' => $return_url,
201
+					],
202
+			],
203
+		];
204
+
205
+		$request_params = $this->request->requestParams();
206
+
207
+		$this->_bottom_buttons['report_filtered'] = [
208
+			'route'         => 'registrations_checkin_report',
209
+			'extra_request' => [
210
+				'use_filters' => true,
211
+				'filters'     => array_merge(
212
+					[
213
+						'EVT_ID' => $this->event_id,
214
+					],
215
+					array_diff_key(
216
+						$request_params,
217
+						array_flip(
218
+							[
219
+								'page',
220
+								'action',
221
+								'default_nonce',
222
+							]
223
+						)
224
+					)
225
+				),
226
+				'return_url'  => $return_url,
227
+			],
228
+		];
229
+	}
230
+
231
+
232
+	/**
233
+	 * @param EE_Registration $item
234
+	 * @return string
235
+	 */
236
+	protected function _get_row_class($item): string
237
+	{
238
+		$class = parent::_get_row_class($item);
239
+		if ($this->_has_checkbox_column) {
240
+			$class .= ' has-checkbox-column';
241
+		}
242
+		return $class;
243
+	}
244
+
245
+
246
+	/**
247
+	 * @return array
248
+	 * @throws EE_Error
249
+	 * @throws ReflectionException
250
+	 */
251
+	protected function _get_table_filters(): array
252
+	{
253
+		$filters = [];
254
+		$this->hide_expired = $this->request->getRequestParam('hide_expired', false, 'bool');
255
+		$this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, 'bool');
256
+		$hide_expired_checked = $this->hide_expired ? 'checked' : '';
257
+		$hide_upcoming_checked = $this->hide_upcoming ? 'checked' : '';
258
+		// get datetimes for ALL active events (note possible capability restrictions)
259
+		$events   = $this->datetimes_for_event->getAllActiveDatetimesForAllEvents();
260
+		$event_options[] = [
261
+			'id'   => 0,
262
+			'text' => esc_html__(' - select an event - ', 'event_espresso'),
263
+		];
264
+		/** @var EE_Event $event */
265
+		foreach ($events as $event) {
266
+			// any registrations for this event?
267
+			if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
268
+				continue;
269
+			}
270
+			$expired_class = $event->is_expired() ? 'ee-expired-event' : '';
271
+			$upcoming_class  = $event->is_upcoming() ? ' ee-upcoming-event' : '';
272
+			$event_options[] = [
273
+				'id'    => $event->ID(),
274
+				'text'  => apply_filters(
275
+					'FHEE__EE_Event_Registrations___get_table_filters__event_name',
276
+					$event->name(),
277
+					$event
278
+				),
279
+				'class' => $expired_class . $upcoming_class,
280
+			];
281
+			if ($event->ID() === $this->event_id) {
282
+				$this->hide_expired = $expired_class === '';
283
+				$hide_expired_checked  = $expired_class === '' ? $hide_expired_checked : '';
284
+				$this->hide_upcoming = $upcoming_class === '';
285
+				$hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : '';
286
+			}
287
+		}
288
+
289
+		$select_class = $this->hide_expired ? 'ee-hide-expired-events' : '';
290
+		$select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : '';
291
+
292
+		$filters[] = '
293 293
         <div class="ee-event-filter__wrapper">
294 294
             <label class="ee-event-filter-main-label">' . esc_html__('Check-in Status for', 'event_espresso') . '</label>
295 295
             <div class="ee-event-filter">
296 296
                 <span class="ee-event-selector">
297 297
                     <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label>
298 298
                     ' . EEH_Form_Fields::select_input(
299
-                        'event_id',
300
-                        $event_options,
301
-                        $this->event_id,
302
-                        '',
303
-                        $select_class
304
-                    ) . '
299
+						'event_id',
300
+						$event_options,
301
+						$this->event_id,
302
+						'',
303
+						$select_class
304
+					) . '
305 305
                 </span>';
306
-        // DTT datetimes filter
307
-        $datetimes_for_event = $this->datetimes_for_event->getAllActiveDatetimesForEvent($hide_upcoming_checked === 'checked');
308
-        if (count($datetimes_for_event) > 1) {
309
-            $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso');
310
-            foreach ($datetimes_for_event as $datetime) {
311
-                $datetime_string              = $datetime->name();
312
-                $datetime_string              = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
313
-                $datetime_string              =
314
-                    $datetime->start_date_and_time() . ' - ' . $datetime->end_date_and_time() . $datetime_string;
315
-                $datetimes[ $datetime->ID() ] = $datetime_string;
316
-            }
317
-            $filters[] = '
306
+		// DTT datetimes filter
307
+		$datetimes_for_event = $this->datetimes_for_event->getAllActiveDatetimesForEvent($hide_upcoming_checked === 'checked');
308
+		if (count($datetimes_for_event) > 1) {
309
+			$datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso');
310
+			foreach ($datetimes_for_event as $datetime) {
311
+				$datetime_string              = $datetime->name();
312
+				$datetime_string              = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
313
+				$datetime_string              =
314
+					$datetime->start_date_and_time() . ' - ' . $datetime->end_date_and_time() . $datetime_string;
315
+				$datetimes[ $datetime->ID() ] = $datetime_string;
316
+			}
317
+			$filters[] = '
318 318
                 <span class="ee-datetime-selector">
319 319
                     <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label>
320 320
                     ' . EEH_Form_Fields::select_input(
321
-                        'DTT_ID',
322
-                        $datetimes,
323
-                        $this->datetime_id
324
-                    ) . '
321
+						'DTT_ID',
322
+						$datetimes,
323
+						$this->datetime_id
324
+					) . '
325 325
                 </span>';
326
-        }
327
-        $filters[] = '
326
+		}
327
+		$filters[] = '
328 328
                 <span class="ee-hide-upcoming-check">
329 329
                     <label for="js-ee-hide-upcoming-events">
330 330
                         <input type="checkbox" id="js-ee-hide-upcoming-events" name="hide_upcoming" '
331
-                         . $hide_upcoming_checked
332
-                         . '>
331
+						 . $hide_upcoming_checked
332
+						 . '>
333 333
                         '
334
-                         . esc_html__('Hide Upcoming Events', 'event_espresso')
335
-                         . '
334
+						 . esc_html__('Hide Upcoming Events', 'event_espresso')
335
+						 . '
336 336
                     </label>
337 337
                     <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" aria-label="'
338
-                         . esc_html__(
339
-                             'Will not display events with start dates in the future (ie: have not yet begun)',
340
-                             'event_espresso'
341
-                         )
342
-                         . '"></span>
338
+						 . esc_html__(
339
+							 'Will not display events with start dates in the future (ie: have not yet begun)',
340
+							 'event_espresso'
341
+						 )
342
+						 . '"></span>
343 343
                 </span>
344 344
                 <span class="ee-hide-expired-check">
345 345
                     <label for="js-ee-hide-expired-events">
346 346
                         <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" '
347
-                         . $hide_expired_checked
348
-                         . '>
347
+						 . $hide_expired_checked
348
+						 . '>
349 349
                         '
350
-                         . esc_html__('Hide Expired Events', 'event_espresso')
351
-                         . '
350
+						 . esc_html__('Hide Expired Events', 'event_espresso')
351
+						 . '
352 352
                     </label>
353 353
                     <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" aria-label="'
354
-                         . esc_html__(
355
-                             'Will not display events with end dates in the past (ie: have already finished)',
356
-                             'event_espresso'
357
-                         )
358
-                         . '"></span>
354
+						 . esc_html__(
355
+							 'Will not display events with end dates in the past (ie: have already finished)',
356
+							 'event_espresso'
357
+						 )
358
+						 . '"></span>
359 359
                 </span>
360 360
             </div>
361 361
         </div>';
362
-        return $filters;
363
-    }
364
-
365
-
366
-    /**
367
-     * @throws EE_Error
368
-     * @throws ReflectionException
369
-     */
370
-    protected function _add_view_counts()
371
-    {
372
-        $this->_views['all']['count'] = $this->_get_total_event_attendees();
373
-    }
374
-
375
-
376
-    /**
377
-     * @return int
378
-     * @throws EE_Error
379
-     * @throws ReflectionException
380
-     */
381
-    protected function _get_total_event_attendees(): int
382
-    {
383
-        $query_params      = [];
384
-        if ($this->event_id) {
385
-            $query_params[0]['EVT_ID'] = $this->event_id;
386
-        }
387
-        // if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
388
-        if ($this->datetime_id) {
389
-            $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id;
390
-        }
391
-        $status_ids_array          = apply_filters(
392
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
393
-            [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
394
-        );
395
-        $query_params[0]['STS_ID'] = ['IN', $status_ids_array];
396
-        return EEM_Registration::instance()->count($query_params);
397
-    }
398
-
399
-
400
-    /**
401
-     * @param EE_Registration $item
402
-     * @return string
403
-     * @throws EE_Error
404
-     * @throws ReflectionException
405
-     */
406
-    public function column_cb($item): string
407
-    {
408
-        return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
409
-    }
410
-
411
-
412
-    /**
413
-     * column_REG_att_checked_in
414
-     *
415
-     * @param EE_Registration $registration
416
-     * @return string
417
-     * @throws EE_Error
418
-     * @throws InvalidArgumentException
419
-     * @throws InvalidDataTypeException
420
-     * @throws InvalidInterfaceException
421
-     * @throws ReflectionException
422
-     */
423
-    public function column__REG_att_checked_in(EE_Registration $registration): string
424
-    {
425
-        $reg_date_id = 0;
426
-        $reg_datetimes = $registration->ticket()->datetimes();
427
-        if (count($reg_datetimes) === 1) {
428
-            $reg_datetime = reset($reg_datetimes);
429
-            $reg_date_id = $reg_datetime instanceof EE_Datetime ? $reg_datetime->ID() : 0;
430
-        }
431
-        // we need a local variable for the datetime for each row
432
-        // (so that we don't pollute state for the entire table)
433
-        // so let's try to get it from the registration's event
434
-        $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration);
435
-        $datetime = $this->datetimes_for_current_row->getOneActiveDatetimeForEvent(
436
-            $reg_date_id ?: $this->datetime_id,
437
-            $this->hide_expired
438
-        );
439
-
440
-        $DTD_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
441
-
442
-        $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
443
-            $registration,
444
-            $DTD_ID
445
-        );
446
-
447
-        $aria_label = $checkin_status_dashicon->ariaLabel();
448
-        $dashicon_class = $checkin_status_dashicon->cssClasses();
449
-        $attributes = ' onClick="return false"';
450
-        $button_class = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box';
451
-
452
-        if (
453
-            $DTD_ID
454
-            && EE_Registry::instance()->CAP->current_user_can(
455
-                'ee_edit_checkin',
456
-                'espresso_registrations_toggle_checkin_status',
457
-                $registration->ID()
458
-            )
459
-        ) {
460
-            // overwrite the disabled attribute with data attributes for performing checkin
461
-            $attributes = 'data-_regid="' . $registration->ID() . '"';
462
-            $attributes .= ' data-dttid="' . $DTD_ID . '"';
463
-            $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"';
464
-            $button_class .= ' clickable trigger-checkin';
465
-        }
466
-
467
-        $content = '
362
+		return $filters;
363
+	}
364
+
365
+
366
+	/**
367
+	 * @throws EE_Error
368
+	 * @throws ReflectionException
369
+	 */
370
+	protected function _add_view_counts()
371
+	{
372
+		$this->_views['all']['count'] = $this->_get_total_event_attendees();
373
+	}
374
+
375
+
376
+	/**
377
+	 * @return int
378
+	 * @throws EE_Error
379
+	 * @throws ReflectionException
380
+	 */
381
+	protected function _get_total_event_attendees(): int
382
+	{
383
+		$query_params      = [];
384
+		if ($this->event_id) {
385
+			$query_params[0]['EVT_ID'] = $this->event_id;
386
+		}
387
+		// if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
388
+		if ($this->datetime_id) {
389
+			$query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id;
390
+		}
391
+		$status_ids_array          = apply_filters(
392
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
393
+			[EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
394
+		);
395
+		$query_params[0]['STS_ID'] = ['IN', $status_ids_array];
396
+		return EEM_Registration::instance()->count($query_params);
397
+	}
398
+
399
+
400
+	/**
401
+	 * @param EE_Registration $item
402
+	 * @return string
403
+	 * @throws EE_Error
404
+	 * @throws ReflectionException
405
+	 */
406
+	public function column_cb($item): string
407
+	{
408
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
409
+	}
410
+
411
+
412
+	/**
413
+	 * column_REG_att_checked_in
414
+	 *
415
+	 * @param EE_Registration $registration
416
+	 * @return string
417
+	 * @throws EE_Error
418
+	 * @throws InvalidArgumentException
419
+	 * @throws InvalidDataTypeException
420
+	 * @throws InvalidInterfaceException
421
+	 * @throws ReflectionException
422
+	 */
423
+	public function column__REG_att_checked_in(EE_Registration $registration): string
424
+	{
425
+		$reg_date_id = 0;
426
+		$reg_datetimes = $registration->ticket()->datetimes();
427
+		if (count($reg_datetimes) === 1) {
428
+			$reg_datetime = reset($reg_datetimes);
429
+			$reg_date_id = $reg_datetime instanceof EE_Datetime ? $reg_datetime->ID() : 0;
430
+		}
431
+		// we need a local variable for the datetime for each row
432
+		// (so that we don't pollute state for the entire table)
433
+		// so let's try to get it from the registration's event
434
+		$this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration);
435
+		$datetime = $this->datetimes_for_current_row->getOneActiveDatetimeForEvent(
436
+			$reg_date_id ?: $this->datetime_id,
437
+			$this->hide_expired
438
+		);
439
+
440
+		$DTD_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
441
+
442
+		$checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
443
+			$registration,
444
+			$DTD_ID
445
+		);
446
+
447
+		$aria_label = $checkin_status_dashicon->ariaLabel();
448
+		$dashicon_class = $checkin_status_dashicon->cssClasses();
449
+		$attributes = ' onClick="return false"';
450
+		$button_class = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box';
451
+
452
+		if (
453
+			$DTD_ID
454
+			&& EE_Registry::instance()->CAP->current_user_can(
455
+				'ee_edit_checkin',
456
+				'espresso_registrations_toggle_checkin_status',
457
+				$registration->ID()
458
+			)
459
+		) {
460
+			// overwrite the disabled attribute with data attributes for performing checkin
461
+			$attributes = 'data-_regid="' . $registration->ID() . '"';
462
+			$attributes .= ' data-dttid="' . $DTD_ID . '"';
463
+			$attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"';
464
+			$button_class .= ' clickable trigger-checkin';
465
+		}
466
+
467
+		$content = '
468 468
         <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '>
469 469
             <span class="' . $dashicon_class . '" ></span>
470 470
         </button>
471 471
         <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>';
472
-        return $this->columnContent('_REG_att_checked_in', $content, 'center');
473
-    }
474
-
475
-
476
-    /**
477
-     * @param EE_Registration $registration
478
-     * @return string
479
-     * @throws EE_Error
480
-     * @throws ReflectionException
481
-     */
482
-    public function column_ATT_name(EE_Registration $registration): string
483
-    {
484
-        $attendee = $registration->attendee();
485
-        if (! $attendee instanceof EE_Attendee) {
486
-            return esc_html__('No contact record for this registration.', 'event_espresso');
487
-        }
488
-        // edit attendee link
489
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
490
-            ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
491
-            REG_ADMIN_URL
492
-        );
493
-        $name_link    = '
472
+		return $this->columnContent('_REG_att_checked_in', $content, 'center');
473
+	}
474
+
475
+
476
+	/**
477
+	 * @param EE_Registration $registration
478
+	 * @return string
479
+	 * @throws EE_Error
480
+	 * @throws ReflectionException
481
+	 */
482
+	public function column_ATT_name(EE_Registration $registration): string
483
+	{
484
+		$attendee = $registration->attendee();
485
+		if (! $attendee instanceof EE_Attendee) {
486
+			return esc_html__('No contact record for this registration.', 'event_espresso');
487
+		}
488
+		// edit attendee link
489
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
490
+			['action' => 'view_registration', '_REG_ID' => $registration->ID()],
491
+			REG_ADMIN_URL
492
+		);
493
+		$name_link    = '
494 494
             <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip"
495 495
             aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '">
496 496
             </span>';
497
-        $name_link    .= EE_Registry::instance()->CAP->current_user_can(
498
-            'ee_edit_contacts',
499
-            'espresso_registrations_edit_attendee'
500
-        )
501
-            ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__(
502
-                'View Registration Details',
503
-                'event_espresso'
504
-            ) . '">'
505
-              . $registration->attendee()->full_name()
506
-              . '</a>'
507
-            : $registration->attendee()->full_name();
508
-        $name_link    .= $registration->count() === 1
509
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
510
-            : '';
511
-        // add group details
512
-        $name_link .= '&nbsp;' . sprintf(
513
-            esc_html__('(%s of %s)', 'event_espresso'),
514
-            $registration->count(),
515
-            $registration->group_size()
516
-        );
517
-        // add regcode
518
-        $link      = EE_Admin_Page::add_query_args_and_nonce(
519
-            ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
520
-            REG_ADMIN_URL
521
-        );
522
-        $name_link .= '<br>';
523
-        $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
524
-            'ee_read_registration',
525
-            'view_registration',
526
-            $registration->ID()
527
-        )
528
-            ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__(
529
-                'View Registration Details',
530
-                'event_espresso'
531
-            ) . '">'
532
-              . $registration->reg_code()
533
-              . '</a>'
534
-            : $registration->reg_code();
535
-
536
-        $actions                 = [];
537
-        if (
538
-            $this->datetime_id
539
-            && EE_Registry::instance()->CAP->current_user_can(
540
-                'ee_read_checkins',
541
-                'espresso_registrations_registration_checkins'
542
-            )
543
-        ) {
544
-            $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
545
-                ['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id],
546
-                REG_ADMIN_URL
547
-            );
548
-            // get the timestamps for this registration's checkins, related to the selected datetime
549
-            /** @var EE_Checkin[] $checkins */
550
-            $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]);
551
-            if (! empty($checkins)) {
552
-                // get the last timestamp
553
-                $last_checkin = end($checkins);
554
-                // get timestamp string
555
-                $timestamp_string   = $last_checkin->get_datetime('CHK_timestamp');
556
-                $actions['checkin'] = '
497
+		$name_link    .= EE_Registry::instance()->CAP->current_user_can(
498
+			'ee_edit_contacts',
499
+			'espresso_registrations_edit_attendee'
500
+		)
501
+			? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__(
502
+				'View Registration Details',
503
+				'event_espresso'
504
+			) . '">'
505
+			  . $registration->attendee()->full_name()
506
+			  . '</a>'
507
+			: $registration->attendee()->full_name();
508
+		$name_link    .= $registration->count() === 1
509
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
510
+			: '';
511
+		// add group details
512
+		$name_link .= '&nbsp;' . sprintf(
513
+			esc_html__('(%s of %s)', 'event_espresso'),
514
+			$registration->count(),
515
+			$registration->group_size()
516
+		);
517
+		// add regcode
518
+		$link      = EE_Admin_Page::add_query_args_and_nonce(
519
+			['action' => 'view_registration', '_REG_ID' => $registration->ID()],
520
+			REG_ADMIN_URL
521
+		);
522
+		$name_link .= '<br>';
523
+		$name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
524
+			'ee_read_registration',
525
+			'view_registration',
526
+			$registration->ID()
527
+		)
528
+			? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__(
529
+				'View Registration Details',
530
+				'event_espresso'
531
+			) . '">'
532
+			  . $registration->reg_code()
533
+			  . '</a>'
534
+			: $registration->reg_code();
535
+
536
+		$actions                 = [];
537
+		if (
538
+			$this->datetime_id
539
+			&& EE_Registry::instance()->CAP->current_user_can(
540
+				'ee_read_checkins',
541
+				'espresso_registrations_registration_checkins'
542
+			)
543
+		) {
544
+			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
545
+				['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id],
546
+				REG_ADMIN_URL
547
+			);
548
+			// get the timestamps for this registration's checkins, related to the selected datetime
549
+			/** @var EE_Checkin[] $checkins */
550
+			$checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]);
551
+			if (! empty($checkins)) {
552
+				// get the last timestamp
553
+				$last_checkin = end($checkins);
554
+				// get timestamp string
555
+				$timestamp_string   = $last_checkin->get_datetime('CHK_timestamp');
556
+				$actions['checkin'] = '
557 557
                     <a  class="ee-aria-tooltip"
558 558
                         href="' . $checkin_list_url . '"
559 559
                         aria-label="' . esc_attr__(
560
-                            'View this registrant\'s check-ins/checkouts for the datetime',
561
-                            'event_espresso'
562
-                        ) . '"
560
+							'View this registrant\'s check-ins/checkouts for the datetime',
561
+							'event_espresso'
562
+						) . '"
563 563
                     >
564 564
                         ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . '
565 565
                     </a>';
566
-            }
567
-        }
568
-        $content = (! empty($this->datetime_id) && ! empty($checkins))
569
-            ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
570
-            : $name_link;
571
-        return $this->columnContent('ATT_name', $content);
572
-    }
573
-
574
-
575
-    /**
576
-     * @param EE_Registration $registration
577
-     * @return string
578
-     * @throws EE_Error
579
-     * @throws EE_Error
580
-     */
581
-    public function column_ATT_email(EE_Registration $registration): string
582
-    {
583
-        $attendee = $registration->attendee();
584
-        $content = $attendee instanceof EE_Attendee ? $attendee->email() : '';
585
-        return $this->columnContent('ATT_email', $content);
586
-    }
587
-
588
-
589
-    /**
590
-     * @param EE_Registration $registration
591
-     * @return string
592
-     * @throws EE_Error
593
-     * @throws ReflectionException
594
-     */
595
-    public function column_Event(EE_Registration $registration): string
596
-    {
597
-        try {
598
-            $event            = $this->event instanceof EE_Event ? $this->event : $registration->event();
599
-            $checkin_link_url = EE_Admin_Page::add_query_args_and_nonce(
600
-                ['action' => 'event_registrations', 'event_id' => $event->ID()],
601
-                REG_ADMIN_URL
602
-            );
603
-            $content      = EE_Registry::instance()->CAP->current_user_can(
604
-                'ee_read_checkins',
605
-                'espresso_registrations_registration_checkins'
606
-            ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="'
607
-                . esc_attr__(
608
-                    'View Checkins for this Event',
609
-                    'event_espresso'
610
-                ) . '">' . $event->name() . '</a>' : $event->name();
611
-        } catch (EntityNotFoundException $e) {
612
-            $content = esc_html__('Unknown', 'event_espresso');
613
-        }
614
-        return $this->columnContent('Event', $content);
615
-    }
616
-
617
-
618
-    /**
619
-     * @param EE_Registration $registration
620
-     * @return string
621
-     * @throws EE_Error
622
-     * @throws ReflectionException
623
-     */
624
-    public function column_PRC_name(EE_Registration $registration): string
625
-    {
626
-        $content = $registration->ticket() instanceof EE_Ticket
627
-            ? $registration->ticket()->name()
628
-            : esc_html__(
629
-                "Unknown",
630
-                "event_espresso"
631
-            );
632
-        return $this->columnContent('PRC_name', $content);
633
-    }
634
-
635
-
636
-    /**
637
-     * column_REG_final_price
638
-     *
639
-     * @param EE_Registration $registration
640
-     * @return string
641
-     * @throws EE_Error
642
-     */
643
-    public function column__REG_final_price(EE_Registration $registration): string
644
-    {
645
-        return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end');
646
-    }
647
-
648
-
649
-    /**
650
-     * column_TXN_paid
651
-     *
652
-     * @param EE_Registration $registration
653
-     * @return string
654
-     * @throws EE_Error
655
-     * @throws ReflectionException
656
-     */
657
-    public function column_TXN_paid(EE_Registration $registration): string
658
-    {
659
-        $content = '';
660
-        if ($registration->count() === 1) {
661
-            if ($registration->transaction()->paid() >= $registration->transaction()->total()) {
662
-                return '<div class="dashicons dashicons-yes green-icon"></div>';
663
-            } else {
664
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
665
-                    ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()],
666
-                    TXN_ADMIN_URL
667
-                );
668
-                $content = EE_Registry::instance()->CAP->current_user_can(
669
-                    'ee_read_transaction',
670
-                    'espresso_transactions_view_transaction'
671
-                ) ? '
566
+			}
567
+		}
568
+		$content = (! empty($this->datetime_id) && ! empty($checkins))
569
+			? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
570
+			: $name_link;
571
+		return $this->columnContent('ATT_name', $content);
572
+	}
573
+
574
+
575
+	/**
576
+	 * @param EE_Registration $registration
577
+	 * @return string
578
+	 * @throws EE_Error
579
+	 * @throws EE_Error
580
+	 */
581
+	public function column_ATT_email(EE_Registration $registration): string
582
+	{
583
+		$attendee = $registration->attendee();
584
+		$content = $attendee instanceof EE_Attendee ? $attendee->email() : '';
585
+		return $this->columnContent('ATT_email', $content);
586
+	}
587
+
588
+
589
+	/**
590
+	 * @param EE_Registration $registration
591
+	 * @return string
592
+	 * @throws EE_Error
593
+	 * @throws ReflectionException
594
+	 */
595
+	public function column_Event(EE_Registration $registration): string
596
+	{
597
+		try {
598
+			$event            = $this->event instanceof EE_Event ? $this->event : $registration->event();
599
+			$checkin_link_url = EE_Admin_Page::add_query_args_and_nonce(
600
+				['action' => 'event_registrations', 'event_id' => $event->ID()],
601
+				REG_ADMIN_URL
602
+			);
603
+			$content      = EE_Registry::instance()->CAP->current_user_can(
604
+				'ee_read_checkins',
605
+				'espresso_registrations_registration_checkins'
606
+			) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="'
607
+				. esc_attr__(
608
+					'View Checkins for this Event',
609
+					'event_espresso'
610
+				) . '">' . $event->name() . '</a>' : $event->name();
611
+		} catch (EntityNotFoundException $e) {
612
+			$content = esc_html__('Unknown', 'event_espresso');
613
+		}
614
+		return $this->columnContent('Event', $content);
615
+	}
616
+
617
+
618
+	/**
619
+	 * @param EE_Registration $registration
620
+	 * @return string
621
+	 * @throws EE_Error
622
+	 * @throws ReflectionException
623
+	 */
624
+	public function column_PRC_name(EE_Registration $registration): string
625
+	{
626
+		$content = $registration->ticket() instanceof EE_Ticket
627
+			? $registration->ticket()->name()
628
+			: esc_html__(
629
+				"Unknown",
630
+				"event_espresso"
631
+			);
632
+		return $this->columnContent('PRC_name', $content);
633
+	}
634
+
635
+
636
+	/**
637
+	 * column_REG_final_price
638
+	 *
639
+	 * @param EE_Registration $registration
640
+	 * @return string
641
+	 * @throws EE_Error
642
+	 */
643
+	public function column__REG_final_price(EE_Registration $registration): string
644
+	{
645
+		return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end');
646
+	}
647
+
648
+
649
+	/**
650
+	 * column_TXN_paid
651
+	 *
652
+	 * @param EE_Registration $registration
653
+	 * @return string
654
+	 * @throws EE_Error
655
+	 * @throws ReflectionException
656
+	 */
657
+	public function column_TXN_paid(EE_Registration $registration): string
658
+	{
659
+		$content = '';
660
+		if ($registration->count() === 1) {
661
+			if ($registration->transaction()->paid() >= $registration->transaction()->total()) {
662
+				return '<div class="dashicons dashicons-yes green-icon"></div>';
663
+			} else {
664
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
665
+					['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()],
666
+					TXN_ADMIN_URL
667
+				);
668
+				$content = EE_Registry::instance()->CAP->current_user_can(
669
+					'ee_read_transaction',
670
+					'espresso_transactions_view_transaction'
671
+				) ? '
672 672
 				<a class="ee-aria-tooltip ee-status-color--'
673
-                    . $registration->transaction()->status_ID()
674
-                    . '" href="'
675
-                    . $view_txn_lnk_url
676
-                    . '"  aria-label="'
677
-                    . esc_attr__('View Transaction', 'event_espresso')
678
-                    . '">
673
+					. $registration->transaction()->status_ID()
674
+					. '" href="'
675
+					. $view_txn_lnk_url
676
+					. '"  aria-label="'
677
+					. esc_attr__('View Transaction', 'event_espresso')
678
+					. '">
679 679
 						'
680
-                    . $registration->transaction()->pretty_paid()
681
-                    . '
680
+					. $registration->transaction()->pretty_paid()
681
+					. '
682 682
 					</a>
683 683
 				' : $registration->transaction()->pretty_paid();
684
-            }
685
-        }
686
-        return $this->columnContent('TXN_paid', $content, 'end');
687
-    }
688
-
689
-
690
-    /**
691
-     *        column_TXN_total
692
-     *
693
-     * @param EE_Registration $registration
694
-     * @return string
695
-     * @throws EE_Error
696
-     * @throws ReflectionException
697
-     */
698
-    public function column_TXN_total(EE_Registration $registration): string
699
-    {
700
-        $content = '';
701
-        $txn = $registration->transaction();
702
-        $view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL);
703
-        if ($registration->get('REG_count') === 1) {
704
-            $line_total_obj = $txn->total_line_item();
705
-            $txn_total      = $line_total_obj instanceof EE_Line_Item
706
-                ? $line_total_obj->get_pretty('LIN_total')
707
-                : esc_html__(
708
-                    'View Transaction',
709
-                    'event_espresso'
710
-                );
711
-            $content = EE_Registry::instance()->CAP->current_user_can(
712
-                'ee_read_transaction',
713
-                'espresso_transactions_view_transaction'
714
-            ) ? '<a class="ee-aria-tooltip" href="'
715
-                . $view_txn_url
716
-                . '" aria-label="'
717
-                . esc_attr__('View Transaction', 'event_espresso')
718
-                . '">'
719
-                . $txn_total
720
-                . '</a>'
721
-                : $txn_total;
722
-        }
723
-        return $this->columnContent('TXN_total', $content, 'end');
724
-    }
684
+			}
685
+		}
686
+		return $this->columnContent('TXN_paid', $content, 'end');
687
+	}
688
+
689
+
690
+	/**
691
+	 *        column_TXN_total
692
+	 *
693
+	 * @param EE_Registration $registration
694
+	 * @return string
695
+	 * @throws EE_Error
696
+	 * @throws ReflectionException
697
+	 */
698
+	public function column_TXN_total(EE_Registration $registration): string
699
+	{
700
+		$content = '';
701
+		$txn = $registration->transaction();
702
+		$view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL);
703
+		if ($registration->get('REG_count') === 1) {
704
+			$line_total_obj = $txn->total_line_item();
705
+			$txn_total      = $line_total_obj instanceof EE_Line_Item
706
+				? $line_total_obj->get_pretty('LIN_total')
707
+				: esc_html__(
708
+					'View Transaction',
709
+					'event_espresso'
710
+				);
711
+			$content = EE_Registry::instance()->CAP->current_user_can(
712
+				'ee_read_transaction',
713
+				'espresso_transactions_view_transaction'
714
+			) ? '<a class="ee-aria-tooltip" href="'
715
+				. $view_txn_url
716
+				. '" aria-label="'
717
+				. esc_attr__('View Transaction', 'event_espresso')
718
+				. '">'
719
+				. $txn_total
720
+				. '</a>'
721
+				: $txn_total;
722
+		}
723
+		return $this->columnContent('TXN_total', $content, 'end');
724
+	}
725 725
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             'screen'   => $this->_admin_page->get_current_screen()->id,
133 133
         ];
134 134
 
135
-        $this->_columns      = [
135
+        $this->_columns = [
136 136
             'cb' => '<input type="checkbox" />', // Render a checkbox instead of text
137 137
             '_REG_att_checked_in' => esc_html__('Check In', 'event_espresso'),
138 138
             'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         $hide_expired_checked = $this->hide_expired ? 'checked' : '';
257 257
         $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : '';
258 258
         // get datetimes for ALL active events (note possible capability restrictions)
259
-        $events   = $this->datetimes_for_event->getAllActiveDatetimesForAllEvents();
259
+        $events = $this->datetimes_for_event->getAllActiveDatetimesForAllEvents();
260 260
         $event_options[] = [
261 261
             'id'   => 0,
262 262
             'text' => esc_html__(' - select an event - ', 'event_espresso'),
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         /** @var EE_Event $event */
265 265
         foreach ($events as $event) {
266 266
             // any registrations for this event?
267
-            if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
267
+            if ( ! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
268 268
                 continue;
269 269
             }
270 270
             $expired_class = $event->is_expired() ? 'ee-expired-event' : '';
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
                     $event->name(),
277 277
                     $event
278 278
                 ),
279
-                'class' => $expired_class . $upcoming_class,
279
+                'class' => $expired_class.$upcoming_class,
280 280
             ];
281 281
             if ($event->ID() === $this->event_id) {
282 282
                 $this->hide_expired = $expired_class === '';
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
 
292 292
         $filters[] = '
293 293
         <div class="ee-event-filter__wrapper">
294
-            <label class="ee-event-filter-main-label">' . esc_html__('Check-in Status for', 'event_espresso') . '</label>
294
+            <label class="ee-event-filter-main-label">' . esc_html__('Check-in Status for', 'event_espresso').'</label>
295 295
             <div class="ee-event-filter">
296 296
                 <span class="ee-event-selector">
297
-                    <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label>
297
+                    <label for="event_id">' . esc_html__('Event', 'event_espresso').'</label>
298 298
                     ' . EEH_Form_Fields::select_input(
299 299
                         'event_id',
300 300
                         $event_options,
301 301
                         $this->event_id,
302 302
                         '',
303 303
                         $select_class
304
-                    ) . '
304
+                    ).'
305 305
                 </span>';
306 306
         // DTT datetimes filter
307 307
         $datetimes_for_event = $this->datetimes_for_event->getAllActiveDatetimesForEvent($hide_upcoming_checked === 'checked');
@@ -309,19 +309,19 @@  discard block
 block discarded – undo
309 309
             $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso');
310 310
             foreach ($datetimes_for_event as $datetime) {
311 311
                 $datetime_string              = $datetime->name();
312
-                $datetime_string              = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
312
+                $datetime_string              = ! empty($datetime_string) ? ' ('.$datetime_string.')' : '';
313 313
                 $datetime_string              =
314
-                    $datetime->start_date_and_time() . ' - ' . $datetime->end_date_and_time() . $datetime_string;
315
-                $datetimes[ $datetime->ID() ] = $datetime_string;
314
+                    $datetime->start_date_and_time().' - '.$datetime->end_date_and_time().$datetime_string;
315
+                $datetimes[$datetime->ID()] = $datetime_string;
316 316
             }
317 317
             $filters[] = '
318 318
                 <span class="ee-datetime-selector">
319
-                    <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label>
319
+                    <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso').'</label>
320 320
                     ' . EEH_Form_Fields::select_input(
321 321
                         'DTT_ID',
322 322
                         $datetimes,
323 323
                         $this->datetime_id
324
-                    ) . '
324
+                    ).'
325 325
                 </span>';
326 326
         }
327 327
         $filters[] = '
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      */
381 381
     protected function _get_total_event_attendees(): int
382 382
     {
383
-        $query_params      = [];
383
+        $query_params = [];
384 384
         if ($this->event_id) {
385 385
             $query_params[0]['EVT_ID'] = $this->event_id;
386 386
         }
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
         if ($this->datetime_id) {
389 389
             $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id;
390 390
         }
391
-        $status_ids_array          = apply_filters(
391
+        $status_ids_array = apply_filters(
392 392
             'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
393 393
             [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
394 394
         );
@@ -458,17 +458,17 @@  discard block
 block discarded – undo
458 458
             )
459 459
         ) {
460 460
             // overwrite the disabled attribute with data attributes for performing checkin
461
-            $attributes = 'data-_regid="' . $registration->ID() . '"';
462
-            $attributes .= ' data-dttid="' . $DTD_ID . '"';
463
-            $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"';
461
+            $attributes = 'data-_regid="'.$registration->ID().'"';
462
+            $attributes .= ' data-dttid="'.$DTD_ID.'"';
463
+            $attributes .= ' data-nonce="'.wp_create_nonce('checkin_nonce').'"';
464 464
             $button_class .= ' clickable trigger-checkin';
465 465
         }
466 466
 
467 467
         $content = '
468
-        <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '>
469
-            <span class="' . $dashicon_class . '" ></span>
468
+        <button aria-label="' . $aria_label.'" class="'.$button_class.'" '.$attributes.'>
469
+            <span class="' . $dashicon_class.'" ></span>
470 470
         </button>
471
-        <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>';
471
+        <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration).'</span>';
472 472
         return $this->columnContent('_REG_att_checked_in', $content, 'center');
473 473
     }
474 474
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     public function column_ATT_name(EE_Registration $registration): string
483 483
     {
484 484
         $attendee = $registration->attendee();
485
-        if (! $attendee instanceof EE_Attendee) {
485
+        if ( ! $attendee instanceof EE_Attendee) {
486 486
             return esc_html__('No contact record for this registration.', 'event_espresso');
487 487
         }
488 488
         // edit attendee link
@@ -490,32 +490,32 @@  discard block
 block discarded – undo
490 490
             ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
491 491
             REG_ADMIN_URL
492 492
         );
493
-        $name_link    = '
494
-            <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip"
495
-            aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '">
493
+        $name_link = '
494
+            <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()).' ee-aria-tooltip"
495
+            aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence').'">
496 496
             </span>';
497
-        $name_link    .= EE_Registry::instance()->CAP->current_user_can(
497
+        $name_link .= EE_Registry::instance()->CAP->current_user_can(
498 498
             'ee_edit_contacts',
499 499
             'espresso_registrations_edit_attendee'
500 500
         )
501
-            ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__(
501
+            ? '<a class="ee-aria-tooltip" href="'.$edit_lnk_url.'" aria-label="'.esc_attr__(
502 502
                 'View Registration Details',
503 503
                 'event_espresso'
504
-            ) . '">'
504
+            ).'">'
505 505
               . $registration->attendee()->full_name()
506 506
               . '</a>'
507 507
             : $registration->attendee()->full_name();
508
-        $name_link    .= $registration->count() === 1
508
+        $name_link .= $registration->count() === 1
509 509
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
510 510
             : '';
511 511
         // add group details
512
-        $name_link .= '&nbsp;' . sprintf(
512
+        $name_link .= '&nbsp;'.sprintf(
513 513
             esc_html__('(%s of %s)', 'event_espresso'),
514 514
             $registration->count(),
515 515
             $registration->group_size()
516 516
         );
517 517
         // add regcode
518
-        $link      = EE_Admin_Page::add_query_args_and_nonce(
518
+        $link = EE_Admin_Page::add_query_args_and_nonce(
519 519
             ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
520 520
             REG_ADMIN_URL
521 521
         );
@@ -525,15 +525,15 @@  discard block
 block discarded – undo
525 525
             'view_registration',
526 526
             $registration->ID()
527 527
         )
528
-            ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__(
528
+            ? '<a class="ee-aria-tooltip" href="'.$link.'" aria-label="'.esc_attr__(
529 529
                 'View Registration Details',
530 530
                 'event_espresso'
531
-            ) . '">'
531
+            ).'">'
532 532
               . $registration->reg_code()
533 533
               . '</a>'
534 534
             : $registration->reg_code();
535 535
 
536
-        $actions                 = [];
536
+        $actions = [];
537 537
         if (
538 538
             $this->datetime_id
539 539
             && EE_Registry::instance()->CAP->current_user_can(
@@ -548,24 +548,24 @@  discard block
 block discarded – undo
548 548
             // get the timestamps for this registration's checkins, related to the selected datetime
549 549
             /** @var EE_Checkin[] $checkins */
550 550
             $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]);
551
-            if (! empty($checkins)) {
551
+            if ( ! empty($checkins)) {
552 552
                 // get the last timestamp
553 553
                 $last_checkin = end($checkins);
554 554
                 // get timestamp string
555 555
                 $timestamp_string   = $last_checkin->get_datetime('CHK_timestamp');
556 556
                 $actions['checkin'] = '
557 557
                     <a  class="ee-aria-tooltip"
558
-                        href="' . $checkin_list_url . '"
558
+                        href="' . $checkin_list_url.'"
559 559
                         aria-label="' . esc_attr__(
560 560
                             'View this registrant\'s check-ins/checkouts for the datetime',
561 561
                             'event_espresso'
562
-                        ) . '"
562
+                        ).'"
563 563
                     >
564
-                        ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . '
564
+                        ' . $last_checkin->getCheckInText().': '.$timestamp_string.'
565 565
                     </a>';
566 566
             }
567 567
         }
568
-        $content = (! empty($this->datetime_id) && ! empty($checkins))
568
+        $content = ( ! empty($this->datetime_id) && ! empty($checkins))
569 569
             ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
570 570
             : $name_link;
571 571
         return $this->columnContent('ATT_name', $content);
@@ -600,14 +600,14 @@  discard block
 block discarded – undo
600 600
                 ['action' => 'event_registrations', 'event_id' => $event->ID()],
601 601
                 REG_ADMIN_URL
602 602
             );
603
-            $content      = EE_Registry::instance()->CAP->current_user_can(
603
+            $content = EE_Registry::instance()->CAP->current_user_can(
604 604
                 'ee_read_checkins',
605 605
                 'espresso_registrations_registration_checkins'
606
-            ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="'
606
+            ) ? '<a class="ee-aria-tooltip" href="'.$checkin_link_url.'" aria-label="'
607 607
                 . esc_attr__(
608 608
                     'View Checkins for this Event',
609 609
                     'event_espresso'
610
-                ) . '">' . $event->name() . '</a>' : $event->name();
610
+                ).'">'.$event->name().'</a>' : $event->name();
611 611
         } catch (EntityNotFoundException $e) {
612 612
             $content = esc_html__('Unknown', 'event_espresso');
613 613
         }
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 2 patches
Indentation   +2137 added lines, -2137 removed lines patch added patch discarded remove patch
@@ -14,2199 +14,2199 @@
 block discarded – undo
14 14
  */
15 15
 class espresso_events_Pricing_Hooks extends EE_Admin_Hooks
16 16
 {
17
-    /**
18
-     * This property is just used to hold the status of whether an event is currently being
19
-     * created (true) or edited (false)
20
-     *
21
-     * @access protected
22
-     * @var bool
23
-     */
24
-    protected $_is_creating_event;
17
+	/**
18
+	 * This property is just used to hold the status of whether an event is currently being
19
+	 * created (true) or edited (false)
20
+	 *
21
+	 * @access protected
22
+	 * @var bool
23
+	 */
24
+	protected $_is_creating_event;
25 25
 
26
-    /**
27
-     * Used to contain the format strings for date and time that will be used for php date and
28
-     * time.
29
-     * Is set in the _set_hooks_properties() method.
30
-     *
31
-     * @var array
32
-     */
33
-    protected $_date_format_strings;
26
+	/**
27
+	 * Used to contain the format strings for date and time that will be used for php date and
28
+	 * time.
29
+	 * Is set in the _set_hooks_properties() method.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	protected $_date_format_strings;
34 34
 
35
-    /**
36
-     * @var string $_date_time_format
37
-     */
38
-    protected $_date_time_format;
35
+	/**
36
+	 * @var string $_date_time_format
37
+	 */
38
+	protected $_date_time_format;
39 39
 
40 40
 
41
-    /**
42
-     * @throws InvalidArgumentException
43
-     * @throws InvalidInterfaceException
44
-     * @throws InvalidDataTypeException
45
-     */
46
-    protected function _set_hooks_properties()
47
-    {
48
-        $this->_name = 'pricing';
49
-        // capability check
50
-        if (
51
-            $this->_adminpage_obj->adminConfig()->useAdvancedEditor()
52
-            || ! EE_Registry::instance()->CAP->current_user_can(
53
-                'ee_read_default_prices',
54
-                'advanced_ticket_datetime_metabox'
55
-            )
56
-        ) {
57
-            $this->_metaboxes      = [];
58
-            $this->_scripts_styles = [];
59
-            return;
60
-        }
61
-        $this->_setup_metaboxes();
62
-        $this->_set_date_time_formats();
63
-        $this->_validate_format_strings();
64
-        $this->_set_scripts_styles();
65
-        // commented out temporarily until logic is implemented in callback
66
-        // add_action(
67
-        //     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
68
-        //     array($this, 'autosave_handling')
69
-        // );
70
-        add_filter(
71
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
72
-            array($this, 'caf_updates')
73
-        );
74
-    }
41
+	/**
42
+	 * @throws InvalidArgumentException
43
+	 * @throws InvalidInterfaceException
44
+	 * @throws InvalidDataTypeException
45
+	 */
46
+	protected function _set_hooks_properties()
47
+	{
48
+		$this->_name = 'pricing';
49
+		// capability check
50
+		if (
51
+			$this->_adminpage_obj->adminConfig()->useAdvancedEditor()
52
+			|| ! EE_Registry::instance()->CAP->current_user_can(
53
+				'ee_read_default_prices',
54
+				'advanced_ticket_datetime_metabox'
55
+			)
56
+		) {
57
+			$this->_metaboxes      = [];
58
+			$this->_scripts_styles = [];
59
+			return;
60
+		}
61
+		$this->_setup_metaboxes();
62
+		$this->_set_date_time_formats();
63
+		$this->_validate_format_strings();
64
+		$this->_set_scripts_styles();
65
+		// commented out temporarily until logic is implemented in callback
66
+		// add_action(
67
+		//     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
68
+		//     array($this, 'autosave_handling')
69
+		// );
70
+		add_filter(
71
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
72
+			array($this, 'caf_updates')
73
+		);
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * @return void
79
-     */
80
-    protected function _setup_metaboxes()
81
-    {
82
-        // if we were going to add our own metaboxes we'd use the below.
83
-        $this->_metaboxes = array(
84
-            0 => array(
85
-                'page_route' => array('edit', 'create_new'),
86
-                'func'       => 'pricing_metabox',
87
-                'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
88
-                'priority'   => 'high',
89
-                'context'    => 'normal',
90
-            ),
91
-        );
92
-        $this->_remove_metaboxes = array(
93
-            0 => array(
94
-                'page_route' => array('edit', 'create_new'),
95
-                'id'         => 'espresso_event_editor_tickets',
96
-                'context'    => 'normal',
97
-            ),
98
-        );
99
-    }
77
+	/**
78
+	 * @return void
79
+	 */
80
+	protected function _setup_metaboxes()
81
+	{
82
+		// if we were going to add our own metaboxes we'd use the below.
83
+		$this->_metaboxes = array(
84
+			0 => array(
85
+				'page_route' => array('edit', 'create_new'),
86
+				'func'       => 'pricing_metabox',
87
+				'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
88
+				'priority'   => 'high',
89
+				'context'    => 'normal',
90
+			),
91
+		);
92
+		$this->_remove_metaboxes = array(
93
+			0 => array(
94
+				'page_route' => array('edit', 'create_new'),
95
+				'id'         => 'espresso_event_editor_tickets',
96
+				'context'    => 'normal',
97
+			),
98
+		);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * @return void
104
-     */
105
-    protected function _set_date_time_formats()
106
-    {
107
-        /**
108
-         * Format strings for date and time.  Defaults are existing behaviour from 4.1.
109
-         * Note, that if you return null as the value for 'date', and 'time' in the array, then
110
-         * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
111
-         *
112
-         * @since 4.6.7
113
-         * @var array  Expected an array returned with 'date' and 'time' keys.
114
-         */
115
-        $this->_date_format_strings = apply_filters(
116
-            'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
117
-            array(
118
-                'date' => 'Y-m-d',
119
-                'time' => 'h:i a',
120
-            )
121
-        );
122
-        // validate
123
-        $this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
124
-            ? $this->_date_format_strings['date']
125
-            : null;
126
-        $this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
127
-            ? $this->_date_format_strings['time']
128
-            : null;
129
-        $this->_date_time_format = $this->_date_format_strings['date']
130
-                                   . ' '
131
-                                   . $this->_date_format_strings['time'];
132
-    }
102
+	/**
103
+	 * @return void
104
+	 */
105
+	protected function _set_date_time_formats()
106
+	{
107
+		/**
108
+		 * Format strings for date and time.  Defaults are existing behaviour from 4.1.
109
+		 * Note, that if you return null as the value for 'date', and 'time' in the array, then
110
+		 * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
111
+		 *
112
+		 * @since 4.6.7
113
+		 * @var array  Expected an array returned with 'date' and 'time' keys.
114
+		 */
115
+		$this->_date_format_strings = apply_filters(
116
+			'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
117
+			array(
118
+				'date' => 'Y-m-d',
119
+				'time' => 'h:i a',
120
+			)
121
+		);
122
+		// validate
123
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
124
+			? $this->_date_format_strings['date']
125
+			: null;
126
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
127
+			? $this->_date_format_strings['time']
128
+			: null;
129
+		$this->_date_time_format = $this->_date_format_strings['date']
130
+								   . ' '
131
+								   . $this->_date_format_strings['time'];
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * @return void
137
-     */
138
-    protected function _validate_format_strings()
139
-    {
140
-        // validate format strings
141
-        $format_validation = EEH_DTT_Helper::validate_format_string(
142
-            $this->_date_time_format
143
-        );
144
-        if (is_array($format_validation)) {
145
-            $msg = '<p>';
146
-            $msg .= sprintf(
147
-                esc_html__(
148
-                    'The format "%s" was likely added via a filter and is invalid for the following reasons:',
149
-                    'event_espresso'
150
-                ),
151
-                $this->_date_time_format
152
-            );
153
-            $msg .= '</p><ul>';
154
-            foreach ($format_validation as $error) {
155
-                $msg .= '<li>' . $error . '</li>';
156
-            }
157
-            $msg .= '</ul><p>';
158
-            $msg .= sprintf(
159
-                esc_html__(
160
-                    '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
161
-                    'event_espresso'
162
-                ),
163
-                '<span style="color:#D54E21;">',
164
-                '</span>'
165
-            );
166
-            $msg .= '</p>';
167
-            EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
168
-            $this->_date_format_strings = array(
169
-                'date' => 'Y-m-d',
170
-                'time' => 'h:i a',
171
-            );
172
-        }
173
-    }
135
+	/**
136
+	 * @return void
137
+	 */
138
+	protected function _validate_format_strings()
139
+	{
140
+		// validate format strings
141
+		$format_validation = EEH_DTT_Helper::validate_format_string(
142
+			$this->_date_time_format
143
+		);
144
+		if (is_array($format_validation)) {
145
+			$msg = '<p>';
146
+			$msg .= sprintf(
147
+				esc_html__(
148
+					'The format "%s" was likely added via a filter and is invalid for the following reasons:',
149
+					'event_espresso'
150
+				),
151
+				$this->_date_time_format
152
+			);
153
+			$msg .= '</p><ul>';
154
+			foreach ($format_validation as $error) {
155
+				$msg .= '<li>' . $error . '</li>';
156
+			}
157
+			$msg .= '</ul><p>';
158
+			$msg .= sprintf(
159
+				esc_html__(
160
+					'%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
161
+					'event_espresso'
162
+				),
163
+				'<span style="color:#D54E21;">',
164
+				'</span>'
165
+			);
166
+			$msg .= '</p>';
167
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
168
+			$this->_date_format_strings = array(
169
+				'date' => 'Y-m-d',
170
+				'time' => 'h:i a',
171
+			);
172
+		}
173
+	}
174 174
 
175 175
 
176
-    /**
177
-     * @return void
178
-     */
179
-    protected function _set_scripts_styles()
180
-    {
181
-        $this->_scripts_styles = array(
182
-            'registers'   => array(
183
-                'ee-tickets-datetimes-css' => array(
184
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
185
-                    'type' => 'css',
186
-                ),
187
-                'ee-dtt-ticket-metabox'    => array(
188
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
189
-                    'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
190
-                ),
191
-            ),
192
-            'deregisters' => array(
193
-                'event-editor-css'       => array('type' => 'css'),
194
-                'event-datetime-metabox' => array('type' => 'js'),
195
-            ),
196
-            'enqueues'    => array(
197
-                'ee-tickets-datetimes-css' => array('edit', 'create_new'),
198
-                'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
199
-            ),
200
-            'localize'    => array(
201
-                'ee-dtt-ticket-metabox' => array(
202
-                    'DTT_TRASH_BLOCK'       => array(
203
-                        'main_warning'            => esc_html__(
204
-                            'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
205
-                            'event_espresso'
206
-                        ),
207
-                        'after_warning'           => esc_html__(
208
-                            'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
209
-                            'event_espresso'
210
-                        ),
211
-                        'cancel_button'           => '<button class="button--secondary ee-modal-cancel">'
212
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
213
-                        'close_button'            => '<button class="button--secondary ee-modal-cancel">'
214
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
215
-                        'single_warning_from_tkt' => esc_html__(
216
-                            'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
217
-                            'event_espresso'
218
-                        ),
219
-                        'single_warning_from_dtt' => esc_html__(
220
-                            'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
221
-                            'event_espresso'
222
-                        ),
223
-                        'dismiss_button'          => '<button class="button--secondary ee-modal-cancel">'
224
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
225
-                    ),
226
-                    'DTT_ERROR_MSG'         => array(
227
-                        'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
228
-                        'dismiss_button' => '<div class="save-cancel-button-container">'
229
-                                            . '<button class="button--secondary ee-modal-cancel">'
230
-                                            . esc_html__('Dismiss', 'event_espresso')
231
-                                            . '</button></div>',
232
-                    ),
233
-                    'DTT_OVERSELL_WARNING'  => array(
234
-                        'datetime_ticket' => esc_html__(
235
-                            'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
236
-                            'event_espresso'
237
-                        ),
238
-                        'ticket_datetime' => esc_html__(
239
-                            'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
240
-                            'event_espresso'
241
-                        ),
242
-                    ),
243
-                    'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
244
-                        $this->_date_format_strings['date'],
245
-                        $this->_date_format_strings['time']
246
-                    ),
247
-                    'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
248
-                ),
249
-            ),
250
-        );
251
-    }
176
+	/**
177
+	 * @return void
178
+	 */
179
+	protected function _set_scripts_styles()
180
+	{
181
+		$this->_scripts_styles = array(
182
+			'registers'   => array(
183
+				'ee-tickets-datetimes-css' => array(
184
+					'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
185
+					'type' => 'css',
186
+				),
187
+				'ee-dtt-ticket-metabox'    => array(
188
+					'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
189
+					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
190
+				),
191
+			),
192
+			'deregisters' => array(
193
+				'event-editor-css'       => array('type' => 'css'),
194
+				'event-datetime-metabox' => array('type' => 'js'),
195
+			),
196
+			'enqueues'    => array(
197
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
198
+				'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
199
+			),
200
+			'localize'    => array(
201
+				'ee-dtt-ticket-metabox' => array(
202
+					'DTT_TRASH_BLOCK'       => array(
203
+						'main_warning'            => esc_html__(
204
+							'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
205
+							'event_espresso'
206
+						),
207
+						'after_warning'           => esc_html__(
208
+							'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
209
+							'event_espresso'
210
+						),
211
+						'cancel_button'           => '<button class="button--secondary ee-modal-cancel">'
212
+													 . esc_html__('Cancel', 'event_espresso') . '</button>',
213
+						'close_button'            => '<button class="button--secondary ee-modal-cancel">'
214
+													 . esc_html__('Close', 'event_espresso') . '</button>',
215
+						'single_warning_from_tkt' => esc_html__(
216
+							'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
217
+							'event_espresso'
218
+						),
219
+						'single_warning_from_dtt' => esc_html__(
220
+							'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
221
+							'event_espresso'
222
+						),
223
+						'dismiss_button'          => '<button class="button--secondary ee-modal-cancel">'
224
+													 . esc_html__('Dismiss', 'event_espresso') . '</button>',
225
+					),
226
+					'DTT_ERROR_MSG'         => array(
227
+						'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
228
+						'dismiss_button' => '<div class="save-cancel-button-container">'
229
+											. '<button class="button--secondary ee-modal-cancel">'
230
+											. esc_html__('Dismiss', 'event_espresso')
231
+											. '</button></div>',
232
+					),
233
+					'DTT_OVERSELL_WARNING'  => array(
234
+						'datetime_ticket' => esc_html__(
235
+							'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
236
+							'event_espresso'
237
+						),
238
+						'ticket_datetime' => esc_html__(
239
+							'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
240
+							'event_espresso'
241
+						),
242
+					),
243
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
244
+						$this->_date_format_strings['date'],
245
+						$this->_date_format_strings['time']
246
+					),
247
+					'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
248
+				),
249
+			),
250
+		);
251
+	}
252 252
 
253 253
 
254
-    /**
255
-     * @param array $update_callbacks
256
-     * @return array
257
-     */
258
-    public function caf_updates(array $update_callbacks)
259
-    {
260
-        unset($update_callbacks['_default_tickets_update']);
261
-        $update_callbacks['datetime_and_tickets_caf_update'] = array($this, 'datetime_and_tickets_caf_update');
262
-        return $update_callbacks;
263
-    }
254
+	/**
255
+	 * @param array $update_callbacks
256
+	 * @return array
257
+	 */
258
+	public function caf_updates(array $update_callbacks)
259
+	{
260
+		unset($update_callbacks['_default_tickets_update']);
261
+		$update_callbacks['datetime_and_tickets_caf_update'] = array($this, 'datetime_and_tickets_caf_update');
262
+		return $update_callbacks;
263
+	}
264 264
 
265 265
 
266
-    /**
267
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
268
-     *
269
-     * @param  EE_Event $event The Event object we're attaching data to
270
-     * @param  array    $data  The request data from the form
271
-     * @throws ReflectionException
272
-     * @throws Exception
273
-     * @throws InvalidInterfaceException
274
-     * @throws InvalidDataTypeException
275
-     * @throws EE_Error
276
-     * @throws InvalidArgumentException
277
-     */
278
-    public function datetime_and_tickets_caf_update($event, $data)
279
-    {
280
-        // first we need to start with datetimes cause they are the "root" items attached to events.
281
-        $saved_datetimes = $this->_update_datetimes($event, $data);
282
-        // next tackle the tickets (and prices?)
283
-        $this->_update_tickets($event, $saved_datetimes, $data);
284
-    }
266
+	/**
267
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
268
+	 *
269
+	 * @param  EE_Event $event The Event object we're attaching data to
270
+	 * @param  array    $data  The request data from the form
271
+	 * @throws ReflectionException
272
+	 * @throws Exception
273
+	 * @throws InvalidInterfaceException
274
+	 * @throws InvalidDataTypeException
275
+	 * @throws EE_Error
276
+	 * @throws InvalidArgumentException
277
+	 */
278
+	public function datetime_and_tickets_caf_update($event, $data)
279
+	{
280
+		// first we need to start with datetimes cause they are the "root" items attached to events.
281
+		$saved_datetimes = $this->_update_datetimes($event, $data);
282
+		// next tackle the tickets (and prices?)
283
+		$this->_update_tickets($event, $saved_datetimes, $data);
284
+	}
285 285
 
286 286
 
287
-    /**
288
-     * update event_datetimes
289
-     *
290
-     * @param  EE_Event $event Event being updated
291
-     * @param  array    $data  the request data from the form
292
-     * @return EE_Datetime[]
293
-     * @throws Exception
294
-     * @throws ReflectionException
295
-     * @throws InvalidInterfaceException
296
-     * @throws InvalidDataTypeException
297
-     * @throws InvalidArgumentException
298
-     * @throws EE_Error
299
-     */
300
-    protected function _update_datetimes($event, $data)
301
-    {
302
-        $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
303
-        $saved_dtt_ids = array();
304
-        $saved_dtt_objs = array();
305
-        if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
306
-            throw new InvalidArgumentException(
307
-                esc_html__(
308
-                    'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
309
-                    'event_espresso'
310
-                )
311
-            );
312
-        }
313
-        foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
314
-            // trim all values to ensure any excess whitespace is removed.
315
-            $datetime_data = array_map(
316
-                function ($datetime_data) {
317
-                    return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
318
-                },
319
-                $datetime_data
320
-            );
321
-            $datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
322
-                                            && ! empty($datetime_data['DTT_EVT_end'])
323
-                ? $datetime_data['DTT_EVT_end']
324
-                : $datetime_data['DTT_EVT_start'];
325
-            $datetime_values = array(
326
-                'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
327
-                    ? $datetime_data['DTT_ID']
328
-                    : null,
329
-                'DTT_name'        => ! empty($datetime_data['DTT_name'])
330
-                    ? $datetime_data['DTT_name']
331
-                    : '',
332
-                'DTT_description' => ! empty($datetime_data['DTT_description'])
333
-                    ? $datetime_data['DTT_description']
334
-                    : '',
335
-                'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
336
-                'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
337
-                'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
338
-                    ? EE_INF
339
-                    : $datetime_data['DTT_reg_limit'],
340
-                'DTT_order'       => ! isset($datetime_data['DTT_order'])
341
-                    ? $row
342
-                    : $datetime_data['DTT_order'],
343
-            );
344
-            // if we have an id then let's get existing object first and then set the new values.
345
-            // Otherwise we instantiate a new object for save.
346
-            if (! empty($datetime_data['DTT_ID'])) {
347
-                $datetime = EE_Registry::instance()
348
-                                       ->load_model('Datetime', array($timezone))
349
-                                       ->get_one_by_ID($datetime_data['DTT_ID']);
350
-                // set date and time format according to what is set in this class.
351
-                $datetime->set_date_format($this->_date_format_strings['date']);
352
-                $datetime->set_time_format($this->_date_format_strings['time']);
353
-                foreach ($datetime_values as $field => $value) {
354
-                    $datetime->set($field, $value);
355
-                }
356
-                // make sure the $dtt_id here is saved just in case
357
-                // after the add_relation_to() the autosave replaces it.
358
-                // We need to do this so we dont' TRASH the parent DTT.
359
-                // (save the ID for both key and value to avoid duplications)
360
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
361
-            } else {
362
-                $datetime = EE_Registry::instance()->load_class(
363
-                    'Datetime',
364
-                    array(
365
-                        $datetime_values,
366
-                        $timezone,
367
-                        array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
368
-                    ),
369
-                    false,
370
-                    false
371
-                );
372
-                foreach ($datetime_values as $field => $value) {
373
-                    $datetime->set($field, $value);
374
-                }
375
-            }
376
-            $datetime->save();
377
-            do_action(
378
-                'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
379
-                $datetime,
380
-                $row,
381
-                $datetime_data,
382
-                $data
383
-            );
384
-            $datetime = $event->_add_relation_to($datetime, 'Datetime');
385
-            // before going any further make sure our dates are setup correctly
386
-            // so that the end date is always equal or greater than the start date.
387
-            if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
388
-                $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
389
-                $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
390
-                $datetime->save();
391
-            }
392
-            // now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
393
-            // because it is possible there was a new one created for the autosave.
394
-            // (save the ID for both key and value to avoid duplications)
395
-            $DTT_ID = $datetime->ID();
396
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
397
-            $saved_dtt_objs[ $row ] = $datetime;
398
-            // @todo if ANY of these updates fail then we want the appropriate global error message.
399
-        }
400
-        $event->save();
401
-        // now we need to REMOVE any datetimes that got deleted.
402
-        // Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
403
-        // So its safe to permanently delete at this point.
404
-        $old_datetimes = explode(',', $data['datetime_IDs']);
405
-        $old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
406
-        if (is_array($old_datetimes)) {
407
-            $datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
408
-            foreach ($datetimes_to_delete as $id) {
409
-                $id = absint($id);
410
-                if (empty($id)) {
411
-                    continue;
412
-                }
413
-                $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
414
-                // remove tkt relationships.
415
-                $related_tickets = $dtt_to_remove->get_many_related('Ticket');
416
-                foreach ($related_tickets as $tkt) {
417
-                    $dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
418
-                }
419
-                $event->_remove_relation_to($id, 'Datetime');
420
-                $dtt_to_remove->refresh_cache_of_related_objects();
421
-            }
422
-        }
423
-        return $saved_dtt_objs;
424
-    }
287
+	/**
288
+	 * update event_datetimes
289
+	 *
290
+	 * @param  EE_Event $event Event being updated
291
+	 * @param  array    $data  the request data from the form
292
+	 * @return EE_Datetime[]
293
+	 * @throws Exception
294
+	 * @throws ReflectionException
295
+	 * @throws InvalidInterfaceException
296
+	 * @throws InvalidDataTypeException
297
+	 * @throws InvalidArgumentException
298
+	 * @throws EE_Error
299
+	 */
300
+	protected function _update_datetimes($event, $data)
301
+	{
302
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
303
+		$saved_dtt_ids = array();
304
+		$saved_dtt_objs = array();
305
+		if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
306
+			throw new InvalidArgumentException(
307
+				esc_html__(
308
+					'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
309
+					'event_espresso'
310
+				)
311
+			);
312
+		}
313
+		foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
314
+			// trim all values to ensure any excess whitespace is removed.
315
+			$datetime_data = array_map(
316
+				function ($datetime_data) {
317
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
318
+				},
319
+				$datetime_data
320
+			);
321
+			$datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
322
+											&& ! empty($datetime_data['DTT_EVT_end'])
323
+				? $datetime_data['DTT_EVT_end']
324
+				: $datetime_data['DTT_EVT_start'];
325
+			$datetime_values = array(
326
+				'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
327
+					? $datetime_data['DTT_ID']
328
+					: null,
329
+				'DTT_name'        => ! empty($datetime_data['DTT_name'])
330
+					? $datetime_data['DTT_name']
331
+					: '',
332
+				'DTT_description' => ! empty($datetime_data['DTT_description'])
333
+					? $datetime_data['DTT_description']
334
+					: '',
335
+				'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
336
+				'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
337
+				'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
338
+					? EE_INF
339
+					: $datetime_data['DTT_reg_limit'],
340
+				'DTT_order'       => ! isset($datetime_data['DTT_order'])
341
+					? $row
342
+					: $datetime_data['DTT_order'],
343
+			);
344
+			// if we have an id then let's get existing object first and then set the new values.
345
+			// Otherwise we instantiate a new object for save.
346
+			if (! empty($datetime_data['DTT_ID'])) {
347
+				$datetime = EE_Registry::instance()
348
+									   ->load_model('Datetime', array($timezone))
349
+									   ->get_one_by_ID($datetime_data['DTT_ID']);
350
+				// set date and time format according to what is set in this class.
351
+				$datetime->set_date_format($this->_date_format_strings['date']);
352
+				$datetime->set_time_format($this->_date_format_strings['time']);
353
+				foreach ($datetime_values as $field => $value) {
354
+					$datetime->set($field, $value);
355
+				}
356
+				// make sure the $dtt_id here is saved just in case
357
+				// after the add_relation_to() the autosave replaces it.
358
+				// We need to do this so we dont' TRASH the parent DTT.
359
+				// (save the ID for both key and value to avoid duplications)
360
+				$saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
361
+			} else {
362
+				$datetime = EE_Registry::instance()->load_class(
363
+					'Datetime',
364
+					array(
365
+						$datetime_values,
366
+						$timezone,
367
+						array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
368
+					),
369
+					false,
370
+					false
371
+				);
372
+				foreach ($datetime_values as $field => $value) {
373
+					$datetime->set($field, $value);
374
+				}
375
+			}
376
+			$datetime->save();
377
+			do_action(
378
+				'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
379
+				$datetime,
380
+				$row,
381
+				$datetime_data,
382
+				$data
383
+			);
384
+			$datetime = $event->_add_relation_to($datetime, 'Datetime');
385
+			// before going any further make sure our dates are setup correctly
386
+			// so that the end date is always equal or greater than the start date.
387
+			if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
388
+				$datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
389
+				$datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
390
+				$datetime->save();
391
+			}
392
+			// now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
393
+			// because it is possible there was a new one created for the autosave.
394
+			// (save the ID for both key and value to avoid duplications)
395
+			$DTT_ID = $datetime->ID();
396
+			$saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
397
+			$saved_dtt_objs[ $row ] = $datetime;
398
+			// @todo if ANY of these updates fail then we want the appropriate global error message.
399
+		}
400
+		$event->save();
401
+		// now we need to REMOVE any datetimes that got deleted.
402
+		// Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
403
+		// So its safe to permanently delete at this point.
404
+		$old_datetimes = explode(',', $data['datetime_IDs']);
405
+		$old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
406
+		if (is_array($old_datetimes)) {
407
+			$datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
408
+			foreach ($datetimes_to_delete as $id) {
409
+				$id = absint($id);
410
+				if (empty($id)) {
411
+					continue;
412
+				}
413
+				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
414
+				// remove tkt relationships.
415
+				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
416
+				foreach ($related_tickets as $tkt) {
417
+					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
418
+				}
419
+				$event->_remove_relation_to($id, 'Datetime');
420
+				$dtt_to_remove->refresh_cache_of_related_objects();
421
+			}
422
+		}
423
+		return $saved_dtt_objs;
424
+	}
425 425
 
426 426
 
427
-    /**
428
-     * update tickets
429
-     *
430
-     * @param  EE_Event      $event           Event object being updated
431
-     * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
432
-     * @param  array         $data            incoming request data
433
-     * @return EE_Ticket[]
434
-     * @throws Exception
435
-     * @throws ReflectionException
436
-     * @throws InvalidInterfaceException
437
-     * @throws InvalidDataTypeException
438
-     * @throws InvalidArgumentException
439
-     * @throws EE_Error
440
-     */
441
-    protected function _update_tickets($event, $saved_datetimes, $data)
442
-    {
443
-        $new_tkt = null;
444
-        // stripslashes because WP filtered the $_POST ($data) array to add slashes
445
-        $data = stripslashes_deep($data);
446
-        $timezone = $data['timezone_string'] ?? null;
447
-        $saved_tickets = array();
448
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
449
-        if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
450
-            throw new InvalidArgumentException(
451
-                esc_html__(
452
-                    'The "edit_tickets" array is invalid therefore the event can not be updated.',
453
-                    'event_espresso'
454
-                )
455
-            );
456
-        }
457
-        foreach ($data['edit_tickets'] as $row => $tkt) {
458
-            $update_prices = $create_new_TKT = false;
459
-            // figure out what datetimes were added to the ticket
460
-            // and what datetimes were removed from the ticket in the session.
461
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
462
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
463
-            $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
464
-            $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
465
-            // trim inputs to ensure any excess whitespace is removed.
466
-            $tkt = array_map(
467
-                function ($ticket_data) {
468
-                    return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
469
-                },
470
-                $tkt
471
-            );
472
-            // note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
473
-            // because we're doing calculations prior to using the models.
474
-            // note incoming ['TKT_price'] value is already in standard notation (via js).
475
-            $ticket_price = isset($tkt['TKT_price'])
476
-                ? round((float) $tkt['TKT_price'], 3)
477
-                : 0;
478
-            // note incoming base price needs converted from localized value.
479
-            $base_price = isset($tkt['TKT_base_price'])
480
-                ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
481
-                : 0;
482
-            // if ticket price == 0 and $base_price != 0 then ticket price == base_price
483
-            $ticket_price = $ticket_price === 0 && $base_price !== 0
484
-                ? $base_price
485
-                : $ticket_price;
486
-            $base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
487
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
488
-                ? $data['edit_prices'][ $row ]
489
-                : array();
490
-            $now = null;
491
-            if (empty($tkt['TKT_start_date'])) {
492
-                // lets' use now in the set timezone.
493
-                $now = new DateTime('now', new DateTimeZone($event->get_timezone()));
494
-                $tkt['TKT_start_date'] = $now->format($this->_date_time_format);
495
-            }
496
-            if (empty($tkt['TKT_end_date'])) {
497
-                /**
498
-                 * set the TKT_end_date to the first datetime attached to the ticket.
499
-                 */
500
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
501
-                $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
502
-            }
503
-            $TKT_values = array(
504
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
505
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
506
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
507
-                'TKT_description' => ! empty($tkt['TKT_description'])
508
-                                     && $tkt['TKT_description'] !== esc_html__(
509
-                                         'You can modify this description',
510
-                                         'event_espresso'
511
-                                     )
512
-                    ? $tkt['TKT_description']
513
-                    : '',
514
-                'TKT_start_date'  => $tkt['TKT_start_date'],
515
-                'TKT_end_date'    => $tkt['TKT_end_date'],
516
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
517
-                    ? EE_INF
518
-                    : $tkt['TKT_qty'],
519
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
520
-                    ? EE_INF
521
-                    : $tkt['TKT_uses'],
522
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
523
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
524
-                'TKT_row'         => $row,
525
-                'TKT_order'       => $tkt['TKT_order'] ?? 0,
526
-                'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
527
-                'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
528
-                'TKT_price'       => $ticket_price,
529
-            );
530
-            // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
531
-            // which means in turn that the prices will become new prices as well.
532
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
533
-                $TKT_values['TKT_ID'] = 0;
534
-                $TKT_values['TKT_is_default'] = 0;
535
-                $update_prices = true;
536
-            }
537
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
538
-            // we actually do our saves ahead of doing any add_relations to
539
-            // because its entirely possible that this ticket wasn't removed or added to any datetime in the session
540
-            // but DID have it's items modified.
541
-            // keep in mind that if the TKT has been sold (and we have changed pricing information),
542
-            // then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
543
-            if (absint($TKT_values['TKT_ID'])) {
544
-                $ticket = EE_Registry::instance()
545
-                                     ->load_model('Ticket', array($timezone))
546
-                                     ->get_one_by_ID($tkt['TKT_ID']);
547
-                if ($ticket instanceof EE_Ticket) {
548
-                    $ticket = $this->_update_ticket_datetimes(
549
-                        $ticket,
550
-                        $saved_datetimes,
551
-                        $datetimes_added,
552
-                        $datetimes_removed
553
-                    );
554
-                    // are there any registrations using this ticket ?
555
-                    $tickets_sold = $ticket->count_related(
556
-                        'Registration',
557
-                        array(
558
-                            array(
559
-                                'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
560
-                            ),
561
-                        )
562
-                    );
563
-                    // set ticket formats
564
-                    $ticket->set_date_format($this->_date_format_strings['date']);
565
-                    $ticket->set_time_format($this->_date_format_strings['time']);
566
-                    // let's just check the total price for the existing ticket
567
-                    // and determine if it matches the new total price.
568
-                    // if they are different then we create a new ticket (if tickets sold)
569
-                    // if they aren't different then we go ahead and modify existing ticket.
570
-                    $create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
571
-                    // set new values
572
-                    foreach ($TKT_values as $field => $value) {
573
-                        if ($field === 'TKT_qty') {
574
-                            $ticket->set_qty($value);
575
-                        } else {
576
-                            $ticket->set($field, $value);
577
-                        }
578
-                    }
579
-                    // if $create_new_TKT is false then we can safely update the existing ticket.
580
-                    // Otherwise we have to create a new ticket.
581
-                    if ($create_new_TKT) {
582
-                        $new_tkt = $this->_duplicate_ticket(
583
-                            $ticket,
584
-                            $price_rows,
585
-                            $ticket_price,
586
-                            $base_price,
587
-                            $base_price_id
588
-                        );
589
-                    }
590
-                }
591
-            } else {
592
-                // no TKT_id so a new TKT
593
-                $ticket = EE_Ticket::new_instance(
594
-                    $TKT_values,
595
-                    $timezone,
596
-                    array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
597
-                );
598
-                if ($ticket instanceof EE_Ticket) {
599
-                    // make sure ticket has an ID of setting relations won't work
600
-                    $ticket->save();
601
-                    $ticket = $this->_update_ticket_datetimes(
602
-                        $ticket,
603
-                        $saved_datetimes,
604
-                        $datetimes_added,
605
-                        $datetimes_removed
606
-                    );
607
-                    $update_prices = true;
608
-                }
609
-            }
610
-            // make sure any current values have been saved.
611
-            // $ticket->save();
612
-            // before going any further make sure our dates are setup correctly
613
-            // so that the end date is always equal or greater than the start date.
614
-            if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
615
-                $ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
616
-                $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
617
-            }
618
-            // let's make sure the base price is handled
619
-            $ticket = ! $create_new_TKT
620
-                ? $this->_add_prices_to_ticket(
621
-                    array(),
622
-                    $ticket,
623
-                    $update_prices,
624
-                    $base_price,
625
-                    $base_price_id
626
-                )
627
-                : $ticket;
628
-            // add/update price_modifiers
629
-            $ticket = ! $create_new_TKT
630
-                ? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
631
-                : $ticket;
632
-            // need to make sue that the TKT_price is accurate after saving the prices.
633
-            $ticket->ensure_TKT_Price_correct();
634
-            // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
635
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
636
-                $update_prices = true;
637
-                $new_default = clone $ticket;
638
-                $new_default->set('TKT_ID', 0);
639
-                $new_default->set('TKT_is_default', 1);
640
-                $new_default->set('TKT_row', 1);
641
-                $new_default->set('TKT_price', $ticket_price);
642
-                // remove any dtt relations cause we DON'T want dtt relations attached
643
-                // (note this is just removing the cached relations in the object)
644
-                $new_default->_remove_relations('Datetime');
645
-                // @todo we need to add the current attached prices as new prices to the new default ticket.
646
-                $new_default = $this->_add_prices_to_ticket(
647
-                    $price_rows,
648
-                    $new_default,
649
-                    $update_prices
650
-                );
651
-                // don't forget the base price!
652
-                $new_default = $this->_add_prices_to_ticket(
653
-                    array(),
654
-                    $new_default,
655
-                    $update_prices,
656
-                    $base_price,
657
-                    $base_price_id
658
-                );
659
-                $new_default->save();
660
-                do_action(
661
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
662
-                    $new_default,
663
-                    $row,
664
-                    $ticket,
665
-                    $data
666
-                );
667
-            }
668
-            // DO ALL dtt relationships for both current tickets and any archived tickets
669
-            // for the given dtt that are related to the current ticket.
670
-            // TODO... not sure exactly how we're going to do this considering we don't know
671
-            // what current ticket the archived tickets are related to
672
-            // (and TKT_parent is used for autosaves so that's not a field we can reliably use).
673
-            // let's assign any tickets that have been setup to the saved_tickets tracker
674
-            // save existing TKT
675
-            $ticket->save();
676
-            if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
677
-                // save new TKT
678
-                $new_tkt->save();
679
-                // add new ticket to array
680
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
681
-                do_action(
682
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
683
-                    $new_tkt,
684
-                    $row,
685
-                    $tkt,
686
-                    $data
687
-                );
688
-            } else {
689
-                // add tkt to saved tkts
690
-                $saved_tickets[ $ticket->ID() ] = $ticket;
691
-                do_action(
692
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
693
-                    $ticket,
694
-                    $row,
695
-                    $tkt,
696
-                    $data
697
-                );
698
-            }
699
-        }
700
-        // now we need to handle tickets actually "deleted permanently".
701
-        // There are cases where we'd want this to happen
702
-        // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
703
-        // Or a draft event was saved and in the process of editing a ticket is trashed.
704
-        // No sense in keeping all the related data in the db!
705
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
706
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
707
-        foreach ($tickets_removed as $id) {
708
-            $id = absint($id);
709
-            // get the ticket for this id
710
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
711
-            // if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
712
-            if ($tkt_to_remove->get('TKT_is_default')) {
713
-                continue;
714
-            }
715
-            // if this tkt has any registrations attached so then we just ARCHIVE
716
-            // because we don't actually permanently delete these tickets.
717
-            if ($tkt_to_remove->count_related('Registration') > 0) {
718
-                $tkt_to_remove->delete();
719
-                continue;
720
-            }
721
-            // need to get all the related datetimes on this ticket and remove from every single one of them
722
-            // (remember this process can ONLY kick off if there are NO tkts_sold)
723
-            $datetimes = $tkt_to_remove->get_many_related('Datetime');
724
-            foreach ($datetimes as $datetime) {
725
-                $tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
726
-            }
727
-            // need to do the same for prices (except these prices can also be deleted because again,
728
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
729
-            $tkt_to_remove->delete_related_permanently('Price');
730
-            do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
731
-            // finally let's delete this ticket
732
-            // (which should not be blocked at this point b/c we've removed all our relationships)
733
-            $tkt_to_remove->delete_permanently();
734
-        }
735
-        return $saved_tickets;
736
-    }
427
+	/**
428
+	 * update tickets
429
+	 *
430
+	 * @param  EE_Event      $event           Event object being updated
431
+	 * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
432
+	 * @param  array         $data            incoming request data
433
+	 * @return EE_Ticket[]
434
+	 * @throws Exception
435
+	 * @throws ReflectionException
436
+	 * @throws InvalidInterfaceException
437
+	 * @throws InvalidDataTypeException
438
+	 * @throws InvalidArgumentException
439
+	 * @throws EE_Error
440
+	 */
441
+	protected function _update_tickets($event, $saved_datetimes, $data)
442
+	{
443
+		$new_tkt = null;
444
+		// stripslashes because WP filtered the $_POST ($data) array to add slashes
445
+		$data = stripslashes_deep($data);
446
+		$timezone = $data['timezone_string'] ?? null;
447
+		$saved_tickets = array();
448
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
449
+		if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
450
+			throw new InvalidArgumentException(
451
+				esc_html__(
452
+					'The "edit_tickets" array is invalid therefore the event can not be updated.',
453
+					'event_espresso'
454
+				)
455
+			);
456
+		}
457
+		foreach ($data['edit_tickets'] as $row => $tkt) {
458
+			$update_prices = $create_new_TKT = false;
459
+			// figure out what datetimes were added to the ticket
460
+			// and what datetimes were removed from the ticket in the session.
461
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
462
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
463
+			$datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
464
+			$datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
465
+			// trim inputs to ensure any excess whitespace is removed.
466
+			$tkt = array_map(
467
+				function ($ticket_data) {
468
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
469
+				},
470
+				$tkt
471
+			);
472
+			// note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
473
+			// because we're doing calculations prior to using the models.
474
+			// note incoming ['TKT_price'] value is already in standard notation (via js).
475
+			$ticket_price = isset($tkt['TKT_price'])
476
+				? round((float) $tkt['TKT_price'], 3)
477
+				: 0;
478
+			// note incoming base price needs converted from localized value.
479
+			$base_price = isset($tkt['TKT_base_price'])
480
+				? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
481
+				: 0;
482
+			// if ticket price == 0 and $base_price != 0 then ticket price == base_price
483
+			$ticket_price = $ticket_price === 0 && $base_price !== 0
484
+				? $base_price
485
+				: $ticket_price;
486
+			$base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
487
+			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
488
+				? $data['edit_prices'][ $row ]
489
+				: array();
490
+			$now = null;
491
+			if (empty($tkt['TKT_start_date'])) {
492
+				// lets' use now in the set timezone.
493
+				$now = new DateTime('now', new DateTimeZone($event->get_timezone()));
494
+				$tkt['TKT_start_date'] = $now->format($this->_date_time_format);
495
+			}
496
+			if (empty($tkt['TKT_end_date'])) {
497
+				/**
498
+				 * set the TKT_end_date to the first datetime attached to the ticket.
499
+				 */
500
+				$first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
501
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
502
+			}
503
+			$TKT_values = array(
504
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
505
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
506
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
507
+				'TKT_description' => ! empty($tkt['TKT_description'])
508
+									 && $tkt['TKT_description'] !== esc_html__(
509
+										 'You can modify this description',
510
+										 'event_espresso'
511
+									 )
512
+					? $tkt['TKT_description']
513
+					: '',
514
+				'TKT_start_date'  => $tkt['TKT_start_date'],
515
+				'TKT_end_date'    => $tkt['TKT_end_date'],
516
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
517
+					? EE_INF
518
+					: $tkt['TKT_qty'],
519
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
520
+					? EE_INF
521
+					: $tkt['TKT_uses'],
522
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
523
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
524
+				'TKT_row'         => $row,
525
+				'TKT_order'       => $tkt['TKT_order'] ?? 0,
526
+				'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
527
+				'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
528
+				'TKT_price'       => $ticket_price,
529
+			);
530
+			// if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
531
+			// which means in turn that the prices will become new prices as well.
532
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
533
+				$TKT_values['TKT_ID'] = 0;
534
+				$TKT_values['TKT_is_default'] = 0;
535
+				$update_prices = true;
536
+			}
537
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
538
+			// we actually do our saves ahead of doing any add_relations to
539
+			// because its entirely possible that this ticket wasn't removed or added to any datetime in the session
540
+			// but DID have it's items modified.
541
+			// keep in mind that if the TKT has been sold (and we have changed pricing information),
542
+			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
543
+			if (absint($TKT_values['TKT_ID'])) {
544
+				$ticket = EE_Registry::instance()
545
+									 ->load_model('Ticket', array($timezone))
546
+									 ->get_one_by_ID($tkt['TKT_ID']);
547
+				if ($ticket instanceof EE_Ticket) {
548
+					$ticket = $this->_update_ticket_datetimes(
549
+						$ticket,
550
+						$saved_datetimes,
551
+						$datetimes_added,
552
+						$datetimes_removed
553
+					);
554
+					// are there any registrations using this ticket ?
555
+					$tickets_sold = $ticket->count_related(
556
+						'Registration',
557
+						array(
558
+							array(
559
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
560
+							),
561
+						)
562
+					);
563
+					// set ticket formats
564
+					$ticket->set_date_format($this->_date_format_strings['date']);
565
+					$ticket->set_time_format($this->_date_format_strings['time']);
566
+					// let's just check the total price for the existing ticket
567
+					// and determine if it matches the new total price.
568
+					// if they are different then we create a new ticket (if tickets sold)
569
+					// if they aren't different then we go ahead and modify existing ticket.
570
+					$create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
571
+					// set new values
572
+					foreach ($TKT_values as $field => $value) {
573
+						if ($field === 'TKT_qty') {
574
+							$ticket->set_qty($value);
575
+						} else {
576
+							$ticket->set($field, $value);
577
+						}
578
+					}
579
+					// if $create_new_TKT is false then we can safely update the existing ticket.
580
+					// Otherwise we have to create a new ticket.
581
+					if ($create_new_TKT) {
582
+						$new_tkt = $this->_duplicate_ticket(
583
+							$ticket,
584
+							$price_rows,
585
+							$ticket_price,
586
+							$base_price,
587
+							$base_price_id
588
+						);
589
+					}
590
+				}
591
+			} else {
592
+				// no TKT_id so a new TKT
593
+				$ticket = EE_Ticket::new_instance(
594
+					$TKT_values,
595
+					$timezone,
596
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
597
+				);
598
+				if ($ticket instanceof EE_Ticket) {
599
+					// make sure ticket has an ID of setting relations won't work
600
+					$ticket->save();
601
+					$ticket = $this->_update_ticket_datetimes(
602
+						$ticket,
603
+						$saved_datetimes,
604
+						$datetimes_added,
605
+						$datetimes_removed
606
+					);
607
+					$update_prices = true;
608
+				}
609
+			}
610
+			// make sure any current values have been saved.
611
+			// $ticket->save();
612
+			// before going any further make sure our dates are setup correctly
613
+			// so that the end date is always equal or greater than the start date.
614
+			if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
615
+				$ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
616
+				$ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
617
+			}
618
+			// let's make sure the base price is handled
619
+			$ticket = ! $create_new_TKT
620
+				? $this->_add_prices_to_ticket(
621
+					array(),
622
+					$ticket,
623
+					$update_prices,
624
+					$base_price,
625
+					$base_price_id
626
+				)
627
+				: $ticket;
628
+			// add/update price_modifiers
629
+			$ticket = ! $create_new_TKT
630
+				? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
631
+				: $ticket;
632
+			// need to make sue that the TKT_price is accurate after saving the prices.
633
+			$ticket->ensure_TKT_Price_correct();
634
+			// handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
635
+			if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
636
+				$update_prices = true;
637
+				$new_default = clone $ticket;
638
+				$new_default->set('TKT_ID', 0);
639
+				$new_default->set('TKT_is_default', 1);
640
+				$new_default->set('TKT_row', 1);
641
+				$new_default->set('TKT_price', $ticket_price);
642
+				// remove any dtt relations cause we DON'T want dtt relations attached
643
+				// (note this is just removing the cached relations in the object)
644
+				$new_default->_remove_relations('Datetime');
645
+				// @todo we need to add the current attached prices as new prices to the new default ticket.
646
+				$new_default = $this->_add_prices_to_ticket(
647
+					$price_rows,
648
+					$new_default,
649
+					$update_prices
650
+				);
651
+				// don't forget the base price!
652
+				$new_default = $this->_add_prices_to_ticket(
653
+					array(),
654
+					$new_default,
655
+					$update_prices,
656
+					$base_price,
657
+					$base_price_id
658
+				);
659
+				$new_default->save();
660
+				do_action(
661
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
662
+					$new_default,
663
+					$row,
664
+					$ticket,
665
+					$data
666
+				);
667
+			}
668
+			// DO ALL dtt relationships for both current tickets and any archived tickets
669
+			// for the given dtt that are related to the current ticket.
670
+			// TODO... not sure exactly how we're going to do this considering we don't know
671
+			// what current ticket the archived tickets are related to
672
+			// (and TKT_parent is used for autosaves so that's not a field we can reliably use).
673
+			// let's assign any tickets that have been setup to the saved_tickets tracker
674
+			// save existing TKT
675
+			$ticket->save();
676
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
677
+				// save new TKT
678
+				$new_tkt->save();
679
+				// add new ticket to array
680
+				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
681
+				do_action(
682
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
683
+					$new_tkt,
684
+					$row,
685
+					$tkt,
686
+					$data
687
+				);
688
+			} else {
689
+				// add tkt to saved tkts
690
+				$saved_tickets[ $ticket->ID() ] = $ticket;
691
+				do_action(
692
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
693
+					$ticket,
694
+					$row,
695
+					$tkt,
696
+					$data
697
+				);
698
+			}
699
+		}
700
+		// now we need to handle tickets actually "deleted permanently".
701
+		// There are cases where we'd want this to happen
702
+		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
703
+		// Or a draft event was saved and in the process of editing a ticket is trashed.
704
+		// No sense in keeping all the related data in the db!
705
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
706
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
707
+		foreach ($tickets_removed as $id) {
708
+			$id = absint($id);
709
+			// get the ticket for this id
710
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
711
+			// if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
712
+			if ($tkt_to_remove->get('TKT_is_default')) {
713
+				continue;
714
+			}
715
+			// if this tkt has any registrations attached so then we just ARCHIVE
716
+			// because we don't actually permanently delete these tickets.
717
+			if ($tkt_to_remove->count_related('Registration') > 0) {
718
+				$tkt_to_remove->delete();
719
+				continue;
720
+			}
721
+			// need to get all the related datetimes on this ticket and remove from every single one of them
722
+			// (remember this process can ONLY kick off if there are NO tkts_sold)
723
+			$datetimes = $tkt_to_remove->get_many_related('Datetime');
724
+			foreach ($datetimes as $datetime) {
725
+				$tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
726
+			}
727
+			// need to do the same for prices (except these prices can also be deleted because again,
728
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
729
+			$tkt_to_remove->delete_related_permanently('Price');
730
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
731
+			// finally let's delete this ticket
732
+			// (which should not be blocked at this point b/c we've removed all our relationships)
733
+			$tkt_to_remove->delete_permanently();
734
+		}
735
+		return $saved_tickets;
736
+	}
737 737
 
738 738
 
739
-    /**
740
-     * @access  protected
741
-     * @param EE_Ticket      $ticket
742
-     * @param \EE_Datetime[] $saved_datetimes
743
-     * @param \EE_Datetime[] $added_datetimes
744
-     * @param \EE_Datetime[] $removed_datetimes
745
-     * @return EE_Ticket
746
-     * @throws EE_Error
747
-     */
748
-    protected function _update_ticket_datetimes(
749
-        EE_Ticket $ticket,
750
-        $saved_datetimes = array(),
751
-        $added_datetimes = array(),
752
-        $removed_datetimes = array()
753
-    ) {
754
-        // to start we have to add the ticket to all the datetimes its supposed to be with,
755
-        // and removing the ticket from datetimes it got removed from.
756
-        // first let's add datetimes
757
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
758
-            foreach ($added_datetimes as $row_id) {
759
-                $row_id = (int) $row_id;
760
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
761
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
762
-                }
763
-            }
764
-        }
765
-        // then remove datetimes
766
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
767
-            foreach ($removed_datetimes as $row_id) {
768
-                $row_id = (int) $row_id;
769
-                // its entirely possible that a datetime got deleted (instead of just removed from relationship.
770
-                // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
771
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
772
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
773
-                }
774
-            }
775
-        }
776
-        // cap ticket qty by datetime reg limits
777
-        $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
778
-        return $ticket;
779
-    }
739
+	/**
740
+	 * @access  protected
741
+	 * @param EE_Ticket      $ticket
742
+	 * @param \EE_Datetime[] $saved_datetimes
743
+	 * @param \EE_Datetime[] $added_datetimes
744
+	 * @param \EE_Datetime[] $removed_datetimes
745
+	 * @return EE_Ticket
746
+	 * @throws EE_Error
747
+	 */
748
+	protected function _update_ticket_datetimes(
749
+		EE_Ticket $ticket,
750
+		$saved_datetimes = array(),
751
+		$added_datetimes = array(),
752
+		$removed_datetimes = array()
753
+	) {
754
+		// to start we have to add the ticket to all the datetimes its supposed to be with,
755
+		// and removing the ticket from datetimes it got removed from.
756
+		// first let's add datetimes
757
+		if (! empty($added_datetimes) && is_array($added_datetimes)) {
758
+			foreach ($added_datetimes as $row_id) {
759
+				$row_id = (int) $row_id;
760
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
761
+					$ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
762
+				}
763
+			}
764
+		}
765
+		// then remove datetimes
766
+		if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
767
+			foreach ($removed_datetimes as $row_id) {
768
+				$row_id = (int) $row_id;
769
+				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
770
+				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
771
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
772
+					$ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
773
+				}
774
+			}
775
+		}
776
+		// cap ticket qty by datetime reg limits
777
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
778
+		return $ticket;
779
+	}
780 780
 
781 781
 
782
-    /**
783
-     * @access  protected
784
-     * @param EE_Ticket $ticket
785
-     * @param array     $price_rows
786
-     * @param int       $ticket_price
787
-     * @param int       $base_price
788
-     * @param int       $base_price_id
789
-     * @return EE_Ticket
790
-     * @throws ReflectionException
791
-     * @throws InvalidArgumentException
792
-     * @throws InvalidInterfaceException
793
-     * @throws InvalidDataTypeException
794
-     * @throws EE_Error
795
-     */
796
-    protected function _duplicate_ticket(
797
-        EE_Ticket $ticket,
798
-        $price_rows = array(),
799
-        $ticket_price = 0,
800
-        $base_price = 0,
801
-        $base_price_id = 0
802
-    ) {
803
-        // create new ticket that's a copy of the existing
804
-        // except a new id of course (and not archived)
805
-        // AND has the new TKT_price associated with it.
806
-        $new_ticket = clone $ticket;
807
-        $new_ticket->set('TKT_ID', 0);
808
-        $new_ticket->set_deleted(0);
809
-        $new_ticket->set_price($ticket_price);
810
-        $new_ticket->set_sold(0);
811
-        // let's get a new ID for this ticket
812
-        $new_ticket->save();
813
-        // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
814
-        $datetimes_on_existing = $ticket->datetimes();
815
-        $new_ticket = $this->_update_ticket_datetimes(
816
-            $new_ticket,
817
-            $datetimes_on_existing,
818
-            array_keys($datetimes_on_existing)
819
-        );
820
-        // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
821
-        // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
822
-        // available.
823
-        if ($ticket->sold() > 0) {
824
-            $new_qty = $ticket->qty() - $ticket->sold();
825
-            $new_ticket->set_qty($new_qty);
826
-        }
827
-        // now we update the prices just for this ticket
828
-        $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
829
-        // and we update the base price
830
-        $new_ticket = $this->_add_prices_to_ticket(
831
-            array(),
832
-            $new_ticket,
833
-            true,
834
-            $base_price,
835
-            $base_price_id
836
-        );
837
-        return $new_ticket;
838
-    }
782
+	/**
783
+	 * @access  protected
784
+	 * @param EE_Ticket $ticket
785
+	 * @param array     $price_rows
786
+	 * @param int       $ticket_price
787
+	 * @param int       $base_price
788
+	 * @param int       $base_price_id
789
+	 * @return EE_Ticket
790
+	 * @throws ReflectionException
791
+	 * @throws InvalidArgumentException
792
+	 * @throws InvalidInterfaceException
793
+	 * @throws InvalidDataTypeException
794
+	 * @throws EE_Error
795
+	 */
796
+	protected function _duplicate_ticket(
797
+		EE_Ticket $ticket,
798
+		$price_rows = array(),
799
+		$ticket_price = 0,
800
+		$base_price = 0,
801
+		$base_price_id = 0
802
+	) {
803
+		// create new ticket that's a copy of the existing
804
+		// except a new id of course (and not archived)
805
+		// AND has the new TKT_price associated with it.
806
+		$new_ticket = clone $ticket;
807
+		$new_ticket->set('TKT_ID', 0);
808
+		$new_ticket->set_deleted(0);
809
+		$new_ticket->set_price($ticket_price);
810
+		$new_ticket->set_sold(0);
811
+		// let's get a new ID for this ticket
812
+		$new_ticket->save();
813
+		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
814
+		$datetimes_on_existing = $ticket->datetimes();
815
+		$new_ticket = $this->_update_ticket_datetimes(
816
+			$new_ticket,
817
+			$datetimes_on_existing,
818
+			array_keys($datetimes_on_existing)
819
+		);
820
+		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
821
+		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
822
+		// available.
823
+		if ($ticket->sold() > 0) {
824
+			$new_qty = $ticket->qty() - $ticket->sold();
825
+			$new_ticket->set_qty($new_qty);
826
+		}
827
+		// now we update the prices just for this ticket
828
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
829
+		// and we update the base price
830
+		$new_ticket = $this->_add_prices_to_ticket(
831
+			array(),
832
+			$new_ticket,
833
+			true,
834
+			$base_price,
835
+			$base_price_id
836
+		);
837
+		return $new_ticket;
838
+	}
839 839
 
840 840
 
841
-    /**
842
-     * This attaches a list of given prices to a ticket.
843
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
844
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
845
-     * price info and prices are automatically "archived" via the ticket.
846
-     *
847
-     * @access  private
848
-     * @param array     $prices        Array of prices from the form.
849
-     * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
850
-     * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
851
-     * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
852
-     * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
853
-     * @return EE_Ticket
854
-     * @throws ReflectionException
855
-     * @throws InvalidArgumentException
856
-     * @throws InvalidInterfaceException
857
-     * @throws InvalidDataTypeException
858
-     * @throws EE_Error
859
-     */
860
-    protected function _add_prices_to_ticket(
861
-        $prices = array(),
862
-        EE_Ticket $ticket,
863
-        $new_prices = false,
864
-        $base_price = false,
865
-        $base_price_id = false
866
-    ) {
867
-        // let's just get any current prices that may exist on the given ticket
868
-        // so we can remove any prices that got trashed in this session.
869
-        $current_prices_on_ticket = $base_price !== false
870
-            ? $ticket->base_price(true)
871
-            : $ticket->price_modifiers();
872
-        $updated_prices = array();
873
-        // if $base_price ! FALSE then updating a base price.
874
-        if ($base_price !== false) {
875
-            $prices[1] = array(
876
-                'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
877
-                'PRT_ID'     => 1,
878
-                'PRC_amount' => $base_price,
879
-                'PRC_name'   => $ticket->get('TKT_name'),
880
-                'PRC_desc'   => $ticket->get('TKT_description'),
881
-            );
882
-        }
883
-        // possibly need to save tkt
884
-        if (! $ticket->ID()) {
885
-            $ticket->save();
886
-        }
887
-        foreach ($prices as $row => $prc) {
888
-            $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
889
-            if (empty($prt_id)) {
890
-                continue;
891
-            } //prices MUST have a price type id.
892
-            $PRC_values = array(
893
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
894
-                'PRT_ID'         => $prt_id,
895
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
896
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
897
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
898
-                'PRC_is_default' => false,
899
-                // make sure we set PRC_is_default to false for all ticket saves from event_editor
900
-                'PRC_order'      => $row,
901
-            );
902
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
903
-                $PRC_values['PRC_ID'] = 0;
904
-                $price = EE_Registry::instance()->load_class(
905
-                    'Price',
906
-                    array($PRC_values),
907
-                    false,
908
-                    false
909
-                );
910
-            } else {
911
-                $price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
912
-                // update this price with new values
913
-                foreach ($PRC_values as $field => $value) {
914
-                    $price->set($field, $value);
915
-                }
916
-            }
917
-            $price->save();
918
-            $updated_prices[ $price->ID() ] = $price;
919
-            $ticket->_add_relation_to($price, 'Price');
920
-        }
921
-        // now let's remove any prices that got removed from the ticket
922
-        if (! empty($current_prices_on_ticket)) {
923
-            $current = array_keys($current_prices_on_ticket);
924
-            $updated = array_keys($updated_prices);
925
-            $prices_to_remove = array_diff($current, $updated);
926
-            if (! empty($prices_to_remove)) {
927
-                foreach ($prices_to_remove as $prc_id) {
928
-                    $p = $current_prices_on_ticket[ $prc_id ];
929
-                    $ticket->_remove_relation_to($p, 'Price');
930
-                    // delete permanently the price
931
-                    $p->delete_permanently();
932
-                }
933
-            }
934
-        }
935
-        return $ticket;
936
-    }
841
+	/**
842
+	 * This attaches a list of given prices to a ticket.
843
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
844
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
845
+	 * price info and prices are automatically "archived" via the ticket.
846
+	 *
847
+	 * @access  private
848
+	 * @param array     $prices        Array of prices from the form.
849
+	 * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
850
+	 * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
851
+	 * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
852
+	 * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
853
+	 * @return EE_Ticket
854
+	 * @throws ReflectionException
855
+	 * @throws InvalidArgumentException
856
+	 * @throws InvalidInterfaceException
857
+	 * @throws InvalidDataTypeException
858
+	 * @throws EE_Error
859
+	 */
860
+	protected function _add_prices_to_ticket(
861
+		$prices = array(),
862
+		EE_Ticket $ticket,
863
+		$new_prices = false,
864
+		$base_price = false,
865
+		$base_price_id = false
866
+	) {
867
+		// let's just get any current prices that may exist on the given ticket
868
+		// so we can remove any prices that got trashed in this session.
869
+		$current_prices_on_ticket = $base_price !== false
870
+			? $ticket->base_price(true)
871
+			: $ticket->price_modifiers();
872
+		$updated_prices = array();
873
+		// if $base_price ! FALSE then updating a base price.
874
+		if ($base_price !== false) {
875
+			$prices[1] = array(
876
+				'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
877
+				'PRT_ID'     => 1,
878
+				'PRC_amount' => $base_price,
879
+				'PRC_name'   => $ticket->get('TKT_name'),
880
+				'PRC_desc'   => $ticket->get('TKT_description'),
881
+			);
882
+		}
883
+		// possibly need to save tkt
884
+		if (! $ticket->ID()) {
885
+			$ticket->save();
886
+		}
887
+		foreach ($prices as $row => $prc) {
888
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
889
+			if (empty($prt_id)) {
890
+				continue;
891
+			} //prices MUST have a price type id.
892
+			$PRC_values = array(
893
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
894
+				'PRT_ID'         => $prt_id,
895
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
896
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
897
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
898
+				'PRC_is_default' => false,
899
+				// make sure we set PRC_is_default to false for all ticket saves from event_editor
900
+				'PRC_order'      => $row,
901
+			);
902
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
903
+				$PRC_values['PRC_ID'] = 0;
904
+				$price = EE_Registry::instance()->load_class(
905
+					'Price',
906
+					array($PRC_values),
907
+					false,
908
+					false
909
+				);
910
+			} else {
911
+				$price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
912
+				// update this price with new values
913
+				foreach ($PRC_values as $field => $value) {
914
+					$price->set($field, $value);
915
+				}
916
+			}
917
+			$price->save();
918
+			$updated_prices[ $price->ID() ] = $price;
919
+			$ticket->_add_relation_to($price, 'Price');
920
+		}
921
+		// now let's remove any prices that got removed from the ticket
922
+		if (! empty($current_prices_on_ticket)) {
923
+			$current = array_keys($current_prices_on_ticket);
924
+			$updated = array_keys($updated_prices);
925
+			$prices_to_remove = array_diff($current, $updated);
926
+			if (! empty($prices_to_remove)) {
927
+				foreach ($prices_to_remove as $prc_id) {
928
+					$p = $current_prices_on_ticket[ $prc_id ];
929
+					$ticket->_remove_relation_to($p, 'Price');
930
+					// delete permanently the price
931
+					$p->delete_permanently();
932
+				}
933
+			}
934
+		}
935
+		return $ticket;
936
+	}
937 937
 
938 938
 
939
-    /**
940
-     * @param Events_Admin_Page $event_admin_obj
941
-     * @return Events_Admin_Page
942
-     */
943
-    public function autosave_handling(Events_Admin_Page $event_admin_obj)
944
-    {
945
-        return $event_admin_obj;
946
-        // doing nothing for the moment.
947
-        // todo when I get to this remember that I need to set the template args on the $event_admin_obj
948
-        // (use the set_template_args() method)
949
-        /**
950
-         * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
951
-         * 1. TKT_is_default_selector (visible)
952
-         * 2. TKT_is_default (hidden)
953
-         * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
954
-         * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
955
-         * this ticket to be saved as a default.
956
-         * The tricky part is, on an initial display on create or edit (or after manually updating),
957
-         * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
958
-         * if this is a create.  However, after an autosave, users will want some sort of indicator that
959
-         * the TKT HAS been saved as a default..
960
-         * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
961
-         * On Autosave:
962
-         * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
963
-         * then set the TKT_is_default to false.
964
-         * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
965
-         *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
966
-         * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
967
-         */
968
-    }
939
+	/**
940
+	 * @param Events_Admin_Page $event_admin_obj
941
+	 * @return Events_Admin_Page
942
+	 */
943
+	public function autosave_handling(Events_Admin_Page $event_admin_obj)
944
+	{
945
+		return $event_admin_obj;
946
+		// doing nothing for the moment.
947
+		// todo when I get to this remember that I need to set the template args on the $event_admin_obj
948
+		// (use the set_template_args() method)
949
+		/**
950
+		 * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
951
+		 * 1. TKT_is_default_selector (visible)
952
+		 * 2. TKT_is_default (hidden)
953
+		 * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
954
+		 * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
955
+		 * this ticket to be saved as a default.
956
+		 * The tricky part is, on an initial display on create or edit (or after manually updating),
957
+		 * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
958
+		 * if this is a create.  However, after an autosave, users will want some sort of indicator that
959
+		 * the TKT HAS been saved as a default..
960
+		 * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
961
+		 * On Autosave:
962
+		 * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
963
+		 * then set the TKT_is_default to false.
964
+		 * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
965
+		 *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
966
+		 * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
967
+		 */
968
+	}
969 969
 
970 970
 
971
-    /**
972
-     * @throws ReflectionException
973
-     * @throws InvalidArgumentException
974
-     * @throws InvalidInterfaceException
975
-     * @throws InvalidDataTypeException
976
-     * @throws DomainException
977
-     * @throws EE_Error
978
-     */
979
-    public function pricing_metabox()
980
-    {
981
-        $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
982
-        $event = $this->_adminpage_obj->get_cpt_model_obj();
983
-        // set is_creating_event property.
984
-        $EVT_ID = $event->ID();
985
-        $this->_is_creating_event = empty($this->_req_data['post']);
986
-        // default main template args
987
-        $main_template_args = array(
988
-            'event_datetime_help_link' => EEH_Template::get_help_tab_link(
989
-                'event_editor_event_datetimes_help_tab',
990
-                $this->_adminpage_obj->page_slug,
991
-                $this->_adminpage_obj->get_req_action(),
992
-                false,
993
-                false
994
-            ),
995
-            // todo need to add a filter to the template for the help text
996
-            // in the Events_Admin_Page core file so we can add further help
997
-            'existing_datetime_ids'    => '',
998
-            'total_dtt_rows'           => 1,
999
-            'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1000
-                'add_new_dtt_info',
1001
-                $this->_adminpage_obj->page_slug,
1002
-                $this->_adminpage_obj->get_req_action(),
1003
-                false,
1004
-                false
1005
-            ),
1006
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1007
-            'datetime_rows'            => '',
1008
-            'show_tickets_container'   => '',
1009
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1010
-            'ticket_rows'              => '',
1011
-            'existing_ticket_ids'      => '',
1012
-            'total_ticket_rows'        => 1,
1013
-            'ticket_js_structure'      => '',
1014
-            'ee_collapsible_status'    => ' ee-collapsible-open'
1015
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1016
-        );
1017
-        $timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1018
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1019
-        /**
1020
-         * 1. Start with retrieving Datetimes
1021
-         * 2. For each datetime get related tickets
1022
-         * 3. For each ticket get related prices
1023
-         */
1024
-        /** @var EEM_Datetime $datetime_model */
1025
-        $datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1026
-        $datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1027
-        $main_template_args['total_dtt_rows'] = count($datetimes);
1028
-        /**
1029
-         * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1030
-         * for why we are counting $datetime_row and then setting that on the Datetime object
1031
-         */
1032
-        $datetime_row = 1;
1033
-        foreach ($datetimes as $datetime) {
1034
-            $DTT_ID = $datetime->get('DTT_ID');
1035
-            $datetime->set('DTT_order', $datetime_row);
1036
-            $existing_datetime_ids[] = $DTT_ID;
1037
-            // tickets attached
1038
-            $related_tickets = $datetime->ID() > 0
1039
-                ? $datetime->get_many_related(
1040
-                    'Ticket',
1041
-                    array(
1042
-                        array(
1043
-                            'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1044
-                        ),
1045
-                        'default_where_conditions' => 'none',
1046
-                        'order_by'                 => array('TKT_order' => 'ASC'),
1047
-                    )
1048
-                )
1049
-                : array();
1050
-            // if there are no related tickets this is likely a new event OR autodraft
1051
-            // event so we need to generate the default tickets because datetimes
1052
-            // ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1053
-            // datetime on the event.
1054
-            if (empty($related_tickets) && count($datetimes) < 2) {
1055
-                /** @var EEM_Ticket $ticket_model */
1056
-                $ticket_model = EE_Registry::instance()->load_model('Ticket');
1057
-                $related_tickets = $ticket_model->get_all_default_tickets();
1058
-                // this should be ordered by TKT_ID, so let's grab the first default ticket
1059
-                // (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1060
-                $default_prices = EEM_Price::instance()->get_all_default_prices();
1061
-                $main_default_ticket = reset($related_tickets);
1062
-                if ($main_default_ticket instanceof EE_Ticket) {
1063
-                    foreach ($default_prices as $default_price) {
1064
-                        if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1065
-                            continue;
1066
-                        }
1067
-                        $main_default_ticket->cache('Price', $default_price);
1068
-                    }
1069
-                }
1070
-            }
1071
-            // we can't actually setup rows in this loop yet cause we don't know all
1072
-            // the unique tickets for this event yet (tickets are linked through all datetimes).
1073
-            // So we're going to temporarily cache some of that information.
1074
-            // loop through and setup the ticket rows and make sure the order is set.
1075
-            foreach ($related_tickets as $ticket) {
1076
-                $TKT_ID = $ticket->get('TKT_ID');
1077
-                $ticket_row = $ticket->get('TKT_row');
1078
-                // we only want unique tickets in our final display!!
1079
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1080
-                    $existing_ticket_ids[] = $TKT_ID;
1081
-                    $all_tickets[] = $ticket;
1082
-                }
1083
-                // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1084
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1085
-                // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1086
-                if (
1087
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1088
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1089
-                ) {
1090
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1091
-                }
1092
-            }
1093
-            $datetime_row++;
1094
-        }
1095
-        $main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1096
-        $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1097
-        $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1098
-        // sort $all_tickets by order
1099
-        usort(
1100
-            $all_tickets,
1101
-            function (EE_Ticket $a, EE_Ticket $b) {
1102
-                $a_order = (int) $a->get('TKT_order');
1103
-                $b_order = (int) $b->get('TKT_order');
1104
-                if ($a_order === $b_order) {
1105
-                    return 0;
1106
-                }
1107
-                return ($a_order < $b_order) ? -1 : 1;
1108
-            }
1109
-        );
1110
-        // k NOW we have all the data we need for setting up the dtt rows
1111
-        // and ticket rows so we start our dtt loop again.
1112
-        $datetime_row = 1;
1113
-        foreach ($datetimes as $datetime) {
1114
-            $main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1115
-                $datetime_row,
1116
-                $datetime,
1117
-                $datetime_tickets,
1118
-                $all_tickets,
1119
-                false,
1120
-                $datetimes
1121
-            );
1122
-            $datetime_row++;
1123
-        }
1124
-        // then loop through all tickets for the ticket rows.
1125
-        $ticket_row = 1;
1126
-        foreach ($all_tickets as $ticket) {
1127
-            $main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1128
-                $ticket_row,
1129
-                $ticket,
1130
-                $ticket_datetimes,
1131
-                $datetimes,
1132
-                false,
1133
-                $all_tickets
1134
-            );
1135
-            $ticket_row++;
1136
-        }
1137
-        $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
971
+	/**
972
+	 * @throws ReflectionException
973
+	 * @throws InvalidArgumentException
974
+	 * @throws InvalidInterfaceException
975
+	 * @throws InvalidDataTypeException
976
+	 * @throws DomainException
977
+	 * @throws EE_Error
978
+	 */
979
+	public function pricing_metabox()
980
+	{
981
+		$existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
982
+		$event = $this->_adminpage_obj->get_cpt_model_obj();
983
+		// set is_creating_event property.
984
+		$EVT_ID = $event->ID();
985
+		$this->_is_creating_event = empty($this->_req_data['post']);
986
+		// default main template args
987
+		$main_template_args = array(
988
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link(
989
+				'event_editor_event_datetimes_help_tab',
990
+				$this->_adminpage_obj->page_slug,
991
+				$this->_adminpage_obj->get_req_action(),
992
+				false,
993
+				false
994
+			),
995
+			// todo need to add a filter to the template for the help text
996
+			// in the Events_Admin_Page core file so we can add further help
997
+			'existing_datetime_ids'    => '',
998
+			'total_dtt_rows'           => 1,
999
+			'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1000
+				'add_new_dtt_info',
1001
+				$this->_adminpage_obj->page_slug,
1002
+				$this->_adminpage_obj->get_req_action(),
1003
+				false,
1004
+				false
1005
+			),
1006
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1007
+			'datetime_rows'            => '',
1008
+			'show_tickets_container'   => '',
1009
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1010
+			'ticket_rows'              => '',
1011
+			'existing_ticket_ids'      => '',
1012
+			'total_ticket_rows'        => 1,
1013
+			'ticket_js_structure'      => '',
1014
+			'ee_collapsible_status'    => ' ee-collapsible-open'
1015
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1016
+		);
1017
+		$timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1018
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1019
+		/**
1020
+		 * 1. Start with retrieving Datetimes
1021
+		 * 2. For each datetime get related tickets
1022
+		 * 3. For each ticket get related prices
1023
+		 */
1024
+		/** @var EEM_Datetime $datetime_model */
1025
+		$datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1026
+		$datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1027
+		$main_template_args['total_dtt_rows'] = count($datetimes);
1028
+		/**
1029
+		 * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1030
+		 * for why we are counting $datetime_row and then setting that on the Datetime object
1031
+		 */
1032
+		$datetime_row = 1;
1033
+		foreach ($datetimes as $datetime) {
1034
+			$DTT_ID = $datetime->get('DTT_ID');
1035
+			$datetime->set('DTT_order', $datetime_row);
1036
+			$existing_datetime_ids[] = $DTT_ID;
1037
+			// tickets attached
1038
+			$related_tickets = $datetime->ID() > 0
1039
+				? $datetime->get_many_related(
1040
+					'Ticket',
1041
+					array(
1042
+						array(
1043
+							'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1044
+						),
1045
+						'default_where_conditions' => 'none',
1046
+						'order_by'                 => array('TKT_order' => 'ASC'),
1047
+					)
1048
+				)
1049
+				: array();
1050
+			// if there are no related tickets this is likely a new event OR autodraft
1051
+			// event so we need to generate the default tickets because datetimes
1052
+			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1053
+			// datetime on the event.
1054
+			if (empty($related_tickets) && count($datetimes) < 2) {
1055
+				/** @var EEM_Ticket $ticket_model */
1056
+				$ticket_model = EE_Registry::instance()->load_model('Ticket');
1057
+				$related_tickets = $ticket_model->get_all_default_tickets();
1058
+				// this should be ordered by TKT_ID, so let's grab the first default ticket
1059
+				// (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1060
+				$default_prices = EEM_Price::instance()->get_all_default_prices();
1061
+				$main_default_ticket = reset($related_tickets);
1062
+				if ($main_default_ticket instanceof EE_Ticket) {
1063
+					foreach ($default_prices as $default_price) {
1064
+						if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1065
+							continue;
1066
+						}
1067
+						$main_default_ticket->cache('Price', $default_price);
1068
+					}
1069
+				}
1070
+			}
1071
+			// we can't actually setup rows in this loop yet cause we don't know all
1072
+			// the unique tickets for this event yet (tickets are linked through all datetimes).
1073
+			// So we're going to temporarily cache some of that information.
1074
+			// loop through and setup the ticket rows and make sure the order is set.
1075
+			foreach ($related_tickets as $ticket) {
1076
+				$TKT_ID = $ticket->get('TKT_ID');
1077
+				$ticket_row = $ticket->get('TKT_row');
1078
+				// we only want unique tickets in our final display!!
1079
+				if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1080
+					$existing_ticket_ids[] = $TKT_ID;
1081
+					$all_tickets[] = $ticket;
1082
+				}
1083
+				// temporary cache of this ticket info for this datetime for later processing of datetime rows.
1084
+				$datetime_tickets[ $DTT_ID ][] = $ticket_row;
1085
+				// temporary cache of this datetime info for this ticket for later processing of ticket rows.
1086
+				if (
1087
+					! isset($ticket_datetimes[ $TKT_ID ])
1088
+					|| ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1089
+				) {
1090
+					$ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1091
+				}
1092
+			}
1093
+			$datetime_row++;
1094
+		}
1095
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1096
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1097
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1098
+		// sort $all_tickets by order
1099
+		usort(
1100
+			$all_tickets,
1101
+			function (EE_Ticket $a, EE_Ticket $b) {
1102
+				$a_order = (int) $a->get('TKT_order');
1103
+				$b_order = (int) $b->get('TKT_order');
1104
+				if ($a_order === $b_order) {
1105
+					return 0;
1106
+				}
1107
+				return ($a_order < $b_order) ? -1 : 1;
1108
+			}
1109
+		);
1110
+		// k NOW we have all the data we need for setting up the dtt rows
1111
+		// and ticket rows so we start our dtt loop again.
1112
+		$datetime_row = 1;
1113
+		foreach ($datetimes as $datetime) {
1114
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1115
+				$datetime_row,
1116
+				$datetime,
1117
+				$datetime_tickets,
1118
+				$all_tickets,
1119
+				false,
1120
+				$datetimes
1121
+			);
1122
+			$datetime_row++;
1123
+		}
1124
+		// then loop through all tickets for the ticket rows.
1125
+		$ticket_row = 1;
1126
+		foreach ($all_tickets as $ticket) {
1127
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1128
+				$ticket_row,
1129
+				$ticket,
1130
+				$ticket_datetimes,
1131
+				$datetimes,
1132
+				false,
1133
+				$all_tickets
1134
+			);
1135
+			$ticket_row++;
1136
+		}
1137
+		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1138 1138
 
1139
-        $status_change_notice = EventEspresso\core\services\loaders\LoaderFactory::getLoader()->getShared(
1140
-            'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
1141
-        );
1142
-        $main_template_args['status_change_notice'] = $status_change_notice->display(
1143
-            '__event-editor',
1144
-            'espresso-events'
1145
-        );
1139
+		$status_change_notice = EventEspresso\core\services\loaders\LoaderFactory::getLoader()->getShared(
1140
+			'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
1141
+		);
1142
+		$main_template_args['status_change_notice'] = $status_change_notice->display(
1143
+			'__event-editor',
1144
+			'espresso-events'
1145
+		);
1146 1146
 
1147
-        EEH_Template::display_template(
1148
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1149
-            $main_template_args
1150
-        );
1151
-    }
1147
+		EEH_Template::display_template(
1148
+			PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1149
+			$main_template_args
1150
+		);
1151
+	}
1152 1152
 
1153 1153
 
1154
-    /**
1155
-     * @param int         $datetime_row
1156
-     * @param EE_Datetime $datetime
1157
-     * @param array       $datetime_tickets
1158
-     * @param array       $all_tickets
1159
-     * @param bool        $default
1160
-     * @param array       $all_datetimes
1161
-     * @return mixed
1162
-     * @throws DomainException
1163
-     * @throws EE_Error
1164
-     */
1165
-    protected function _get_datetime_row(
1166
-        $datetime_row,
1167
-        EE_Datetime $datetime,
1168
-        $datetime_tickets = array(),
1169
-        $all_tickets = array(),
1170
-        $default = false,
1171
-        $all_datetimes = array()
1172
-    ) {
1173
-        $dtt_display_template_args = array(
1174
-            'dtt_edit_row'             => $this->_get_dtt_edit_row(
1175
-                $datetime_row,
1176
-                $datetime,
1177
-                $default,
1178
-                $all_datetimes
1179
-            ),
1180
-            'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1181
-                $datetime_row,
1182
-                $datetime,
1183
-                $datetime_tickets,
1184
-                $all_tickets,
1185
-                $default
1186
-            ),
1187
-            'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1188
-        );
1189
-        return EEH_Template::display_template(
1190
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1191
-            $dtt_display_template_args,
1192
-            true
1193
-        );
1194
-    }
1154
+	/**
1155
+	 * @param int         $datetime_row
1156
+	 * @param EE_Datetime $datetime
1157
+	 * @param array       $datetime_tickets
1158
+	 * @param array       $all_tickets
1159
+	 * @param bool        $default
1160
+	 * @param array       $all_datetimes
1161
+	 * @return mixed
1162
+	 * @throws DomainException
1163
+	 * @throws EE_Error
1164
+	 */
1165
+	protected function _get_datetime_row(
1166
+		$datetime_row,
1167
+		EE_Datetime $datetime,
1168
+		$datetime_tickets = array(),
1169
+		$all_tickets = array(),
1170
+		$default = false,
1171
+		$all_datetimes = array()
1172
+	) {
1173
+		$dtt_display_template_args = array(
1174
+			'dtt_edit_row'             => $this->_get_dtt_edit_row(
1175
+				$datetime_row,
1176
+				$datetime,
1177
+				$default,
1178
+				$all_datetimes
1179
+			),
1180
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1181
+				$datetime_row,
1182
+				$datetime,
1183
+				$datetime_tickets,
1184
+				$all_tickets,
1185
+				$default
1186
+			),
1187
+			'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1188
+		);
1189
+		return EEH_Template::display_template(
1190
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1191
+			$dtt_display_template_args,
1192
+			true
1193
+		);
1194
+	}
1195 1195
 
1196 1196
 
1197
-    /**
1198
-     * This method is used to generate a dtt fields  edit row.
1199
-     * The same row is used to generate a row with valid DTT objects
1200
-     * and the default row that is used as the skeleton by the js.
1201
-     *
1202
-     * @param int           $datetime_row  The row number for the row being generated.
1203
-     * @param EE_Datetime   $datetime
1204
-     * @param bool          $default       Whether a default row is being generated or not.
1205
-     * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1206
-     * @return string
1207
-     * @throws DomainException
1208
-     * @throws EE_Error
1209
-     */
1210
-    protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1211
-    {
1212
-        // if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1213
-        $default = ! $datetime instanceof EE_Datetime ? true : $default;
1214
-        $template_args = array(
1215
-            'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1216
-            'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1217
-            'edit_dtt_expanded'    => '',
1218
-            'DTT_ID'               => $default ? '' : $datetime->ID(),
1219
-            'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1220
-            'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1221
-            'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1222
-            'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1223
-            'DTT_reg_limit'        => $default
1224
-                ? ''
1225
-                : $datetime->get_pretty(
1226
-                    'DTT_reg_limit',
1227
-                    'input'
1228
-                ),
1229
-            'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1230
-            'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1231
-            'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1232
-            'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1233
-                ? ''
1234
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1235
-            'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1236
-                ? 'dashicons dashicons-lock'
1237
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1238
-            'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1239
-                ? ''
1240
-                : EE_Admin_Page::add_query_args_and_nonce(
1241
-                    array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1242
-                    REG_ADMIN_URL
1243
-                ),
1244
-        );
1245
-        $template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1246
-            ? ' style="display:none"'
1247
-            : '';
1248
-        // allow filtering of template args at this point.
1249
-        $template_args = apply_filters(
1250
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1251
-            $template_args,
1252
-            $datetime_row,
1253
-            $datetime,
1254
-            $default,
1255
-            $all_datetimes,
1256
-            $this->_is_creating_event
1257
-        );
1258
-        return EEH_Template::display_template(
1259
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1260
-            $template_args,
1261
-            true
1262
-        );
1263
-    }
1197
+	/**
1198
+	 * This method is used to generate a dtt fields  edit row.
1199
+	 * The same row is used to generate a row with valid DTT objects
1200
+	 * and the default row that is used as the skeleton by the js.
1201
+	 *
1202
+	 * @param int           $datetime_row  The row number for the row being generated.
1203
+	 * @param EE_Datetime   $datetime
1204
+	 * @param bool          $default       Whether a default row is being generated or not.
1205
+	 * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1206
+	 * @return string
1207
+	 * @throws DomainException
1208
+	 * @throws EE_Error
1209
+	 */
1210
+	protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1211
+	{
1212
+		// if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1213
+		$default = ! $datetime instanceof EE_Datetime ? true : $default;
1214
+		$template_args = array(
1215
+			'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1216
+			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1217
+			'edit_dtt_expanded'    => '',
1218
+			'DTT_ID'               => $default ? '' : $datetime->ID(),
1219
+			'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1220
+			'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1221
+			'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1222
+			'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1223
+			'DTT_reg_limit'        => $default
1224
+				? ''
1225
+				: $datetime->get_pretty(
1226
+					'DTT_reg_limit',
1227
+					'input'
1228
+				),
1229
+			'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1230
+			'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1231
+			'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1232
+			'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1233
+				? ''
1234
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1235
+			'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1236
+				? 'dashicons dashicons-lock'
1237
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1238
+			'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1239
+				? ''
1240
+				: EE_Admin_Page::add_query_args_and_nonce(
1241
+					array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1242
+					REG_ADMIN_URL
1243
+				),
1244
+		);
1245
+		$template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1246
+			? ' style="display:none"'
1247
+			: '';
1248
+		// allow filtering of template args at this point.
1249
+		$template_args = apply_filters(
1250
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1251
+			$template_args,
1252
+			$datetime_row,
1253
+			$datetime,
1254
+			$default,
1255
+			$all_datetimes,
1256
+			$this->_is_creating_event
1257
+		);
1258
+		return EEH_Template::display_template(
1259
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1260
+			$template_args,
1261
+			true
1262
+		);
1263
+	}
1264 1264
 
1265 1265
 
1266
-    /**
1267
-     * @param int         $datetime_row
1268
-     * @param EE_Datetime $datetime
1269
-     * @param array       $datetime_tickets
1270
-     * @param array       $all_tickets
1271
-     * @param bool        $default
1272
-     * @return mixed
1273
-     * @throws DomainException
1274
-     * @throws EE_Error
1275
-     */
1276
-    protected function _get_dtt_attached_tickets_row(
1277
-        $datetime_row,
1278
-        $datetime,
1279
-        $datetime_tickets = array(),
1280
-        $all_tickets = array(),
1281
-        $default
1282
-    ) {
1283
-        $template_args = array(
1284
-            'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1285
-            'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1286
-            'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1287
-            'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1288
-            'show_tickets_row'                  => ' style="display:none;"',
1289
-            'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1290
-                'add_new_ticket_via_datetime',
1291
-                $this->_adminpage_obj->page_slug,
1292
-                $this->_adminpage_obj->get_req_action(),
1293
-                false,
1294
-                false
1295
-            ),
1296
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1297
-            'DTT_ID'                            => $default ? '' : $datetime->ID(),
1298
-        );
1299
-        // need to setup the list items (but only if this isn't a default skeleton setup)
1300
-        if (! $default) {
1301
-            $ticket_row = 1;
1302
-            foreach ($all_tickets as $ticket) {
1303
-                $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1304
-                    $datetime_row,
1305
-                    $ticket_row,
1306
-                    $datetime,
1307
-                    $ticket,
1308
-                    $datetime_tickets,
1309
-                    $default
1310
-                );
1311
-                $ticket_row++;
1312
-            }
1313
-        }
1314
-        // filter template args at this point
1315
-        $template_args = apply_filters(
1316
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1317
-            $template_args,
1318
-            $datetime_row,
1319
-            $datetime,
1320
-            $datetime_tickets,
1321
-            $all_tickets,
1322
-            $default,
1323
-            $this->_is_creating_event
1324
-        );
1325
-        return EEH_Template::display_template(
1326
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1327
-            $template_args,
1328
-            true
1329
-        );
1330
-    }
1266
+	/**
1267
+	 * @param int         $datetime_row
1268
+	 * @param EE_Datetime $datetime
1269
+	 * @param array       $datetime_tickets
1270
+	 * @param array       $all_tickets
1271
+	 * @param bool        $default
1272
+	 * @return mixed
1273
+	 * @throws DomainException
1274
+	 * @throws EE_Error
1275
+	 */
1276
+	protected function _get_dtt_attached_tickets_row(
1277
+		$datetime_row,
1278
+		$datetime,
1279
+		$datetime_tickets = array(),
1280
+		$all_tickets = array(),
1281
+		$default
1282
+	) {
1283
+		$template_args = array(
1284
+			'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1285
+			'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1286
+			'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1287
+			'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1288
+			'show_tickets_row'                  => ' style="display:none;"',
1289
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1290
+				'add_new_ticket_via_datetime',
1291
+				$this->_adminpage_obj->page_slug,
1292
+				$this->_adminpage_obj->get_req_action(),
1293
+				false,
1294
+				false
1295
+			),
1296
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1297
+			'DTT_ID'                            => $default ? '' : $datetime->ID(),
1298
+		);
1299
+		// need to setup the list items (but only if this isn't a default skeleton setup)
1300
+		if (! $default) {
1301
+			$ticket_row = 1;
1302
+			foreach ($all_tickets as $ticket) {
1303
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1304
+					$datetime_row,
1305
+					$ticket_row,
1306
+					$datetime,
1307
+					$ticket,
1308
+					$datetime_tickets,
1309
+					$default
1310
+				);
1311
+				$ticket_row++;
1312
+			}
1313
+		}
1314
+		// filter template args at this point
1315
+		$template_args = apply_filters(
1316
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1317
+			$template_args,
1318
+			$datetime_row,
1319
+			$datetime,
1320
+			$datetime_tickets,
1321
+			$all_tickets,
1322
+			$default,
1323
+			$this->_is_creating_event
1324
+		);
1325
+		return EEH_Template::display_template(
1326
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1327
+			$template_args,
1328
+			true
1329
+		);
1330
+	}
1331 1331
 
1332 1332
 
1333
-    /**
1334
-     * @param int         $datetime_row
1335
-     * @param int         $ticket_row
1336
-     * @param EE_Datetime $datetime
1337
-     * @param EE_Ticket   $ticket
1338
-     * @param array       $datetime_tickets
1339
-     * @param bool        $default
1340
-     * @return mixed
1341
-     * @throws DomainException
1342
-     * @throws EE_Error
1343
-     */
1344
-    protected function _get_datetime_tickets_list_item(
1345
-        $datetime_row,
1346
-        $ticket_row,
1347
-        $datetime,
1348
-        $ticket,
1349
-        $datetime_tickets = array(),
1350
-        $default
1351
-    ) {
1352
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1353
-            ? $datetime_tickets[ $datetime->ID() ]
1354
-            : array();
1355
-        $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1356
-        $no_ticket = $default && empty($ticket);
1357
-        $template_args = array(
1358
-            'dtt_row'                 => $default
1359
-                ? 'DTTNUM'
1360
-                : $datetime_row,
1361
-            'tkt_row'                 => $no_ticket
1362
-                ? 'TICKETNUM'
1363
-                : $ticket_row,
1364
-            'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1365
-                ? ' checked'
1366
-                : '',
1367
-            'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1368
-                ? ' ticket-selected'
1369
-                : '',
1370
-            'TKT_name'                => $no_ticket
1371
-                ? 'TKTNAME'
1372
-                : $ticket->get('TKT_name'),
1373
-            'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1374
-                ? ' tkt-status-' . EE_Ticket::onsale
1375
-                : ' tkt-status-' . $ticket->ticket_status(),
1376
-        );
1377
-        // filter template args
1378
-        $template_args = apply_filters(
1379
-            'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1380
-            $template_args,
1381
-            $datetime_row,
1382
-            $ticket_row,
1383
-            $datetime,
1384
-            $ticket,
1385
-            $datetime_tickets,
1386
-            $default,
1387
-            $this->_is_creating_event
1388
-        );
1389
-        return EEH_Template::display_template(
1390
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1391
-            $template_args,
1392
-            true
1393
-        );
1394
-    }
1333
+	/**
1334
+	 * @param int         $datetime_row
1335
+	 * @param int         $ticket_row
1336
+	 * @param EE_Datetime $datetime
1337
+	 * @param EE_Ticket   $ticket
1338
+	 * @param array       $datetime_tickets
1339
+	 * @param bool        $default
1340
+	 * @return mixed
1341
+	 * @throws DomainException
1342
+	 * @throws EE_Error
1343
+	 */
1344
+	protected function _get_datetime_tickets_list_item(
1345
+		$datetime_row,
1346
+		$ticket_row,
1347
+		$datetime,
1348
+		$ticket,
1349
+		$datetime_tickets = array(),
1350
+		$default
1351
+	) {
1352
+		$dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1353
+			? $datetime_tickets[ $datetime->ID() ]
1354
+			: array();
1355
+		$display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1356
+		$no_ticket = $default && empty($ticket);
1357
+		$template_args = array(
1358
+			'dtt_row'                 => $default
1359
+				? 'DTTNUM'
1360
+				: $datetime_row,
1361
+			'tkt_row'                 => $no_ticket
1362
+				? 'TICKETNUM'
1363
+				: $ticket_row,
1364
+			'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1365
+				? ' checked'
1366
+				: '',
1367
+			'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1368
+				? ' ticket-selected'
1369
+				: '',
1370
+			'TKT_name'                => $no_ticket
1371
+				? 'TKTNAME'
1372
+				: $ticket->get('TKT_name'),
1373
+			'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1374
+				? ' tkt-status-' . EE_Ticket::onsale
1375
+				: ' tkt-status-' . $ticket->ticket_status(),
1376
+		);
1377
+		// filter template args
1378
+		$template_args = apply_filters(
1379
+			'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1380
+			$template_args,
1381
+			$datetime_row,
1382
+			$ticket_row,
1383
+			$datetime,
1384
+			$ticket,
1385
+			$datetime_tickets,
1386
+			$default,
1387
+			$this->_is_creating_event
1388
+		);
1389
+		return EEH_Template::display_template(
1390
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1391
+			$template_args,
1392
+			true
1393
+		);
1394
+	}
1395 1395
 
1396 1396
 
1397
-    /**
1398
-     * This generates the ticket row for tickets.
1399
-     * This same method is used to generate both the actual rows and the js skeleton row
1400
-     * (when default === true)
1401
-     *
1402
-     * @param int           $ticket_row       Represents the row number being generated.
1403
-     * @param               $ticket
1404
-     * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1405
-     *                                        or empty for default
1406
-     * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1407
-     * @param bool          $default          Whether default row being generated or not.
1408
-     * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1409
-     *                                        (or empty in the case of defaults)
1410
-     * @return mixed
1411
-     * @throws InvalidArgumentException
1412
-     * @throws InvalidInterfaceException
1413
-     * @throws InvalidDataTypeException
1414
-     * @throws DomainException
1415
-     * @throws EE_Error
1416
-     * @throws ReflectionException
1417
-     */
1418
-    protected function _get_ticket_row(
1419
-        $ticket_row,
1420
-        $ticket,
1421
-        $ticket_datetimes,
1422
-        $all_datetimes,
1423
-        $default = false,
1424
-        $all_tickets = array()
1425
-    ) {
1426
-        // if $ticket is not an instance of EE_Ticket then force default to true.
1427
-        $default = ! $ticket instanceof EE_Ticket ? true : $default;
1428
-        $prices = ! empty($ticket) && ! $default
1429
-            ? $ticket->get_many_related(
1430
-                'Price',
1431
-                array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1432
-            )
1433
-            : array();
1434
-        // if there is only one price (which would be the base price)
1435
-        // or NO prices and this ticket is a default ticket,
1436
-        // let's just make sure there are no cached default prices on the object.
1437
-        // This is done by not including any query_params.
1438
-        if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1439
-            $prices = $ticket->prices();
1440
-        }
1441
-        // check if we're dealing with a default ticket in which case
1442
-        // we don't want any starting_ticket_datetime_row values set
1443
-        // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1444
-        // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1445
-        $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1446
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1447
-            ? $ticket_datetimes[ $ticket->ID() ]
1448
-            : array();
1449
-        $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1450
-        $base_price = $default ? null : $ticket->base_price();
1451
-        $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1452
-        // breaking out complicated condition for ticket_status
1453
-        if ($default) {
1454
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1455
-        } else {
1456
-            $ticket_status_class = $ticket->is_default()
1457
-                ? ' tkt-status-' . EE_Ticket::onsale
1458
-                : ' tkt-status-' . $ticket->ticket_status();
1459
-        }
1460
-        // breaking out complicated condition for TKT_taxable
1461
-        if ($default) {
1462
-            $TKT_taxable = '';
1463
-        } else {
1464
-            $TKT_taxable = $ticket->taxable()
1465
-                ? ' checked'
1466
-                : '';
1467
-        }
1468
-        if ($default) {
1469
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1470
-        } elseif ($ticket->is_default()) {
1471
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1472
-        } else {
1473
-            $TKT_status = $ticket->ticket_status(true);
1474
-        }
1475
-        if ($default) {
1476
-            $TKT_min = '';
1477
-        } else {
1478
-            $TKT_min = $ticket->min();
1479
-            if ($TKT_min === -1 || $TKT_min === 0) {
1480
-                $TKT_min = '';
1481
-            }
1482
-        }
1483
-        $template_args = array(
1484
-            'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1485
-            'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1486
-            // on initial page load this will always be the correct order.
1487
-            'tkt_status_class'              => $ticket_status_class,
1488
-            'display_edit_tkt_row'          => ' style="display:none;"',
1489
-            'edit_tkt_expanded'             => '',
1490
-            'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1491
-            'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1492
-            'TKT_start_date'                => $default
1493
-                ? ''
1494
-                : $ticket->get_date('TKT_start_date', $this->_date_time_format),
1495
-            'TKT_end_date'                  => $default
1496
-                ? ''
1497
-                : $ticket->get_date('TKT_end_date', $this->_date_time_format),
1498
-            'TKT_status'                    => $TKT_status,
1499
-            'TKT_price'                     => $default
1500
-                ? ''
1501
-                : EEH_Template::format_currency(
1502
-                    $ticket->get_ticket_total_with_taxes(),
1503
-                    false,
1504
-                    false
1505
-                ),
1506
-            'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1507
-            'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1508
-            'TKT_qty'                       => $default
1509
-                ? ''
1510
-                : $ticket->get_pretty('TKT_qty', 'symbol'),
1511
-            'TKT_qty_for_input'             => $default
1512
-                ? ''
1513
-                : $ticket->get_pretty('TKT_qty', 'input'),
1514
-            'TKT_uses'                      => $default
1515
-                ? ''
1516
-                : $ticket->get_pretty('TKT_uses', 'input'),
1517
-            'TKT_min'                       => $TKT_min,
1518
-            'TKT_max'                       => $default
1519
-                ? ''
1520
-                : $ticket->get_pretty('TKT_max', 'input'),
1521
-            'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1522
-            'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1523
-            'TKT_registrations'             => $default
1524
-                ? 0
1525
-                : $ticket->count_registrations(
1526
-                    array(
1527
-                        array(
1528
-                            'STS_ID' => array(
1529
-                                '!=',
1530
-                                EEM_Registration::status_id_incomplete,
1531
-                            ),
1532
-                        ),
1533
-                    )
1534
-                ),
1535
-            'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1536
-            'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1537
-            'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1538
-            'TKT_required'                  => $default ? 0 : $ticket->required(),
1539
-            'TKT_is_default_selector'       => '',
1540
-            'ticket_price_rows'             => '',
1541
-            'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1542
-                ? ''
1543
-                : $base_price->get_pretty('PRC_amount', 'localized_float'),
1544
-            'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1545
-            'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1546
-                ? ''
1547
-                : ' style="display:none;"',
1548
-            'show_price_mod_button'         => count($prices) > 1
1549
-                                               || ($default && $count_price_mods > 0)
1550
-                                               || (! $default && $ticket->deleted())
1551
-                ? ' style="display:none;"'
1552
-                : '',
1553
-            'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1554
-            'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1555
-            'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1556
-            'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1557
-            'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1558
-            'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1559
-            'TKT_taxable'                   => $TKT_taxable,
1560
-            'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1561
-                ? ''
1562
-                : ' style="display:none"',
1563
-            'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1564
-            'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1565
-                $ticket_subtotal,
1566
-                false,
1567
-                false
1568
-            ),
1569
-            'TKT_subtotal_amount'           => $ticket_subtotal,
1570
-            'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1571
-            'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1572
-            'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1573
-                ? ' ticket-archived'
1574
-                : '',
1575
-            'trash_icon'                    => $ticket instanceof EE_Ticket
1576
-                                               && $ticket->deleted()
1577
-                                               && ! $ticket->is_permanently_deleteable()
1578
-                ? 'dashicons dashicons-lock '
1579
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1580
-            'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1581
-                ? ''
1582
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1583
-        );
1584
-        $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1585
-            ? ' style="display:none"'
1586
-            : '';
1587
-        // handle rows that should NOT be empty
1588
-        if (empty($template_args['TKT_start_date'])) {
1589
-            // if empty then the start date will be now.
1590
-            $template_args['TKT_start_date'] = date(
1591
-                $this->_date_time_format,
1592
-                current_time('timestamp')
1593
-            );
1594
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1595
-        }
1596
-        if (empty($template_args['TKT_end_date'])) {
1597
-            // get the earliest datetime (if present);
1598
-            $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1599
-                ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1600
-                    'Datetime',
1601
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1602
-                )
1603
-                : null;
1604
-            if (! empty($earliest_dtt)) {
1605
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1606
-                    'DTT_EVT_start',
1607
-                    $this->_date_time_format
1608
-                );
1609
-            } else {
1610
-                // default so let's just use what's been set for the default date-time which is 30 days from now.
1611
-                $template_args['TKT_end_date'] = date(
1612
-                    $this->_date_time_format,
1613
-                    mktime(
1614
-                        24,
1615
-                        0,
1616
-                        0,
1617
-                        date('m'),
1618
-                        date('d') + 29,
1619
-                        date('Y')
1620
-                    )
1621
-                );
1622
-            }
1623
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1624
-        }
1625
-        // generate ticket_datetime items
1626
-        if (! $default) {
1627
-            $datetime_row = 1;
1628
-            foreach ($all_datetimes as $datetime) {
1629
-                $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1630
-                    $datetime_row,
1631
-                    $ticket_row,
1632
-                    $datetime,
1633
-                    $ticket,
1634
-                    $ticket_datetimes,
1635
-                    $default
1636
-                );
1637
-                $datetime_row++;
1638
-            }
1639
-        }
1640
-        $price_row = 1;
1641
-        foreach ($prices as $price) {
1642
-            if (! $price instanceof EE_Price) {
1643
-                continue;
1644
-            }
1645
-            if ($price->is_base_price()) {
1646
-                $price_row++;
1647
-                continue;
1648
-            }
1649
-            $show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1650
-            $show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1651
-            $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1652
-                $ticket_row,
1653
-                $price_row,
1654
-                $price,
1655
-                $default,
1656
-                $ticket,
1657
-                $show_trash,
1658
-                $show_create
1659
-            );
1660
-            $price_row++;
1661
-        }
1662
-        // filter $template_args
1663
-        $template_args = apply_filters(
1664
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1665
-            $template_args,
1666
-            $ticket_row,
1667
-            $ticket,
1668
-            $ticket_datetimes,
1669
-            $all_datetimes,
1670
-            $default,
1671
-            $all_tickets,
1672
-            $this->_is_creating_event
1673
-        );
1674
-        return EEH_Template::display_template(
1675
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1676
-            $template_args,
1677
-            true
1678
-        );
1679
-    }
1397
+	/**
1398
+	 * This generates the ticket row for tickets.
1399
+	 * This same method is used to generate both the actual rows and the js skeleton row
1400
+	 * (when default === true)
1401
+	 *
1402
+	 * @param int           $ticket_row       Represents the row number being generated.
1403
+	 * @param               $ticket
1404
+	 * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1405
+	 *                                        or empty for default
1406
+	 * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1407
+	 * @param bool          $default          Whether default row being generated or not.
1408
+	 * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1409
+	 *                                        (or empty in the case of defaults)
1410
+	 * @return mixed
1411
+	 * @throws InvalidArgumentException
1412
+	 * @throws InvalidInterfaceException
1413
+	 * @throws InvalidDataTypeException
1414
+	 * @throws DomainException
1415
+	 * @throws EE_Error
1416
+	 * @throws ReflectionException
1417
+	 */
1418
+	protected function _get_ticket_row(
1419
+		$ticket_row,
1420
+		$ticket,
1421
+		$ticket_datetimes,
1422
+		$all_datetimes,
1423
+		$default = false,
1424
+		$all_tickets = array()
1425
+	) {
1426
+		// if $ticket is not an instance of EE_Ticket then force default to true.
1427
+		$default = ! $ticket instanceof EE_Ticket ? true : $default;
1428
+		$prices = ! empty($ticket) && ! $default
1429
+			? $ticket->get_many_related(
1430
+				'Price',
1431
+				array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1432
+			)
1433
+			: array();
1434
+		// if there is only one price (which would be the base price)
1435
+		// or NO prices and this ticket is a default ticket,
1436
+		// let's just make sure there are no cached default prices on the object.
1437
+		// This is done by not including any query_params.
1438
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1439
+			$prices = $ticket->prices();
1440
+		}
1441
+		// check if we're dealing with a default ticket in which case
1442
+		// we don't want any starting_ticket_datetime_row values set
1443
+		// (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1444
+		// This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1445
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1446
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1447
+			? $ticket_datetimes[ $ticket->ID() ]
1448
+			: array();
1449
+		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1450
+		$base_price = $default ? null : $ticket->base_price();
1451
+		$count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1452
+		// breaking out complicated condition for ticket_status
1453
+		if ($default) {
1454
+			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1455
+		} else {
1456
+			$ticket_status_class = $ticket->is_default()
1457
+				? ' tkt-status-' . EE_Ticket::onsale
1458
+				: ' tkt-status-' . $ticket->ticket_status();
1459
+		}
1460
+		// breaking out complicated condition for TKT_taxable
1461
+		if ($default) {
1462
+			$TKT_taxable = '';
1463
+		} else {
1464
+			$TKT_taxable = $ticket->taxable()
1465
+				? ' checked'
1466
+				: '';
1467
+		}
1468
+		if ($default) {
1469
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1470
+		} elseif ($ticket->is_default()) {
1471
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1472
+		} else {
1473
+			$TKT_status = $ticket->ticket_status(true);
1474
+		}
1475
+		if ($default) {
1476
+			$TKT_min = '';
1477
+		} else {
1478
+			$TKT_min = $ticket->min();
1479
+			if ($TKT_min === -1 || $TKT_min === 0) {
1480
+				$TKT_min = '';
1481
+			}
1482
+		}
1483
+		$template_args = array(
1484
+			'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1485
+			'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1486
+			// on initial page load this will always be the correct order.
1487
+			'tkt_status_class'              => $ticket_status_class,
1488
+			'display_edit_tkt_row'          => ' style="display:none;"',
1489
+			'edit_tkt_expanded'             => '',
1490
+			'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1491
+			'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1492
+			'TKT_start_date'                => $default
1493
+				? ''
1494
+				: $ticket->get_date('TKT_start_date', $this->_date_time_format),
1495
+			'TKT_end_date'                  => $default
1496
+				? ''
1497
+				: $ticket->get_date('TKT_end_date', $this->_date_time_format),
1498
+			'TKT_status'                    => $TKT_status,
1499
+			'TKT_price'                     => $default
1500
+				? ''
1501
+				: EEH_Template::format_currency(
1502
+					$ticket->get_ticket_total_with_taxes(),
1503
+					false,
1504
+					false
1505
+				),
1506
+			'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1507
+			'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1508
+			'TKT_qty'                       => $default
1509
+				? ''
1510
+				: $ticket->get_pretty('TKT_qty', 'symbol'),
1511
+			'TKT_qty_for_input'             => $default
1512
+				? ''
1513
+				: $ticket->get_pretty('TKT_qty', 'input'),
1514
+			'TKT_uses'                      => $default
1515
+				? ''
1516
+				: $ticket->get_pretty('TKT_uses', 'input'),
1517
+			'TKT_min'                       => $TKT_min,
1518
+			'TKT_max'                       => $default
1519
+				? ''
1520
+				: $ticket->get_pretty('TKT_max', 'input'),
1521
+			'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1522
+			'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1523
+			'TKT_registrations'             => $default
1524
+				? 0
1525
+				: $ticket->count_registrations(
1526
+					array(
1527
+						array(
1528
+							'STS_ID' => array(
1529
+								'!=',
1530
+								EEM_Registration::status_id_incomplete,
1531
+							),
1532
+						),
1533
+					)
1534
+				),
1535
+			'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1536
+			'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1537
+			'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1538
+			'TKT_required'                  => $default ? 0 : $ticket->required(),
1539
+			'TKT_is_default_selector'       => '',
1540
+			'ticket_price_rows'             => '',
1541
+			'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1542
+				? ''
1543
+				: $base_price->get_pretty('PRC_amount', 'localized_float'),
1544
+			'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1545
+			'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1546
+				? ''
1547
+				: ' style="display:none;"',
1548
+			'show_price_mod_button'         => count($prices) > 1
1549
+											   || ($default && $count_price_mods > 0)
1550
+											   || (! $default && $ticket->deleted())
1551
+				? ' style="display:none;"'
1552
+				: '',
1553
+			'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1554
+			'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1555
+			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1556
+			'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1557
+			'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1558
+			'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1559
+			'TKT_taxable'                   => $TKT_taxable,
1560
+			'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1561
+				? ''
1562
+				: ' style="display:none"',
1563
+			'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1564
+			'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1565
+				$ticket_subtotal,
1566
+				false,
1567
+				false
1568
+			),
1569
+			'TKT_subtotal_amount'           => $ticket_subtotal,
1570
+			'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1571
+			'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1572
+			'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1573
+				? ' ticket-archived'
1574
+				: '',
1575
+			'trash_icon'                    => $ticket instanceof EE_Ticket
1576
+											   && $ticket->deleted()
1577
+											   && ! $ticket->is_permanently_deleteable()
1578
+				? 'dashicons dashicons-lock '
1579
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1580
+			'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1581
+				? ''
1582
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1583
+		);
1584
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1585
+			? ' style="display:none"'
1586
+			: '';
1587
+		// handle rows that should NOT be empty
1588
+		if (empty($template_args['TKT_start_date'])) {
1589
+			// if empty then the start date will be now.
1590
+			$template_args['TKT_start_date'] = date(
1591
+				$this->_date_time_format,
1592
+				current_time('timestamp')
1593
+			);
1594
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1595
+		}
1596
+		if (empty($template_args['TKT_end_date'])) {
1597
+			// get the earliest datetime (if present);
1598
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1599
+				? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1600
+					'Datetime',
1601
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1602
+				)
1603
+				: null;
1604
+			if (! empty($earliest_dtt)) {
1605
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1606
+					'DTT_EVT_start',
1607
+					$this->_date_time_format
1608
+				);
1609
+			} else {
1610
+				// default so let's just use what's been set for the default date-time which is 30 days from now.
1611
+				$template_args['TKT_end_date'] = date(
1612
+					$this->_date_time_format,
1613
+					mktime(
1614
+						24,
1615
+						0,
1616
+						0,
1617
+						date('m'),
1618
+						date('d') + 29,
1619
+						date('Y')
1620
+					)
1621
+				);
1622
+			}
1623
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1624
+		}
1625
+		// generate ticket_datetime items
1626
+		if (! $default) {
1627
+			$datetime_row = 1;
1628
+			foreach ($all_datetimes as $datetime) {
1629
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1630
+					$datetime_row,
1631
+					$ticket_row,
1632
+					$datetime,
1633
+					$ticket,
1634
+					$ticket_datetimes,
1635
+					$default
1636
+				);
1637
+				$datetime_row++;
1638
+			}
1639
+		}
1640
+		$price_row = 1;
1641
+		foreach ($prices as $price) {
1642
+			if (! $price instanceof EE_Price) {
1643
+				continue;
1644
+			}
1645
+			if ($price->is_base_price()) {
1646
+				$price_row++;
1647
+				continue;
1648
+			}
1649
+			$show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1650
+			$show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1651
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1652
+				$ticket_row,
1653
+				$price_row,
1654
+				$price,
1655
+				$default,
1656
+				$ticket,
1657
+				$show_trash,
1658
+				$show_create
1659
+			);
1660
+			$price_row++;
1661
+		}
1662
+		// filter $template_args
1663
+		$template_args = apply_filters(
1664
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1665
+			$template_args,
1666
+			$ticket_row,
1667
+			$ticket,
1668
+			$ticket_datetimes,
1669
+			$all_datetimes,
1670
+			$default,
1671
+			$all_tickets,
1672
+			$this->_is_creating_event
1673
+		);
1674
+		return EEH_Template::display_template(
1675
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1676
+			$template_args,
1677
+			true
1678
+		);
1679
+	}
1680 1680
 
1681 1681
 
1682
-    /**
1683
-     * @param int            $ticket_row
1684
-     * @param EE_Ticket|null $ticket
1685
-     * @return string
1686
-     * @throws DomainException
1687
-     * @throws EE_Error
1688
-     */
1689
-    protected function _get_tax_rows($ticket_row, $ticket)
1690
-    {
1691
-        $tax_rows = '';
1692
-        /** @var EE_Price[] $taxes */
1693
-        $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1694
-        foreach ($taxes as $tax) {
1695
-            $tax_added = $this->_get_tax_added($tax, $ticket);
1696
-            $template_args = array(
1697
-                'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1698
-                    ? ''
1699
-                    : ' style="display:none;"',
1700
-                'tax_id'            => $tax->ID(),
1701
-                'tkt_row'           => $ticket_row,
1702
-                'tax_label'         => $tax->get('PRC_name'),
1703
-                'tax_added'         => $tax_added,
1704
-                'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1705
-                'tax_amount'        => $tax->get('PRC_amount'),
1706
-            );
1707
-            $template_args = apply_filters(
1708
-                'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1709
-                $template_args,
1710
-                $ticket_row,
1711
-                $ticket,
1712
-                $this->_is_creating_event
1713
-            );
1714
-            $tax_rows .= EEH_Template::display_template(
1715
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1716
-                $template_args,
1717
-                true
1718
-            );
1719
-        }
1720
-        return $tax_rows;
1721
-    }
1682
+	/**
1683
+	 * @param int            $ticket_row
1684
+	 * @param EE_Ticket|null $ticket
1685
+	 * @return string
1686
+	 * @throws DomainException
1687
+	 * @throws EE_Error
1688
+	 */
1689
+	protected function _get_tax_rows($ticket_row, $ticket)
1690
+	{
1691
+		$tax_rows = '';
1692
+		/** @var EE_Price[] $taxes */
1693
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1694
+		foreach ($taxes as $tax) {
1695
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1696
+			$template_args = array(
1697
+				'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1698
+					? ''
1699
+					: ' style="display:none;"',
1700
+				'tax_id'            => $tax->ID(),
1701
+				'tkt_row'           => $ticket_row,
1702
+				'tax_label'         => $tax->get('PRC_name'),
1703
+				'tax_added'         => $tax_added,
1704
+				'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1705
+				'tax_amount'        => $tax->get('PRC_amount'),
1706
+			);
1707
+			$template_args = apply_filters(
1708
+				'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1709
+				$template_args,
1710
+				$ticket_row,
1711
+				$ticket,
1712
+				$this->_is_creating_event
1713
+			);
1714
+			$tax_rows .= EEH_Template::display_template(
1715
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1716
+				$template_args,
1717
+				true
1718
+			);
1719
+		}
1720
+		return $tax_rows;
1721
+	}
1722 1722
 
1723 1723
 
1724
-    /**
1725
-     * @param EE_Price       $tax
1726
-     * @param EE_Ticket|null $ticket
1727
-     * @return float|int
1728
-     * @throws EE_Error
1729
-     */
1730
-    protected function _get_tax_added(EE_Price $tax, $ticket)
1731
-    {
1732
-        $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1733
-        return $subtotal * $tax->get('PRC_amount') / 100;
1734
-    }
1724
+	/**
1725
+	 * @param EE_Price       $tax
1726
+	 * @param EE_Ticket|null $ticket
1727
+	 * @return float|int
1728
+	 * @throws EE_Error
1729
+	 */
1730
+	protected function _get_tax_added(EE_Price $tax, $ticket)
1731
+	{
1732
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1733
+		return $subtotal * $tax->get('PRC_amount') / 100;
1734
+	}
1735 1735
 
1736 1736
 
1737
-    /**
1738
-     * @param int            $ticket_row
1739
-     * @param int            $price_row
1740
-     * @param EE_Price|null  $price
1741
-     * @param bool           $default
1742
-     * @param EE_Ticket|null $ticket
1743
-     * @param bool           $show_trash
1744
-     * @param bool           $show_create
1745
-     * @return mixed
1746
-     * @throws InvalidArgumentException
1747
-     * @throws InvalidInterfaceException
1748
-     * @throws InvalidDataTypeException
1749
-     * @throws DomainException
1750
-     * @throws EE_Error
1751
-     * @throws ReflectionException
1752
-     */
1753
-    protected function _get_ticket_price_row(
1754
-        $ticket_row,
1755
-        $price_row,
1756
-        $price,
1757
-        $default,
1758
-        $ticket,
1759
-        $show_trash = true,
1760
-        $show_create = true
1761
-    ) {
1762
-        $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1763
-        $template_args = array(
1764
-            'tkt_row'               => $default && empty($ticket)
1765
-                ? 'TICKETNUM'
1766
-                : $ticket_row,
1767
-            'PRC_order'             => $default && empty($price)
1768
-                ? 'PRICENUM'
1769
-                : $price_row,
1770
-            'edit_prices_name'      => $default && empty($price)
1771
-                ? 'PRICENAMEATTR'
1772
-                : 'edit_prices',
1773
-            'price_type_selector'   => $default && empty($price)
1774
-                ? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1775
-                : $this->_get_price_type_selector(
1776
-                    $ticket_row,
1777
-                    $price_row,
1778
-                    $price,
1779
-                    $default,
1780
-                    $send_disabled
1781
-                ),
1782
-            'PRC_ID'                => $default && empty($price)
1783
-                ? 0
1784
-                : $price->ID(),
1785
-            'PRC_is_default'        => $default && empty($price)
1786
-                ? 0
1787
-                : $price->get('PRC_is_default'),
1788
-            'PRC_name'              => $default && empty($price)
1789
-                ? ''
1790
-                : $price->get('PRC_name'),
1791
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1792
-            'show_plus_or_minus'    => $default && empty($price)
1793
-                ? ''
1794
-                : ' style="display:none;"',
1795
-            'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1796
-                ? ' style="display:none;"'
1797
-                : '',
1798
-            'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1799
-                ? ' style="display:none;"'
1800
-                : '',
1801
-            'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1802
-                ? ' style="display:none"'
1803
-                : '',
1804
-            'PRC_amount'            => $default && empty($price)
1805
-                ? 0
1806
-                : $price->get_pretty('PRC_amount', 'localized_float'),
1807
-            'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1808
-                ? ' style="display:none;"'
1809
-                : '',
1810
-            'show_trash_icon'       => $show_trash
1811
-                ? ''
1812
-                : ' style="display:none;"',
1813
-            'show_create_button'    => $show_create
1814
-                ? ''
1815
-                : ' style="display:none;"',
1816
-            'PRC_desc'              => $default && empty($price)
1817
-                ? ''
1818
-                : $price->get('PRC_desc'),
1819
-            'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1820
-        );
1821
-        $template_args = apply_filters(
1822
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1823
-            $template_args,
1824
-            $ticket_row,
1825
-            $price_row,
1826
-            $price,
1827
-            $default,
1828
-            $ticket,
1829
-            $show_trash,
1830
-            $show_create,
1831
-            $this->_is_creating_event
1832
-        );
1833
-        return EEH_Template::display_template(
1834
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1835
-            $template_args,
1836
-            true
1837
-        );
1838
-    }
1737
+	/**
1738
+	 * @param int            $ticket_row
1739
+	 * @param int            $price_row
1740
+	 * @param EE_Price|null  $price
1741
+	 * @param bool           $default
1742
+	 * @param EE_Ticket|null $ticket
1743
+	 * @param bool           $show_trash
1744
+	 * @param bool           $show_create
1745
+	 * @return mixed
1746
+	 * @throws InvalidArgumentException
1747
+	 * @throws InvalidInterfaceException
1748
+	 * @throws InvalidDataTypeException
1749
+	 * @throws DomainException
1750
+	 * @throws EE_Error
1751
+	 * @throws ReflectionException
1752
+	 */
1753
+	protected function _get_ticket_price_row(
1754
+		$ticket_row,
1755
+		$price_row,
1756
+		$price,
1757
+		$default,
1758
+		$ticket,
1759
+		$show_trash = true,
1760
+		$show_create = true
1761
+	) {
1762
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1763
+		$template_args = array(
1764
+			'tkt_row'               => $default && empty($ticket)
1765
+				? 'TICKETNUM'
1766
+				: $ticket_row,
1767
+			'PRC_order'             => $default && empty($price)
1768
+				? 'PRICENUM'
1769
+				: $price_row,
1770
+			'edit_prices_name'      => $default && empty($price)
1771
+				? 'PRICENAMEATTR'
1772
+				: 'edit_prices',
1773
+			'price_type_selector'   => $default && empty($price)
1774
+				? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1775
+				: $this->_get_price_type_selector(
1776
+					$ticket_row,
1777
+					$price_row,
1778
+					$price,
1779
+					$default,
1780
+					$send_disabled
1781
+				),
1782
+			'PRC_ID'                => $default && empty($price)
1783
+				? 0
1784
+				: $price->ID(),
1785
+			'PRC_is_default'        => $default && empty($price)
1786
+				? 0
1787
+				: $price->get('PRC_is_default'),
1788
+			'PRC_name'              => $default && empty($price)
1789
+				? ''
1790
+				: $price->get('PRC_name'),
1791
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1792
+			'show_plus_or_minus'    => $default && empty($price)
1793
+				? ''
1794
+				: ' style="display:none;"',
1795
+			'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1796
+				? ' style="display:none;"'
1797
+				: '',
1798
+			'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1799
+				? ' style="display:none;"'
1800
+				: '',
1801
+			'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1802
+				? ' style="display:none"'
1803
+				: '',
1804
+			'PRC_amount'            => $default && empty($price)
1805
+				? 0
1806
+				: $price->get_pretty('PRC_amount', 'localized_float'),
1807
+			'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1808
+				? ' style="display:none;"'
1809
+				: '',
1810
+			'show_trash_icon'       => $show_trash
1811
+				? ''
1812
+				: ' style="display:none;"',
1813
+			'show_create_button'    => $show_create
1814
+				? ''
1815
+				: ' style="display:none;"',
1816
+			'PRC_desc'              => $default && empty($price)
1817
+				? ''
1818
+				: $price->get('PRC_desc'),
1819
+			'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1820
+		);
1821
+		$template_args = apply_filters(
1822
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1823
+			$template_args,
1824
+			$ticket_row,
1825
+			$price_row,
1826
+			$price,
1827
+			$default,
1828
+			$ticket,
1829
+			$show_trash,
1830
+			$show_create,
1831
+			$this->_is_creating_event
1832
+		);
1833
+		return EEH_Template::display_template(
1834
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1835
+			$template_args,
1836
+			true
1837
+		);
1838
+	}
1839 1839
 
1840 1840
 
1841
-    /**
1842
-     * @param int      $ticket_row
1843
-     * @param int      $price_row
1844
-     * @param EE_Price $price
1845
-     * @param bool     $default
1846
-     * @param bool     $disabled
1847
-     * @return mixed
1848
-     * @throws ReflectionException
1849
-     * @throws InvalidArgumentException
1850
-     * @throws InvalidInterfaceException
1851
-     * @throws InvalidDataTypeException
1852
-     * @throws DomainException
1853
-     * @throws EE_Error
1854
-     */
1855
-    protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1856
-    {
1857
-        if ($price->is_base_price()) {
1858
-            return $this->_get_base_price_template(
1859
-                $ticket_row,
1860
-                $price_row,
1861
-                $price,
1862
-                $default
1863
-            );
1864
-        }
1865
-        return $this->_get_price_modifier_template(
1866
-            $ticket_row,
1867
-            $price_row,
1868
-            $price,
1869
-            $default,
1870
-            $disabled
1871
-        );
1872
-    }
1841
+	/**
1842
+	 * @param int      $ticket_row
1843
+	 * @param int      $price_row
1844
+	 * @param EE_Price $price
1845
+	 * @param bool     $default
1846
+	 * @param bool     $disabled
1847
+	 * @return mixed
1848
+	 * @throws ReflectionException
1849
+	 * @throws InvalidArgumentException
1850
+	 * @throws InvalidInterfaceException
1851
+	 * @throws InvalidDataTypeException
1852
+	 * @throws DomainException
1853
+	 * @throws EE_Error
1854
+	 */
1855
+	protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1856
+	{
1857
+		if ($price->is_base_price()) {
1858
+			return $this->_get_base_price_template(
1859
+				$ticket_row,
1860
+				$price_row,
1861
+				$price,
1862
+				$default
1863
+			);
1864
+		}
1865
+		return $this->_get_price_modifier_template(
1866
+			$ticket_row,
1867
+			$price_row,
1868
+			$price,
1869
+			$default,
1870
+			$disabled
1871
+		);
1872
+	}
1873 1873
 
1874 1874
 
1875
-    /**
1876
-     * @param int      $ticket_row
1877
-     * @param int      $price_row
1878
-     * @param EE_Price $price
1879
-     * @param bool     $default
1880
-     * @return mixed
1881
-     * @throws DomainException
1882
-     * @throws EE_Error
1883
-     */
1884
-    protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1885
-    {
1886
-        $template_args = array(
1887
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1888
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1889
-            'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1890
-            'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1891
-            'price_selected_operator'   => '+',
1892
-            'price_selected_is_percent' => 0,
1893
-        );
1894
-        $template_args = apply_filters(
1895
-            'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1896
-            $template_args,
1897
-            $ticket_row,
1898
-            $price_row,
1899
-            $price,
1900
-            $default,
1901
-            $this->_is_creating_event
1902
-        );
1903
-        return EEH_Template::display_template(
1904
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1905
-            $template_args,
1906
-            true
1907
-        );
1908
-    }
1875
+	/**
1876
+	 * @param int      $ticket_row
1877
+	 * @param int      $price_row
1878
+	 * @param EE_Price $price
1879
+	 * @param bool     $default
1880
+	 * @return mixed
1881
+	 * @throws DomainException
1882
+	 * @throws EE_Error
1883
+	 */
1884
+	protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1885
+	{
1886
+		$template_args = array(
1887
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1888
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1889
+			'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1890
+			'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1891
+			'price_selected_operator'   => '+',
1892
+			'price_selected_is_percent' => 0,
1893
+		);
1894
+		$template_args = apply_filters(
1895
+			'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1896
+			$template_args,
1897
+			$ticket_row,
1898
+			$price_row,
1899
+			$price,
1900
+			$default,
1901
+			$this->_is_creating_event
1902
+		);
1903
+		return EEH_Template::display_template(
1904
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1905
+			$template_args,
1906
+			true
1907
+		);
1908
+	}
1909 1909
 
1910 1910
 
1911
-    /**
1912
-     * @param int      $ticket_row
1913
-     * @param int      $price_row
1914
-     * @param EE_Price $price
1915
-     * @param bool     $default
1916
-     * @param bool     $disabled
1917
-     * @return mixed
1918
-     * @throws ReflectionException
1919
-     * @throws InvalidArgumentException
1920
-     * @throws InvalidInterfaceException
1921
-     * @throws InvalidDataTypeException
1922
-     * @throws DomainException
1923
-     * @throws EE_Error
1924
-     */
1925
-    protected function _get_price_modifier_template(
1926
-        $ticket_row,
1927
-        $price_row,
1928
-        $price,
1929
-        $default,
1930
-        $disabled = false
1931
-    ) {
1932
-        $select_name = $default && ! $price instanceof EE_Price
1933
-            ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1934
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1935
-        /** @var EEM_Price_Type $price_type_model */
1936
-        $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1937
-        $price_types = $price_type_model->get_all(array(
1938
-            array(
1939
-                'OR' => array(
1940
-                    'PBT_ID'  => '2',
1941
-                    'PBT_ID*' => '3',
1942
-                ),
1943
-            ),
1944
-        ));
1945
-        $all_price_types = $default && ! $price instanceof EE_Price
1946
-            ? array(esc_html__('Select Modifier', 'event_espresso'))
1947
-            : array();
1948
-        $selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1949
-        $price_option_spans = '';
1950
-        // setup price types for selector
1951
-        foreach ($price_types as $price_type) {
1952
-            if (! $price_type instanceof EE_Price_Type) {
1953
-                continue;
1954
-            }
1955
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1956
-            // while we're in the loop let's setup the option spans used by js
1957
-            $span_args = array(
1958
-                'PRT_ID'         => $price_type->ID(),
1959
-                'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1960
-                'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1961
-            );
1962
-            $price_option_spans .= EEH_Template::display_template(
1963
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1964
-                $span_args,
1965
-                true
1966
-            );
1967
-        }
1968
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1969
-            : $select_name;
1970
-        $select_input = new EE_Select_Input(
1971
-            $all_price_types,
1972
-            array(
1973
-                'default'               => $selected_price_type_id,
1974
-                'html_name'             => $select_name,
1975
-                'html_class'            => 'edit-price-PRT_ID',
1976
-                'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1977
-            )
1978
-        );
1979
-        $price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1980
-        $price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1981
-        $price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1982
-        $price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1983
-        $template_args = array(
1984
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1985
-            'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1986
-            'price_modifier_selector'   => $select_input->get_html_for_input(),
1987
-            'main_name'                 => $select_name,
1988
-            'selected_price_type_id'    => $selected_price_type_id,
1989
-            'price_option_spans'        => $price_option_spans,
1990
-            'price_selected_operator'   => $price_selected_operator,
1991
-            'price_selected_is_percent' => $price_selected_is_percent,
1992
-            'disabled'                  => $disabled,
1993
-        );
1994
-        $template_args = apply_filters(
1995
-            'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1996
-            $template_args,
1997
-            $ticket_row,
1998
-            $price_row,
1999
-            $price,
2000
-            $default,
2001
-            $disabled,
2002
-            $this->_is_creating_event
2003
-        );
2004
-        return EEH_Template::display_template(
2005
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2006
-            $template_args,
2007
-            true
2008
-        );
2009
-    }
1911
+	/**
1912
+	 * @param int      $ticket_row
1913
+	 * @param int      $price_row
1914
+	 * @param EE_Price $price
1915
+	 * @param bool     $default
1916
+	 * @param bool     $disabled
1917
+	 * @return mixed
1918
+	 * @throws ReflectionException
1919
+	 * @throws InvalidArgumentException
1920
+	 * @throws InvalidInterfaceException
1921
+	 * @throws InvalidDataTypeException
1922
+	 * @throws DomainException
1923
+	 * @throws EE_Error
1924
+	 */
1925
+	protected function _get_price_modifier_template(
1926
+		$ticket_row,
1927
+		$price_row,
1928
+		$price,
1929
+		$default,
1930
+		$disabled = false
1931
+	) {
1932
+		$select_name = $default && ! $price instanceof EE_Price
1933
+			? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1934
+			: 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1935
+		/** @var EEM_Price_Type $price_type_model */
1936
+		$price_type_model = EE_Registry::instance()->load_model('Price_Type');
1937
+		$price_types = $price_type_model->get_all(array(
1938
+			array(
1939
+				'OR' => array(
1940
+					'PBT_ID'  => '2',
1941
+					'PBT_ID*' => '3',
1942
+				),
1943
+			),
1944
+		));
1945
+		$all_price_types = $default && ! $price instanceof EE_Price
1946
+			? array(esc_html__('Select Modifier', 'event_espresso'))
1947
+			: array();
1948
+		$selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1949
+		$price_option_spans = '';
1950
+		// setup price types for selector
1951
+		foreach ($price_types as $price_type) {
1952
+			if (! $price_type instanceof EE_Price_Type) {
1953
+				continue;
1954
+			}
1955
+			$all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1956
+			// while we're in the loop let's setup the option spans used by js
1957
+			$span_args = array(
1958
+				'PRT_ID'         => $price_type->ID(),
1959
+				'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1960
+				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1961
+			);
1962
+			$price_option_spans .= EEH_Template::display_template(
1963
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1964
+				$span_args,
1965
+				true
1966
+			);
1967
+		}
1968
+		$select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1969
+			: $select_name;
1970
+		$select_input = new EE_Select_Input(
1971
+			$all_price_types,
1972
+			array(
1973
+				'default'               => $selected_price_type_id,
1974
+				'html_name'             => $select_name,
1975
+				'html_class'            => 'edit-price-PRT_ID',
1976
+				'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1977
+			)
1978
+		);
1979
+		$price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1980
+		$price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1981
+		$price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1982
+		$price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1983
+		$template_args = array(
1984
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1985
+			'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1986
+			'price_modifier_selector'   => $select_input->get_html_for_input(),
1987
+			'main_name'                 => $select_name,
1988
+			'selected_price_type_id'    => $selected_price_type_id,
1989
+			'price_option_spans'        => $price_option_spans,
1990
+			'price_selected_operator'   => $price_selected_operator,
1991
+			'price_selected_is_percent' => $price_selected_is_percent,
1992
+			'disabled'                  => $disabled,
1993
+		);
1994
+		$template_args = apply_filters(
1995
+			'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1996
+			$template_args,
1997
+			$ticket_row,
1998
+			$price_row,
1999
+			$price,
2000
+			$default,
2001
+			$disabled,
2002
+			$this->_is_creating_event
2003
+		);
2004
+		return EEH_Template::display_template(
2005
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2006
+			$template_args,
2007
+			true
2008
+		);
2009
+	}
2010 2010
 
2011 2011
 
2012
-    /**
2013
-     * @param int              $datetime_row
2014
-     * @param int              $ticket_row
2015
-     * @param EE_Datetime|null $datetime
2016
-     * @param EE_Ticket|null   $ticket
2017
-     * @param array            $ticket_datetimes
2018
-     * @param bool             $default
2019
-     * @return mixed
2020
-     * @throws DomainException
2021
-     * @throws EE_Error
2022
-     */
2023
-    protected function _get_ticket_datetime_list_item(
2024
-        $datetime_row,
2025
-        $ticket_row,
2026
-        $datetime,
2027
-        $ticket,
2028
-        $ticket_datetimes = array(),
2029
-        $default
2030
-    ) {
2031
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2032
-            ? $ticket_datetimes[ $ticket->ID() ]
2033
-            : array();
2034
-        $template_args = array(
2035
-            'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2036
-                ? 'DTTNUM'
2037
-                : $datetime_row,
2038
-            'tkt_row'                  => $default
2039
-                ? 'TICKETNUM'
2040
-                : $ticket_row,
2041
-            'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2042
-                ? ' ticket-selected'
2043
-                : '',
2044
-            'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2045
-                ? ' checked'
2046
-                : '',
2047
-            'DTT_name'                 => $default && empty($datetime)
2048
-                ? 'DTTNAME'
2049
-                : $datetime->get_dtt_display_name(true),
2050
-            'tkt_status_class'         => '',
2051
-        );
2052
-        $template_args = apply_filters(
2053
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2054
-            $template_args,
2055
-            $datetime_row,
2056
-            $ticket_row,
2057
-            $datetime,
2058
-            $ticket,
2059
-            $ticket_datetimes,
2060
-            $default,
2061
-            $this->_is_creating_event
2062
-        );
2063
-        return EEH_Template::display_template(
2064
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2065
-            $template_args,
2066
-            true
2067
-        );
2068
-    }
2012
+	/**
2013
+	 * @param int              $datetime_row
2014
+	 * @param int              $ticket_row
2015
+	 * @param EE_Datetime|null $datetime
2016
+	 * @param EE_Ticket|null   $ticket
2017
+	 * @param array            $ticket_datetimes
2018
+	 * @param bool             $default
2019
+	 * @return mixed
2020
+	 * @throws DomainException
2021
+	 * @throws EE_Error
2022
+	 */
2023
+	protected function _get_ticket_datetime_list_item(
2024
+		$datetime_row,
2025
+		$ticket_row,
2026
+		$datetime,
2027
+		$ticket,
2028
+		$ticket_datetimes = array(),
2029
+		$default
2030
+	) {
2031
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2032
+			? $ticket_datetimes[ $ticket->ID() ]
2033
+			: array();
2034
+		$template_args = array(
2035
+			'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2036
+				? 'DTTNUM'
2037
+				: $datetime_row,
2038
+			'tkt_row'                  => $default
2039
+				? 'TICKETNUM'
2040
+				: $ticket_row,
2041
+			'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2042
+				? ' ticket-selected'
2043
+				: '',
2044
+			'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2045
+				? ' checked'
2046
+				: '',
2047
+			'DTT_name'                 => $default && empty($datetime)
2048
+				? 'DTTNAME'
2049
+				: $datetime->get_dtt_display_name(true),
2050
+			'tkt_status_class'         => '',
2051
+		);
2052
+		$template_args = apply_filters(
2053
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2054
+			$template_args,
2055
+			$datetime_row,
2056
+			$ticket_row,
2057
+			$datetime,
2058
+			$ticket,
2059
+			$ticket_datetimes,
2060
+			$default,
2061
+			$this->_is_creating_event
2062
+		);
2063
+		return EEH_Template::display_template(
2064
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2065
+			$template_args,
2066
+			true
2067
+		);
2068
+	}
2069 2069
 
2070 2070
 
2071
-    /**
2072
-     * @param array $all_datetimes
2073
-     * @param array $all_tickets
2074
-     * @return mixed
2075
-     * @throws ReflectionException
2076
-     * @throws InvalidArgumentException
2077
-     * @throws InvalidInterfaceException
2078
-     * @throws InvalidDataTypeException
2079
-     * @throws DomainException
2080
-     * @throws EE_Error
2081
-     */
2082
-    protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2083
-    {
2084
-        $template_args = array(
2085
-            'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2086
-                'DTTNUM',
2087
-                null,
2088
-                true,
2089
-                $all_datetimes
2090
-            ),
2091
-            'default_ticket_row'                       => $this->_get_ticket_row(
2092
-                'TICKETNUM',
2093
-                null,
2094
-                array(),
2095
-                array(),
2096
-                true
2097
-            ),
2098
-            'default_price_row'                        => $this->_get_ticket_price_row(
2099
-                'TICKETNUM',
2100
-                'PRICENUM',
2101
-                null,
2102
-                true,
2103
-                null
2104
-            ),
2105
-            'default_price_rows'                       => '',
2106
-            'default_base_price_amount'                => 0,
2107
-            'default_base_price_name'                  => '',
2108
-            'default_base_price_description'           => '',
2109
-            'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2110
-                'TICKETNUM',
2111
-                'PRICENUM',
2112
-                null,
2113
-                true
2114
-            ),
2115
-            'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2116
-                'DTTNUM',
2117
-                null,
2118
-                array(),
2119
-                array(),
2120
-                true
2121
-            ),
2122
-            'existing_available_datetime_tickets_list' => '',
2123
-            'existing_available_ticket_datetimes_list' => '',
2124
-            'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2125
-                'DTTNUM',
2126
-                'TICKETNUM',
2127
-                null,
2128
-                null,
2129
-                array(),
2130
-                true
2131
-            ),
2132
-            'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2133
-                'DTTNUM',
2134
-                'TICKETNUM',
2135
-                null,
2136
-                null,
2137
-                array(),
2138
-                true
2139
-            ),
2140
-        );
2141
-        $ticket_row = 1;
2142
-        foreach ($all_tickets as $ticket) {
2143
-            $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2144
-                'DTTNUM',
2145
-                $ticket_row,
2146
-                null,
2147
-                $ticket,
2148
-                array(),
2149
-                true
2150
-            );
2151
-            $ticket_row++;
2152
-        }
2153
-        $datetime_row = 1;
2154
-        foreach ($all_datetimes as $datetime) {
2155
-            $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2156
-                $datetime_row,
2157
-                'TICKETNUM',
2158
-                $datetime,
2159
-                null,
2160
-                array(),
2161
-                true
2162
-            );
2163
-            $datetime_row++;
2164
-        }
2165
-        /** @var EEM_Price $price_model */
2166
-        $price_model = EE_Registry::instance()->load_model('Price');
2167
-        $default_prices = $price_model->get_all_default_prices();
2168
-        $price_row = 1;
2169
-        foreach ($default_prices as $price) {
2170
-            if (! $price instanceof EE_Price) {
2171
-                continue;
2172
-            }
2173
-            if ($price->is_base_price()) {
2174
-                $template_args['default_base_price_amount'] = $price->get_pretty(
2175
-                    'PRC_amount',
2176
-                    'localized_float'
2177
-                );
2178
-                $template_args['default_base_price_name'] = $price->get('PRC_name');
2179
-                $template_args['default_base_price_description'] = $price->get('PRC_desc');
2180
-                $price_row++;
2181
-                continue;
2182
-            }
2183
-            $show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2184
-                             || count($default_prices) === 1);
2185
-            $show_create = ! (count($default_prices) > 1
2186
-                              && count($default_prices)
2187
-                                 !== $price_row);
2188
-            $template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2189
-                'TICKETNUM',
2190
-                $price_row,
2191
-                $price,
2192
-                true,
2193
-                null,
2194
-                $show_trash,
2195
-                $show_create
2196
-            );
2197
-            $price_row++;
2198
-        }
2199
-        $template_args = apply_filters(
2200
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2201
-            $template_args,
2202
-            $all_datetimes,
2203
-            $all_tickets,
2204
-            $this->_is_creating_event
2205
-        );
2206
-        return EEH_Template::display_template(
2207
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2208
-            $template_args,
2209
-            true
2210
-        );
2211
-    }
2071
+	/**
2072
+	 * @param array $all_datetimes
2073
+	 * @param array $all_tickets
2074
+	 * @return mixed
2075
+	 * @throws ReflectionException
2076
+	 * @throws InvalidArgumentException
2077
+	 * @throws InvalidInterfaceException
2078
+	 * @throws InvalidDataTypeException
2079
+	 * @throws DomainException
2080
+	 * @throws EE_Error
2081
+	 */
2082
+	protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2083
+	{
2084
+		$template_args = array(
2085
+			'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2086
+				'DTTNUM',
2087
+				null,
2088
+				true,
2089
+				$all_datetimes
2090
+			),
2091
+			'default_ticket_row'                       => $this->_get_ticket_row(
2092
+				'TICKETNUM',
2093
+				null,
2094
+				array(),
2095
+				array(),
2096
+				true
2097
+			),
2098
+			'default_price_row'                        => $this->_get_ticket_price_row(
2099
+				'TICKETNUM',
2100
+				'PRICENUM',
2101
+				null,
2102
+				true,
2103
+				null
2104
+			),
2105
+			'default_price_rows'                       => '',
2106
+			'default_base_price_amount'                => 0,
2107
+			'default_base_price_name'                  => '',
2108
+			'default_base_price_description'           => '',
2109
+			'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2110
+				'TICKETNUM',
2111
+				'PRICENUM',
2112
+				null,
2113
+				true
2114
+			),
2115
+			'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2116
+				'DTTNUM',
2117
+				null,
2118
+				array(),
2119
+				array(),
2120
+				true
2121
+			),
2122
+			'existing_available_datetime_tickets_list' => '',
2123
+			'existing_available_ticket_datetimes_list' => '',
2124
+			'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2125
+				'DTTNUM',
2126
+				'TICKETNUM',
2127
+				null,
2128
+				null,
2129
+				array(),
2130
+				true
2131
+			),
2132
+			'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2133
+				'DTTNUM',
2134
+				'TICKETNUM',
2135
+				null,
2136
+				null,
2137
+				array(),
2138
+				true
2139
+			),
2140
+		);
2141
+		$ticket_row = 1;
2142
+		foreach ($all_tickets as $ticket) {
2143
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2144
+				'DTTNUM',
2145
+				$ticket_row,
2146
+				null,
2147
+				$ticket,
2148
+				array(),
2149
+				true
2150
+			);
2151
+			$ticket_row++;
2152
+		}
2153
+		$datetime_row = 1;
2154
+		foreach ($all_datetimes as $datetime) {
2155
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2156
+				$datetime_row,
2157
+				'TICKETNUM',
2158
+				$datetime,
2159
+				null,
2160
+				array(),
2161
+				true
2162
+			);
2163
+			$datetime_row++;
2164
+		}
2165
+		/** @var EEM_Price $price_model */
2166
+		$price_model = EE_Registry::instance()->load_model('Price');
2167
+		$default_prices = $price_model->get_all_default_prices();
2168
+		$price_row = 1;
2169
+		foreach ($default_prices as $price) {
2170
+			if (! $price instanceof EE_Price) {
2171
+				continue;
2172
+			}
2173
+			if ($price->is_base_price()) {
2174
+				$template_args['default_base_price_amount'] = $price->get_pretty(
2175
+					'PRC_amount',
2176
+					'localized_float'
2177
+				);
2178
+				$template_args['default_base_price_name'] = $price->get('PRC_name');
2179
+				$template_args['default_base_price_description'] = $price->get('PRC_desc');
2180
+				$price_row++;
2181
+				continue;
2182
+			}
2183
+			$show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2184
+							 || count($default_prices) === 1);
2185
+			$show_create = ! (count($default_prices) > 1
2186
+							  && count($default_prices)
2187
+								 !== $price_row);
2188
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2189
+				'TICKETNUM',
2190
+				$price_row,
2191
+				$price,
2192
+				true,
2193
+				null,
2194
+				$show_trash,
2195
+				$show_create
2196
+			);
2197
+			$price_row++;
2198
+		}
2199
+		$template_args = apply_filters(
2200
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2201
+			$template_args,
2202
+			$all_datetimes,
2203
+			$all_tickets,
2204
+			$this->_is_creating_event
2205
+		);
2206
+		return EEH_Template::display_template(
2207
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2208
+			$template_args,
2209
+			true
2210
+		);
2211
+	}
2212 2212
 }
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             );
153 153
             $msg .= '</p><ul>';
154 154
             foreach ($format_validation as $error) {
155
-                $msg .= '<li>' . $error . '</li>';
155
+                $msg .= '<li>'.$error.'</li>';
156 156
             }
157 157
             $msg .= '</ul><p>';
158 158
             $msg .= sprintf(
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
         $this->_scripts_styles = array(
182 182
             'registers'   => array(
183 183
                 'ee-tickets-datetimes-css' => array(
184
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
184
+                    'url'  => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
185 185
                     'type' => 'css',
186 186
                 ),
187 187
                 'ee-dtt-ticket-metabox'    => array(
188
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
188
+                    'url'     => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
189 189
                     'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
190 190
                 ),
191 191
             ),
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                             'event_espresso'
210 210
                         ),
211 211
                         'cancel_button'           => '<button class="button--secondary ee-modal-cancel">'
212
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
212
+                                                     . esc_html__('Cancel', 'event_espresso').'</button>',
213 213
                         'close_button'            => '<button class="button--secondary ee-modal-cancel">'
214
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
214
+                                                     . esc_html__('Close', 'event_espresso').'</button>',
215 215
                         'single_warning_from_tkt' => esc_html__(
216 216
                             'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
217 217
                             'event_espresso'
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
                             'event_espresso'
222 222
                         ),
223 223
                         'dismiss_button'          => '<button class="button--secondary ee-modal-cancel">'
224
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
224
+                                                     . esc_html__('Dismiss', 'event_espresso').'</button>',
225 225
                     ),
226 226
                     'DTT_ERROR_MSG'         => array(
227 227
                         'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
314 314
             // trim all values to ensure any excess whitespace is removed.
315 315
             $datetime_data = array_map(
316
-                function ($datetime_data) {
316
+                function($datetime_data) {
317 317
                     return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
318 318
                 },
319 319
                 $datetime_data
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
             );
344 344
             // if we have an id then let's get existing object first and then set the new values.
345 345
             // Otherwise we instantiate a new object for save.
346
-            if (! empty($datetime_data['DTT_ID'])) {
346
+            if ( ! empty($datetime_data['DTT_ID'])) {
347 347
                 $datetime = EE_Registry::instance()
348 348
                                        ->load_model('Datetime', array($timezone))
349 349
                                        ->get_one_by_ID($datetime_data['DTT_ID']);
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
                 // after the add_relation_to() the autosave replaces it.
358 358
                 // We need to do this so we dont' TRASH the parent DTT.
359 359
                 // (save the ID for both key and value to avoid duplications)
360
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
360
+                $saved_dtt_ids[$datetime->ID()] = $datetime->ID();
361 361
             } else {
362 362
                 $datetime = EE_Registry::instance()->load_class(
363 363
                     'Datetime',
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
             // because it is possible there was a new one created for the autosave.
394 394
             // (save the ID for both key and value to avoid duplications)
395 395
             $DTT_ID = $datetime->ID();
396
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
397
-            $saved_dtt_objs[ $row ] = $datetime;
396
+            $saved_dtt_ids[$DTT_ID] = $DTT_ID;
397
+            $saved_dtt_objs[$row] = $datetime;
398 398
             // @todo if ANY of these updates fail then we want the appropriate global error message.
399 399
         }
400 400
         $event->save();
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
             $update_prices = $create_new_TKT = false;
459 459
             // figure out what datetimes were added to the ticket
460 460
             // and what datetimes were removed from the ticket in the session.
461
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
462
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
461
+            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
462
+            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]);
463 463
             $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
464 464
             $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
465 465
             // trim inputs to ensure any excess whitespace is removed.
466 466
             $tkt = array_map(
467
-                function ($ticket_data) {
467
+                function($ticket_data) {
468 468
                     return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
469 469
                 },
470 470
                 $tkt
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
                 ? $base_price
485 485
                 : $ticket_price;
486 486
             $base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
487
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
488
-                ? $data['edit_prices'][ $row ]
487
+            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row])
488
+                ? $data['edit_prices'][$row]
489 489
                 : array();
490 490
             $now = null;
491 491
             if (empty($tkt['TKT_start_date'])) {
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                 /**
498 498
                  * set the TKT_end_date to the first datetime attached to the ticket.
499 499
                  */
500
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
500
+                $first_dtt = $saved_datetimes[reset($tkt_dtt_rows)];
501 501
                 $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
502 502
             }
503 503
             $TKT_values = array(
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
             // need to make sue that the TKT_price is accurate after saving the prices.
633 633
             $ticket->ensure_TKT_Price_correct();
634 634
             // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
635
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
635
+            if ( ! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
636 636
                 $update_prices = true;
637 637
                 $new_default = clone $ticket;
638 638
                 $new_default->set('TKT_ID', 0);
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
                 // save new TKT
678 678
                 $new_tkt->save();
679 679
                 // add new ticket to array
680
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
680
+                $saved_tickets[$new_tkt->ID()] = $new_tkt;
681 681
                 do_action(
682 682
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
683 683
                     $new_tkt,
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
                 );
688 688
             } else {
689 689
                 // add tkt to saved tkts
690
-                $saved_tickets[ $ticket->ID() ] = $ticket;
690
+                $saved_tickets[$ticket->ID()] = $ticket;
691 691
                 do_action(
692 692
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
693 693
                     $ticket,
@@ -754,22 +754,22 @@  discard block
 block discarded – undo
754 754
         // to start we have to add the ticket to all the datetimes its supposed to be with,
755 755
         // and removing the ticket from datetimes it got removed from.
756 756
         // first let's add datetimes
757
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
757
+        if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
758 758
             foreach ($added_datetimes as $row_id) {
759 759
                 $row_id = (int) $row_id;
760
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
761
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
760
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
761
+                    $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
762 762
                 }
763 763
             }
764 764
         }
765 765
         // then remove datetimes
766
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
766
+        if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
767 767
             foreach ($removed_datetimes as $row_id) {
768 768
                 $row_id = (int) $row_id;
769 769
                 // its entirely possible that a datetime got deleted (instead of just removed from relationship.
770 770
                 // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
771
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
772
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
771
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
772
+                    $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
773 773
                 }
774 774
             }
775 775
         }
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
             );
882 882
         }
883 883
         // possibly need to save tkt
884
-        if (! $ticket->ID()) {
884
+        if ( ! $ticket->ID()) {
885 885
             $ticket->save();
886 886
         }
887 887
         foreach ($prices as $row => $prc) {
@@ -915,17 +915,17 @@  discard block
 block discarded – undo
915 915
                 }
916 916
             }
917 917
             $price->save();
918
-            $updated_prices[ $price->ID() ] = $price;
918
+            $updated_prices[$price->ID()] = $price;
919 919
             $ticket->_add_relation_to($price, 'Price');
920 920
         }
921 921
         // now let's remove any prices that got removed from the ticket
922
-        if (! empty($current_prices_on_ticket)) {
922
+        if ( ! empty($current_prices_on_ticket)) {
923 923
             $current = array_keys($current_prices_on_ticket);
924 924
             $updated = array_keys($updated_prices);
925 925
             $prices_to_remove = array_diff($current, $updated);
926
-            if (! empty($prices_to_remove)) {
926
+            if ( ! empty($prices_to_remove)) {
927 927
                 foreach ($prices_to_remove as $prc_id) {
928
-                    $p = $current_prices_on_ticket[ $prc_id ];
928
+                    $p = $current_prices_on_ticket[$prc_id];
929 929
                     $ticket->_remove_relation_to($p, 'Price');
930 930
                     // delete permanently the price
931 931
                     $p->delete_permanently();
@@ -1076,18 +1076,18 @@  discard block
 block discarded – undo
1076 1076
                 $TKT_ID = $ticket->get('TKT_ID');
1077 1077
                 $ticket_row = $ticket->get('TKT_row');
1078 1078
                 // we only want unique tickets in our final display!!
1079
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1079
+                if ( ! in_array($TKT_ID, $existing_ticket_ids, true)) {
1080 1080
                     $existing_ticket_ids[] = $TKT_ID;
1081 1081
                     $all_tickets[] = $ticket;
1082 1082
                 }
1083 1083
                 // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1084
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1084
+                $datetime_tickets[$DTT_ID][] = $ticket_row;
1085 1085
                 // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1086 1086
                 if (
1087
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1088
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1087
+                    ! isset($ticket_datetimes[$TKT_ID])
1088
+                    || ! in_array($datetime_row, $ticket_datetimes[$TKT_ID], true)
1089 1089
                 ) {
1090
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1090
+                    $ticket_datetimes[$TKT_ID][] = $datetime_row;
1091 1091
                 }
1092 1092
             }
1093 1093
             $datetime_row++;
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
         // sort $all_tickets by order
1099 1099
         usort(
1100 1100
             $all_tickets,
1101
-            function (EE_Ticket $a, EE_Ticket $b) {
1101
+            function(EE_Ticket $a, EE_Ticket $b) {
1102 1102
                 $a_order = (int) $a->get('TKT_order');
1103 1103
                 $b_order = (int) $b->get('TKT_order');
1104 1104
                 if ($a_order === $b_order) {
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
         );
1146 1146
 
1147 1147
         EEH_Template::display_template(
1148
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1148
+            PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php',
1149 1149
             $main_template_args
1150 1150
         );
1151 1151
     }
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
             'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1188 1188
         );
1189 1189
         return EEH_Template::display_template(
1190
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1190
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php',
1191 1191
             $dtt_display_template_args,
1192 1192
             true
1193 1193
         );
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
             $this->_is_creating_event
1257 1257
         );
1258 1258
         return EEH_Template::display_template(
1259
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1259
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php',
1260 1260
             $template_args,
1261 1261
             true
1262 1262
         );
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
             'DTT_ID'                            => $default ? '' : $datetime->ID(),
1298 1298
         );
1299 1299
         // need to setup the list items (but only if this isn't a default skeleton setup)
1300
-        if (! $default) {
1300
+        if ( ! $default) {
1301 1301
             $ticket_row = 1;
1302 1302
             foreach ($all_tickets as $ticket) {
1303 1303
                 $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
             $this->_is_creating_event
1324 1324
         );
1325 1325
         return EEH_Template::display_template(
1326
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1326
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php',
1327 1327
             $template_args,
1328 1328
             true
1329 1329
         );
@@ -1349,8 +1349,8 @@  discard block
 block discarded – undo
1349 1349
         $datetime_tickets = array(),
1350 1350
         $default
1351 1351
     ) {
1352
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1353
-            ? $datetime_tickets[ $datetime->ID() ]
1352
+        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[$datetime->ID()])
1353
+            ? $datetime_tickets[$datetime->ID()]
1354 1354
             : array();
1355 1355
         $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1356 1356
         $no_ticket = $default && empty($ticket);
@@ -1371,8 +1371,8 @@  discard block
 block discarded – undo
1371 1371
                 ? 'TKTNAME'
1372 1372
                 : $ticket->get('TKT_name'),
1373 1373
             'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1374
-                ? ' tkt-status-' . EE_Ticket::onsale
1375
-                : ' tkt-status-' . $ticket->ticket_status(),
1374
+                ? ' tkt-status-'.EE_Ticket::onsale
1375
+                : ' tkt-status-'.$ticket->ticket_status(),
1376 1376
         );
1377 1377
         // filter template args
1378 1378
         $template_args = apply_filters(
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
             $this->_is_creating_event
1388 1388
         );
1389 1389
         return EEH_Template::display_template(
1390
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1390
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php',
1391 1391
             $template_args,
1392 1392
             true
1393 1393
         );
@@ -1443,19 +1443,19 @@  discard block
 block discarded – undo
1443 1443
         // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1444 1444
         // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1445 1445
         $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1446
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1447
-            ? $ticket_datetimes[ $ticket->ID() ]
1446
+        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
1447
+            ? $ticket_datetimes[$ticket->ID()]
1448 1448
             : array();
1449 1449
         $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1450 1450
         $base_price = $default ? null : $ticket->base_price();
1451 1451
         $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1452 1452
         // breaking out complicated condition for ticket_status
1453 1453
         if ($default) {
1454
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1454
+            $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1455 1455
         } else {
1456 1456
             $ticket_status_class = $ticket->is_default()
1457
-                ? ' tkt-status-' . EE_Ticket::onsale
1458
-                : ' tkt-status-' . $ticket->ticket_status();
1457
+                ? ' tkt-status-'.EE_Ticket::onsale
1458
+                : ' tkt-status-'.$ticket->ticket_status();
1459 1459
         }
1460 1460
         // breaking out complicated condition for TKT_taxable
1461 1461
         if ($default) {
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
                 : ' style="display:none;"',
1548 1548
             'show_price_mod_button'         => count($prices) > 1
1549 1549
                                                || ($default && $count_price_mods > 0)
1550
-                                               || (! $default && $ticket->deleted())
1550
+                                               || ( ! $default && $ticket->deleted())
1551 1551
                 ? ' style="display:none;"'
1552 1552
                 : '',
1553 1553
             'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
                 $this->_date_time_format,
1592 1592
                 current_time('timestamp')
1593 1593
             );
1594
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1594
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1595 1595
         }
1596 1596
         if (empty($template_args['TKT_end_date'])) {
1597 1597
             // get the earliest datetime (if present);
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
                     array('order_by' => array('DTT_EVT_start' => 'ASC'))
1602 1602
                 )
1603 1603
                 : null;
1604
-            if (! empty($earliest_dtt)) {
1604
+            if ( ! empty($earliest_dtt)) {
1605 1605
                 $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1606 1606
                     'DTT_EVT_start',
1607 1607
                     $this->_date_time_format
@@ -1620,10 +1620,10 @@  discard block
 block discarded – undo
1620 1620
                     )
1621 1621
                 );
1622 1622
             }
1623
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1623
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1624 1624
         }
1625 1625
         // generate ticket_datetime items
1626
-        if (! $default) {
1626
+        if ( ! $default) {
1627 1627
             $datetime_row = 1;
1628 1628
             foreach ($all_datetimes as $datetime) {
1629 1629
                 $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
         }
1640 1640
         $price_row = 1;
1641 1641
         foreach ($prices as $price) {
1642
-            if (! $price instanceof EE_Price) {
1642
+            if ( ! $price instanceof EE_Price) {
1643 1643
                 continue;
1644 1644
             }
1645 1645
             if ($price->is_base_price()) {
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
             $this->_is_creating_event
1673 1673
         );
1674 1674
         return EEH_Template::display_template(
1675
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1675
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php',
1676 1676
             $template_args,
1677 1677
             true
1678 1678
         );
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
                 $this->_is_creating_event
1713 1713
             );
1714 1714
             $tax_rows .= EEH_Template::display_template(
1715
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1715
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php',
1716 1716
                 $template_args,
1717 1717
                 true
1718 1718
             );
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
             $this->_is_creating_event
1832 1832
         );
1833 1833
         return EEH_Template::display_template(
1834
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1834
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php',
1835 1835
             $template_args,
1836 1836
             true
1837 1837
         );
@@ -1901,7 +1901,7 @@  discard block
 block discarded – undo
1901 1901
             $this->_is_creating_event
1902 1902
         );
1903 1903
         return EEH_Template::display_template(
1904
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1904
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php',
1905 1905
             $template_args,
1906 1906
             true
1907 1907
         );
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
     ) {
1932 1932
         $select_name = $default && ! $price instanceof EE_Price
1933 1933
             ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1934
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1934
+            : 'edit_prices['.esc_attr($ticket_row).']['.esc_attr($price_row).'][PRT_ID]';
1935 1935
         /** @var EEM_Price_Type $price_type_model */
1936 1936
         $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1937 1937
         $price_types = $price_type_model->get_all(array(
@@ -1949,10 +1949,10 @@  discard block
 block discarded – undo
1949 1949
         $price_option_spans = '';
1950 1950
         // setup price types for selector
1951 1951
         foreach ($price_types as $price_type) {
1952
-            if (! $price_type instanceof EE_Price_Type) {
1952
+            if ( ! $price_type instanceof EE_Price_Type) {
1953 1953
                 continue;
1954 1954
             }
1955
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1955
+            $all_price_types[$price_type->ID()] = $price_type->get('PRT_name');
1956 1956
             // while we're in the loop let's setup the option spans used by js
1957 1957
             $span_args = array(
1958 1958
                 'PRT_ID'         => $price_type->ID(),
@@ -1960,12 +1960,12 @@  discard block
 block discarded – undo
1960 1960
                 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1961 1961
             );
1962 1962
             $price_option_spans .= EEH_Template::display_template(
1963
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1963
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php',
1964 1964
                 $span_args,
1965 1965
                 true
1966 1966
             );
1967 1967
         }
1968
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1968
+        $select_name = $disabled ? 'archive_price['.$ticket_row.']['.$price_row.'][PRT_ID]'
1969 1969
             : $select_name;
1970 1970
         $select_input = new EE_Select_Input(
1971 1971
             $all_price_types,
@@ -2002,7 +2002,7 @@  discard block
 block discarded – undo
2002 2002
             $this->_is_creating_event
2003 2003
         );
2004 2004
         return EEH_Template::display_template(
2005
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2005
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php',
2006 2006
             $template_args,
2007 2007
             true
2008 2008
         );
@@ -2028,8 +2028,8 @@  discard block
 block discarded – undo
2028 2028
         $ticket_datetimes = array(),
2029 2029
         $default
2030 2030
     ) {
2031
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2032
-            ? $ticket_datetimes[ $ticket->ID() ]
2031
+        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
2032
+            ? $ticket_datetimes[$ticket->ID()]
2033 2033
             : array();
2034 2034
         $template_args = array(
2035 2035
             'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
@@ -2061,7 +2061,7 @@  discard block
 block discarded – undo
2061 2061
             $this->_is_creating_event
2062 2062
         );
2063 2063
         return EEH_Template::display_template(
2064
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2064
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2065 2065
             $template_args,
2066 2066
             true
2067 2067
         );
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
         $default_prices = $price_model->get_all_default_prices();
2168 2168
         $price_row = 1;
2169 2169
         foreach ($default_prices as $price) {
2170
-            if (! $price instanceof EE_Price) {
2170
+            if ( ! $price instanceof EE_Price) {
2171 2171
                 continue;
2172 2172
             }
2173 2173
             if ($price->is_base_price()) {
@@ -2204,7 +2204,7 @@  discard block
 block discarded – undo
2204 2204
             $this->_is_creating_event
2205 2205
         );
2206 2206
         return EEH_Template::display_template(
2207
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2207
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php',
2208 2208
             $template_args,
2209 2209
             true
2210 2210
         );
Please login to merge, or discard this patch.
messages/templates/ee_msg_details_main_add_meta_box.template.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
  $header = $event_name
16
-    ? sprintf(
17
-        /* translators: %s: event name */
18
-        esc_html__('%1$s Custom Template', 'event_espresso'),
19
-        $event_name
20
-    )
21
-    : '';
22
-    ?>
16
+	? sprintf(
17
+		/* translators: %s: event name */
18
+		esc_html__('%1$s Custom Template', 'event_espresso'),
19
+		$event_name
20
+	)
21
+	: '';
22
+	?>
23 23
 
24 24
 <div id="admin-primary-mbox-dv" class="admin-primary-mbox-dv">
25 25
     <?php if ($header) : ?>
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
     >
36 36
         <input type="hidden" id="evt_id" name="EVT_ID" value="<?php echo absint($EVT_ID) ?: ''; ?>" />
37 37
         <?php
38
-        if (isset($hidden_fields)) {
39
-            echo wp_kses($hidden_fields, AllowedTags::getWithFormTags());
40
-        } ?>
38
+		if (isset($hidden_fields)) {
39
+			echo wp_kses($hidden_fields, AllowedTags::getWithFormTags());
40
+		} ?>
41 41
         <!--active_messengers -->
42 42
         <label for="MTP-messenger"><?php esc_html_e('Select Messenger', 'event_espresso'); ?></label>
43 43
         <select name="MTP_messenger" id="MTP-messenger">
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 2 patches
Indentation   +1407 added lines, -1407 removed lines patch added patch discarded remove patch
@@ -19,1424 +19,1424 @@
 block discarded – undo
19 19
  */
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22
-    /**
23
-     * @var EE_Core_Config
24
-     */
25
-    public $core_config;
26
-
27
-
28
-    /**
29
-     * Initialize basic properties.
30
-     */
31
-    protected function _init_page_props()
32
-    {
33
-        $this->page_slug        = GEN_SET_PG_SLUG;
34
-        $this->page_label       = GEN_SET_LABEL;
35
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
36
-        $this->_admin_base_path = GEN_SET_ADMIN;
37
-    }
38
-
39
-
40
-    /**
41
-     * Set ajax hooks
42
-     */
43
-    protected function _ajax_hooks()
44
-    {
45
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
46
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
47
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
48
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
49
-    }
50
-
51
-
52
-    /**
53
-     * More page properties initialization.
54
-     */
55
-    protected function _define_page_props()
56
-    {
57
-        $this->_admin_page_title = GEN_SET_LABEL;
58
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
59
-    }
60
-
61
-
62
-    /**
63
-     * Set page routes property.
64
-     */
65
-    protected function _set_page_routes()
66
-    {
67
-        $this->_page_routes = [
68
-            'critical_pages'                => [
69
-                'func'       => '_espresso_page_settings',
70
-                'capability' => 'manage_options',
71
-            ],
72
-            'update_espresso_page_settings' => [
73
-                'func'       => '_update_espresso_page_settings',
74
-                'capability' => 'manage_options',
75
-                'noheader'   => true,
76
-            ],
77
-            'default'                       => [
78
-                'func'       => '_your_organization_settings',
79
-                'capability' => 'manage_options',
80
-            ],
81
-
82
-            'update_your_organization_settings' => [
83
-                'func'       => '_update_your_organization_settings',
84
-                'capability' => 'manage_options',
85
-                'noheader'   => true,
86
-            ],
87
-
88
-            'admin_option_settings' => [
89
-                'func'       => '_admin_option_settings',
90
-                'capability' => 'manage_options',
91
-            ],
92
-
93
-            'update_admin_option_settings' => [
94
-                'func'       => '_update_admin_option_settings',
95
-                'capability' => 'manage_options',
96
-                'noheader'   => true,
97
-            ],
98
-
99
-            'country_settings' => [
100
-                'func'       => '_country_settings',
101
-                'capability' => 'manage_options',
102
-            ],
103
-
104
-            'update_country_settings' => [
105
-                'func'       => '_update_country_settings',
106
-                'capability' => 'manage_options',
107
-                'noheader'   => true,
108
-            ],
109
-
110
-            'display_country_settings' => [
111
-                'func'       => 'display_country_settings',
112
-                'capability' => 'manage_options',
113
-                'noheader'   => true,
114
-            ],
115
-
116
-            'add_new_state' => [
117
-                'func'       => 'add_new_state',
118
-                'capability' => 'manage_options',
119
-                'noheader'   => true,
120
-            ],
121
-
122
-            'delete_state'            => [
123
-                'func'       => 'delete_state',
124
-                'capability' => 'manage_options',
125
-                'noheader'   => true,
126
-            ],
127
-            'privacy_settings'        => [
128
-                'func'       => 'privacySettings',
129
-                'capability' => 'manage_options',
130
-            ],
131
-            'update_privacy_settings' => [
132
-                'func'               => 'updatePrivacySettings',
133
-                'capability'         => 'manage_options',
134
-                'noheader'           => true,
135
-                'headers_sent_route' => 'privacy_settings',
136
-            ],
137
-        ];
138
-    }
139
-
140
-
141
-    /**
142
-     * Set page configuration property
143
-     */
144
-    protected function _set_page_config()
145
-    {
146
-        $this->_page_config = [
147
-            'critical_pages'        => [
148
-                'nav'           => [
149
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
150
-                    'order' => 50,
151
-                ],
152
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
153
-                'help_tabs'     => [
154
-                    'general_settings_critical_pages_help_tab' => [
155
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
156
-                        'filename' => 'general_settings_critical_pages',
157
-                    ],
158
-                ],
159
-                'require_nonce' => false,
160
-            ],
161
-            'default'               => [
162
-                'nav'           => [
163
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
164
-                    'order' => 20,
165
-                ],
166
-                'help_tabs'     => [
167
-                    'general_settings_your_organization_help_tab' => [
168
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
169
-                        'filename' => 'general_settings_your_organization',
170
-                    ],
171
-                ],
172
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
173
-                'require_nonce' => false,
174
-            ],
175
-            'admin_option_settings' => [
176
-                'nav'           => [
177
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
178
-                    'order' => 60,
179
-                ],
180
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
181
-                'help_tabs'     => [
182
-                    'general_settings_admin_options_help_tab' => [
183
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
184
-                        'filename' => 'general_settings_admin_options',
185
-                    ],
186
-                ],
187
-                'require_nonce' => false,
188
-            ],
189
-            'country_settings'      => [
190
-                'nav'           => [
191
-                    'label' => esc_html__('Countries', 'event_espresso'),
192
-                    'order' => 70,
193
-                ],
194
-                'help_tabs'     => [
195
-                    'general_settings_countries_help_tab' => [
196
-                        'title'    => esc_html__('Countries', 'event_espresso'),
197
-                        'filename' => 'general_settings_countries',
198
-                    ],
199
-                ],
200
-                'require_nonce' => false,
201
-            ],
202
-            'privacy_settings'      => [
203
-                'nav'           => [
204
-                    'label' => esc_html__('Privacy', 'event_espresso'),
205
-                    'order' => 80,
206
-                ],
207
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
208
-                'require_nonce' => false,
209
-            ],
210
-        ];
211
-    }
212
-
213
-
214
-    protected function _add_screen_options()
215
-    {
216
-    }
217
-
218
-
219
-    protected function _add_feature_pointers()
220
-    {
221
-    }
222
-
223
-
224
-    /**
225
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
226
-     */
227
-    public function load_scripts_styles()
228
-    {
229
-        // styles
230
-        wp_enqueue_style('espresso-ui-theme');
231
-        // scripts
232
-        wp_enqueue_script('ee_admin_js');
233
-    }
234
-
235
-
236
-    /**
237
-     * Execute logic running on `admin_init`
238
-     */
239
-    public function admin_init()
240
-    {
241
-        $this->core_config = EE_Registry::instance()->CFG->core;
242
-
243
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
244
-            esc_html__(
245
-                'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
246
-                'event_espresso'
247
-            )
248
-        );
249
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
250
-            esc_html__(
251
-                'An error occurred! Please refresh the page and try again.',
252
-                'event_espresso'
253
-            )
254
-        );
255
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
256
-            esc_html__(
257
-                'Are you sure you want to delete this State / Province?',
258
-                'event_espresso'
259
-            )
260
-        );
261
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
262
-            'admin-ajax.php?page=espresso_general_settings',
263
-            is_ssl() ? 'https://' : 'http://'
264
-        );
265
-    }
266
-
267
-
268
-    public function admin_notices()
269
-    {
270
-    }
271
-
272
-
273
-    public function admin_footer_scripts()
274
-    {
275
-    }
276
-
277
-
278
-    /**
279
-     * Enqueue scripts and styles for the default route.
280
-     */
281
-    public function load_scripts_styles_default()
282
-    {
283
-        // styles
284
-        wp_enqueue_style('thickbox');
285
-        // scripts
286
-        wp_enqueue_script('media-upload');
287
-        wp_enqueue_script('thickbox');
288
-        wp_register_script(
289
-            'organization_settings',
290
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
291
-            ['jquery', 'media-upload', 'thickbox'],
292
-            EVENT_ESPRESSO_VERSION,
293
-            true
294
-        );
295
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
296
-        wp_enqueue_script('organization_settings');
297
-        wp_enqueue_style('organization-css');
298
-        $confirm_image_delete = [
299
-            'text' => wp_strip_all_tags(
300
-                esc_html__(
301
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
302
-                    'event_espresso'
303
-                )
304
-            ),
305
-        ];
306
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
-    }
308
-
309
-
310
-    /**
311
-     * Enqueue scripts and styles for the country settings route.
312
-     */
313
-    public function load_scripts_styles_country_settings()
314
-    {
315
-        // scripts
316
-        wp_register_script(
317
-            'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
-            ['ee_admin_js'],
320
-            EVENT_ESPRESSO_VERSION,
321
-            true
322
-        );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
324
-        wp_enqueue_script('gen_settings_countries');
325
-        wp_enqueue_style('organization-css');
326
-    }
327
-
328
-
329
-    /*************        Espresso Pages        *************/
330
-    /**
331
-     * _espresso_page_settings
332
-     *
333
-     * @throws EE_Error
334
-     * @throws DomainException
335
-     * @throws DomainException
336
-     * @throws InvalidDataTypeException
337
-     * @throws InvalidArgumentException
338
-     */
339
-    protected function _espresso_page_settings()
340
-    {
341
-        // Check to make sure all of the main pages are set up properly,
342
-        // if not create the default pages and display an admin notice
343
-        EEH_Activation::verify_default_pages_exist();
344
-        $this->_transient_garbage_collection();
345
-
346
-        $this->_template_args['values']             = $this->_yes_no_values;
347
-
348
-        $this->_template_args['reg_page_id']        = $this->core_config->reg_page_id ?? null;
349
-        $this->_template_args['reg_page_obj']       = isset($this->core_config->reg_page_id)
350
-            ? get_post($this->core_config->reg_page_id)
351
-            : false;
352
-
353
-        $this->_template_args['txn_page_id']        = $this->core_config->txn_page_id ?? null;
354
-        $this->_template_args['txn_page_obj']       = isset($this->core_config->txn_page_id)
355
-            ? get_post($this->core_config->txn_page_id)
356
-            : false;
357
-
358
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
359
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
360
-            ? get_post($this->core_config->thank_you_page_id)
361
-            : false;
362
-
363
-        $this->_template_args['cancel_page_id']     = $this->core_config->cancel_page_id ?? null;
364
-        $this->_template_args['cancel_page_obj']    = isset($this->core_config->cancel_page_id)
365
-            ? get_post($this->core_config->cancel_page_id)
366
-            : false;
367
-
368
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
369
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
370
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
372
-            $this->_template_args,
373
-            true
374
-        );
375
-        $this->display_admin_page_with_sidebar();
376
-    }
377
-
378
-
379
-    /**
380
-     * Handler for updating espresso page settings.
381
-     *
382
-     * @throws EE_Error
383
-     */
384
-    protected function _update_espresso_page_settings()
385
-    {
386
-        // capture incoming request data && set page IDs
387
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
388
-            'reg_page_id',
389
-            $this->core_config->reg_page_id,
390
-            DataType::INT
391
-        );
392
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
393
-            'txn_page_id',
394
-            $this->core_config->txn_page_id,
395
-            DataType::INT
396
-        );
397
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
398
-            'thank_you_page_id',
399
-            $this->core_config->thank_you_page_id,
400
-            DataType::INT
401
-        );
402
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
403
-            'cancel_page_id',
404
-            $this->core_config->cancel_page_id,
405
-            DataType::INT
406
-        );
407
-
408
-        $this->core_config = apply_filters(
409
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
410
-            $this->core_config,
411
-            $this->request->requestParams()
412
-        );
413
-
414
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
415
-        $this->_redirect_after_action(
416
-            $this->_update_espresso_configuration(
417
-                $what,
418
-                $this->core_config,
419
-                __FILE__,
420
-                __FUNCTION__,
421
-                __LINE__
422
-            ),
423
-            $what,
424
-            '',
425
-            [
426
-                'action' => 'critical_pages',
427
-            ],
428
-            true
429
-        );
430
-    }
431
-
432
-
433
-    /*************        Your Organization        *************/
434
-
435
-
436
-    /**
437
-     * @throws DomainException
438
-     * @throws EE_Error
439
-     * @throws InvalidArgumentException
440
-     * @throws InvalidDataTypeException
441
-     * @throws InvalidInterfaceException
442
-     */
443
-    protected function _your_organization_settings()
444
-    {
445
-        $this->_template_args['admin_page_content'] = '';
446
-        try {
447
-            /** @var OrganizationSettings $organization_settings_form */
448
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
449
-
450
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
451
-                $organization_settings_form->display(),
452
-                '',
453
-                'padding'
454
-            );
455
-        } catch (Exception $e) {
456
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
457
-        }
458
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
459
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
460
-        $this->display_admin_page_with_sidebar();
461
-    }
462
-
463
-
464
-    /**
465
-     * Handler for updating organization settings.
466
-     *
467
-     * @throws EE_Error
468
-     */
469
-    protected function _update_your_organization_settings()
470
-    {
471
-        try {
472
-            /** @var OrganizationSettings $organization_settings_form */
473
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
474
-
475
-            $success = $organization_settings_form->process($this->request->requestParams());
476
-
477
-            EE_Registry::instance()->CFG = apply_filters(
478
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
479
-                EE_Registry::instance()->CFG
480
-            );
481
-        } catch (Exception $e) {
482
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
483
-            $success = false;
484
-        }
485
-
486
-        if ($success) {
487
-            $success = $this->_update_espresso_configuration(
488
-                esc_html__('Your Organization Settings', 'event_espresso'),
489
-                EE_Registry::instance()->CFG,
490
-                __FILE__,
491
-                __FUNCTION__,
492
-                __LINE__
493
-            );
494
-        }
495
-
496
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
497
-    }
498
-
499
-
500
-
501
-    /*************        Admin Options        *************/
502
-
503
-
504
-    /**
505
-     * _admin_option_settings
506
-     *
507
-     * @throws EE_Error
508
-     * @throws LogicException
509
-     */
510
-    protected function _admin_option_settings()
511
-    {
512
-        $this->_template_args['admin_page_content'] = '';
513
-        try {
514
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
515
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
516
-            $this->_template_args['values'] = $this->_yes_no_values;
517
-            // also need to account for the do_action that was in the old template
518
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
519
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
520
-                $admin_options_settings_form->display(),
521
-                '',
522
-                'padding'
523
-            );
524
-        } catch (Exception $e) {
525
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
526
-        }
527
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
528
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
529
-        $this->display_admin_page_with_sidebar();
530
-    }
531
-
532
-
533
-    /**
534
-     * _update_admin_option_settings
535
-     *
536
-     * @throws EE_Error
537
-     * @throws InvalidDataTypeException
538
-     * @throws InvalidFormSubmissionException
539
-     * @throws InvalidArgumentException
540
-     * @throws LogicException
541
-     */
542
-    protected function _update_admin_option_settings()
543
-    {
544
-        try {
545
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
546
-            $admin_options_settings_form->process(
547
-                $this->request->getRequestParam(
548
-                    $admin_options_settings_form->slug(),
549
-                    [],
550
-                    DataType::STRING,
551
-                    true
552
-                )
553
-            );
554
-            EE_Registry::instance()->CFG->admin = apply_filters(
555
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
556
-                EE_Registry::instance()->CFG->admin
557
-            );
558
-        } catch (Exception $e) {
559
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
560
-        }
561
-        $this->_redirect_after_action(
562
-            apply_filters(
563
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
564
-                $this->_update_espresso_configuration(
565
-                    esc_html__('Admin Options', 'event_espresso'),
566
-                    EE_Registry::instance()->CFG->admin,
567
-                    __FILE__,
568
-                    __FUNCTION__,
569
-                    __LINE__
570
-                )
571
-            ),
572
-            esc_html__('Admin Options', 'event_espresso'),
573
-            'updated',
574
-            ['action' => 'admin_option_settings']
575
-        );
576
-    }
577
-
578
-
579
-    /*************        Countries        *************/
580
-
581
-
582
-    /**
583
-     * @param string|null $default
584
-     * @return string
585
-     */
586
-    protected function getCountryISO(?string $default = null): string
587
-    {
588
-        $default = $default ?? $this->getCountryIsoForSite();
589
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
590
-        return strtoupper($CNT_ISO);
591
-    }
592
-
593
-
594
-    /**
595
-     * @return string
596
-     */
597
-    protected function getCountryIsoForSite(): string
598
-    {
599
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
600
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
601
-            : 'US';
602
-    }
603
-
604
-
605
-    /**
606
-     * @param string          $CNT_ISO
607
-     * @param EE_Country|null $country
608
-     * @return EE_Base_Class|EE_Country
609
-     * @throws EE_Error
610
-     * @throws InvalidArgumentException
611
-     * @throws InvalidDataTypeException
612
-     * @throws InvalidInterfaceException
613
-     * @throws ReflectionException
614
-     */
615
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
616
-    {
617
-        /** @var EE_Country $country */
618
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
619
-            ? $country
620
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
621
-    }
622
-
623
-
624
-    /**
625
-     * Output Country Settings view.
626
-     *
627
-     * @throws DomainException
628
-     * @throws EE_Error
629
-     * @throws InvalidArgumentException
630
-     * @throws InvalidDataTypeException
631
-     * @throws InvalidInterfaceException
632
-     * @throws ReflectionException
633
-     */
634
-    protected function _country_settings()
635
-    {
636
-        $CNT_ISO = $this->getCountryISO();
637
-
638
-        $this->_template_args['values']    = $this->_yes_no_values;
639
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
640
-            EE_Question::new_instance(
641
-                [
642
-                  'QST_ID'           => 0,
643
-                  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
644
-                  'QST_system'       => 'admin-country',
645
-                ]
646
-            ),
647
-            EE_Answer::new_instance(
648
-                [
649
-                    'ANS_ID'    => 0,
650
-                    'ANS_value' => $CNT_ISO,
651
-                ]
652
-            ),
653
-            [
654
-                'input_id'       => 'country',
655
-                'input_name'     => 'country',
656
-                'input_prefix'   => '',
657
-                'append_qstn_id' => false,
658
-            ]
659
-        );
660
-
661
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
662
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
663
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
664
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
665
-            $country->ID(),
666
-            $country
667
-        );
668
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
669
-            $country->ID(),
670
-            $country
671
-        );
672
-        $this->_template_args['CNT_name_for_site']        = $country->name();
673
-
674
-        $this->_set_add_edit_form_tags('update_country_settings');
675
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
676
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
677
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
678
-            $this->_template_args,
679
-            true
680
-        );
681
-        $this->display_admin_page_with_no_sidebar();
682
-    }
683
-
684
-
685
-    /**
686
-     * @param string          $CNT_ISO
687
-     * @param EE_Country|null $country
688
-     * @return string
689
-     * @throws DomainException
690
-     * @throws EE_Error
691
-     * @throws InvalidArgumentException
692
-     * @throws InvalidDataTypeException
693
-     * @throws InvalidInterfaceException
694
-     * @throws ReflectionException
695
-     */
696
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
697
-    {
698
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
699
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
700
-
701
-        if (! $CNT_ISO) {
702
-            return '';
703
-        }
704
-
705
-        // for ajax
706
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
707
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
708
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
709
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
710
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
711
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
712
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
713
-
714
-        $country_input_types            = [
715
-            'CNT_active'      => [
716
-                'type'             => 'RADIO_BTN',
717
-                'input_name'       => "cntry[$CNT_ISO]",
718
-                'class'            => '',
719
-                'options'          => $this->_yes_no_values,
720
-                'use_desc_4_label' => true,
721
-            ],
722
-            'CNT_ISO'         => [
723
-                'type'       => 'TEXT',
724
-                'input_name' => "cntry[$CNT_ISO]",
725
-                'class'      => 'ee-input-width--small',
726
-            ],
727
-            'CNT_ISO3'        => [
728
-                'type'       => 'TEXT',
729
-                'input_name' => "cntry[$CNT_ISO]",
730
-                'class'      => 'ee-input-width--small',
731
-            ],
732
-            // 'RGN_ID'          => [
733
-            //     'type'       => 'TEXT',
734
-            //     'input_name' => "cntry[$CNT_ISO]",
735
-            //     'class'      => 'ee-input-width--small',
736
-            // ],
737
-            'CNT_name'        => [
738
-                'type'       => 'TEXT',
739
-                'input_name' => "cntry[$CNT_ISO]",
740
-                'class'      => 'ee-input-width--big',
741
-            ],
742
-            'CNT_cur_code'    => [
743
-                'type'       => 'TEXT',
744
-                'input_name' => "cntry[$CNT_ISO]",
745
-                'class'      => 'ee-input-width--small',
746
-                'disabled'   => $CNT_cur_disabled,
747
-            ],
748
-            'CNT_cur_single'  => [
749
-                'type'       => 'TEXT',
750
-                'input_name' => "cntry[$CNT_ISO]",
751
-                'class'      => 'ee-input-width--reg',
752
-                'disabled'   => $CNT_cur_disabled,
753
-            ],
754
-            'CNT_cur_plural'  => [
755
-                'type'       => 'TEXT',
756
-                'input_name' => "cntry[$CNT_ISO]",
757
-                'class'      => 'ee-input-width--reg',
758
-                'disabled'   => $CNT_cur_disabled,
759
-            ],
760
-            'CNT_cur_sign'    => [
761
-                'type'         => 'TEXT',
762
-                'input_name'   => "cntry[$CNT_ISO]",
763
-                'class'        => 'ee-input-width--small',
764
-                'htmlentities' => false,
765
-                'disabled'     => $CNT_cur_disabled,
766
-            ],
767
-            'CNT_cur_sign_b4' => [
768
-                'type'             => 'RADIO_BTN',
769
-                'input_name'       => "cntry[$CNT_ISO]",
770
-                'class'            => '',
771
-                'options'          => $this->_yes_no_values,
772
-                'use_desc_4_label' => true,
773
-                'disabled'         => $CNT_cur_disabled,
774
-            ],
775
-            'CNT_cur_dec_plc' => [
776
-                'type'       => 'RADIO_BTN',
777
-                'input_name' => "cntry[$CNT_ISO]",
778
-                'class'      => '',
779
-                'options'    => [
780
-                    ['id' => 0, 'text' => ''],
781
-                    ['id' => 1, 'text' => ''],
782
-                    ['id' => 2, 'text' => ''],
783
-                    ['id' => 3, 'text' => ''],
784
-                ],
785
-                'disabled'   => $CNT_cur_disabled,
786
-            ],
787
-            'CNT_cur_dec_mrk' => [
788
-                'type'             => 'RADIO_BTN',
789
-                'input_name'       => "cntry[$CNT_ISO]",
790
-                'class'            => '',
791
-                'options'          => [
792
-                    [
793
-                        'id'   => ',',
794
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
795
-                    ],
796
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
797
-                ],
798
-                'use_desc_4_label' => true,
799
-                'disabled'         => $CNT_cur_disabled,
800
-            ],
801
-            'CNT_cur_thsnds'  => [
802
-                'type'             => 'RADIO_BTN',
803
-                'input_name'       => "cntry[$CNT_ISO]",
804
-                'class'            => '',
805
-                'options'          => [
806
-                    [
807
-                        'id'   => ',',
808
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
809
-                    ],
810
-                    [
811
-                        'id'   => '.',
812
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
813
-                    ],
814
-                    [
815
-                        'id'   => '&nbsp;',
816
-                        'text' => esc_html__('(space)', 'event_espresso'),
817
-                    ],
818
-                ],
819
-                'use_desc_4_label' => true,
820
-                'disabled'         => $CNT_cur_disabled,
821
-            ],
822
-            'CNT_tel_code'    => [
823
-                'type'       => 'TEXT',
824
-                'input_name' => "cntry[$CNT_ISO]",
825
-                'class'      => 'ee-input-width--small',
826
-            ],
827
-            'CNT_is_EU'       => [
828
-                'type'             => 'RADIO_BTN',
829
-                'input_name'       => "cntry[$CNT_ISO]",
830
-                'class'            => '',
831
-                'options'          => $this->_yes_no_values,
832
-                'use_desc_4_label' => true,
833
-            ],
834
-        ];
835
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
836
-            $country,
837
-            $country_input_types
838
-        );
839
-        $country_details_settings       = EEH_Template::display_template(
840
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
841
-            $this->_template_args,
842
-            true
843
-        );
844
-
845
-        if (defined('DOING_AJAX')) {
846
-            $notices = EE_Error::get_notices(false, false, false);
847
-            echo wp_json_encode(
848
-                [
849
-                    'return_data' => $country_details_settings,
850
-                    'success'     => $notices['success'],
851
-                    'errors'      => $notices['errors'],
852
-                ]
853
-            );
854
-            die();
855
-        }
856
-        return $country_details_settings;
857
-    }
858
-
859
-
860
-    /**
861
-     * @param string          $CNT_ISO
862
-     * @param EE_Country|null $country
863
-     * @return string
864
-     * @throws DomainException
865
-     * @throws EE_Error
866
-     * @throws InvalidArgumentException
867
-     * @throws InvalidDataTypeException
868
-     * @throws InvalidInterfaceException
869
-     * @throws ReflectionException
870
-     */
871
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
872
-    {
873
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
874
-        if (! $CNT_ISO) {
875
-            return '';
876
-        }
877
-        // for ajax
878
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
879
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
880
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
881
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
882
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
883
-        if (empty($states)) {
884
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
885
-            $countrySubRegionDao = $this->loader->getShared(
886
-                'EventEspresso\core\services\address\CountrySubRegionDao'
887
-            );
888
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
889
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
890
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
891
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
892
-                }
893
-            }
894
-        }
895
-        if (is_array($states)) {
896
-            foreach ($states as $STA_ID => $state) {
897
-                if ($state instanceof EE_State) {
898
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
899
-                        $state,
900
-                        [
901
-                            'STA_abbrev' => [
902
-                                'type'             => 'TEXT',
903
-                                'label'            => esc_html__('Code', 'event_espresso'),
904
-                                'input_name'       => "states[$STA_ID]",
905
-                                'class'            => 'ee-input-width--tiny',
906
-                                'add_mobile_label' => true,
907
-                            ],
908
-                            'STA_name'   => [
909
-                                'type'             => 'TEXT',
910
-                                'label'            => esc_html__('Name', 'event_espresso'),
911
-                                'input_name'       => "states[$STA_ID]",
912
-                                'class'            => 'ee-input-width--big',
913
-                                'add_mobile_label' => true,
914
-                            ],
915
-                            'STA_active' => [
916
-                                'type'             => 'RADIO_BTN',
917
-                                'label'            => esc_html__('State Appears in Dropdown Select Lists', 'event_espresso'),
918
-                                'input_name'       => "states[$STA_ID]",
919
-                                'options'          => $this->_yes_no_values,
920
-                                'use_desc_4_label' => true,
921
-                                'add_mobile_label' => true,
922
-                            ],
923
-                        ]
924
-                    );
925
-
926
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
927
-                        [
928
-                            'action'     => 'delete_state',
929
-                            'STA_ID'     => $STA_ID,
930
-                            'CNT_ISO'    => $CNT_ISO,
931
-                            'STA_abbrev' => $state->abbrev(),
932
-                        ],
933
-                        GEN_SET_ADMIN_URL
934
-                    );
935
-
936
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
937
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
938
-                }
939
-            }
940
-        } else {
941
-            $this->_template_args['states'] = false;
942
-        }
943
-
944
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
945
-            ['action' => 'add_new_state'],
946
-            GEN_SET_ADMIN_URL
947
-        );
948
-
949
-        $state_details_settings = EEH_Template::display_template(
950
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
951
-            $this->_template_args,
952
-            true
953
-        );
954
-
955
-        if (defined('DOING_AJAX')) {
956
-            $notices = EE_Error::get_notices(false, false, false);
957
-            echo wp_json_encode(
958
-                [
959
-                    'return_data' => $state_details_settings,
960
-                    'success'     => $notices['success'],
961
-                    'errors'      => $notices['errors'],
962
-                ]
963
-            );
964
-            die();
965
-        }
966
-        return $state_details_settings;
967
-    }
968
-
969
-
970
-    /**
971
-     * @return void
972
-     * @throws EE_Error
973
-     * @throws InvalidArgumentException
974
-     * @throws InvalidDataTypeException
975
-     * @throws InvalidInterfaceException
976
-     * @throws ReflectionException
977
-     */
978
-    public function add_new_state()
979
-    {
980
-        $success = true;
981
-        $CNT_ISO = $this->getCountryISO('');
982
-        if (! $CNT_ISO) {
983
-            EE_Error::add_error(
984
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
985
-                __FILE__,
986
-                __FUNCTION__,
987
-                __LINE__
988
-            );
989
-            $success = false;
990
-        }
991
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
992
-        if (! $STA_abbrev) {
993
-            EE_Error::add_error(
994
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
995
-                __FILE__,
996
-                __FUNCTION__,
997
-                __LINE__
998
-            );
999
-            $success = false;
1000
-        }
1001
-        $STA_name = $this->request->getRequestParam('STA_name');
1002
-        if (! $STA_name) {
1003
-            EE_Error::add_error(
1004
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1005
-                __FILE__,
1006
-                __FUNCTION__,
1007
-                __LINE__
1008
-            );
1009
-            $success = false;
1010
-        }
1011
-
1012
-        if ($success) {
1013
-            $cols_n_values = [
1014
-                'CNT_ISO'    => $CNT_ISO,
1015
-                'STA_abbrev' => $STA_abbrev,
1016
-                'STA_name'   => $STA_name,
1017
-                'STA_active' => true,
1018
-            ];
1019
-            $success       = EEM_State::instance()->insert($cols_n_values);
1020
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1021
-        }
1022
-
1023
-        if (defined('DOING_AJAX')) {
1024
-            $notices = EE_Error::get_notices(false, false, false);
1025
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1026
-            die();
1027
-        }
1028
-        $this->_redirect_after_action(
1029
-            $success,
1030
-            esc_html__('State', 'event_espresso'),
1031
-            'added',
1032
-            ['action' => 'country_settings']
1033
-        );
1034
-    }
1035
-
1036
-
1037
-    /**
1038
-     * @return void
1039
-     * @throws EE_Error
1040
-     * @throws InvalidArgumentException
1041
-     * @throws InvalidDataTypeException
1042
-     * @throws InvalidInterfaceException
1043
-     * @throws ReflectionException
1044
-     */
1045
-    public function delete_state()
1046
-    {
1047
-        $CNT_ISO    = $this->getCountryISO();
1048
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1049
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1050
-
1051
-        if (! $STA_ID) {
1052
-            EE_Error::add_error(
1053
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1054
-                __FILE__,
1055
-                __FUNCTION__,
1056
-                __LINE__
1057
-            );
1058
-            return;
1059
-        }
1060
-
1061
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1062
-        if ($success !== false) {
1063
-            do_action(
1064
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1065
-                $CNT_ISO,
1066
-                $STA_ID,
1067
-                ['STA_abbrev' => $STA_abbrev]
1068
-            );
1069
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1070
-        }
1071
-        if (defined('DOING_AJAX')) {
1072
-            $notices                = EE_Error::get_notices(false);
1073
-            $notices['return_data'] = true;
1074
-            echo wp_json_encode($notices);
1075
-            die();
1076
-        }
1077
-        $this->_redirect_after_action(
1078
-            $success,
1079
-            esc_html__('State', 'event_espresso'),
1080
-            'deleted',
1081
-            ['action' => 'country_settings']
1082
-        );
1083
-    }
1084
-
1085
-
1086
-    /**
1087
-     * @return void
1088
-     * @throws EE_Error
1089
-     * @throws InvalidArgumentException
1090
-     * @throws InvalidDataTypeException
1091
-     * @throws InvalidInterfaceException
1092
-     * @throws ReflectionException
1093
-     */
1094
-    protected function _update_country_settings()
1095
-    {
1096
-        $CNT_ISO = $this->getCountryISO();
1097
-        if (! $CNT_ISO) {
1098
-            EE_Error::add_error(
1099
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1100
-                __FILE__,
1101
-                __FUNCTION__,
1102
-                __LINE__
1103
-            );
1104
-            return;
1105
-        }
1106
-
1107
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1108
-
1109
-        $cols_n_values                    = [];
1110
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1111
-            $this->request->getRequestParam('cntry', '', $country->ISO3())
1112
-        );
1113
-        $cols_n_values['CNT_name']        =
1114
-            $this->request->getRequestParam("cntry[$CNT_ISO][CNT_name]", $country->name());
1115
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1116
-            $this->request->getRequestParam(
1117
-                "cntry[$CNT_ISO][CNT_cur_code]",
1118
-                $country->currency_code()
1119
-            )
1120
-        );
1121
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1122
-            "cntry[$CNT_ISO][CNT_cur_single]",
1123
-            $country->currency_name_single()
1124
-        );
1125
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1126
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1127
-            $country->currency_name_plural()
1128
-        );
1129
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1130
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1131
-            $country->currency_sign()
1132
-        );
1133
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1134
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1135
-            $country->currency_sign_before(),
1136
-            DataType::BOOL
1137
-        );
1138
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1139
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1140
-            $country->currency_decimal_places()
1141
-        );
1142
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1143
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1144
-            $country->currency_decimal_mark()
1145
-        );
1146
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1147
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1148
-            $country->currency_thousands_separator()
1149
-        );
1150
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1151
-            "cntry[$CNT_ISO][CNT_tel_code]",
1152
-            $country->telephoneCode()
1153
-        );
1154
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1155
-            "cntry[$CNT_ISO][CNT_active]",
1156
-            $country->isActive(),
1157
-            DataType::BOOL
1158
-        );
1159
-
1160
-        // allow filtering of country data
1161
-        $cols_n_values = apply_filters(
1162
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1163
-            $cols_n_values
1164
-        );
1165
-
1166
-        // where values
1167
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1168
-        // run the update
1169
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1170
-
1171
-        // allow filtering of states data
1172
-        $states = apply_filters(
1173
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1174
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1175
-        );
1176
-
1177
-        if (! empty($states) && $success !== false) {
1178
-            // loop thru state data ( looks like : states[75][STA_name] )
1179
-            foreach ($states as $STA_ID => $state) {
1180
-                $cols_n_values = [
1181
-                    'CNT_ISO'    => $CNT_ISO,
1182
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1183
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1184
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1185
-                ];
1186
-                // where values
1187
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1188
-                // run the update
1189
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1190
-                if ($success !== false) {
1191
-                    do_action(
1192
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1193
-                        $CNT_ISO,
1194
-                        $STA_ID,
1195
-                        $cols_n_values
1196
-                    );
1197
-                }
1198
-            }
1199
-        }
1200
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1201
-        if (
1202
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1203
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1204
-        ) {
1205
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1206
-            EE_Registry::instance()->CFG->update_espresso_config();
1207
-        }
1208
-
1209
-        if ($success !== false) {
1210
-            EE_Error::add_success(
1211
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1212
-            );
1213
-        }
1214
-        $this->_redirect_after_action(
1215
-            $success,
1216
-            '',
1217
-            '',
1218
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1219
-            true
1220
-        );
1221
-    }
1222
-
1223
-
1224
-    /**
1225
-     * form_form_field_label_wrap
1226
-     *
1227
-     * @param string $label
1228
-     * @return string
1229
-     */
1230
-    public function country_form_field_label_wrap(string $label): string
1231
-    {
1232
-        return '
22
+	/**
23
+	 * @var EE_Core_Config
24
+	 */
25
+	public $core_config;
26
+
27
+
28
+	/**
29
+	 * Initialize basic properties.
30
+	 */
31
+	protected function _init_page_props()
32
+	{
33
+		$this->page_slug        = GEN_SET_PG_SLUG;
34
+		$this->page_label       = GEN_SET_LABEL;
35
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
36
+		$this->_admin_base_path = GEN_SET_ADMIN;
37
+	}
38
+
39
+
40
+	/**
41
+	 * Set ajax hooks
42
+	 */
43
+	protected function _ajax_hooks()
44
+	{
45
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
46
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
47
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
48
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
49
+	}
50
+
51
+
52
+	/**
53
+	 * More page properties initialization.
54
+	 */
55
+	protected function _define_page_props()
56
+	{
57
+		$this->_admin_page_title = GEN_SET_LABEL;
58
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
59
+	}
60
+
61
+
62
+	/**
63
+	 * Set page routes property.
64
+	 */
65
+	protected function _set_page_routes()
66
+	{
67
+		$this->_page_routes = [
68
+			'critical_pages'                => [
69
+				'func'       => '_espresso_page_settings',
70
+				'capability' => 'manage_options',
71
+			],
72
+			'update_espresso_page_settings' => [
73
+				'func'       => '_update_espresso_page_settings',
74
+				'capability' => 'manage_options',
75
+				'noheader'   => true,
76
+			],
77
+			'default'                       => [
78
+				'func'       => '_your_organization_settings',
79
+				'capability' => 'manage_options',
80
+			],
81
+
82
+			'update_your_organization_settings' => [
83
+				'func'       => '_update_your_organization_settings',
84
+				'capability' => 'manage_options',
85
+				'noheader'   => true,
86
+			],
87
+
88
+			'admin_option_settings' => [
89
+				'func'       => '_admin_option_settings',
90
+				'capability' => 'manage_options',
91
+			],
92
+
93
+			'update_admin_option_settings' => [
94
+				'func'       => '_update_admin_option_settings',
95
+				'capability' => 'manage_options',
96
+				'noheader'   => true,
97
+			],
98
+
99
+			'country_settings' => [
100
+				'func'       => '_country_settings',
101
+				'capability' => 'manage_options',
102
+			],
103
+
104
+			'update_country_settings' => [
105
+				'func'       => '_update_country_settings',
106
+				'capability' => 'manage_options',
107
+				'noheader'   => true,
108
+			],
109
+
110
+			'display_country_settings' => [
111
+				'func'       => 'display_country_settings',
112
+				'capability' => 'manage_options',
113
+				'noheader'   => true,
114
+			],
115
+
116
+			'add_new_state' => [
117
+				'func'       => 'add_new_state',
118
+				'capability' => 'manage_options',
119
+				'noheader'   => true,
120
+			],
121
+
122
+			'delete_state'            => [
123
+				'func'       => 'delete_state',
124
+				'capability' => 'manage_options',
125
+				'noheader'   => true,
126
+			],
127
+			'privacy_settings'        => [
128
+				'func'       => 'privacySettings',
129
+				'capability' => 'manage_options',
130
+			],
131
+			'update_privacy_settings' => [
132
+				'func'               => 'updatePrivacySettings',
133
+				'capability'         => 'manage_options',
134
+				'noheader'           => true,
135
+				'headers_sent_route' => 'privacy_settings',
136
+			],
137
+		];
138
+	}
139
+
140
+
141
+	/**
142
+	 * Set page configuration property
143
+	 */
144
+	protected function _set_page_config()
145
+	{
146
+		$this->_page_config = [
147
+			'critical_pages'        => [
148
+				'nav'           => [
149
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
150
+					'order' => 50,
151
+				],
152
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
153
+				'help_tabs'     => [
154
+					'general_settings_critical_pages_help_tab' => [
155
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
156
+						'filename' => 'general_settings_critical_pages',
157
+					],
158
+				],
159
+				'require_nonce' => false,
160
+			],
161
+			'default'               => [
162
+				'nav'           => [
163
+					'label' => esc_html__('Your Organization', 'event_espresso'),
164
+					'order' => 20,
165
+				],
166
+				'help_tabs'     => [
167
+					'general_settings_your_organization_help_tab' => [
168
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
169
+						'filename' => 'general_settings_your_organization',
170
+					],
171
+				],
172
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
173
+				'require_nonce' => false,
174
+			],
175
+			'admin_option_settings' => [
176
+				'nav'           => [
177
+					'label' => esc_html__('Admin Options', 'event_espresso'),
178
+					'order' => 60,
179
+				],
180
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
181
+				'help_tabs'     => [
182
+					'general_settings_admin_options_help_tab' => [
183
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
184
+						'filename' => 'general_settings_admin_options',
185
+					],
186
+				],
187
+				'require_nonce' => false,
188
+			],
189
+			'country_settings'      => [
190
+				'nav'           => [
191
+					'label' => esc_html__('Countries', 'event_espresso'),
192
+					'order' => 70,
193
+				],
194
+				'help_tabs'     => [
195
+					'general_settings_countries_help_tab' => [
196
+						'title'    => esc_html__('Countries', 'event_espresso'),
197
+						'filename' => 'general_settings_countries',
198
+					],
199
+				],
200
+				'require_nonce' => false,
201
+			],
202
+			'privacy_settings'      => [
203
+				'nav'           => [
204
+					'label' => esc_html__('Privacy', 'event_espresso'),
205
+					'order' => 80,
206
+				],
207
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
208
+				'require_nonce' => false,
209
+			],
210
+		];
211
+	}
212
+
213
+
214
+	protected function _add_screen_options()
215
+	{
216
+	}
217
+
218
+
219
+	protected function _add_feature_pointers()
220
+	{
221
+	}
222
+
223
+
224
+	/**
225
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
226
+	 */
227
+	public function load_scripts_styles()
228
+	{
229
+		// styles
230
+		wp_enqueue_style('espresso-ui-theme');
231
+		// scripts
232
+		wp_enqueue_script('ee_admin_js');
233
+	}
234
+
235
+
236
+	/**
237
+	 * Execute logic running on `admin_init`
238
+	 */
239
+	public function admin_init()
240
+	{
241
+		$this->core_config = EE_Registry::instance()->CFG->core;
242
+
243
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
244
+			esc_html__(
245
+				'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
246
+				'event_espresso'
247
+			)
248
+		);
249
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
250
+			esc_html__(
251
+				'An error occurred! Please refresh the page and try again.',
252
+				'event_espresso'
253
+			)
254
+		);
255
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
256
+			esc_html__(
257
+				'Are you sure you want to delete this State / Province?',
258
+				'event_espresso'
259
+			)
260
+		);
261
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
262
+			'admin-ajax.php?page=espresso_general_settings',
263
+			is_ssl() ? 'https://' : 'http://'
264
+		);
265
+	}
266
+
267
+
268
+	public function admin_notices()
269
+	{
270
+	}
271
+
272
+
273
+	public function admin_footer_scripts()
274
+	{
275
+	}
276
+
277
+
278
+	/**
279
+	 * Enqueue scripts and styles for the default route.
280
+	 */
281
+	public function load_scripts_styles_default()
282
+	{
283
+		// styles
284
+		wp_enqueue_style('thickbox');
285
+		// scripts
286
+		wp_enqueue_script('media-upload');
287
+		wp_enqueue_script('thickbox');
288
+		wp_register_script(
289
+			'organization_settings',
290
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
291
+			['jquery', 'media-upload', 'thickbox'],
292
+			EVENT_ESPRESSO_VERSION,
293
+			true
294
+		);
295
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
296
+		wp_enqueue_script('organization_settings');
297
+		wp_enqueue_style('organization-css');
298
+		$confirm_image_delete = [
299
+			'text' => wp_strip_all_tags(
300
+				esc_html__(
301
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
302
+					'event_espresso'
303
+				)
304
+			),
305
+		];
306
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
+	}
308
+
309
+
310
+	/**
311
+	 * Enqueue scripts and styles for the country settings route.
312
+	 */
313
+	public function load_scripts_styles_country_settings()
314
+	{
315
+		// scripts
316
+		wp_register_script(
317
+			'gen_settings_countries',
318
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
+			['ee_admin_js'],
320
+			EVENT_ESPRESSO_VERSION,
321
+			true
322
+		);
323
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
324
+		wp_enqueue_script('gen_settings_countries');
325
+		wp_enqueue_style('organization-css');
326
+	}
327
+
328
+
329
+	/*************        Espresso Pages        *************/
330
+	/**
331
+	 * _espresso_page_settings
332
+	 *
333
+	 * @throws EE_Error
334
+	 * @throws DomainException
335
+	 * @throws DomainException
336
+	 * @throws InvalidDataTypeException
337
+	 * @throws InvalidArgumentException
338
+	 */
339
+	protected function _espresso_page_settings()
340
+	{
341
+		// Check to make sure all of the main pages are set up properly,
342
+		// if not create the default pages and display an admin notice
343
+		EEH_Activation::verify_default_pages_exist();
344
+		$this->_transient_garbage_collection();
345
+
346
+		$this->_template_args['values']             = $this->_yes_no_values;
347
+
348
+		$this->_template_args['reg_page_id']        = $this->core_config->reg_page_id ?? null;
349
+		$this->_template_args['reg_page_obj']       = isset($this->core_config->reg_page_id)
350
+			? get_post($this->core_config->reg_page_id)
351
+			: false;
352
+
353
+		$this->_template_args['txn_page_id']        = $this->core_config->txn_page_id ?? null;
354
+		$this->_template_args['txn_page_obj']       = isset($this->core_config->txn_page_id)
355
+			? get_post($this->core_config->txn_page_id)
356
+			: false;
357
+
358
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
359
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
360
+			? get_post($this->core_config->thank_you_page_id)
361
+			: false;
362
+
363
+		$this->_template_args['cancel_page_id']     = $this->core_config->cancel_page_id ?? null;
364
+		$this->_template_args['cancel_page_obj']    = isset($this->core_config->cancel_page_id)
365
+			? get_post($this->core_config->cancel_page_id)
366
+			: false;
367
+
368
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
369
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
370
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
372
+			$this->_template_args,
373
+			true
374
+		);
375
+		$this->display_admin_page_with_sidebar();
376
+	}
377
+
378
+
379
+	/**
380
+	 * Handler for updating espresso page settings.
381
+	 *
382
+	 * @throws EE_Error
383
+	 */
384
+	protected function _update_espresso_page_settings()
385
+	{
386
+		// capture incoming request data && set page IDs
387
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
388
+			'reg_page_id',
389
+			$this->core_config->reg_page_id,
390
+			DataType::INT
391
+		);
392
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
393
+			'txn_page_id',
394
+			$this->core_config->txn_page_id,
395
+			DataType::INT
396
+		);
397
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
398
+			'thank_you_page_id',
399
+			$this->core_config->thank_you_page_id,
400
+			DataType::INT
401
+		);
402
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
403
+			'cancel_page_id',
404
+			$this->core_config->cancel_page_id,
405
+			DataType::INT
406
+		);
407
+
408
+		$this->core_config = apply_filters(
409
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
410
+			$this->core_config,
411
+			$this->request->requestParams()
412
+		);
413
+
414
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
415
+		$this->_redirect_after_action(
416
+			$this->_update_espresso_configuration(
417
+				$what,
418
+				$this->core_config,
419
+				__FILE__,
420
+				__FUNCTION__,
421
+				__LINE__
422
+			),
423
+			$what,
424
+			'',
425
+			[
426
+				'action' => 'critical_pages',
427
+			],
428
+			true
429
+		);
430
+	}
431
+
432
+
433
+	/*************        Your Organization        *************/
434
+
435
+
436
+	/**
437
+	 * @throws DomainException
438
+	 * @throws EE_Error
439
+	 * @throws InvalidArgumentException
440
+	 * @throws InvalidDataTypeException
441
+	 * @throws InvalidInterfaceException
442
+	 */
443
+	protected function _your_organization_settings()
444
+	{
445
+		$this->_template_args['admin_page_content'] = '';
446
+		try {
447
+			/** @var OrganizationSettings $organization_settings_form */
448
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
449
+
450
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
451
+				$organization_settings_form->display(),
452
+				'',
453
+				'padding'
454
+			);
455
+		} catch (Exception $e) {
456
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
457
+		}
458
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
459
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
460
+		$this->display_admin_page_with_sidebar();
461
+	}
462
+
463
+
464
+	/**
465
+	 * Handler for updating organization settings.
466
+	 *
467
+	 * @throws EE_Error
468
+	 */
469
+	protected function _update_your_organization_settings()
470
+	{
471
+		try {
472
+			/** @var OrganizationSettings $organization_settings_form */
473
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
474
+
475
+			$success = $organization_settings_form->process($this->request->requestParams());
476
+
477
+			EE_Registry::instance()->CFG = apply_filters(
478
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
479
+				EE_Registry::instance()->CFG
480
+			);
481
+		} catch (Exception $e) {
482
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
483
+			$success = false;
484
+		}
485
+
486
+		if ($success) {
487
+			$success = $this->_update_espresso_configuration(
488
+				esc_html__('Your Organization Settings', 'event_espresso'),
489
+				EE_Registry::instance()->CFG,
490
+				__FILE__,
491
+				__FUNCTION__,
492
+				__LINE__
493
+			);
494
+		}
495
+
496
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
497
+	}
498
+
499
+
500
+
501
+	/*************        Admin Options        *************/
502
+
503
+
504
+	/**
505
+	 * _admin_option_settings
506
+	 *
507
+	 * @throws EE_Error
508
+	 * @throws LogicException
509
+	 */
510
+	protected function _admin_option_settings()
511
+	{
512
+		$this->_template_args['admin_page_content'] = '';
513
+		try {
514
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
515
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
516
+			$this->_template_args['values'] = $this->_yes_no_values;
517
+			// also need to account for the do_action that was in the old template
518
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
519
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
520
+				$admin_options_settings_form->display(),
521
+				'',
522
+				'padding'
523
+			);
524
+		} catch (Exception $e) {
525
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
526
+		}
527
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
528
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
529
+		$this->display_admin_page_with_sidebar();
530
+	}
531
+
532
+
533
+	/**
534
+	 * _update_admin_option_settings
535
+	 *
536
+	 * @throws EE_Error
537
+	 * @throws InvalidDataTypeException
538
+	 * @throws InvalidFormSubmissionException
539
+	 * @throws InvalidArgumentException
540
+	 * @throws LogicException
541
+	 */
542
+	protected function _update_admin_option_settings()
543
+	{
544
+		try {
545
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
546
+			$admin_options_settings_form->process(
547
+				$this->request->getRequestParam(
548
+					$admin_options_settings_form->slug(),
549
+					[],
550
+					DataType::STRING,
551
+					true
552
+				)
553
+			);
554
+			EE_Registry::instance()->CFG->admin = apply_filters(
555
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
556
+				EE_Registry::instance()->CFG->admin
557
+			);
558
+		} catch (Exception $e) {
559
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
560
+		}
561
+		$this->_redirect_after_action(
562
+			apply_filters(
563
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
564
+				$this->_update_espresso_configuration(
565
+					esc_html__('Admin Options', 'event_espresso'),
566
+					EE_Registry::instance()->CFG->admin,
567
+					__FILE__,
568
+					__FUNCTION__,
569
+					__LINE__
570
+				)
571
+			),
572
+			esc_html__('Admin Options', 'event_espresso'),
573
+			'updated',
574
+			['action' => 'admin_option_settings']
575
+		);
576
+	}
577
+
578
+
579
+	/*************        Countries        *************/
580
+
581
+
582
+	/**
583
+	 * @param string|null $default
584
+	 * @return string
585
+	 */
586
+	protected function getCountryISO(?string $default = null): string
587
+	{
588
+		$default = $default ?? $this->getCountryIsoForSite();
589
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
590
+		return strtoupper($CNT_ISO);
591
+	}
592
+
593
+
594
+	/**
595
+	 * @return string
596
+	 */
597
+	protected function getCountryIsoForSite(): string
598
+	{
599
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
600
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
601
+			: 'US';
602
+	}
603
+
604
+
605
+	/**
606
+	 * @param string          $CNT_ISO
607
+	 * @param EE_Country|null $country
608
+	 * @return EE_Base_Class|EE_Country
609
+	 * @throws EE_Error
610
+	 * @throws InvalidArgumentException
611
+	 * @throws InvalidDataTypeException
612
+	 * @throws InvalidInterfaceException
613
+	 * @throws ReflectionException
614
+	 */
615
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
616
+	{
617
+		/** @var EE_Country $country */
618
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
619
+			? $country
620
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
621
+	}
622
+
623
+
624
+	/**
625
+	 * Output Country Settings view.
626
+	 *
627
+	 * @throws DomainException
628
+	 * @throws EE_Error
629
+	 * @throws InvalidArgumentException
630
+	 * @throws InvalidDataTypeException
631
+	 * @throws InvalidInterfaceException
632
+	 * @throws ReflectionException
633
+	 */
634
+	protected function _country_settings()
635
+	{
636
+		$CNT_ISO = $this->getCountryISO();
637
+
638
+		$this->_template_args['values']    = $this->_yes_no_values;
639
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
640
+			EE_Question::new_instance(
641
+				[
642
+				  'QST_ID'           => 0,
643
+				  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
644
+				  'QST_system'       => 'admin-country',
645
+				]
646
+			),
647
+			EE_Answer::new_instance(
648
+				[
649
+					'ANS_ID'    => 0,
650
+					'ANS_value' => $CNT_ISO,
651
+				]
652
+			),
653
+			[
654
+				'input_id'       => 'country',
655
+				'input_name'     => 'country',
656
+				'input_prefix'   => '',
657
+				'append_qstn_id' => false,
658
+			]
659
+		);
660
+
661
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
662
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
663
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
664
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
665
+			$country->ID(),
666
+			$country
667
+		);
668
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
669
+			$country->ID(),
670
+			$country
671
+		);
672
+		$this->_template_args['CNT_name_for_site']        = $country->name();
673
+
674
+		$this->_set_add_edit_form_tags('update_country_settings');
675
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
676
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
677
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
678
+			$this->_template_args,
679
+			true
680
+		);
681
+		$this->display_admin_page_with_no_sidebar();
682
+	}
683
+
684
+
685
+	/**
686
+	 * @param string          $CNT_ISO
687
+	 * @param EE_Country|null $country
688
+	 * @return string
689
+	 * @throws DomainException
690
+	 * @throws EE_Error
691
+	 * @throws InvalidArgumentException
692
+	 * @throws InvalidDataTypeException
693
+	 * @throws InvalidInterfaceException
694
+	 * @throws ReflectionException
695
+	 */
696
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
697
+	{
698
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
699
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
700
+
701
+		if (! $CNT_ISO) {
702
+			return '';
703
+		}
704
+
705
+		// for ajax
706
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
707
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
708
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
709
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
710
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
711
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
712
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
713
+
714
+		$country_input_types            = [
715
+			'CNT_active'      => [
716
+				'type'             => 'RADIO_BTN',
717
+				'input_name'       => "cntry[$CNT_ISO]",
718
+				'class'            => '',
719
+				'options'          => $this->_yes_no_values,
720
+				'use_desc_4_label' => true,
721
+			],
722
+			'CNT_ISO'         => [
723
+				'type'       => 'TEXT',
724
+				'input_name' => "cntry[$CNT_ISO]",
725
+				'class'      => 'ee-input-width--small',
726
+			],
727
+			'CNT_ISO3'        => [
728
+				'type'       => 'TEXT',
729
+				'input_name' => "cntry[$CNT_ISO]",
730
+				'class'      => 'ee-input-width--small',
731
+			],
732
+			// 'RGN_ID'          => [
733
+			//     'type'       => 'TEXT',
734
+			//     'input_name' => "cntry[$CNT_ISO]",
735
+			//     'class'      => 'ee-input-width--small',
736
+			// ],
737
+			'CNT_name'        => [
738
+				'type'       => 'TEXT',
739
+				'input_name' => "cntry[$CNT_ISO]",
740
+				'class'      => 'ee-input-width--big',
741
+			],
742
+			'CNT_cur_code'    => [
743
+				'type'       => 'TEXT',
744
+				'input_name' => "cntry[$CNT_ISO]",
745
+				'class'      => 'ee-input-width--small',
746
+				'disabled'   => $CNT_cur_disabled,
747
+			],
748
+			'CNT_cur_single'  => [
749
+				'type'       => 'TEXT',
750
+				'input_name' => "cntry[$CNT_ISO]",
751
+				'class'      => 'ee-input-width--reg',
752
+				'disabled'   => $CNT_cur_disabled,
753
+			],
754
+			'CNT_cur_plural'  => [
755
+				'type'       => 'TEXT',
756
+				'input_name' => "cntry[$CNT_ISO]",
757
+				'class'      => 'ee-input-width--reg',
758
+				'disabled'   => $CNT_cur_disabled,
759
+			],
760
+			'CNT_cur_sign'    => [
761
+				'type'         => 'TEXT',
762
+				'input_name'   => "cntry[$CNT_ISO]",
763
+				'class'        => 'ee-input-width--small',
764
+				'htmlentities' => false,
765
+				'disabled'     => $CNT_cur_disabled,
766
+			],
767
+			'CNT_cur_sign_b4' => [
768
+				'type'             => 'RADIO_BTN',
769
+				'input_name'       => "cntry[$CNT_ISO]",
770
+				'class'            => '',
771
+				'options'          => $this->_yes_no_values,
772
+				'use_desc_4_label' => true,
773
+				'disabled'         => $CNT_cur_disabled,
774
+			],
775
+			'CNT_cur_dec_plc' => [
776
+				'type'       => 'RADIO_BTN',
777
+				'input_name' => "cntry[$CNT_ISO]",
778
+				'class'      => '',
779
+				'options'    => [
780
+					['id' => 0, 'text' => ''],
781
+					['id' => 1, 'text' => ''],
782
+					['id' => 2, 'text' => ''],
783
+					['id' => 3, 'text' => ''],
784
+				],
785
+				'disabled'   => $CNT_cur_disabled,
786
+			],
787
+			'CNT_cur_dec_mrk' => [
788
+				'type'             => 'RADIO_BTN',
789
+				'input_name'       => "cntry[$CNT_ISO]",
790
+				'class'            => '',
791
+				'options'          => [
792
+					[
793
+						'id'   => ',',
794
+						'text' => esc_html__(', (comma)', 'event_espresso'),
795
+					],
796
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
797
+				],
798
+				'use_desc_4_label' => true,
799
+				'disabled'         => $CNT_cur_disabled,
800
+			],
801
+			'CNT_cur_thsnds'  => [
802
+				'type'             => 'RADIO_BTN',
803
+				'input_name'       => "cntry[$CNT_ISO]",
804
+				'class'            => '',
805
+				'options'          => [
806
+					[
807
+						'id'   => ',',
808
+						'text' => esc_html__(', (comma)', 'event_espresso'),
809
+					],
810
+					[
811
+						'id'   => '.',
812
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
813
+					],
814
+					[
815
+						'id'   => '&nbsp;',
816
+						'text' => esc_html__('(space)', 'event_espresso'),
817
+					],
818
+				],
819
+				'use_desc_4_label' => true,
820
+				'disabled'         => $CNT_cur_disabled,
821
+			],
822
+			'CNT_tel_code'    => [
823
+				'type'       => 'TEXT',
824
+				'input_name' => "cntry[$CNT_ISO]",
825
+				'class'      => 'ee-input-width--small',
826
+			],
827
+			'CNT_is_EU'       => [
828
+				'type'             => 'RADIO_BTN',
829
+				'input_name'       => "cntry[$CNT_ISO]",
830
+				'class'            => '',
831
+				'options'          => $this->_yes_no_values,
832
+				'use_desc_4_label' => true,
833
+			],
834
+		];
835
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
836
+			$country,
837
+			$country_input_types
838
+		);
839
+		$country_details_settings       = EEH_Template::display_template(
840
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
841
+			$this->_template_args,
842
+			true
843
+		);
844
+
845
+		if (defined('DOING_AJAX')) {
846
+			$notices = EE_Error::get_notices(false, false, false);
847
+			echo wp_json_encode(
848
+				[
849
+					'return_data' => $country_details_settings,
850
+					'success'     => $notices['success'],
851
+					'errors'      => $notices['errors'],
852
+				]
853
+			);
854
+			die();
855
+		}
856
+		return $country_details_settings;
857
+	}
858
+
859
+
860
+	/**
861
+	 * @param string          $CNT_ISO
862
+	 * @param EE_Country|null $country
863
+	 * @return string
864
+	 * @throws DomainException
865
+	 * @throws EE_Error
866
+	 * @throws InvalidArgumentException
867
+	 * @throws InvalidDataTypeException
868
+	 * @throws InvalidInterfaceException
869
+	 * @throws ReflectionException
870
+	 */
871
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
872
+	{
873
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
874
+		if (! $CNT_ISO) {
875
+			return '';
876
+		}
877
+		// for ajax
878
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
879
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
880
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
881
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
882
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
883
+		if (empty($states)) {
884
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
885
+			$countrySubRegionDao = $this->loader->getShared(
886
+				'EventEspresso\core\services\address\CountrySubRegionDao'
887
+			);
888
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
889
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
890
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
891
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
892
+				}
893
+			}
894
+		}
895
+		if (is_array($states)) {
896
+			foreach ($states as $STA_ID => $state) {
897
+				if ($state instanceof EE_State) {
898
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
899
+						$state,
900
+						[
901
+							'STA_abbrev' => [
902
+								'type'             => 'TEXT',
903
+								'label'            => esc_html__('Code', 'event_espresso'),
904
+								'input_name'       => "states[$STA_ID]",
905
+								'class'            => 'ee-input-width--tiny',
906
+								'add_mobile_label' => true,
907
+							],
908
+							'STA_name'   => [
909
+								'type'             => 'TEXT',
910
+								'label'            => esc_html__('Name', 'event_espresso'),
911
+								'input_name'       => "states[$STA_ID]",
912
+								'class'            => 'ee-input-width--big',
913
+								'add_mobile_label' => true,
914
+							],
915
+							'STA_active' => [
916
+								'type'             => 'RADIO_BTN',
917
+								'label'            => esc_html__('State Appears in Dropdown Select Lists', 'event_espresso'),
918
+								'input_name'       => "states[$STA_ID]",
919
+								'options'          => $this->_yes_no_values,
920
+								'use_desc_4_label' => true,
921
+								'add_mobile_label' => true,
922
+							],
923
+						]
924
+					);
925
+
926
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
927
+						[
928
+							'action'     => 'delete_state',
929
+							'STA_ID'     => $STA_ID,
930
+							'CNT_ISO'    => $CNT_ISO,
931
+							'STA_abbrev' => $state->abbrev(),
932
+						],
933
+						GEN_SET_ADMIN_URL
934
+					);
935
+
936
+					$this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
937
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
938
+				}
939
+			}
940
+		} else {
941
+			$this->_template_args['states'] = false;
942
+		}
943
+
944
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
945
+			['action' => 'add_new_state'],
946
+			GEN_SET_ADMIN_URL
947
+		);
948
+
949
+		$state_details_settings = EEH_Template::display_template(
950
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
951
+			$this->_template_args,
952
+			true
953
+		);
954
+
955
+		if (defined('DOING_AJAX')) {
956
+			$notices = EE_Error::get_notices(false, false, false);
957
+			echo wp_json_encode(
958
+				[
959
+					'return_data' => $state_details_settings,
960
+					'success'     => $notices['success'],
961
+					'errors'      => $notices['errors'],
962
+				]
963
+			);
964
+			die();
965
+		}
966
+		return $state_details_settings;
967
+	}
968
+
969
+
970
+	/**
971
+	 * @return void
972
+	 * @throws EE_Error
973
+	 * @throws InvalidArgumentException
974
+	 * @throws InvalidDataTypeException
975
+	 * @throws InvalidInterfaceException
976
+	 * @throws ReflectionException
977
+	 */
978
+	public function add_new_state()
979
+	{
980
+		$success = true;
981
+		$CNT_ISO = $this->getCountryISO('');
982
+		if (! $CNT_ISO) {
983
+			EE_Error::add_error(
984
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
985
+				__FILE__,
986
+				__FUNCTION__,
987
+				__LINE__
988
+			);
989
+			$success = false;
990
+		}
991
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
992
+		if (! $STA_abbrev) {
993
+			EE_Error::add_error(
994
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
995
+				__FILE__,
996
+				__FUNCTION__,
997
+				__LINE__
998
+			);
999
+			$success = false;
1000
+		}
1001
+		$STA_name = $this->request->getRequestParam('STA_name');
1002
+		if (! $STA_name) {
1003
+			EE_Error::add_error(
1004
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1005
+				__FILE__,
1006
+				__FUNCTION__,
1007
+				__LINE__
1008
+			);
1009
+			$success = false;
1010
+		}
1011
+
1012
+		if ($success) {
1013
+			$cols_n_values = [
1014
+				'CNT_ISO'    => $CNT_ISO,
1015
+				'STA_abbrev' => $STA_abbrev,
1016
+				'STA_name'   => $STA_name,
1017
+				'STA_active' => true,
1018
+			];
1019
+			$success       = EEM_State::instance()->insert($cols_n_values);
1020
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1021
+		}
1022
+
1023
+		if (defined('DOING_AJAX')) {
1024
+			$notices = EE_Error::get_notices(false, false, false);
1025
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1026
+			die();
1027
+		}
1028
+		$this->_redirect_after_action(
1029
+			$success,
1030
+			esc_html__('State', 'event_espresso'),
1031
+			'added',
1032
+			['action' => 'country_settings']
1033
+		);
1034
+	}
1035
+
1036
+
1037
+	/**
1038
+	 * @return void
1039
+	 * @throws EE_Error
1040
+	 * @throws InvalidArgumentException
1041
+	 * @throws InvalidDataTypeException
1042
+	 * @throws InvalidInterfaceException
1043
+	 * @throws ReflectionException
1044
+	 */
1045
+	public function delete_state()
1046
+	{
1047
+		$CNT_ISO    = $this->getCountryISO();
1048
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1049
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1050
+
1051
+		if (! $STA_ID) {
1052
+			EE_Error::add_error(
1053
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1054
+				__FILE__,
1055
+				__FUNCTION__,
1056
+				__LINE__
1057
+			);
1058
+			return;
1059
+		}
1060
+
1061
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1062
+		if ($success !== false) {
1063
+			do_action(
1064
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1065
+				$CNT_ISO,
1066
+				$STA_ID,
1067
+				['STA_abbrev' => $STA_abbrev]
1068
+			);
1069
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1070
+		}
1071
+		if (defined('DOING_AJAX')) {
1072
+			$notices                = EE_Error::get_notices(false);
1073
+			$notices['return_data'] = true;
1074
+			echo wp_json_encode($notices);
1075
+			die();
1076
+		}
1077
+		$this->_redirect_after_action(
1078
+			$success,
1079
+			esc_html__('State', 'event_espresso'),
1080
+			'deleted',
1081
+			['action' => 'country_settings']
1082
+		);
1083
+	}
1084
+
1085
+
1086
+	/**
1087
+	 * @return void
1088
+	 * @throws EE_Error
1089
+	 * @throws InvalidArgumentException
1090
+	 * @throws InvalidDataTypeException
1091
+	 * @throws InvalidInterfaceException
1092
+	 * @throws ReflectionException
1093
+	 */
1094
+	protected function _update_country_settings()
1095
+	{
1096
+		$CNT_ISO = $this->getCountryISO();
1097
+		if (! $CNT_ISO) {
1098
+			EE_Error::add_error(
1099
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1100
+				__FILE__,
1101
+				__FUNCTION__,
1102
+				__LINE__
1103
+			);
1104
+			return;
1105
+		}
1106
+
1107
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1108
+
1109
+		$cols_n_values                    = [];
1110
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1111
+			$this->request->getRequestParam('cntry', '', $country->ISO3())
1112
+		);
1113
+		$cols_n_values['CNT_name']        =
1114
+			$this->request->getRequestParam("cntry[$CNT_ISO][CNT_name]", $country->name());
1115
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1116
+			$this->request->getRequestParam(
1117
+				"cntry[$CNT_ISO][CNT_cur_code]",
1118
+				$country->currency_code()
1119
+			)
1120
+		);
1121
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1122
+			"cntry[$CNT_ISO][CNT_cur_single]",
1123
+			$country->currency_name_single()
1124
+		);
1125
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1126
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1127
+			$country->currency_name_plural()
1128
+		);
1129
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1130
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1131
+			$country->currency_sign()
1132
+		);
1133
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1134
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1135
+			$country->currency_sign_before(),
1136
+			DataType::BOOL
1137
+		);
1138
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1139
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1140
+			$country->currency_decimal_places()
1141
+		);
1142
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1143
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1144
+			$country->currency_decimal_mark()
1145
+		);
1146
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1147
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1148
+			$country->currency_thousands_separator()
1149
+		);
1150
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1151
+			"cntry[$CNT_ISO][CNT_tel_code]",
1152
+			$country->telephoneCode()
1153
+		);
1154
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1155
+			"cntry[$CNT_ISO][CNT_active]",
1156
+			$country->isActive(),
1157
+			DataType::BOOL
1158
+		);
1159
+
1160
+		// allow filtering of country data
1161
+		$cols_n_values = apply_filters(
1162
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1163
+			$cols_n_values
1164
+		);
1165
+
1166
+		// where values
1167
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1168
+		// run the update
1169
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1170
+
1171
+		// allow filtering of states data
1172
+		$states = apply_filters(
1173
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1174
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1175
+		);
1176
+
1177
+		if (! empty($states) && $success !== false) {
1178
+			// loop thru state data ( looks like : states[75][STA_name] )
1179
+			foreach ($states as $STA_ID => $state) {
1180
+				$cols_n_values = [
1181
+					'CNT_ISO'    => $CNT_ISO,
1182
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1183
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1184
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1185
+				];
1186
+				// where values
1187
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1188
+				// run the update
1189
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1190
+				if ($success !== false) {
1191
+					do_action(
1192
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1193
+						$CNT_ISO,
1194
+						$STA_ID,
1195
+						$cols_n_values
1196
+					);
1197
+				}
1198
+			}
1199
+		}
1200
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1201
+		if (
1202
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1203
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1204
+		) {
1205
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1206
+			EE_Registry::instance()->CFG->update_espresso_config();
1207
+		}
1208
+
1209
+		if ($success !== false) {
1210
+			EE_Error::add_success(
1211
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1212
+			);
1213
+		}
1214
+		$this->_redirect_after_action(
1215
+			$success,
1216
+			'',
1217
+			'',
1218
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1219
+			true
1220
+		);
1221
+	}
1222
+
1223
+
1224
+	/**
1225
+	 * form_form_field_label_wrap
1226
+	 *
1227
+	 * @param string $label
1228
+	 * @return string
1229
+	 */
1230
+	public function country_form_field_label_wrap(string $label): string
1231
+	{
1232
+		return '
1233 1233
 			<tr>
1234 1234
 				<th>
1235 1235
 					' . $label . '
1236 1236
 				</th>';
1237
-    }
1238
-
1239
-
1240
-    /**
1241
-     * form_form_field_input__wrap
1242
-     *
1243
-     * @param string $input
1244
-     * @return string
1245
-     */
1246
-    public function country_form_field_input__wrap(string $input): string
1247
-    {
1248
-        return '
1237
+	}
1238
+
1239
+
1240
+	/**
1241
+	 * form_form_field_input__wrap
1242
+	 *
1243
+	 * @param string $input
1244
+	 * @return string
1245
+	 */
1246
+	public function country_form_field_input__wrap(string $input): string
1247
+	{
1248
+		return '
1249 1249
 				<td class="general-settings-country-input-td">
1250 1250
 					' . $input . '
1251 1251
 				</td>
1252 1252
 			</tr>';
1253
-    }
1254
-
1255
-
1256
-    /**
1257
-     * form_form_field_label_wrap
1258
-     *
1259
-     * @param string $label
1260
-     * @param string $required_text
1261
-     * @return string
1262
-     */
1263
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1264
-    {
1265
-        return $required_text;
1266
-    }
1267
-
1268
-
1269
-    /**
1270
-     * form_form_field_input__wrap
1271
-     *
1272
-     * @param string $input
1273
-     * @return string
1274
-     */
1275
-    public function state_form_field_input__wrap(string $input): string
1276
-    {
1277
-        return '
1253
+	}
1254
+
1255
+
1256
+	/**
1257
+	 * form_form_field_label_wrap
1258
+	 *
1259
+	 * @param string $label
1260
+	 * @param string $required_text
1261
+	 * @return string
1262
+	 */
1263
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1264
+	{
1265
+		return $required_text;
1266
+	}
1267
+
1268
+
1269
+	/**
1270
+	 * form_form_field_input__wrap
1271
+	 *
1272
+	 * @param string $input
1273
+	 * @return string
1274
+	 */
1275
+	public function state_form_field_input__wrap(string $input): string
1276
+	{
1277
+		return '
1278 1278
 				<td class="general-settings-country-state-input-td">
1279 1279
 					' . $input . '
1280 1280
 				</td>';
1281
-    }
1282
-
1283
-
1284
-    /***********/
1285
-
1286
-
1287
-    /**
1288
-     * displays edit and view links for critical EE pages
1289
-     *
1290
-     * @param int $ee_page_id
1291
-     * @return string
1292
-     */
1293
-    public static function edit_view_links(int $ee_page_id): string
1294
-    {
1295
-        $edit_url = add_query_arg(
1296
-            ['post' => $ee_page_id, 'action' => 'edit'],
1297
-            admin_url('post.php')
1298
-        );
1299
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1300
-        $links    .= ' &nbsp;|&nbsp; ';
1301
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1302
-
1303
-        return $links;
1304
-    }
1305
-
1306
-
1307
-    /**
1308
-     * displays page and shortcode status for critical EE pages
1309
-     *
1310
-     * @param WP_Post $ee_page
1311
-     * @param string  $shortcode
1312
-     * @return string
1313
-     */
1314
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1315
-    {
1316
-        // page status
1317
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1318
-            $pg_class  = 'ee-status-bg--success';
1319
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1320
-        } else {
1321
-            $pg_class  = 'ee-status-bg--error';
1322
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1323
-        }
1324
-
1325
-        // shortcode status
1326
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1327
-            $sc_class  = 'ee-status-bg--success';
1328
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1329
-        } else {
1330
-            $sc_class  = 'ee-status-bg--error';
1331
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1332
-        }
1333
-
1334
-        return '
1281
+	}
1282
+
1283
+
1284
+	/***********/
1285
+
1286
+
1287
+	/**
1288
+	 * displays edit and view links for critical EE pages
1289
+	 *
1290
+	 * @param int $ee_page_id
1291
+	 * @return string
1292
+	 */
1293
+	public static function edit_view_links(int $ee_page_id): string
1294
+	{
1295
+		$edit_url = add_query_arg(
1296
+			['post' => $ee_page_id, 'action' => 'edit'],
1297
+			admin_url('post.php')
1298
+		);
1299
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1300
+		$links    .= ' &nbsp;|&nbsp; ';
1301
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1302
+
1303
+		return $links;
1304
+	}
1305
+
1306
+
1307
+	/**
1308
+	 * displays page and shortcode status for critical EE pages
1309
+	 *
1310
+	 * @param WP_Post $ee_page
1311
+	 * @param string  $shortcode
1312
+	 * @return string
1313
+	 */
1314
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1315
+	{
1316
+		// page status
1317
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1318
+			$pg_class  = 'ee-status-bg--success';
1319
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1320
+		} else {
1321
+			$pg_class  = 'ee-status-bg--error';
1322
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1323
+		}
1324
+
1325
+		// shortcode status
1326
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1327
+			$sc_class  = 'ee-status-bg--success';
1328
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1329
+		} else {
1330
+			$sc_class  = 'ee-status-bg--error';
1331
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1332
+		}
1333
+
1334
+		return '
1335 1335
         <span class="ee-page-status ' . $pg_class . '"><strong>' . $pg_status . '</strong></span>
1336 1336
         <span class="ee-page-status ' . $sc_class . '"><strong>' . $sc_status . '</strong></span>';
1337
-    }
1338
-
1339
-
1340
-    /**
1341
-     * generates a dropdown of all parent pages - copied from WP core
1342
-     *
1343
-     * @param int  $default
1344
-     * @param int  $parent
1345
-     * @param int  $level
1346
-     * @param bool $echo
1347
-     * @return string;
1348
-     */
1349
-    public static function page_settings_dropdown(
1350
-        int $default = 0,
1351
-        int $parent = 0,
1352
-        int $level = 0,
1353
-        bool $echo = true
1354
-    ): string {
1355
-        global $wpdb;
1356
-        $items  = $wpdb->get_results(
1357
-            $wpdb->prepare(
1358
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1359
-                $parent
1360
-            )
1361
-        );
1362
-        $output = '';
1363
-
1364
-        if ($items) {
1365
-            $level = absint($level);
1366
-            foreach ($items as $item) {
1367
-                $ID         = absint($item->ID);
1368
-                $post_title = wp_strip_all_tags($item->post_title);
1369
-                $pad    = str_repeat('&nbsp;', $level * 3);
1370
-                $option = "\n\t";
1371
-                $option .= '<option class="level-' . $level . '" ';
1372
-                $option .= 'value="' . $ID . '" ';
1373
-                $option .= $ID === absint($default) ? ' selected' : '';
1374
-                $option .= '>';
1375
-                $option .= "$pad {$post_title}";
1376
-                $option .= '</option>';
1377
-                $output .= $option;
1378
-                ob_start();
1379
-                parent_dropdown($default, $item->ID, $level + 1);
1380
-                $output .= ob_get_clean();
1381
-            }
1382
-        }
1383
-        if ($echo) {
1384
-            echo wp_kses($output, AllowedTags::getWithFormTags());
1385
-            return '';
1386
-        }
1387
-        return $output;
1388
-    }
1389
-
1390
-
1391
-    /**
1392
-     * Loads the scripts for the privacy settings form
1393
-     */
1394
-    public function load_scripts_styles_privacy_settings()
1395
-    {
1396
-        $form_handler = $this->loader->getShared(
1397
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1398
-        );
1399
-        $form_handler->enqueueStylesAndScripts();
1400
-    }
1401
-
1402
-
1403
-    /**
1404
-     * display the privacy settings form
1405
-     *
1406
-     * @throws EE_Error
1407
-     */
1408
-    public function privacySettings()
1409
-    {
1410
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1411
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1412
-        $form_handler                               = $this->loader->getShared(
1413
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1414
-        );
1415
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1416
-            $form_handler->display(),
1417
-            '',
1418
-            'padding'
1419
-        );
1420
-        $this->display_admin_page_with_sidebar();
1421
-    }
1422
-
1423
-
1424
-    /**
1425
-     * Update the privacy settings from form data
1426
-     *
1427
-     * @throws EE_Error
1428
-     */
1429
-    public function updatePrivacySettings()
1430
-    {
1431
-        $form_handler = $this->loader->getShared(
1432
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1433
-        );
1434
-        $success      = $form_handler->process($this->get_request_data());
1435
-        $this->_redirect_after_action(
1436
-            $success,
1437
-            esc_html__('Registration Form Options', 'event_espresso'),
1438
-            'updated',
1439
-            ['action' => 'privacy_settings']
1440
-        );
1441
-    }
1337
+	}
1338
+
1339
+
1340
+	/**
1341
+	 * generates a dropdown of all parent pages - copied from WP core
1342
+	 *
1343
+	 * @param int  $default
1344
+	 * @param int  $parent
1345
+	 * @param int  $level
1346
+	 * @param bool $echo
1347
+	 * @return string;
1348
+	 */
1349
+	public static function page_settings_dropdown(
1350
+		int $default = 0,
1351
+		int $parent = 0,
1352
+		int $level = 0,
1353
+		bool $echo = true
1354
+	): string {
1355
+		global $wpdb;
1356
+		$items  = $wpdb->get_results(
1357
+			$wpdb->prepare(
1358
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1359
+				$parent
1360
+			)
1361
+		);
1362
+		$output = '';
1363
+
1364
+		if ($items) {
1365
+			$level = absint($level);
1366
+			foreach ($items as $item) {
1367
+				$ID         = absint($item->ID);
1368
+				$post_title = wp_strip_all_tags($item->post_title);
1369
+				$pad    = str_repeat('&nbsp;', $level * 3);
1370
+				$option = "\n\t";
1371
+				$option .= '<option class="level-' . $level . '" ';
1372
+				$option .= 'value="' . $ID . '" ';
1373
+				$option .= $ID === absint($default) ? ' selected' : '';
1374
+				$option .= '>';
1375
+				$option .= "$pad {$post_title}";
1376
+				$option .= '</option>';
1377
+				$output .= $option;
1378
+				ob_start();
1379
+				parent_dropdown($default, $item->ID, $level + 1);
1380
+				$output .= ob_get_clean();
1381
+			}
1382
+		}
1383
+		if ($echo) {
1384
+			echo wp_kses($output, AllowedTags::getWithFormTags());
1385
+			return '';
1386
+		}
1387
+		return $output;
1388
+	}
1389
+
1390
+
1391
+	/**
1392
+	 * Loads the scripts for the privacy settings form
1393
+	 */
1394
+	public function load_scripts_styles_privacy_settings()
1395
+	{
1396
+		$form_handler = $this->loader->getShared(
1397
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1398
+		);
1399
+		$form_handler->enqueueStylesAndScripts();
1400
+	}
1401
+
1402
+
1403
+	/**
1404
+	 * display the privacy settings form
1405
+	 *
1406
+	 * @throws EE_Error
1407
+	 */
1408
+	public function privacySettings()
1409
+	{
1410
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1411
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1412
+		$form_handler                               = $this->loader->getShared(
1413
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1414
+		);
1415
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1416
+			$form_handler->display(),
1417
+			'',
1418
+			'padding'
1419
+		);
1420
+		$this->display_admin_page_with_sidebar();
1421
+	}
1422
+
1423
+
1424
+	/**
1425
+	 * Update the privacy settings from form data
1426
+	 *
1427
+	 * @throws EE_Error
1428
+	 */
1429
+	public function updatePrivacySettings()
1430
+	{
1431
+		$form_handler = $this->loader->getShared(
1432
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1433
+		);
1434
+		$success      = $form_handler->process($this->get_request_data());
1435
+		$this->_redirect_after_action(
1436
+			$success,
1437
+			esc_html__('Registration Form Options', 'event_espresso'),
1438
+			'updated',
1439
+			['action' => 'privacy_settings']
1440
+		);
1441
+	}
1442 1442
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
                 'event_espresso'
247 247
             )
248 248
         );
249
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
249
+        EE_Registry::$i18n_js_strings['error_occurred'] = wp_strip_all_tags(
250 250
             esc_html__(
251 251
                 'An error occurred! Please refresh the page and try again.',
252 252
                 'event_espresso'
253 253
             )
254 254
         );
255
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
255
+        EE_Registry::$i18n_js_strings['confirm_delete_state'] = wp_strip_all_tags(
256 256
             esc_html__(
257 257
                 'Are you sure you want to delete this State / Province?',
258 258
                 'event_espresso'
259 259
             )
260 260
         );
261
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
261
+        EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
262 262
             'admin-ajax.php?page=espresso_general_settings',
263 263
             is_ssl() ? 'https://' : 'http://'
264 264
         );
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
         wp_enqueue_script('thickbox');
288 288
         wp_register_script(
289 289
             'organization_settings',
290
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
290
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
291 291
             ['jquery', 'media-upload', 'thickbox'],
292 292
             EVENT_ESPRESSO_VERSION,
293 293
             true
294 294
         );
295
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
295
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
296 296
         wp_enqueue_script('organization_settings');
297 297
         wp_enqueue_style('organization-css');
298 298
         $confirm_image_delete = [
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
         // scripts
316 316
         wp_register_script(
317 317
             'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
318
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
319 319
             ['ee_admin_js'],
320 320
             EVENT_ESPRESSO_VERSION,
321 321
             true
322 322
         );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
323
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
324 324
         wp_enqueue_script('gen_settings_countries');
325 325
         wp_enqueue_style('organization-css');
326 326
     }
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
369 369
         $this->_set_publish_post_box_vars(null, false, false, null, false);
370 370
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
371
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
372 372
             $this->_template_args,
373 373
             true
374 374
         );
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
     protected function _update_espresso_page_settings()
385 385
     {
386 386
         // capture incoming request data && set page IDs
387
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
387
+        $this->core_config->reg_page_id = $this->request->getRequestParam(
388 388
             'reg_page_id',
389 389
             $this->core_config->reg_page_id,
390 390
             DataType::INT
391 391
         );
392
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
392
+        $this->core_config->txn_page_id = $this->request->getRequestParam(
393 393
             'txn_page_id',
394 394
             $this->core_config->txn_page_id,
395 395
             DataType::INT
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
             $this->core_config->thank_you_page_id,
400 400
             DataType::INT
401 401
         );
402
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
402
+        $this->core_config->cancel_page_id = $this->request->getRequestParam(
403 403
             'cancel_page_id',
404 404
             $this->core_config->cancel_page_id,
405 405
             DataType::INT
@@ -665,16 +665,16 @@  discard block
 block discarded – undo
665 665
             $country->ID(),
666 666
             $country
667 667
         );
668
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
668
+        $this->_template_args['country_states_settings'] = $this->display_country_states(
669 669
             $country->ID(),
670 670
             $country
671 671
         );
672
-        $this->_template_args['CNT_name_for_site']        = $country->name();
672
+        $this->_template_args['CNT_name_for_site'] = $country->name();
673 673
 
674 674
         $this->_set_add_edit_form_tags('update_country_settings');
675 675
         $this->_set_publish_post_box_vars(null, false, false, null, false);
676 676
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
677
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
677
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
678 678
             $this->_template_args,
679 679
             true
680 680
         );
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
         $CNT_ISO          = $this->getCountryISO($CNT_ISO);
699 699
         $CNT_ISO_for_site = $this->getCountryIsoForSite();
700 700
 
701
-        if (! $CNT_ISO) {
701
+        if ( ! $CNT_ISO) {
702 702
             return '';
703 703
         }
704 704
 
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
         $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
712 712
         $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
713 713
 
714
-        $country_input_types            = [
714
+        $country_input_types = [
715 715
             'CNT_active'      => [
716 716
                 'type'             => 'RADIO_BTN',
717 717
                 'input_name'       => "cntry[$CNT_ISO]",
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
             $country,
837 837
             $country_input_types
838 838
         );
839
-        $country_details_settings       = EEH_Template::display_template(
840
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
839
+        $country_details_settings = EEH_Template::display_template(
840
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
841 841
             $this->_template_args,
842 842
             true
843 843
         );
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
     public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
872 872
     {
873 873
         $CNT_ISO = $this->getCountryISO($CNT_ISO);
874
-        if (! $CNT_ISO) {
874
+        if ( ! $CNT_ISO) {
875 875
             return '';
876 876
         }
877 877
         // for ajax
@@ -933,8 +933,8 @@  discard block
 block discarded – undo
933 933
                         GEN_SET_ADMIN_URL
934 934
                     );
935 935
 
936
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
937
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
936
+                    $this->_template_args['states'][$STA_ID]['inputs']           = $inputs;
937
+                    $this->_template_args['states'][$STA_ID]['delete_state_url'] = $delete_state_url;
938 938
                 }
939 939
             }
940 940
         } else {
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
         );
948 948
 
949 949
         $state_details_settings = EEH_Template::display_template(
950
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
950
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
951 951
             $this->_template_args,
952 952
             true
953 953
         );
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
     {
980 980
         $success = true;
981 981
         $CNT_ISO = $this->getCountryISO('');
982
-        if (! $CNT_ISO) {
982
+        if ( ! $CNT_ISO) {
983 983
             EE_Error::add_error(
984 984
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
985 985
                 __FILE__,
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
             $success = false;
990 990
         }
991 991
         $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
992
-        if (! $STA_abbrev) {
992
+        if ( ! $STA_abbrev) {
993 993
             EE_Error::add_error(
994 994
                 esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
995 995
                 __FILE__,
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
             $success = false;
1000 1000
         }
1001 1001
         $STA_name = $this->request->getRequestParam('STA_name');
1002
-        if (! $STA_name) {
1002
+        if ( ! $STA_name) {
1003 1003
             EE_Error::add_error(
1004 1004
                 esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1005 1005
                 __FILE__,
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
                 'STA_name'   => $STA_name,
1017 1017
                 'STA_active' => true,
1018 1018
             ];
1019
-            $success       = EEM_State::instance()->insert($cols_n_values);
1019
+            $success = EEM_State::instance()->insert($cols_n_values);
1020 1020
             EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1021 1021
         }
1022 1022
 
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
         $STA_ID     = $this->request->getRequestParam('STA_ID');
1049 1049
         $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1050 1050
 
1051
-        if (! $STA_ID) {
1051
+        if ( ! $STA_ID) {
1052 1052
             EE_Error::add_error(
1053 1053
                 esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1054 1054
                 __FILE__,
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
     protected function _update_country_settings()
1095 1095
     {
1096 1096
         $CNT_ISO = $this->getCountryISO();
1097
-        if (! $CNT_ISO) {
1097
+        if ( ! $CNT_ISO) {
1098 1098
             EE_Error::add_error(
1099 1099
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1100 1100
                 __FILE__,
@@ -1118,15 +1118,15 @@  discard block
 block discarded – undo
1118 1118
                 $country->currency_code()
1119 1119
             )
1120 1120
         );
1121
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1121
+        $cols_n_values['CNT_cur_single'] = $this->request->getRequestParam(
1122 1122
             "cntry[$CNT_ISO][CNT_cur_single]",
1123 1123
             $country->currency_name_single()
1124 1124
         );
1125
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1125
+        $cols_n_values['CNT_cur_plural'] = $this->request->getRequestParam(
1126 1126
             "cntry[$CNT_ISO][CNT_cur_plural]",
1127 1127
             $country->currency_name_plural()
1128 1128
         );
1129
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1129
+        $cols_n_values['CNT_cur_sign'] = $this->request->getRequestParam(
1130 1130
             "cntry[$CNT_ISO][CNT_cur_sign]",
1131 1131
             $country->currency_sign()
1132 1132
         );
@@ -1143,15 +1143,15 @@  discard block
 block discarded – undo
1143 1143
             "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1144 1144
             $country->currency_decimal_mark()
1145 1145
         );
1146
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1146
+        $cols_n_values['CNT_cur_thsnds'] = $this->request->getRequestParam(
1147 1147
             "cntry[$CNT_ISO][CNT_cur_thsnds]",
1148 1148
             $country->currency_thousands_separator()
1149 1149
         );
1150
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1150
+        $cols_n_values['CNT_tel_code'] = $this->request->getRequestParam(
1151 1151
             "cntry[$CNT_ISO][CNT_tel_code]",
1152 1152
             $country->telephoneCode()
1153 1153
         );
1154
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1154
+        $cols_n_values['CNT_active'] = $this->request->getRequestParam(
1155 1155
             "cntry[$CNT_ISO][CNT_active]",
1156 1156
             $country->isActive(),
1157 1157
             DataType::BOOL
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
             $this->request->getRequestParam('states', [], DataType::STRING, true)
1175 1175
         );
1176 1176
 
1177
-        if (! empty($states) && $success !== false) {
1177
+        if ( ! empty($states) && $success !== false) {
1178 1178
             // loop thru state data ( looks like : states[75][STA_name] )
1179 1179
             foreach ($states as $STA_ID => $state) {
1180 1180
                 $cols_n_values = [
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
         return '
1233 1233
 			<tr>
1234 1234
 				<th>
1235
-					' . $label . '
1235
+					' . $label.'
1236 1236
 				</th>';
1237 1237
     }
1238 1238
 
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
     {
1248 1248
         return '
1249 1249
 				<td class="general-settings-country-input-td">
1250
-					' . $input . '
1250
+					' . $input.'
1251 1251
 				</td>
1252 1252
 			</tr>';
1253 1253
     }
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
     {
1277 1277
         return '
1278 1278
 				<td class="general-settings-country-state-input-td">
1279
-					' . $input . '
1279
+					' . $input.'
1280 1280
 				</td>';
1281 1281
     }
1282 1282
 
@@ -1296,9 +1296,9 @@  discard block
 block discarded – undo
1296 1296
             ['post' => $ee_page_id, 'action' => 'edit'],
1297 1297
             admin_url('post.php')
1298 1298
         );
1299
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1299
+        $links = '<a href="'.esc_url_raw($edit_url).'" >'.esc_html__('Edit', 'event_espresso').'</a>';
1300 1300
         $links    .= ' &nbsp;|&nbsp; ';
1301
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1301
+        $links    .= '<a href="'.get_permalink($ee_page_id).'" >'.esc_html__('View', 'event_espresso').'</a>';
1302 1302
 
1303 1303
         return $links;
1304 1304
     }
@@ -1332,8 +1332,8 @@  discard block
 block discarded – undo
1332 1332
         }
1333 1333
 
1334 1334
         return '
1335
-        <span class="ee-page-status ' . $pg_class . '"><strong>' . $pg_status . '</strong></span>
1336
-        <span class="ee-page-status ' . $sc_class . '"><strong>' . $sc_status . '</strong></span>';
1335
+        <span class="ee-page-status ' . $pg_class.'"><strong>'.$pg_status.'</strong></span>
1336
+        <span class="ee-page-status ' . $sc_class.'"><strong>'.$sc_status.'</strong></span>';
1337 1337
     }
1338 1338
 
1339 1339
 
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
         bool $echo = true
1354 1354
     ): string {
1355 1355
         global $wpdb;
1356
-        $items  = $wpdb->get_results(
1356
+        $items = $wpdb->get_results(
1357 1357
             $wpdb->prepare(
1358 1358
                 "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1359 1359
                 $parent
@@ -1368,8 +1368,8 @@  discard block
 block discarded – undo
1368 1368
                 $post_title = wp_strip_all_tags($item->post_title);
1369 1369
                 $pad    = str_repeat('&nbsp;', $level * 3);
1370 1370
                 $option = "\n\t";
1371
-                $option .= '<option class="level-' . $level . '" ';
1372
-                $option .= 'value="' . $ID . '" ';
1371
+                $option .= '<option class="level-'.$level.'" ';
1372
+                $option .= 'value="'.$ID.'" ';
1373 1373
                 $option .= $ID === absint($default) ? ' selected' : '';
1374 1374
                 $option .= '>';
1375 1375
                 $option .= "$pad {$post_title}";
Please login to merge, or discard this patch.