Completed
Branch fix/kses-4 (622913)
by
unknown
14:52 queued 13:07
created
venues/templates/event_venues_metabox_content_from_manager.template.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,20 +18,20 @@
 block discarded – undo
18 18
                 <?php esc_html_e('Select from Venue Manager List', 'event_espresso'); ?>
19 19
             </label>
20 20
             <?php
21
-            echo wp_kses($venue_selector, AllowedTags::getWithFormTags());
22
-            echo wp_kses($new_venue_link, AllowedTags::getWithFormTags());
23
-            foreach ($venues as $venue) :
24
-                if (! $venue instanceof EE_Venue) {
25
-                    continue;
26
-                }
27
-                $selected     = $evt_venue_id === $venue->ID() ? 'ee-venue-selected' : 'ee-venue-not-selected';
28
-                $edit_url     = EE_Admin_Page::add_query_args_and_nonce(
29
-                    ['action' => 'edit', 'post' => $venue->ID()],
30
-                    EE_VENUES_ADMIN_URL
31
-                );
32
-                $state_name   = is_object($venue->state_obj()) ? $venue->state_obj()->name() : null;
33
-                $country_name = is_object($venue->country_obj()) ? $venue->country_obj()->name() : null;
34
-                ?>
21
+			echo wp_kses($venue_selector, AllowedTags::getWithFormTags());
22
+			echo wp_kses($new_venue_link, AllowedTags::getWithFormTags());
23
+			foreach ($venues as $venue) :
24
+				if (! $venue instanceof EE_Venue) {
25
+					continue;
26
+				}
27
+				$selected     = $evt_venue_id === $venue->ID() ? 'ee-venue-selected' : 'ee-venue-not-selected';
28
+				$edit_url     = EE_Admin_Page::add_query_args_and_nonce(
29
+					['action' => 'edit', 'post' => $venue->ID()],
30
+					EE_VENUES_ADMIN_URL
31
+				);
32
+				$state_name   = is_object($venue->state_obj()) ? $venue->state_obj()->name() : null;
33
+				$country_name = is_object($venue->country_obj()) ? $venue->country_obj()->name() : null;
34
+				?>
35 35
                 <div class='eebox <?php echo sanitize_html_class($selected); ?>' id="eebox_<?php echo absint($venue->ID()); ?>">
36 36
                     <p class='address-view'>
37 37
                         <span><?php esc_html_e('Address:', 'event_espresso'); ?>&nbsp;</span>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
             echo wp_kses($venue_selector, AllowedTags::getWithFormTags());
22 22
             echo wp_kses($new_venue_link, AllowedTags::getWithFormTags());
23 23
             foreach ($venues as $venue) :
24
-                if (! $venue instanceof EE_Venue) {
24
+                if ( ! $venue instanceof EE_Venue) {
25 25
                     continue;
26 26
                 }
27 27
                 $selected     = $evt_venue_id === $venue->ID() ? 'ee-venue-selected' : 'ee-venue-not-selected';
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
                     <p class='address-view'>
37 37
                         <span><?php esc_html_e('Address:', 'event_espresso'); ?>&nbsp;</span>
38 38
                         <?php echo esc_html($venue->address()); ?>
39
-                        <?php echo ($venue->address2() ? '<br />' . esc_html($venue->address2()) : ''); ?>
39
+                        <?php echo ($venue->address2() ? '<br />'.esc_html($venue->address2()) : ''); ?>
40 40
                         <br />
41 41
                         <span><?php esc_html_e('City:', 'event_espresso'); ?>&nbsp;</span>
42 42
                         <?php echo esc_html($venue->city()); ?>
Please login to merge, or discard this patch.
core/services/request/sanitizers/AllowedTags.php 1 patch
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -13,227 +13,227 @@
 block discarded – undo
13 13
 class AllowedTags
14 14
 {
15 15
 
16
-    /**
17
-     * @var array[]
18
-     */
19
-    private static $attributes = [
20
-        'accept-charset'    => 1,
21
-        'action'            => 1,
22
-        'alt'               => 1,
23
-        'allow'             => 1,
24
-        'allowfullscreen'   => 1,
25
-        'align'             => 1,
26
-        'aria-*'            => 1,
27
-        'autocomplete'      => 1,
28
-        'checked'           => 1,
29
-        'class'             => 1,
30
-        'cols'              => 1,
31
-        'content'           => 1,
32
-        'data-*'            => 1,
33
-        'dir'               => 1,
34
-        'disabled'          => 1,
35
-        'enctype'           => 1,
36
-        'for'               => 1,
37
-        'frameborder'       => 1,
38
-        'height'            => 1,
39
-        'href'              => 1,
40
-        'id'                => 1,
41
-        'itemprop'          => 1,
42
-        'itemscope'         => 1,
43
-        'itemtype'          => 1,
44
-        'label'             => 1,
45
-        'lang'              => 1,
46
-        'max'               => 1,
47
-        'maxlength'         => 1,
48
-        'method'            => 1,
49
-        'min'               => 1,
50
-        'multiple'          => 1,
51
-        'name'              => 1,
52
-        'novalidate'        => 1,
53
-        'placeholder'       => 1,
54
-        'readonly'          => 1,
55
-        'rel'               => 1,
56
-        'required'          => 1,
57
-        'rows'              => 1,
58
-        'selected'          => 1,
59
-        'src'               => 1,
60
-        'size'              => 1,
61
-        'style'             => 1,
62
-        'step'              => 1,
63
-        'tabindex'          => 1,
64
-        'target'            => 1,
65
-        'title'             => 1,
66
-        'type'              => 1,
67
-        'value'             => 1,
68
-        'width'             => 1,
69
-    ];
70
-
71
-
72
-    /**
73
-     * @var array
74
-     */
75
-    private static $tags = [
76
-        'a',
77
-        'abbr',
78
-        'b',
79
-        'br',
80
-        'code',
81
-        'div',
82
-        'em',
83
-        'h1',
84
-        'h2',
85
-        'h3',
86
-        'h4',
87
-        'h5',
88
-        'h6',
89
-        'hr',
90
-        'i',
91
-        'img',
92
-        'li',
93
-        'ol',
94
-        'p',
95
-        'pre',
96
-        'small',
97
-        'span',
98
-        'strong',
99
-        'table',
100
-        'td',
101
-        'tr',
102
-        'ul',
103
-    ];
104
-
105
-
106
-    /**
107
-     * @var array
108
-     */
109
-    private static $allowed_tags;
110
-
111
-
112
-    /**
113
-     * @var array
114
-     */
115
-    private static $allowed_with_embed_tags;
116
-
117
-
118
-    /**
119
-     * @var array
120
-     */
121
-    private static $allowed_with_form_tags;
122
-
123
-
124
-    /**
125
-     * @var array
126
-     */
127
-    private static $allowed_with_script_and_style_tags;
128
-
129
-
130
-    /**
131
-     * merges additional tags and attributes into the WP post tags
132
-     */
133
-    private static function initializeAllowedTags()
134
-    {
135
-        $allowed_post_tags = wp_kses_allowed_html('post');
136
-        $allowed_tags = [];
137
-        foreach (AllowedTags::$tags as $tag) {
138
-            $allowed_tags[ $tag ] = AllowedTags::$attributes;
139
-        }
140
-        AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
141
-    }
142
-
143
-
144
-    /**
145
-     * merges embed tags and attributes into the EE all tags
146
-     */
147
-    private static function initializeWithEmbedTags()
148
-    {
149
-        $all_tags = AllowedTags::getAllowedTags();
150
-        $embed_tags = [
151
-            'iframe' => AllowedTags::$attributes
152
-        ];
153
-        AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
154
-    }
155
-
156
-
157
-    /**
158
-     * merges form tags and attributes into the EE all tags
159
-     */
160
-    private static function initializeWithFormTags()
161
-    {
162
-        $all_tags = AllowedTags::getAllowedTags();
163
-        $form_tags = [
164
-            'form' => AllowedTags::$attributes,
165
-            'label' => AllowedTags::$attributes,
166
-            'input' => AllowedTags::$attributes,
167
-            'select' => AllowedTags::$attributes,
168
-            'option' => AllowedTags::$attributes,
169
-            'optgroup' => AllowedTags::$attributes,
170
-            'textarea' => AllowedTags::$attributes,
171
-            'button' => AllowedTags::$attributes,
172
-            'fieldset' => AllowedTags::$attributes,
173
-            'output' => AllowedTags::$attributes,
174
-        ];
175
-        AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
176
-    }
177
-
178
-
179
-    /**
180
-     * merges form script and style tags and attributes into the EE all tags
181
-     */
182
-    private static function initializeWithScriptAndStyleTags()
183
-    {
184
-        $all_tags = AllowedTags::getAllowedTags();
185
-        $script_and_style_tags = [
186
-            'script' => AllowedTags::$attributes,
187
-            'style' => AllowedTags::$attributes,
188
-        ];
189
-        AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
190
-    }
191
-
192
-
193
-    /**
194
-     * @return array[]
195
-     */
196
-    public static function getAllowedTags()
197
-    {
198
-        if (empty(AllowedTags::$allowed_tags)) {
199
-            AllowedTags::initializeAllowedTags();
200
-        }
201
-        return AllowedTags::$allowed_tags;
202
-    }
203
-
204
-
205
-    /**
206
-     * @return array[]
207
-     */
208
-    public static function getWithEmbedTags()
209
-    {
210
-        if (empty(AllowedTags::$allowed_with_embed_tags)) {
211
-            AllowedTags::initializeWithEmbedTags();
212
-        }
213
-        return AllowedTags::$allowed_with_embed_tags;
214
-    }
215
-
216
-
217
-    /**
218
-     * @return array[]
219
-     */
220
-    public static function getWithFormTags()
221
-    {
222
-        if (empty(AllowedTags::$allowed_with_form_tags)) {
223
-            AllowedTags::initializeWithFormTags();
224
-        }
225
-        return AllowedTags::$allowed_with_form_tags;
226
-    }
227
-
228
-
229
-    /**
230
-     * @return array[]
231
-     */
232
-    public static function getWithScriptAndStyleTags()
233
-    {
234
-        if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
235
-            AllowedTags::initializeWithScriptAndStyleTags();
236
-        }
237
-        return AllowedTags::$allowed_with_script_and_style_tags;
238
-    }
16
+	/**
17
+	 * @var array[]
18
+	 */
19
+	private static $attributes = [
20
+		'accept-charset'    => 1,
21
+		'action'            => 1,
22
+		'alt'               => 1,
23
+		'allow'             => 1,
24
+		'allowfullscreen'   => 1,
25
+		'align'             => 1,
26
+		'aria-*'            => 1,
27
+		'autocomplete'      => 1,
28
+		'checked'           => 1,
29
+		'class'             => 1,
30
+		'cols'              => 1,
31
+		'content'           => 1,
32
+		'data-*'            => 1,
33
+		'dir'               => 1,
34
+		'disabled'          => 1,
35
+		'enctype'           => 1,
36
+		'for'               => 1,
37
+		'frameborder'       => 1,
38
+		'height'            => 1,
39
+		'href'              => 1,
40
+		'id'                => 1,
41
+		'itemprop'          => 1,
42
+		'itemscope'         => 1,
43
+		'itemtype'          => 1,
44
+		'label'             => 1,
45
+		'lang'              => 1,
46
+		'max'               => 1,
47
+		'maxlength'         => 1,
48
+		'method'            => 1,
49
+		'min'               => 1,
50
+		'multiple'          => 1,
51
+		'name'              => 1,
52
+		'novalidate'        => 1,
53
+		'placeholder'       => 1,
54
+		'readonly'          => 1,
55
+		'rel'               => 1,
56
+		'required'          => 1,
57
+		'rows'              => 1,
58
+		'selected'          => 1,
59
+		'src'               => 1,
60
+		'size'              => 1,
61
+		'style'             => 1,
62
+		'step'              => 1,
63
+		'tabindex'          => 1,
64
+		'target'            => 1,
65
+		'title'             => 1,
66
+		'type'              => 1,
67
+		'value'             => 1,
68
+		'width'             => 1,
69
+	];
70
+
71
+
72
+	/**
73
+	 * @var array
74
+	 */
75
+	private static $tags = [
76
+		'a',
77
+		'abbr',
78
+		'b',
79
+		'br',
80
+		'code',
81
+		'div',
82
+		'em',
83
+		'h1',
84
+		'h2',
85
+		'h3',
86
+		'h4',
87
+		'h5',
88
+		'h6',
89
+		'hr',
90
+		'i',
91
+		'img',
92
+		'li',
93
+		'ol',
94
+		'p',
95
+		'pre',
96
+		'small',
97
+		'span',
98
+		'strong',
99
+		'table',
100
+		'td',
101
+		'tr',
102
+		'ul',
103
+	];
104
+
105
+
106
+	/**
107
+	 * @var array
108
+	 */
109
+	private static $allowed_tags;
110
+
111
+
112
+	/**
113
+	 * @var array
114
+	 */
115
+	private static $allowed_with_embed_tags;
116
+
117
+
118
+	/**
119
+	 * @var array
120
+	 */
121
+	private static $allowed_with_form_tags;
122
+
123
+
124
+	/**
125
+	 * @var array
126
+	 */
127
+	private static $allowed_with_script_and_style_tags;
128
+
129
+
130
+	/**
131
+	 * merges additional tags and attributes into the WP post tags
132
+	 */
133
+	private static function initializeAllowedTags()
134
+	{
135
+		$allowed_post_tags = wp_kses_allowed_html('post');
136
+		$allowed_tags = [];
137
+		foreach (AllowedTags::$tags as $tag) {
138
+			$allowed_tags[ $tag ] = AllowedTags::$attributes;
139
+		}
140
+		AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
141
+	}
142
+
143
+
144
+	/**
145
+	 * merges embed tags and attributes into the EE all tags
146
+	 */
147
+	private static function initializeWithEmbedTags()
148
+	{
149
+		$all_tags = AllowedTags::getAllowedTags();
150
+		$embed_tags = [
151
+			'iframe' => AllowedTags::$attributes
152
+		];
153
+		AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
154
+	}
155
+
156
+
157
+	/**
158
+	 * merges form tags and attributes into the EE all tags
159
+	 */
160
+	private static function initializeWithFormTags()
161
+	{
162
+		$all_tags = AllowedTags::getAllowedTags();
163
+		$form_tags = [
164
+			'form' => AllowedTags::$attributes,
165
+			'label' => AllowedTags::$attributes,
166
+			'input' => AllowedTags::$attributes,
167
+			'select' => AllowedTags::$attributes,
168
+			'option' => AllowedTags::$attributes,
169
+			'optgroup' => AllowedTags::$attributes,
170
+			'textarea' => AllowedTags::$attributes,
171
+			'button' => AllowedTags::$attributes,
172
+			'fieldset' => AllowedTags::$attributes,
173
+			'output' => AllowedTags::$attributes,
174
+		];
175
+		AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
176
+	}
177
+
178
+
179
+	/**
180
+	 * merges form script and style tags and attributes into the EE all tags
181
+	 */
182
+	private static function initializeWithScriptAndStyleTags()
183
+	{
184
+		$all_tags = AllowedTags::getAllowedTags();
185
+		$script_and_style_tags = [
186
+			'script' => AllowedTags::$attributes,
187
+			'style' => AllowedTags::$attributes,
188
+		];
189
+		AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
190
+	}
191
+
192
+
193
+	/**
194
+	 * @return array[]
195
+	 */
196
+	public static function getAllowedTags()
197
+	{
198
+		if (empty(AllowedTags::$allowed_tags)) {
199
+			AllowedTags::initializeAllowedTags();
200
+		}
201
+		return AllowedTags::$allowed_tags;
202
+	}
203
+
204
+
205
+	/**
206
+	 * @return array[]
207
+	 */
208
+	public static function getWithEmbedTags()
209
+	{
210
+		if (empty(AllowedTags::$allowed_with_embed_tags)) {
211
+			AllowedTags::initializeWithEmbedTags();
212
+		}
213
+		return AllowedTags::$allowed_with_embed_tags;
214
+	}
215
+
216
+
217
+	/**
218
+	 * @return array[]
219
+	 */
220
+	public static function getWithFormTags()
221
+	{
222
+		if (empty(AllowedTags::$allowed_with_form_tags)) {
223
+			AllowedTags::initializeWithFormTags();
224
+		}
225
+		return AllowedTags::$allowed_with_form_tags;
226
+	}
227
+
228
+
229
+	/**
230
+	 * @return array[]
231
+	 */
232
+	public static function getWithScriptAndStyleTags()
233
+	{
234
+		if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
235
+			AllowedTags::initializeWithScriptAndStyleTags();
236
+		}
237
+		return AllowedTags::$allowed_with_script_and_style_tags;
238
+	}
239 239
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.007');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.007');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
admin/extend/registrations/templates/newsletter-send-form.template.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
             <input type="hidden" name="batch_message[id_type]" value="<?php echo esc_attr($id_type); ?>">
38 38
             <input id="newsletter-batch-ids" type="hidden" name="batch_message[ids]" value="">
39 39
             <h3 class="newsletter-send-form-title"><?php
40
-                printf(
41
-                    esc_html__('Sending batch message to %s people...', 'event_espresso'),
42
-                    '[NUMPEOPLE]'
43
-                ); ?></h3>
40
+				printf(
41
+					esc_html__('Sending batch message to %s people...', 'event_espresso'),
42
+					'[NUMPEOPLE]'
43
+				); ?></h3>
44 44
             <label for="batch-message-template-selector"><?php esc_html_e('Select Template:', 'event_espresso'); ?></label>
45 45
             <?php echo wp_kses($template_selector, AllowedTags::getWithFormTags()); ?>
46 46
             <div class="batch-message-edit-fields" style="display:none;">
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
                     <div id="shortcode-container-subject"
63 63
                          class="shortcodes-info-container ee_shortcode_chooser_container" style="display:none">
64 64
                         <p><?php
65
-                            esc_html_e(
66
-                                'The following shortcodes can be used in the subject field:',
67
-                                'event_espresso'
68
-                            ); ?></p>
65
+							esc_html_e(
66
+								'The following shortcodes can be used in the subject field:',
67
+								'event_espresso'
68
+							); ?></p>
69 69
                         <p><?php echo wp_kses($shortcodes['Subject'], AllowedTags::getAllowedTags()); ?></p>
70 70
                     </div>
71 71
                     <input type="text" name="batch_message[subject]" id="batch-message-subject"
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
                     <div id="shortcode-container-content"
79 79
                          class="shortcodes-info-container ee_shortcode_chooser_container" style="display:none">
80 80
                         <p><?php
81
-                            esc_html_e(
82
-                                'The following shortcodes can be used in the content area:',
83
-                                'event_espresso'
84
-                            ); ?></p>
81
+							esc_html_e(
82
+								'The following shortcodes can be used in the content area:',
83
+								'event_espresso'
84
+							); ?></p>
85 85
                         <p><?php echo wp_kses($shortcodes['[NEWSLETTER_CONTENT]'], AllowedTags::getAllowedTags()); ?></p>
86 86
                     </div>
87 87
                     <textarea name="batch_message[content]" id="batch-message-content"
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
                 <input type="submit" class="batch-message-submit button button-primary alignright"
91 91
                        name="batch-message-submit" value="<?php esc_html_e('Send', 'event_espresso'); ?>">
92 92
                 <button class="batch-message-cancel button button-secondary alignright"><?php
93
-                    esc_html_e(
94
-                        'Cancel',
95
-                        'event_espresso'
96
-                    ); ?></button>
93
+					esc_html_e(
94
+						'Cancel',
95
+						'event_espresso'
96
+					); ?></button>
97 97
                 <div style="clear:both"></div>
98 98
             </div>
99 99
         </form>
Please login to merge, or discard this patch.
admin_pages/registrations/templates/reg_admin_details_header.template.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -18,32 +18,32 @@
 block discarded – undo
18 18
 
19 19
 <div style="float:right">
20 20
     <?php echo sprintf(
21
-        esc_html__('View %1$sRegistrations%4$s /  %2$sTransactions%4$s for this %3$sevent%4$s.', 'event_espresso'),
22
-        '<a href="' . esc_url_raw($filtered_registrations_link) . '">',
23
-        '<a href="' . esc_url_raw($filtered_registrations_link) . '">',
24
-        '<a href="' . esc_url_raw($event_link) . '">',
25
-        '</a>'
26
-    ); ?>
21
+		esc_html__('View %1$sRegistrations%4$s /  %2$sTransactions%4$s for this %3$sevent%4$s.', 'event_espresso'),
22
+		'<a href="' . esc_url_raw($filtered_registrations_link) . '">',
23
+		'<a href="' . esc_url_raw($filtered_registrations_link) . '">',
24
+		'<a href="' . esc_url_raw($event_link) . '">',
25
+		'</a>'
26
+	); ?>
27 27
 </div>
28 28
 <h3 id="reg-admin-reg-details-reg-nmbr-hdr">
29 29
     <?php
30
-    echo wp_kses($previous_registration, AllowedTags::getAllowedTags());
31
-    echo '&nbsp;' . sprintf(
32
-        /* translators: %s: registration number */
33
-        esc_html__('Registration # %1$s', 'event_espresso'),
34
-        esc_html($reg_nmbr['value'])
35
-    ) . '&nbsp;';
36
-    echo wp_kses($next_registration, AllowedTags::getAllowedTags());
37
-    ?>
30
+	echo wp_kses($previous_registration, AllowedTags::getAllowedTags());
31
+	echo '&nbsp;' . sprintf(
32
+		/* translators: %s: registration number */
33
+		esc_html__('Registration # %1$s', 'event_espresso'),
34
+		esc_html($reg_nmbr['value'])
35
+	) . '&nbsp;';
36
+	echo wp_kses($next_registration, AllowedTags::getAllowedTags());
37
+	?>
38 38
 </h3>
39 39
 <h2 id="reg-admin-reg-details-reg-date-hdr"><?php echo esc_html($reg_datetime['value']); ?></h2>
40 40
 
41 41
 <?php if ($registration->group_size() > 1) : ?>
42 42
     <a id="scroll-to-other-attendees" class="scroll-to" href="#other-attendees">
43 43
         <?php echo esc_html__(
44
-            'Scroll to Other Registrations in the Same Transaction',
45
-            'event_espresso'
46
-        ); ?>
44
+			'Scroll to Other Registrations in the Same Transaction',
45
+			'event_espresso'
46
+		); ?>
47 47
     </a>
48 48
 <?php endif; ?>
49 49
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,20 +19,20 @@
 block discarded – undo
19 19
 <div style="float:right">
20 20
     <?php echo sprintf(
21 21
         esc_html__('View %1$sRegistrations%4$s /  %2$sTransactions%4$s for this %3$sevent%4$s.', 'event_espresso'),
22
-        '<a href="' . esc_url_raw($filtered_registrations_link) . '">',
23
-        '<a href="' . esc_url_raw($filtered_registrations_link) . '">',
24
-        '<a href="' . esc_url_raw($event_link) . '">',
22
+        '<a href="'.esc_url_raw($filtered_registrations_link).'">',
23
+        '<a href="'.esc_url_raw($filtered_registrations_link).'">',
24
+        '<a href="'.esc_url_raw($event_link).'">',
25 25
         '</a>'
26 26
     ); ?>
27 27
 </div>
28 28
 <h3 id="reg-admin-reg-details-reg-nmbr-hdr">
29 29
     <?php
30 30
     echo wp_kses($previous_registration, AllowedTags::getAllowedTags());
31
-    echo '&nbsp;' . sprintf(
31
+    echo '&nbsp;'.sprintf(
32 32
         /* translators: %s: registration number */
33 33
         esc_html__('Registration # %1$s', 'event_espresso'),
34 34
         esc_html($reg_nmbr['value'])
35
-    ) . '&nbsp;';
35
+    ).'&nbsp;';
36 36
     echo wp_kses($next_registration, AllowedTags::getAllowedTags());
37 37
     ?>
38 38
 </h3>
Please login to merge, or discard this patch.
templates/reg_admin_details_main_meta_box_reg_questions.template.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 <div id="admin-primary-mbox-questions-dv" class="admin-primary-mbox-dv">
14 14
     <p>
15 15
         <?php esc_html_e(
16
-            'This displays the custom questions and answers for this registrant.  Please note that any answers to system questions have been saved with the contact record.  You can edit those answers via the "View/Edit this Contact" link in the Contact Details metabox in the sidebar.',
17
-            'event_espresso'
18
-        ); ?>
16
+			'This displays the custom questions and answers for this registrant.  Please note that any answers to system questions have been saved with the contact record.  You can edit those answers via the "View/Edit this Contact" link in the Contact Details metabox in the sidebar.',
17
+			'event_espresso'
18
+		); ?>
19 19
     </p>
20 20
 
21 21
     <form action='<?php echo esc_url_raw(REG_ADMIN_URL); ?>'
@@ -30,24 +30,24 @@  discard block
 block discarded – undo
30 30
         <input type="hidden" name="espresso_ajax" id="espresso-ajax" value="0" />
31 31
         <input type="hidden" name="noheader" id="reg-admin-noheader-inp" value="true" />
32 32
         <?php
33
-        echo wp_kses($att_questions, AllowedTags::getWithFormTags());
34
-        if (! empty($att_questions)) :
35
-            if (
36
-                EE_Registry::instance()->CAP->current_user_can(
37
-                    'ee_edit_registration',
38
-                    'edit-reg-questions-mbox',
39
-                    $REG_ID
40
-                )
41
-            ) : ?>
33
+		echo wp_kses($att_questions, AllowedTags::getWithFormTags());
34
+		if (! empty($att_questions)) :
35
+			if (
36
+				EE_Registry::instance()->CAP->current_user_can(
37
+					'ee_edit_registration',
38
+					'edit-reg-questions-mbox',
39
+					$REG_ID
40
+				)
41
+			) : ?>
42 42
                 <input class='button-primary'
43 43
                        id="reg-admin-attendee-questions-submit"
44 44
                        type="submit"
45 45
                        value="Update Registration Questions"
46 46
                 />
47 47
                 <?php
48
-            endif;
49
-        else :
50
-            ?>
48
+			endif;
49
+		else :
50
+			?>
51 51
             <p class="ee-attention">
52 52
                 <?php esc_html_e('There were no custom questions asked for this registration.', 'event_espresso'); ?>
53 53
             </p>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
           name="reg-admin-attendee-questions-frm"
24 24
           method="post"
25 25
     >
26
-        <?php wp_nonce_field($reg_questions_form_action . '_nonce', $reg_questions_form_action . '_nonce'); ?>
26
+        <?php wp_nonce_field($reg_questions_form_action.'_nonce', $reg_questions_form_action.'_nonce'); ?>
27 27
         <input type="hidden" name="page" value="<?php echo esc_attr(REG_PG_SLUG); ?>" />
28 28
         <input type="hidden" name="action" value="<?php echo esc_html($reg_questions_form_action); ?>" />
29 29
         <input type="hidden" name="_REG_ID" value="<?php echo esc_html($REG_ID); ?>" />
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         <input type="hidden" name="noheader" id="reg-admin-noheader-inp" value="true" />
32 32
         <?php
33 33
         echo wp_kses($att_questions, AllowedTags::getWithFormTags());
34
-        if (! empty($att_questions)) :
34
+        if ( ! empty($att_questions)) :
35 35
             if (
36 36
                 EE_Registry::instance()->CAP->current_user_can(
37 37
                     'ee_edit_registration',
Please login to merge, or discard this patch.
templates/reg_admin_register_new_attendee_step_content.template.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@
 block discarded – undo
16 16
     <div class="ee-new-registration-step-content">
17 17
         <?php echo wp_kses($content, AllowedTags::getWithFormTags()); ?>
18 18
         <?php
19
-        if (
20
-            $show_notification_toggle
21
-            && EE_Registry::instance()->CAP->current_user_can(
22
-                'ee_send_message',
23
-                'registration_message_type'
24
-            )
25
-        ) : ?>
19
+		if (
20
+			$show_notification_toggle
21
+			&& EE_Registry::instance()->CAP->current_user_can(
22
+				'ee_send_message',
23
+				'registration_message_type'
24
+			)
25
+		) : ?>
26 26
             <div class="ee-attention">
27 27
                 <label for="txn_reg_status_change" class="last">
28 28
                     <?php esc_html_e('Send Related Messages?', 'event_espresso'); ?>
Please login to merge, or discard this patch.
templates/registration_page_registration_questions.template.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -10,53 +10,53 @@  discard block
 block discarded – undo
10 10
 
11 11
 <div id="single-page-checkout" class="ui-widget">
12 12
     <?php do_action(
13
-        'AHEE__registration_page_registration_questions__template__after_spco_attendee_information_header'
14
-    ) ?>
13
+		'AHEE__registration_page_registration_questions__template__after_spco_attendee_information_header'
14
+	) ?>
15 15
     <div id="spco-attendee_information-dv" class="spco-step-dv">
16 16
 
17 17
         <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text">
18 18
             <?php printf(
19
-                esc_html__(
20
-                    'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.',
21
-                    'event_espresso'
22
-                ),
23
-                '<br />',
24
-                '<span class="asterisk">*</span>'
25
-            ); ?>
19
+				esc_html__(
20
+					'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.',
21
+					'event_espresso'
22
+				),
23
+				'<br />',
24
+				'<span class="asterisk">*</span>'
25
+			); ?>
26 26
         </p>
27 27
 
28 28
         <?php
29
-        global $css_class;
30
-        $att_nmbr   = 0;
31
-        $prev_event = '';
32
-
33
-        if ($event_queue['total_items'] > 0) {
34
-            foreach ($event_queue['items'] as $line_item => $item) {
35
-                $att_nmbr++;
36
-                if ($item['attendee_questions'] != '') { ?>
29
+		global $css_class;
30
+		$att_nmbr   = 0;
31
+		$prev_event = '';
32
+
33
+		if ($event_queue['total_items'] > 0) {
34
+			foreach ($event_queue['items'] as $line_item => $item) {
35
+				$att_nmbr++;
36
+				if ($item['attendee_questions'] != '') { ?>
37 37
                     <div id="spco-attendee-panel-dv-<?php echo esc_attr($line_item); ?>" class="spco-attendee-panel-dv">
38 38
                         <?php
39
-                        if ($item['ticket']->name() != $prev_event) { ?>
39
+						if ($item['ticket']->name() != $prev_event) { ?>
40 40
                             <p class="spco-ticket-info-pg">
41 41
                                 <?php
42
-                                echo esc_html($item['ticket']->name()) . ':  ';
43
-                                echo esc_html(
44
-                                    EEH_Template::format_currency($item['ticket']->price(), false, false)
45
-                                );
46
-                                $qty_price = $item['ticket']->price() * $ticket_count[ $item['ticket']->ID() ];
47
-                                echo ($item['ticket']->qty()
48
-                                    ? ' &nbsp; x &nbsp; '
49
-                                      . absint($ticket_count[ $item['ticket']->ID() ])
50
-                                      . esc_html__(' tickets', 'event_espresso')
51
-                                      . ' &nbsp; = &nbsp; '
52
-                                      . EEH_Template::format_currency($qty_price)
53
-                                    : '');
54
-                                echo ($item['ticket']->description()
55
-                                    ? '<br/>'
56
-                                      . esc_html__('Ticket Details: ', 'event_espresso')
57
-                                      . esc_html($item['ticket']->description())
58
-                                    : '');
59
-                                ?>
42
+								echo esc_html($item['ticket']->name()) . ':  ';
43
+								echo esc_html(
44
+									EEH_Template::format_currency($item['ticket']->price(), false, false)
45
+								);
46
+								$qty_price = $item['ticket']->price() * $ticket_count[ $item['ticket']->ID() ];
47
+								echo ($item['ticket']->qty()
48
+									? ' &nbsp; x &nbsp; '
49
+									  . absint($ticket_count[ $item['ticket']->ID() ])
50
+									  . esc_html__(' tickets', 'event_espresso')
51
+									  . ' &nbsp; = &nbsp; '
52
+									  . EEH_Template::format_currency($qty_price)
53
+									: '');
54
+								echo ($item['ticket']->description()
55
+									? '<br/>'
56
+									  . esc_html__('Ticket Details: ', 'event_espresso')
57
+									  . esc_html($item['ticket']->description())
58
+									: '');
59
+								?>
60 60
                             </p>
61 61
                         <?php } ?>
62 62
 
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
                             </legend>
69 69
 
70 70
                             <?php
71
-                            // do an action before the questions output, including the item and count
72
-                            do_action(
73
-                                'AHEE__registration_page_registration_questions__template___before_questions',
74
-                                $item,
75
-                                $att_nmbr
76
-                            );
71
+							// do an action before the questions output, including the item and count
72
+							do_action(
73
+								'AHEE__registration_page_registration_questions__template___before_questions',
74
+								$item,
75
+								$att_nmbr
76
+							);
77 77
 
78
-                            echo esc_html($item['attendee_questions']);
78
+							echo esc_html($item['attendee_questions']);
79 79
 
80
-                            if ($att_nmbr == 1 && $print_copy_info) { ?>
80
+							if ($att_nmbr == 1 && $print_copy_info) { ?>
81 81
                                 <input id='primary-attendee'
82 82
                                        name="qstn[primary_attendee]"
83 83
                                        type="hidden"
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
                                     <p class="spco-copy-all-attendee-pg">
90 90
                                         <label class="wide">
91 91
                                             <?php esc_html_e(
92
-                                                'Use Registrant #1\'s information for ALL registrants',
93
-                                                'event_espresso'
94
-                                            ); ?>
92
+												'Use Registrant #1\'s information for ALL registrants',
93
+												'event_espresso'
94
+											); ?>
95 95
                                             <input class='spco-copy-all-attendee-chk ui-widget-content ui-corner-all'
96 96
                                                    id="spco-copy-all-attendee-chk"
97 97
                                                    type="checkbox"
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 
103 103
                                     <p class="spco-copy-attendee-pg">
104 104
                                         <?php esc_html_e(
105
-                                            'This option allows you to use the above information for all additional registrant question fields. <span>(&nbsp;Please note that some events may have additional questions that you may still be required to answer in order to complete your registration.&nbsp;)</span>',
106
-                                            'event_espresso'
107
-                                        ); ?>
105
+											'This option allows you to use the above information for all additional registrant question fields. <span>(&nbsp;Please note that some events may have additional questions that you may still be required to answer in order to complete your registration.&nbsp;)</span>',
106
+											'event_espresso'
107
+										); ?>
108 108
                                     </p>
109 109
 
110 110
                                     <a id="display-more-attendee-copy-options"
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
                                         </a>
124 124
                                         <p class="spco-copy-attendee-pg">
125 125
                                             <?php esc_html_e(
126
-                                                'The following checkboxes allow you to use the above information for only the selected additional event registrants.',
127
-                                                'event_espresso'
128
-                                            ); ?>
126
+												'The following checkboxes allow you to use the above information for only the selected additional event registrants.',
127
+												'event_espresso'
128
+											); ?>
129 129
                                         </p>
130 130
 
131 131
                                         <?php
132
-                                        foreach ($additional_event_attendees as $event_attendees) {
133
-                                            foreach ($event_attendees as $attendee) {
134
-                                                if ($attendee['event_hdr']) { ?>
132
+										foreach ($additional_event_attendees as $event_attendees) {
133
+											foreach ($event_attendees as $attendee) {
134
+												if ($attendee['event_hdr']) { ?>
135 135
                                                     <h6 class="spco-copy-attendee-event-hdr">
136 136
                                                         <?php echo esc_html($attendee['event_hdr']); ?>
137 137
                                                     </h6>
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
                                                 <p class="event_form_field spco-copy-attendee-chk-pg">
141 141
                                                     <label>
142 142
                                                         <?php
143
-                                                        echo esc_html__('Attendee #', 'event_espresso')
144
-                                                             . esc_html($attendee['att_nmbr']);
145
-                                                        ?>
143
+														echo esc_html__('Attendee #', 'event_espresso')
144
+															 . esc_html($attendee['att_nmbr']);
145
+														?>
146 146
                                                         <input class="spco-copy-attendee-chk <?php echo esc_attr($css_class); ?>"
147 147
                                                                id="spco-copy-attendee-chk-<?php echo esc_attr($attendee['input_id']);?>"
148 148
                                                                type="checkbox"
@@ -160,25 +160,25 @@  discard block
 block discarded – undo
160 160
                                     <div class="clear-float"></div>
161 161
                                 </div>
162 162
                                 <?php
163
-                                $print_copy_info = false;
164
-                            } elseif ($att_nmbr == 1) {
165
-                                ?>
163
+								$print_copy_info = false;
164
+							} elseif ($att_nmbr == 1) {
165
+								?>
166 166
                                 <p id="spco-auto-copy-attendee-pg" class="smaller-text lt-grey-text">
167 167
                                     <?php esc_html_e(
168
-                                        'The above information will be used for any additional tickets/registrants.',
169
-                                        'event_espresso'
170
-                                    ); ?>
168
+										'The above information will be used for any additional tickets/registrants.',
169
+										'event_espresso'
170
+									); ?>
171 171
                                 </p>
172 172
                                 <?php
173
-                            }
174
-                            ?>
173
+							}
174
+							?>
175 175
                         </fieldset>
176 176
 
177 177
                     </div>
178 178
                     <?php
179
-                } else {
180
-                    if ($att_nmbr == 1) {
181
-                        ?>
179
+				} else {
180
+					if ($att_nmbr == 1) {
181
+						?>
182 182
                         <div class='spco-attendee-panel-dv'
183 183
                              id="spco-attendee-panel-dv-<?php echo esc_attr($line_item); ?>"
184 184
                         >
@@ -192,21 +192,21 @@  discard block
 block discarded – undo
192 192
                             >
193 193
                                 <h6>
194 194
                                     <?php esc_html_e(
195
-                                        'No information is required to attend this event. Please proceed to the next Step',
196
-                                        'event_espresso'
197
-                                    ); ?>
195
+										'No information is required to attend this event. Please proceed to the next Step',
196
+										'event_espresso'
197
+									); ?>
198 198
                                 </h6>
199 199
                                 <input type="hidden" id="no-questions" name="qstn[]" value="0" />
200 200
                             </fieldset>
201 201
                         </div>
202 202
                         <?php
203
-                    }
204
-                }
205
-                echo esc_html($item['additional_attendee_reg_info']);
206
-                $prev_event = $item['ticket']->name();
207
-            } // $event_queue['items'] as $line_item
208
-        } // $event_queue['total_items']
209
-        ?>
203
+					}
204
+				}
205
+				echo esc_html($item['additional_attendee_reg_info']);
206
+				$prev_event = $item['ticket']->name();
207
+			} // $event_queue['items'] as $line_item
208
+		} // $event_queue['total_items']
209
+		?>
210 210
         <div>
211 211
             <a id="spco-display-event-questions-lnk"
212 212
                class="act-like-link smaller-text hidden hide-if-no-js float-right"
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
                         if ($item['ticket']->name() != $prev_event) { ?>
40 40
                             <p class="spco-ticket-info-pg">
41 41
                                 <?php
42
-                                echo esc_html($item['ticket']->name()) . ':  ';
42
+                                echo esc_html($item['ticket']->name()).':  ';
43 43
                                 echo esc_html(
44 44
                                     EEH_Template::format_currency($item['ticket']->price(), false, false)
45 45
                                 );
46
-                                $qty_price = $item['ticket']->price() * $ticket_count[ $item['ticket']->ID() ];
46
+                                $qty_price = $item['ticket']->price() * $ticket_count[$item['ticket']->ID()];
47 47
                                 echo ($item['ticket']->qty()
48 48
                                     ? ' &nbsp; x &nbsp; '
49
-                                      . absint($ticket_count[ $item['ticket']->ID() ])
49
+                                      . absint($ticket_count[$item['ticket']->ID()])
50 50
                                       . esc_html__(' tickets', 'event_espresso')
51 51
                                       . ' &nbsp; = &nbsp; '
52 52
                                       . EEH_Template::format_currency($qty_price)
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                                   id="spco-attendee-wrap-<?php echo esc_attr($line_item); ?>"
65 65
                         >
66 66
                             <legend class="spco-attendee-lgnd smaller-text lt-grey-text">
67
-                                <?php echo esc_html__('Registrant #', 'event_espresso') . $att_nmbr; ?>
67
+                                <?php echo esc_html__('Registrant #', 'event_espresso').$att_nmbr; ?>
68 68
                             </legend>
69 69
 
70 70
                             <?php
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                                                              . esc_html($attendee['att_nmbr']);
145 145
                                                         ?>
146 146
                                                         <input class="spco-copy-attendee-chk <?php echo esc_attr($css_class); ?>"
147
-                                                               id="spco-copy-attendee-chk-<?php echo esc_attr($attendee['input_id']);?>"
147
+                                                               id="spco-copy-attendee-chk-<?php echo esc_attr($attendee['input_id']); ?>"
148 148
                                                                type="checkbox"
149 149
                                                                value="<?php echo esc_attr($attendee['input_id']); ?>"
150 150
                                                         />
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Indentation   +3683 added lines, -3683 removed lines patch added patch discarded remove patch
@@ -20,2227 +20,2227 @@  discard block
 block discarded – undo
20 20
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Registration
25
-     */
26
-    private $_registration;
27
-
28
-    /**
29
-     * @var EE_Event
30
-     */
31
-    private $_reg_event;
32
-
33
-    /**
34
-     * @var EE_Session
35
-     */
36
-    private $_session;
37
-
38
-    /**
39
-     * @var array
40
-     */
41
-    private static $_reg_status;
42
-
43
-    /**
44
-     * Form for displaying the custom questions for this registration.
45
-     * This gets used a few times throughout the request so its best to cache it
46
-     *
47
-     * @var EE_Registration_Custom_Questions_Form
48
-     */
49
-    protected $_reg_custom_questions_form = null;
50
-
51
-    /**
52
-     * @var EEM_Registration $registration_model
53
-     */
54
-    private $registration_model;
55
-
56
-    /**
57
-     * @var EEM_Attendee $attendee_model
58
-     */
59
-    private $attendee_model;
60
-
61
-    /**
62
-     * @var EEM_Event $event_model
63
-     */
64
-    private $event_model;
65
-
66
-    /**
67
-     * @var EEM_Status $status_model
68
-     */
69
-    private $status_model;
70
-
71
-
72
-    /**
73
-     * @param bool $routing
74
-     * @throws EE_Error
75
-     * @throws InvalidArgumentException
76
-     * @throws InvalidDataTypeException
77
-     * @throws InvalidInterfaceException
78
-     * @throws ReflectionException
79
-     */
80
-    public function __construct($routing = true)
81
-    {
82
-        parent::__construct($routing);
83
-        add_action('wp_loaded', [$this, 'wp_loaded']);
84
-    }
85
-
86
-
87
-    /**
88
-     * @return EEM_Registration
89
-     * @throws InvalidArgumentException
90
-     * @throws InvalidDataTypeException
91
-     * @throws InvalidInterfaceException
92
-     * @since 4.10.2.p
93
-     */
94
-    protected function getRegistrationModel()
95
-    {
96
-        if (! $this->registration_model instanceof EEM_Registration) {
97
-            $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
98
-        }
99
-        return $this->registration_model;
100
-    }
101
-
102
-
103
-    /**
104
-     * @return EEM_Attendee
105
-     * @throws InvalidArgumentException
106
-     * @throws InvalidDataTypeException
107
-     * @throws InvalidInterfaceException
108
-     * @since 4.10.2.p
109
-     */
110
-    protected function getAttendeeModel()
111
-    {
112
-        if (! $this->attendee_model instanceof EEM_Attendee) {
113
-            $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
114
-        }
115
-        return $this->attendee_model;
116
-    }
117
-
118
-
119
-    /**
120
-     * @return EEM_Event
121
-     * @throws InvalidArgumentException
122
-     * @throws InvalidDataTypeException
123
-     * @throws InvalidInterfaceException
124
-     * @since 4.10.2.p
125
-     */
126
-    protected function getEventModel()
127
-    {
128
-        if (! $this->event_model instanceof EEM_Event) {
129
-            $this->event_model = $this->getLoader()->getShared('EEM_Event');
130
-        }
131
-        return $this->event_model;
132
-    }
133
-
134
-
135
-    /**
136
-     * @return EEM_Status
137
-     * @throws InvalidArgumentException
138
-     * @throws InvalidDataTypeException
139
-     * @throws InvalidInterfaceException
140
-     * @since 4.10.2.p
141
-     */
142
-    protected function getStatusModel()
143
-    {
144
-        if (! $this->status_model instanceof EEM_Status) {
145
-            $this->status_model = $this->getLoader()->getShared('EEM_Status');
146
-        }
147
-        return $this->status_model;
148
-    }
149
-
150
-
151
-    public function wp_loaded()
152
-    {
153
-        // when adding a new registration...
154
-        $action = $this->request->getRequestParam('action');
155
-        if ($action === 'new_registration') {
156
-            EE_System::do_not_cache();
157
-            if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
158
-                // and it's NOT the attendee information reg step
159
-                // force cookie expiration by setting time to last week
160
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
161
-                // and update the global
162
-                $_COOKIE['ee_registration_added'] = 0;
163
-            }
164
-        }
165
-    }
166
-
167
-
168
-    protected function _init_page_props()
169
-    {
170
-        $this->page_slug        = REG_PG_SLUG;
171
-        $this->_admin_base_url  = REG_ADMIN_URL;
172
-        $this->_admin_base_path = REG_ADMIN;
173
-        $this->page_label       = esc_html__('Registrations', 'event_espresso');
174
-        $this->_cpt_routes      = [
175
-            'add_new_attendee' => 'espresso_attendees',
176
-            'edit_attendee'    => 'espresso_attendees',
177
-            'insert_attendee'  => 'espresso_attendees',
178
-            'update_attendee'  => 'espresso_attendees',
179
-        ];
180
-        $this->_cpt_model_names = [
181
-            'add_new_attendee' => 'EEM_Attendee',
182
-            'edit_attendee'    => 'EEM_Attendee',
183
-        ];
184
-        $this->_cpt_edit_routes = [
185
-            'espresso_attendees' => 'edit_attendee',
186
-        ];
187
-        $this->_pagenow_map     = [
188
-            'add_new_attendee' => 'post-new.php',
189
-            'edit_attendee'    => 'post.php',
190
-            'trash'            => 'post.php',
191
-        ];
192
-        add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
193
-        // add filters so that the comment urls don't take users to a confusing 404 page
194
-        add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
195
-    }
196
-
197
-
198
-    /**
199
-     * @param string     $link    The comment permalink with '#comment-$id' appended.
200
-     * @param WP_Comment $comment The current comment object.
201
-     * @return string
202
-     */
203
-    public function clear_comment_link($link, WP_Comment $comment)
204
-    {
205
-        // gotta make sure this only happens on this route
206
-        $post_type = get_post_type($comment->comment_post_ID);
207
-        if ($post_type === 'espresso_attendees') {
208
-            return '#commentsdiv';
209
-        }
210
-        return $link;
211
-    }
212
-
213
-
214
-    protected function _ajax_hooks()
215
-    {
216
-        // todo: all hooks for registrations ajax goes in here
217
-        add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
218
-    }
219
-
220
-
221
-    protected function _define_page_props()
222
-    {
223
-        $this->_admin_page_title = $this->page_label;
224
-        $this->_labels           = [
225
-            'buttons'                      => [
226
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
227
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
228
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
229
-                'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
230
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
231
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
232
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
233
-                'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
234
-            ],
235
-            'publishbox'                   => [
236
-                'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
237
-                'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
238
-            ],
239
-            'hide_add_button_on_cpt_route' => [
240
-                'edit_attendee' => true,
241
-            ],
242
-        ];
243
-    }
244
-
245
-
246
-    /**
247
-     * grab url requests and route them
248
-     *
249
-     * @return void
250
-     * @throws EE_Error
251
-     */
252
-    public function _set_page_routes()
253
-    {
254
-        $this->_get_registration_status_array();
255
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
256
-        $REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
257
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
258
-        $ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
259
-        $this->_page_routes = [
260
-            'default'                             => [
261
-                'func'       => '_registrations_overview_list_table',
262
-                'capability' => 'ee_read_registrations',
263
-            ],
264
-            'view_registration'                   => [
265
-                'func'       => '_registration_details',
266
-                'capability' => 'ee_read_registration',
267
-                'obj_id'     => $REG_ID,
268
-            ],
269
-            'edit_registration'                   => [
270
-                'func'               => '_update_attendee_registration_form',
271
-                'noheader'           => true,
272
-                'headers_sent_route' => 'view_registration',
273
-                'capability'         => 'ee_edit_registration',
274
-                'obj_id'             => $REG_ID,
275
-                '_REG_ID'            => $REG_ID,
276
-            ],
277
-            'trash_registrations'                 => [
278
-                'func'       => '_trash_or_restore_registrations',
279
-                'args'       => ['trash' => true],
280
-                'noheader'   => true,
281
-                'capability' => 'ee_delete_registrations',
282
-            ],
283
-            'restore_registrations'               => [
284
-                'func'       => '_trash_or_restore_registrations',
285
-                'args'       => ['trash' => false],
286
-                'noheader'   => true,
287
-                'capability' => 'ee_delete_registrations',
288
-            ],
289
-            'delete_registrations'                => [
290
-                'func'       => '_delete_registrations',
291
-                'noheader'   => true,
292
-                'capability' => 'ee_delete_registrations',
293
-            ],
294
-            'new_registration'                    => [
295
-                'func'       => 'new_registration',
296
-                'capability' => 'ee_edit_registrations',
297
-            ],
298
-            'process_reg_step'                    => [
299
-                'func'       => 'process_reg_step',
300
-                'noheader'   => true,
301
-                'capability' => 'ee_edit_registrations',
302
-            ],
303
-            'redirect_to_txn'                     => [
304
-                'func'       => 'redirect_to_txn',
305
-                'noheader'   => true,
306
-                'capability' => 'ee_edit_registrations',
307
-            ],
308
-            'change_reg_status'                   => [
309
-                'func'       => '_change_reg_status',
310
-                'noheader'   => true,
311
-                'capability' => 'ee_edit_registration',
312
-                'obj_id'     => $REG_ID,
313
-            ],
314
-            'approve_registration'                => [
315
-                'func'       => 'approve_registration',
316
-                'noheader'   => true,
317
-                'capability' => 'ee_edit_registration',
318
-                'obj_id'     => $REG_ID,
319
-            ],
320
-            'approve_and_notify_registration'     => [
321
-                'func'       => 'approve_registration',
322
-                'noheader'   => true,
323
-                'args'       => [true],
324
-                'capability' => 'ee_edit_registration',
325
-                'obj_id'     => $REG_ID,
326
-            ],
327
-            'approve_registrations'               => [
328
-                'func'       => 'bulk_action_on_registrations',
329
-                'noheader'   => true,
330
-                'capability' => 'ee_edit_registrations',
331
-                'args'       => ['approve'],
332
-            ],
333
-            'approve_and_notify_registrations'    => [
334
-                'func'       => 'bulk_action_on_registrations',
335
-                'noheader'   => true,
336
-                'capability' => 'ee_edit_registrations',
337
-                'args'       => ['approve', true],
338
-            ],
339
-            'decline_registration'                => [
340
-                'func'       => 'decline_registration',
341
-                'noheader'   => true,
342
-                'capability' => 'ee_edit_registration',
343
-                'obj_id'     => $REG_ID,
344
-            ],
345
-            'decline_and_notify_registration'     => [
346
-                'func'       => 'decline_registration',
347
-                'noheader'   => true,
348
-                'args'       => [true],
349
-                'capability' => 'ee_edit_registration',
350
-                'obj_id'     => $REG_ID,
351
-            ],
352
-            'decline_registrations'               => [
353
-                'func'       => 'bulk_action_on_registrations',
354
-                'noheader'   => true,
355
-                'capability' => 'ee_edit_registrations',
356
-                'args'       => ['decline'],
357
-            ],
358
-            'decline_and_notify_registrations'    => [
359
-                'func'       => 'bulk_action_on_registrations',
360
-                'noheader'   => true,
361
-                'capability' => 'ee_edit_registrations',
362
-                'args'       => ['decline', true],
363
-            ],
364
-            'pending_registration'                => [
365
-                'func'       => 'pending_registration',
366
-                'noheader'   => true,
367
-                'capability' => 'ee_edit_registration',
368
-                'obj_id'     => $REG_ID,
369
-            ],
370
-            'pending_and_notify_registration'     => [
371
-                'func'       => 'pending_registration',
372
-                'noheader'   => true,
373
-                'args'       => [true],
374
-                'capability' => 'ee_edit_registration',
375
-                'obj_id'     => $REG_ID,
376
-            ],
377
-            'pending_registrations'               => [
378
-                'func'       => 'bulk_action_on_registrations',
379
-                'noheader'   => true,
380
-                'capability' => 'ee_edit_registrations',
381
-                'args'       => ['pending'],
382
-            ],
383
-            'pending_and_notify_registrations'    => [
384
-                'func'       => 'bulk_action_on_registrations',
385
-                'noheader'   => true,
386
-                'capability' => 'ee_edit_registrations',
387
-                'args'       => ['pending', true],
388
-            ],
389
-            'no_approve_registration'             => [
390
-                'func'       => 'not_approve_registration',
391
-                'noheader'   => true,
392
-                'capability' => 'ee_edit_registration',
393
-                'obj_id'     => $REG_ID,
394
-            ],
395
-            'no_approve_and_notify_registration'  => [
396
-                'func'       => 'not_approve_registration',
397
-                'noheader'   => true,
398
-                'args'       => [true],
399
-                'capability' => 'ee_edit_registration',
400
-                'obj_id'     => $REG_ID,
401
-            ],
402
-            'no_approve_registrations'            => [
403
-                'func'       => 'bulk_action_on_registrations',
404
-                'noheader'   => true,
405
-                'capability' => 'ee_edit_registrations',
406
-                'args'       => ['not_approve'],
407
-            ],
408
-            'no_approve_and_notify_registrations' => [
409
-                'func'       => 'bulk_action_on_registrations',
410
-                'noheader'   => true,
411
-                'capability' => 'ee_edit_registrations',
412
-                'args'       => ['not_approve', true],
413
-            ],
414
-            'cancel_registration'                 => [
415
-                'func'       => 'cancel_registration',
416
-                'noheader'   => true,
417
-                'capability' => 'ee_edit_registration',
418
-                'obj_id'     => $REG_ID,
419
-            ],
420
-            'cancel_and_notify_registration'      => [
421
-                'func'       => 'cancel_registration',
422
-                'noheader'   => true,
423
-                'args'       => [true],
424
-                'capability' => 'ee_edit_registration',
425
-                'obj_id'     => $REG_ID,
426
-            ],
427
-            'cancel_registrations'                => [
428
-                'func'       => 'bulk_action_on_registrations',
429
-                'noheader'   => true,
430
-                'capability' => 'ee_edit_registrations',
431
-                'args'       => ['cancel'],
432
-            ],
433
-            'cancel_and_notify_registrations'     => [
434
-                'func'       => 'bulk_action_on_registrations',
435
-                'noheader'   => true,
436
-                'capability' => 'ee_edit_registrations',
437
-                'args'       => ['cancel', true],
438
-            ],
439
-            'wait_list_registration'              => [
440
-                'func'       => 'wait_list_registration',
441
-                'noheader'   => true,
442
-                'capability' => 'ee_edit_registration',
443
-                'obj_id'     => $REG_ID,
444
-            ],
445
-            'wait_list_and_notify_registration'   => [
446
-                'func'       => 'wait_list_registration',
447
-                'noheader'   => true,
448
-                'args'       => [true],
449
-                'capability' => 'ee_edit_registration',
450
-                'obj_id'     => $REG_ID,
451
-            ],
452
-            'contact_list'                        => [
453
-                'func'       => '_attendee_contact_list_table',
454
-                'capability' => 'ee_read_contacts',
455
-            ],
456
-            'add_new_attendee'                    => [
457
-                'func' => '_create_new_cpt_item',
458
-                'args' => [
459
-                    'new_attendee' => true,
460
-                    'capability'   => 'ee_edit_contacts',
461
-                ],
462
-            ],
463
-            'edit_attendee'                       => [
464
-                'func'       => '_edit_cpt_item',
465
-                'capability' => 'ee_edit_contacts',
466
-                'obj_id'     => $ATT_ID,
467
-            ],
468
-            'duplicate_attendee'                  => [
469
-                'func'       => '_duplicate_attendee',
470
-                'noheader'   => true,
471
-                'capability' => 'ee_edit_contacts',
472
-                'obj_id'     => $ATT_ID,
473
-            ],
474
-            'insert_attendee'                     => [
475
-                'func'       => '_insert_or_update_attendee',
476
-                'args'       => [
477
-                    'new_attendee' => true,
478
-                ],
479
-                'noheader'   => true,
480
-                'capability' => 'ee_edit_contacts',
481
-            ],
482
-            'update_attendee'                     => [
483
-                'func'       => '_insert_or_update_attendee',
484
-                'args'       => [
485
-                    'new_attendee' => false,
486
-                ],
487
-                'noheader'   => true,
488
-                'capability' => 'ee_edit_contacts',
489
-                'obj_id'     => $ATT_ID,
490
-            ],
491
-            'trash_attendees'                     => [
492
-                'func'       => '_trash_or_restore_attendees',
493
-                'args'       => [
494
-                    'trash' => 'true',
495
-                ],
496
-                'noheader'   => true,
497
-                'capability' => 'ee_delete_contacts',
498
-            ],
499
-            'trash_attendee'                      => [
500
-                'func'       => '_trash_or_restore_attendees',
501
-                'args'       => [
502
-                    'trash' => true,
503
-                ],
504
-                'noheader'   => true,
505
-                'capability' => 'ee_delete_contacts',
506
-                'obj_id'     => $ATT_ID,
507
-            ],
508
-            'restore_attendees'                   => [
509
-                'func'       => '_trash_or_restore_attendees',
510
-                'args'       => [
511
-                    'trash' => false,
512
-                ],
513
-                'noheader'   => true,
514
-                'capability' => 'ee_delete_contacts',
515
-                'obj_id'     => $ATT_ID,
516
-            ],
517
-            'resend_registration'                 => [
518
-                'func'       => '_resend_registration',
519
-                'noheader'   => true,
520
-                'capability' => 'ee_send_message',
521
-            ],
522
-            'registrations_report'                => [
523
-                'func'       => '_registrations_report',
524
-                'noheader'   => true,
525
-                'capability' => 'ee_read_registrations',
526
-            ],
527
-            'contact_list_export'                 => [
528
-                'func'       => '_contact_list_export',
529
-                'noheader'   => true,
530
-                'capability' => 'export',
531
-            ],
532
-            'contact_list_report'                 => [
533
-                'func'       => '_contact_list_report',
534
-                'noheader'   => true,
535
-                'capability' => 'ee_read_contacts',
536
-            ],
537
-        ];
538
-    }
539
-
540
-
541
-    protected function _set_page_config()
542
-    {
543
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
544
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
545
-        $this->_page_config = [
546
-            'default'           => [
547
-                'nav'           => [
548
-                    'label' => esc_html__('Overview', 'event_espresso'),
549
-                    'order' => 5,
550
-                ],
551
-                'help_tabs'     => [
552
-                    'registrations_overview_help_tab'                       => [
553
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
554
-                        'filename' => 'registrations_overview',
555
-                    ],
556
-                    'registrations_overview_table_column_headings_help_tab' => [
557
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
558
-                        'filename' => 'registrations_overview_table_column_headings',
559
-                    ],
560
-                    'registrations_overview_filters_help_tab'               => [
561
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
562
-                        'filename' => 'registrations_overview_filters',
563
-                    ],
564
-                    'registrations_overview_views_help_tab'                 => [
565
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
566
-                        'filename' => 'registrations_overview_views',
567
-                    ],
568
-                    'registrations_regoverview_other_help_tab'              => [
569
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
570
-                        'filename' => 'registrations_overview_other',
571
-                    ],
572
-                ],
573
-                'qtips'         => ['Registration_List_Table_Tips'],
574
-                'list_table'    => 'EE_Registrations_List_Table',
575
-                'require_nonce' => false,
576
-            ],
577
-            'view_registration' => [
578
-                'nav'           => [
579
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
580
-                    'order'      => 15,
581
-                    'url'        => $REG_ID
582
-                        ? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
583
-                        : $this->_admin_base_url,
584
-                    'persistent' => false,
585
-                ],
586
-                'help_tabs'     => [
587
-                    'registrations_details_help_tab'                    => [
588
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
589
-                        'filename' => 'registrations_details',
590
-                    ],
591
-                    'registrations_details_table_help_tab'              => [
592
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
593
-                        'filename' => 'registrations_details_table',
594
-                    ],
595
-                    'registrations_details_form_answers_help_tab'       => [
596
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
597
-                        'filename' => 'registrations_details_form_answers',
598
-                    ],
599
-                    'registrations_details_registrant_details_help_tab' => [
600
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
601
-                        'filename' => 'registrations_details_registrant_details',
602
-                    ],
603
-                ],
604
-                'metaboxes'     => array_merge(
605
-                    $this->_default_espresso_metaboxes,
606
-                    ['_registration_details_metaboxes']
607
-                ),
608
-                'require_nonce' => false,
609
-            ],
610
-            'new_registration'  => [
611
-                'nav'           => [
612
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
613
-                    'url'        => '#',
614
-                    'order'      => 15,
615
-                    'persistent' => false,
616
-                ],
617
-                'metaboxes'     => $this->_default_espresso_metaboxes,
618
-                'labels'        => [
619
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
620
-                ],
621
-                'require_nonce' => false,
622
-            ],
623
-            'add_new_attendee'  => [
624
-                'nav'           => [
625
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
626
-                    'order'      => 15,
627
-                    'persistent' => false,
628
-                ],
629
-                'metaboxes'     => array_merge(
630
-                    $this->_default_espresso_metaboxes,
631
-                    ['_publish_post_box', 'attendee_editor_metaboxes']
632
-                ),
633
-                'require_nonce' => false,
634
-            ],
635
-            'edit_attendee'     => [
636
-                'nav'           => [
637
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
638
-                    'order'      => 15,
639
-                    'persistent' => false,
640
-                    'url'        => $ATT_ID
641
-                        ? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
642
-                        : $this->_admin_base_url,
643
-                ],
644
-                'metaboxes'     => ['attendee_editor_metaboxes'],
645
-                'require_nonce' => false,
646
-            ],
647
-            'contact_list'      => [
648
-                'nav'           => [
649
-                    'label' => esc_html__('Contact List', 'event_espresso'),
650
-                    'order' => 20,
651
-                ],
652
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
653
-                'help_tabs'     => [
654
-                    'registrations_contact_list_help_tab'                       => [
655
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
656
-                        'filename' => 'registrations_contact_list',
657
-                    ],
658
-                    'registrations_contact-list_table_column_headings_help_tab' => [
659
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
660
-                        'filename' => 'registrations_contact_list_table_column_headings',
661
-                    ],
662
-                    'registrations_contact_list_views_help_tab'                 => [
663
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
664
-                        'filename' => 'registrations_contact_list_views',
665
-                    ],
666
-                    'registrations_contact_list_other_help_tab'                 => [
667
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
668
-                        'filename' => 'registrations_contact_list_other',
669
-                    ],
670
-                ],
671
-                'metaboxes'     => [],
672
-                'require_nonce' => false,
673
-            ],
674
-            // override default cpt routes
675
-            'create_new'        => '',
676
-            'edit'              => '',
677
-        ];
678
-    }
679
-
680
-
681
-    /**
682
-     * The below methods aren't used by this class currently
683
-     */
684
-    protected function _add_screen_options()
685
-    {
686
-    }
687
-
688
-
689
-    protected function _add_feature_pointers()
690
-    {
691
-    }
692
-
693
-
694
-    public function admin_init()
695
-    {
696
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
697
-            'click "Update Registration Questions" to save your changes',
698
-            'event_espresso'
699
-        );
700
-    }
701
-
702
-
703
-    public function admin_notices()
704
-    {
705
-    }
706
-
707
-
708
-    public function admin_footer_scripts()
709
-    {
710
-    }
711
-
712
-
713
-    /**
714
-     * get list of registration statuses
715
-     *
716
-     * @return void
717
-     * @throws EE_Error
718
-     */
719
-    private function _get_registration_status_array()
720
-    {
721
-        self::$_reg_status = EEM_Registration::reg_status_array([], true);
722
-    }
723
-
724
-
725
-    /**
726
-     * @throws InvalidArgumentException
727
-     * @throws InvalidDataTypeException
728
-     * @throws InvalidInterfaceException
729
-     * @since 4.10.2.p
730
-     */
731
-    protected function _add_screen_options_default()
732
-    {
733
-        $this->_per_page_screen_option();
734
-    }
735
-
736
-
737
-    /**
738
-     * @throws InvalidArgumentException
739
-     * @throws InvalidDataTypeException
740
-     * @throws InvalidInterfaceException
741
-     * @since 4.10.2.p
742
-     */
743
-    protected function _add_screen_options_contact_list()
744
-    {
745
-        $page_title              = $this->_admin_page_title;
746
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
747
-        $this->_per_page_screen_option();
748
-        $this->_admin_page_title = $page_title;
749
-    }
750
-
751
-
752
-    public function load_scripts_styles()
753
-    {
754
-        // style
755
-        wp_register_style(
756
-            'espresso_reg',
757
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
758
-            ['ee-admin-css'],
759
-            EVENT_ESPRESSO_VERSION
760
-        );
761
-        wp_enqueue_style('espresso_reg');
762
-        // script
763
-        wp_register_script(
764
-            'espresso_reg',
765
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
766
-            ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
767
-            EVENT_ESPRESSO_VERSION,
768
-            true
769
-        );
770
-        wp_enqueue_script('espresso_reg');
771
-    }
772
-
773
-
774
-    /**
775
-     * @throws EE_Error
776
-     * @throws InvalidArgumentException
777
-     * @throws InvalidDataTypeException
778
-     * @throws InvalidInterfaceException
779
-     * @throws ReflectionException
780
-     * @since 4.10.2.p
781
-     */
782
-    public function load_scripts_styles_edit_attendee()
783
-    {
784
-        // stuff to only show up on our attendee edit details page.
785
-        $attendee_details_translations = [
786
-            'att_publish_text' => sprintf(
787
-            /* translators: The date and time */
788
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
789
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
790
-            ),
791
-        ];
792
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
793
-        wp_enqueue_script('jquery-validate');
794
-    }
795
-
796
-
797
-    /**
798
-     * @throws EE_Error
799
-     * @throws InvalidArgumentException
800
-     * @throws InvalidDataTypeException
801
-     * @throws InvalidInterfaceException
802
-     * @throws ReflectionException
803
-     * @since 4.10.2.p
804
-     */
805
-    public function load_scripts_styles_view_registration()
806
-    {
807
-        // styles
808
-        wp_enqueue_style('espresso-ui-theme');
809
-        // scripts
810
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
811
-        $this->_reg_custom_questions_form->wp_enqueue_scripts();
812
-    }
813
-
814
-
815
-    public function load_scripts_styles_contact_list()
816
-    {
817
-        wp_dequeue_style('espresso_reg');
818
-        wp_register_style(
819
-            'espresso_att',
820
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
821
-            ['ee-admin-css'],
822
-            EVENT_ESPRESSO_VERSION
823
-        );
824
-        wp_enqueue_style('espresso_att');
825
-    }
826
-
827
-
828
-    public function load_scripts_styles_new_registration()
829
-    {
830
-        wp_register_script(
831
-            'ee-spco-for-admin',
832
-            REG_ASSETS_URL . 'spco_for_admin.js',
833
-            ['underscore', 'jquery'],
834
-            EVENT_ESPRESSO_VERSION,
835
-            true
836
-        );
837
-        wp_enqueue_script('ee-spco-for-admin');
838
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
839
-        EE_Form_Section_Proper::wp_enqueue_scripts();
840
-        EED_Ticket_Selector::load_tckt_slctr_assets();
841
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
842
-    }
843
-
844
-
845
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
846
-    {
847
-        add_filter('FHEE_load_EE_messages', '__return_true');
848
-    }
849
-
850
-
851
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
852
-    {
853
-        add_filter('FHEE_load_EE_messages', '__return_true');
854
-    }
855
-
856
-
857
-    /**
858
-     * @throws EE_Error
859
-     * @throws InvalidArgumentException
860
-     * @throws InvalidDataTypeException
861
-     * @throws InvalidInterfaceException
862
-     * @throws ReflectionException
863
-     * @since 4.10.2.p
864
-     */
865
-    protected function _set_list_table_views_default()
866
-    {
867
-        // for notification related bulk actions we need to make sure only active messengers have an option.
868
-        EED_Messages::set_autoloaders();
869
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
870
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
871
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
872
-        // key= bulk_action_slug, value= message type.
873
-        $match_array = [
874
-            'approve_registrations'    => 'registration',
875
-            'decline_registrations'    => 'declined_registration',
876
-            'pending_registrations'    => 'pending_approval',
877
-            'no_approve_registrations' => 'not_approved_registration',
878
-            'cancel_registrations'     => 'cancelled_registration',
879
-        ];
880
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
881
-            'ee_send_message',
882
-            'batch_send_messages'
883
-        );
884
-        /** setup reg status bulk actions **/
885
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
886
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
887
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
888
-                'Approve and Notify Registrations',
889
-                'event_espresso'
890
-            );
891
-        }
892
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
893
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
894
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
895
-                'Decline and Notify Registrations',
896
-                'event_espresso'
897
-            );
898
-        }
899
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
900
-            'Set Registrations to Pending Payment',
901
-            'event_espresso'
902
-        );
903
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
904
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
905
-                'Set Registrations to Pending Payment and Notify',
906
-                'event_espresso'
907
-            );
908
-        }
909
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
910
-            'Set Registrations to Not Approved',
911
-            'event_espresso'
912
-        );
913
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
914
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
915
-                'Set Registrations to Not Approved and Notify',
916
-                'event_espresso'
917
-            );
918
-        }
919
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
920
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
921
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
922
-                'Cancel Registrations and Notify',
923
-                'event_espresso'
924
-            );
925
-        }
926
-        $def_reg_status_actions = apply_filters(
927
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
928
-            $def_reg_status_actions,
929
-            $active_mts,
930
-            $can_send
931
-        );
932
-
933
-        $this->_views = [
934
-            'all'   => [
935
-                'slug'        => 'all',
936
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
937
-                'count'       => 0,
938
-                'bulk_action' => array_merge(
939
-                    $def_reg_status_actions,
940
-                    [
941
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
942
-                    ]
943
-                ),
944
-            ],
945
-            'month' => [
946
-                'slug'        => 'month',
947
-                'label'       => esc_html__('This Month', 'event_espresso'),
948
-                'count'       => 0,
949
-                'bulk_action' => array_merge(
950
-                    $def_reg_status_actions,
951
-                    [
952
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
953
-                    ]
954
-                ),
955
-            ],
956
-            'today' => [
957
-                'slug'        => 'today',
958
-                'label'       => sprintf(
959
-                    esc_html__('Today - %s', 'event_espresso'),
960
-                    date('M d, Y', current_time('timestamp'))
961
-                ),
962
-                'count'       => 0,
963
-                'bulk_action' => array_merge(
964
-                    $def_reg_status_actions,
965
-                    [
966
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
967
-                    ]
968
-                ),
969
-            ],
970
-        ];
971
-        if (
972
-            EE_Registry::instance()->CAP->current_user_can(
973
-                'ee_delete_registrations',
974
-                'espresso_registrations_delete_registration'
975
-            )
976
-        ) {
977
-            $this->_views['incomplete'] = [
978
-                'slug'        => 'incomplete',
979
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
980
-                'count'       => 0,
981
-                'bulk_action' => [
982
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
983
-                ],
984
-            ];
985
-            $this->_views['trash']      = [
986
-                'slug'        => 'trash',
987
-                'label'       => esc_html__('Trash', 'event_espresso'),
988
-                'count'       => 0,
989
-                'bulk_action' => [
990
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
991
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
992
-                ],
993
-            ];
994
-        }
995
-    }
996
-
997
-
998
-    protected function _set_list_table_views_contact_list()
999
-    {
1000
-        $this->_views = [
1001
-            'in_use' => [
1002
-                'slug'        => 'in_use',
1003
-                'label'       => esc_html__('In Use', 'event_espresso'),
1004
-                'count'       => 0,
1005
-                'bulk_action' => [
1006
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1007
-                ],
1008
-            ],
1009
-        ];
1010
-        if (
1011
-            EE_Registry::instance()->CAP->current_user_can(
1012
-                'ee_delete_contacts',
1013
-                'espresso_registrations_trash_attendees'
1014
-            )
1015
-        ) {
1016
-            $this->_views['trash'] = [
1017
-                'slug'        => 'trash',
1018
-                'label'       => esc_html__('Trash', 'event_espresso'),
1019
-                'count'       => 0,
1020
-                'bulk_action' => [
1021
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1022
-                ],
1023
-            ];
1024
-        }
1025
-    }
1026
-
1027
-
1028
-    /**
1029
-     * @return array
1030
-     * @throws EE_Error
1031
-     */
1032
-    protected function _registration_legend_items()
1033
-    {
1034
-        $fc_items = [
1035
-            'star-icon'        => [
1036
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1037
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1038
-            ],
1039
-            'view_details'     => [
1040
-                'class' => 'dashicons dashicons-clipboard',
1041
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1042
-            ],
1043
-            'edit_attendee'    => [
1044
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1045
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1046
-            ],
1047
-            'view_transaction' => [
1048
-                'class' => 'dashicons dashicons-cart',
1049
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1050
-            ],
1051
-            'view_invoice'     => [
1052
-                'class' => 'dashicons dashicons-media-spreadsheet',
1053
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1054
-            ],
1055
-        ];
1056
-        if (
1057
-            EE_Registry::instance()->CAP->current_user_can(
1058
-                'ee_send_message',
1059
-                'espresso_registrations_resend_registration'
1060
-            )
1061
-        ) {
1062
-            $fc_items['resend_registration'] = [
1063
-                'class' => 'dashicons dashicons-email-alt',
1064
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1065
-            ];
1066
-        } else {
1067
-            $fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1068
-        }
1069
-        if (
1070
-            EE_Registry::instance()->CAP->current_user_can(
1071
-                'ee_read_global_messages',
1072
-                'view_filtered_messages'
1073
-            )
1074
-        ) {
1075
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1076
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1077
-                $fc_items['view_related_messages'] = [
1078
-                    'class' => $related_for_icon['css_class'],
1079
-                    'desc'  => $related_for_icon['label'],
1080
-                ];
1081
-            }
1082
-        }
1083
-        $sc_items = [
1084
-            'approved_status'   => [
1085
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1086
-                'desc'  => EEH_Template::pretty_status(
1087
-                    EEM_Registration::status_id_approved,
1088
-                    false,
1089
-                    'sentence'
1090
-                ),
1091
-            ],
1092
-            'pending_status'    => [
1093
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1094
-                'desc'  => EEH_Template::pretty_status(
1095
-                    EEM_Registration::status_id_pending_payment,
1096
-                    false,
1097
-                    'sentence'
1098
-                ),
1099
-            ],
1100
-            'wait_list'         => [
1101
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1102
-                'desc'  => EEH_Template::pretty_status(
1103
-                    EEM_Registration::status_id_wait_list,
1104
-                    false,
1105
-                    'sentence'
1106
-                ),
1107
-            ],
1108
-            'incomplete_status' => [
1109
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1110
-                'desc'  => EEH_Template::pretty_status(
1111
-                    EEM_Registration::status_id_incomplete,
1112
-                    false,
1113
-                    'sentence'
1114
-                ),
1115
-            ],
1116
-            'not_approved'      => [
1117
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1118
-                'desc'  => EEH_Template::pretty_status(
1119
-                    EEM_Registration::status_id_not_approved,
1120
-                    false,
1121
-                    'sentence'
1122
-                ),
1123
-            ],
1124
-            'declined_status'   => [
1125
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1126
-                'desc'  => EEH_Template::pretty_status(
1127
-                    EEM_Registration::status_id_declined,
1128
-                    false,
1129
-                    'sentence'
1130
-                ),
1131
-            ],
1132
-            'cancelled_status'  => [
1133
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1134
-                'desc'  => EEH_Template::pretty_status(
1135
-                    EEM_Registration::status_id_cancelled,
1136
-                    false,
1137
-                    'sentence'
1138
-                ),
1139
-            ],
1140
-        ];
1141
-        return array_merge($fc_items, $sc_items);
1142
-    }
1143
-
1144
-
1145
-
1146
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1147
-
1148
-
1149
-    /**
1150
-     * @throws DomainException
1151
-     * @throws EE_Error
1152
-     * @throws InvalidArgumentException
1153
-     * @throws InvalidDataTypeException
1154
-     * @throws InvalidInterfaceException
1155
-     */
1156
-    protected function _registrations_overview_list_table()
1157
-    {
1158
-        $this->appendAddNewRegistrationButtonToPageTitle();
1159
-        $header_text                  = '';
1160
-        $admin_page_header_decorators = [
1161
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1162
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1163
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1164
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1165
-        ];
1166
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1167
-            $filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1168
-            $header_text             = $filter_header_decorator->getHeaderText($header_text);
1169
-        }
1170
-        $this->_template_args['admin_page_header'] = $header_text;
1171
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1172
-        $this->display_admin_list_table_page_with_no_sidebar();
1173
-    }
1174
-
1175
-
1176
-    /**
1177
-     * @throws EE_Error
1178
-     * @throws InvalidArgumentException
1179
-     * @throws InvalidDataTypeException
1180
-     * @throws InvalidInterfaceException
1181
-     */
1182
-    private function appendAddNewRegistrationButtonToPageTitle()
1183
-    {
1184
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1185
-        if (
1186
-            $EVT_ID
1187
-            && EE_Registry::instance()->CAP->current_user_can(
1188
-                'ee_edit_registrations',
1189
-                'espresso_registrations_new_registration',
1190
-                $EVT_ID
1191
-            )
1192
-        ) {
1193
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1194
-                'new_registration',
1195
-                'add-registrant',
1196
-                ['event_id' => $EVT_ID],
1197
-                'add-new-h2'
1198
-            );
1199
-        }
1200
-    }
1201
-
1202
-
1203
-    /**
1204
-     * This sets the _registration property for the registration details screen
1205
-     *
1206
-     * @return void
1207
-     * @throws EE_Error
1208
-     * @throws InvalidArgumentException
1209
-     * @throws InvalidDataTypeException
1210
-     * @throws InvalidInterfaceException
1211
-     */
1212
-    private function _set_registration_object()
1213
-    {
1214
-        // get out if we've already set the object
1215
-        if ($this->_registration instanceof EE_Registration) {
1216
-            return;
1217
-        }
1218
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1219
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1220
-            return;
1221
-        }
1222
-        $error_msg = sprintf(
1223
-            esc_html__(
1224
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1225
-                'event_espresso'
1226
-            ),
1227
-            $REG_ID
1228
-        );
1229
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1230
-        $this->_registration = null;
1231
-    }
1232
-
1233
-
1234
-    /**
1235
-     * Used to retrieve registrations for the list table.
1236
-     *
1237
-     * @param int  $per_page
1238
-     * @param bool $count
1239
-     * @param bool $this_month
1240
-     * @param bool $today
1241
-     * @return EE_Registration[]|int
1242
-     * @throws EE_Error
1243
-     * @throws InvalidArgumentException
1244
-     * @throws InvalidDataTypeException
1245
-     * @throws InvalidInterfaceException
1246
-     */
1247
-    public function get_registrations(
1248
-        $per_page = 10,
1249
-        $count = false,
1250
-        $this_month = false,
1251
-        $today = false
1252
-    ) {
1253
-        if ($this_month) {
1254
-            $this->request->setRequestParam('status', 'month');
1255
-        }
1256
-        if ($today) {
1257
-            $this->request->setRequestParam('status', 'today');
1258
-        }
1259
-        $query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1260
-        /**
1261
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1262
-         *
1263
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1264
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1265
-         *                      or if you have the development copy of EE you can view this at the path:
1266
-         *                      /docs/G--Model-System/model-query-params.md
1267
-         */
1268
-        $query_params['group_by'] = '';
1269
-
1270
-        return $count
1271
-            ? $this->getRegistrationModel()->count($query_params)
1272
-            /** @type EE_Registration[] */
1273
-            : $this->getRegistrationModel()->get_all($query_params);
1274
-    }
1275
-
1276
-
1277
-    /**
1278
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1279
-     * Note: this listens to values on the request for some of the query parameters.
1280
-     *
1281
-     * @param array $request
1282
-     * @param int   $per_page
1283
-     * @param bool  $count
1284
-     * @return array
1285
-     * @throws EE_Error
1286
-     * @throws InvalidArgumentException
1287
-     * @throws InvalidDataTypeException
1288
-     * @throws InvalidInterfaceException
1289
-     */
1290
-    protected function _get_registration_query_parameters(
1291
-        $request = [],
1292
-        $per_page = 10,
1293
-        $count = false
1294
-    ) {
1295
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1296
-        $list_table_query_builder = $this->getLoader()->getNew(
1297
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1298
-            [null, null, $request]
1299
-        );
1300
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1301
-    }
1302
-
1303
-
1304
-    public function get_registration_status_array()
1305
-    {
1306
-        return self::$_reg_status;
1307
-    }
1308
-
1309
-
1310
-
1311
-
1312
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1313
-    /**
1314
-     * generates HTML for the View Registration Details Admin page
1315
-     *
1316
-     * @return void
1317
-     * @throws DomainException
1318
-     * @throws EE_Error
1319
-     * @throws InvalidArgumentException
1320
-     * @throws InvalidDataTypeException
1321
-     * @throws InvalidInterfaceException
1322
-     * @throws EntityNotFoundException
1323
-     * @throws ReflectionException
1324
-     */
1325
-    protected function _registration_details()
1326
-    {
1327
-        $this->_template_args = [];
1328
-        $this->_set_registration_object();
1329
-        if (is_object($this->_registration)) {
1330
-            $transaction                                   = $this->_registration->transaction()
1331
-                ? $this->_registration->transaction()
1332
-                : EE_Transaction::new_instance();
1333
-            $this->_session                                = $transaction->session_data();
1334
-            $event_id                                      = $this->_registration->event_ID();
1335
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1336
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1337
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1338
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1339
-            $this->_template_args['grand_total']           = $transaction->total();
1340
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1341
-            // link back to overview
1342
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1343
-            $this->_template_args['registration']                = $this->_registration;
1344
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1345
-                [
1346
-                    'action'   => 'default',
1347
-                    'event_id' => $event_id,
1348
-                ],
1349
-                REG_ADMIN_URL
1350
-            );
1351
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1352
-                [
1353
-                    'action' => 'default',
1354
-                    'EVT_ID' => $event_id,
1355
-                    'page'   => 'espresso_transactions',
1356
-                ],
1357
-                admin_url('admin.php')
1358
-            );
1359
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1360
-                [
1361
-                    'page'   => 'espresso_events',
1362
-                    'action' => 'edit',
1363
-                    'post'   => $event_id,
1364
-                ],
1365
-                admin_url('admin.php')
1366
-            );
1367
-            // next and previous links
1368
-            $next_reg                                      = $this->_registration->next(
1369
-                null,
1370
-                [],
1371
-                'REG_ID'
1372
-            );
1373
-            $this->_template_args['next_registration']     = $next_reg
1374
-                ? $this->_next_link(
1375
-                    EE_Admin_Page::add_query_args_and_nonce(
1376
-                        [
1377
-                            'action'  => 'view_registration',
1378
-                            '_REG_ID' => $next_reg['REG_ID'],
1379
-                        ],
1380
-                        REG_ADMIN_URL
1381
-                    ),
1382
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1383
-                )
1384
-                : '';
1385
-            $previous_reg                                  = $this->_registration->previous(
1386
-                null,
1387
-                [],
1388
-                'REG_ID'
1389
-            );
1390
-            $this->_template_args['previous_registration'] = $previous_reg
1391
-                ? $this->_previous_link(
1392
-                    EE_Admin_Page::add_query_args_and_nonce(
1393
-                        [
1394
-                            'action'  => 'view_registration',
1395
-                            '_REG_ID' => $previous_reg['REG_ID'],
1396
-                        ],
1397
-                        REG_ADMIN_URL
1398
-                    ),
1399
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1400
-                )
1401
-                : '';
1402
-            // grab header
1403
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1404
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1405
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1406
-                $template_path,
1407
-                $this->_template_args,
1408
-                true
1409
-            );
1410
-        } else {
1411
-            $this->_template_args['admin_page_header'] = '';
1412
-            $this->_display_espresso_notices();
1413
-        }
1414
-        // the details template wrapper
1415
-        $this->display_admin_page_with_sidebar();
1416
-    }
1417
-
1418
-
1419
-    /**
1420
-     * @throws EE_Error
1421
-     * @throws InvalidArgumentException
1422
-     * @throws InvalidDataTypeException
1423
-     * @throws InvalidInterfaceException
1424
-     * @throws ReflectionException
1425
-     * @since 4.10.2.p
1426
-     */
1427
-    protected function _registration_details_metaboxes()
1428
-    {
1429
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1430
-        $this->_set_registration_object();
1431
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1432
-        add_meta_box(
1433
-            'edit-reg-status-mbox',
1434
-            esc_html__('Registration Status', 'event_espresso'),
1435
-            [$this, 'set_reg_status_buttons_metabox'],
1436
-            $this->_wp_page_slug,
1437
-            'normal',
1438
-            'high'
1439
-        );
1440
-        add_meta_box(
1441
-            'edit-reg-details-mbox',
1442
-            esc_html__('Registration Details', 'event_espresso'),
1443
-            [$this, '_reg_details_meta_box'],
1444
-            $this->_wp_page_slug,
1445
-            'normal',
1446
-            'high'
1447
-        );
1448
-        if (
1449
-            $attendee instanceof EE_Attendee
1450
-            && EE_Registry::instance()->CAP->current_user_can(
1451
-                'ee_read_registration',
1452
-                'edit-reg-questions-mbox',
1453
-                $this->_registration->ID()
1454
-            )
1455
-        ) {
1456
-            add_meta_box(
1457
-                'edit-reg-questions-mbox',
1458
-                esc_html__('Registration Form Answers', 'event_espresso'),
1459
-                [$this, '_reg_questions_meta_box'],
1460
-                $this->_wp_page_slug,
1461
-                'normal',
1462
-                'high'
1463
-            );
1464
-        }
1465
-        add_meta_box(
1466
-            'edit-reg-registrant-mbox',
1467
-            esc_html__('Contact Details', 'event_espresso'),
1468
-            [$this, '_reg_registrant_side_meta_box'],
1469
-            $this->_wp_page_slug,
1470
-            'side',
1471
-            'high'
1472
-        );
1473
-        if ($this->_registration->group_size() > 1) {
1474
-            add_meta_box(
1475
-                'edit-reg-attendees-mbox',
1476
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1477
-                [$this, '_reg_attendees_meta_box'],
1478
-                $this->_wp_page_slug,
1479
-                'normal',
1480
-                'high'
1481
-            );
1482
-        }
1483
-    }
1484
-
1485
-
1486
-    /**
1487
-     * set_reg_status_buttons_metabox
1488
-     *
1489
-     * @return void
1490
-     * @throws EE_Error
1491
-     * @throws EntityNotFoundException
1492
-     * @throws InvalidArgumentException
1493
-     * @throws InvalidDataTypeException
1494
-     * @throws InvalidInterfaceException
1495
-     * @throws ReflectionException
1496
-     */
1497
-    public function set_reg_status_buttons_metabox()
1498
-    {
1499
-        $this->_set_registration_object();
1500
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1501
-        $output                 = $change_reg_status_form->form_open(
1502
-            self::add_query_args_and_nonce(
1503
-                [
1504
-                    'action' => 'change_reg_status',
1505
-                ],
1506
-                REG_ADMIN_URL
1507
-            )
1508
-        );
1509
-        $output                 .= $change_reg_status_form->get_html();
1510
-        $output                 .= $change_reg_status_form->form_close();
1511
-        echo wp_kses($output, AllowedTags::getWithFormTags());
1512
-    }
1513
-
1514
-
1515
-    /**
1516
-     * @return EE_Form_Section_Proper
1517
-     * @throws EE_Error
1518
-     * @throws InvalidArgumentException
1519
-     * @throws InvalidDataTypeException
1520
-     * @throws InvalidInterfaceException
1521
-     * @throws EntityNotFoundException
1522
-     * @throws ReflectionException
1523
-     */
1524
-    protected function _generate_reg_status_change_form()
1525
-    {
1526
-        $reg_status_change_form_array = [
1527
-            'name'            => 'reg_status_change_form',
1528
-            'html_id'         => 'reg-status-change-form',
1529
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1530
-            'subsections'     => [
1531
-                'return'         => new EE_Hidden_Input(
1532
-                    [
1533
-                        'name'    => 'return',
1534
-                        'default' => 'view_registration',
1535
-                    ]
1536
-                ),
1537
-                'REG_ID'         => new EE_Hidden_Input(
1538
-                    [
1539
-                        'name'    => 'REG_ID',
1540
-                        'default' => $this->_registration->ID(),
1541
-                    ]
1542
-                ),
1543
-                'current_status' => new EE_Form_Section_HTML(
1544
-                    EEH_HTML::table(
1545
-                        EEH_HTML::tr(
1546
-                            EEH_HTML::th(
1547
-                                EEH_HTML::label(
1548
-                                    EEH_HTML::strong(
1549
-                                        esc_html__('Current Registration Status', 'event_espresso')
1550
-                                    )
1551
-                                )
1552
-                            )
1553
-                            . EEH_HTML::td(
1554
-                                EEH_HTML::strong(
1555
-                                    $this->_registration->pretty_status(),
1556
-                                    '',
1557
-                                    'status-' . $this->_registration->status_ID(),
1558
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1559
-                                )
1560
-                            )
1561
-                        )
1562
-                    )
1563
-                ),
1564
-            ],
1565
-        ];
1566
-        if (
1567
-            EE_Registry::instance()->CAP->current_user_can(
1568
-                'ee_edit_registration',
1569
-                'toggle_registration_status',
1570
-                $this->_registration->ID()
1571
-            )
1572
-        ) {
1573
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1574
-                $this->_get_reg_statuses(),
1575
-                [
1576
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1577
-                    'default'         => $this->_registration->status_ID(),
1578
-                ]
1579
-            );
1580
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1581
-                [
1582
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1583
-                    'default'         => false,
1584
-                    'html_help_text'  => esc_html__(
1585
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1586
-                        'event_espresso'
1587
-                    ),
1588
-                ]
1589
-            );
1590
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1591
-                [
1592
-                    'html_class'      => 'button-primary',
1593
-                    'html_label_text' => '&nbsp;',
1594
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1595
-                ]
1596
-            );
1597
-        }
1598
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1599
-    }
1600
-
1601
-
1602
-    /**
1603
-     * Returns an array of all the buttons for the various statuses and switch status actions
1604
-     *
1605
-     * @return array
1606
-     * @throws EE_Error
1607
-     * @throws InvalidArgumentException
1608
-     * @throws InvalidDataTypeException
1609
-     * @throws InvalidInterfaceException
1610
-     * @throws EntityNotFoundException
1611
-     */
1612
-    protected function _get_reg_statuses()
1613
-    {
1614
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1615
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1616
-        // get current reg status
1617
-        $current_status = $this->_registration->status_ID();
1618
-        // is registration for free event? This will determine whether to display the pending payment option
1619
-        if (
1620
-            $current_status !== EEM_Registration::status_id_pending_payment
1621
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1622
-        ) {
1623
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1624
-        }
1625
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1626
-    }
1627
-
1628
-
1629
-    /**
1630
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1631
-     *
1632
-     * @param bool $status REG status given for changing registrations to.
1633
-     * @param bool $notify Whether to send messages notifications or not.
1634
-     * @return array (array with reg_id(s) updated and whether update was successful.
1635
-     * @throws DomainException
1636
-     * @throws EE_Error
1637
-     * @throws EntityNotFoundException
1638
-     * @throws InvalidArgumentException
1639
-     * @throws InvalidDataTypeException
1640
-     * @throws InvalidInterfaceException
1641
-     * @throws ReflectionException
1642
-     * @throws RuntimeException
1643
-     */
1644
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1645
-    {
1646
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1647
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1648
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1649
-
1650
-        // sanitize $REG_IDs
1651
-        $REG_IDs = array_map('absint', $REG_IDs);
1652
-        // and remove empty entries
1653
-        $REG_IDs = array_filter($REG_IDs);
1654
-
1655
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1656
-
1657
-        /**
1658
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1659
-         * Currently this value is used downstream by the _process_resend_registration method.
1660
-         *
1661
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1662
-         * @param bool                     $status           The status registrations were changed to.
1663
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1664
-         * @param Registrations_Admin_Page $admin_page_object
1665
-         */
1666
-        $REG_ID = apply_filters(
1667
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1668
-            $result['REG_ID'],
1669
-            $status,
1670
-            $result['success'],
1671
-            $this
1672
-        );
1673
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1674
-
1675
-        // notify?
1676
-        if (
1677
-            $notify
1678
-            && $result['success']
1679
-            && ! empty($REG_ID)
1680
-            && EE_Registry::instance()->CAP->current_user_can(
1681
-                'ee_send_message',
1682
-                'espresso_registrations_resend_registration'
1683
-            )
1684
-        ) {
1685
-            $this->_process_resend_registration();
1686
-        }
1687
-        return $result;
1688
-    }
1689
-
1690
-
1691
-    /**
1692
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1693
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1694
-     *
1695
-     * @param array  $REG_IDs
1696
-     * @param string $status
1697
-     * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1698
-     *                       slug sent with setting the registration status.
1699
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1700
-     * @throws EE_Error
1701
-     * @throws InvalidArgumentException
1702
-     * @throws InvalidDataTypeException
1703
-     * @throws InvalidInterfaceException
1704
-     * @throws ReflectionException
1705
-     * @throws RuntimeException
1706
-     * @throws EntityNotFoundException
1707
-     * @throws DomainException
1708
-     */
1709
-    protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1710
-    {
1711
-        $success = false;
1712
-        // typecast $REG_IDs
1713
-        $REG_IDs = (array) $REG_IDs;
1714
-        if (! empty($REG_IDs)) {
1715
-            $success = true;
1716
-            // set default status if none is passed
1717
-            $status         = $status ?: EEM_Registration::status_id_pending_payment;
1718
-            $status_context = $notify
1719
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1720
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1721
-            // loop through REG_ID's and change status
1722
-            foreach ($REG_IDs as $REG_ID) {
1723
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1724
-                if ($registration instanceof EE_Registration) {
1725
-                    $registration->set_status(
1726
-                        $status,
1727
-                        false,
1728
-                        new Context(
1729
-                            $status_context,
1730
-                            esc_html__(
1731
-                                'Manually triggered status change on a Registration Admin Page route.',
1732
-                                'event_espresso'
1733
-                            )
1734
-                        )
1735
-                    );
1736
-                    $result = $registration->save();
1737
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1738
-                    $success = $result !== false ? $success : false;
1739
-                }
1740
-            }
1741
-        }
1742
-
1743
-        // return $success and processed registrations
1744
-        return ['REG_ID' => $REG_IDs, 'success' => $success];
1745
-    }
1746
-
1747
-
1748
-    /**
1749
-     * Common logic for setting up success message and redirecting to appropriate route
1750
-     *
1751
-     * @param string $STS_ID status id for the registration changed to
1752
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1753
-     * @return void
1754
-     * @throws DomainException
1755
-     * @throws EE_Error
1756
-     * @throws EntityNotFoundException
1757
-     * @throws InvalidArgumentException
1758
-     * @throws InvalidDataTypeException
1759
-     * @throws InvalidInterfaceException
1760
-     * @throws ReflectionException
1761
-     * @throws RuntimeException
1762
-     */
1763
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1764
-    {
1765
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1766
-            : ['success' => false];
1767
-        $success = isset($result['success']) && $result['success'];
1768
-        // setup success message
1769
-        if ($success) {
1770
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1771
-                $msg = sprintf(
1772
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1773
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1774
-                );
1775
-            } else {
1776
-                $msg = sprintf(
1777
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1778
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1779
-                );
1780
-            }
1781
-            EE_Error::add_success($msg);
1782
-        } else {
1783
-            EE_Error::add_error(
1784
-                esc_html__(
1785
-                    'Something went wrong, and the status was not changed',
1786
-                    'event_espresso'
1787
-                ),
1788
-                __FILE__,
1789
-                __LINE__,
1790
-                __FUNCTION__
1791
-            );
1792
-        }
1793
-        $return = $this->request->getRequestParam('return');
1794
-        $route  = $return === 'view_registration'
1795
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1796
-            : ['action' => 'default'];
1797
-        $route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1798
-        $this->_redirect_after_action($success, '', '', $route, true);
1799
-    }
1800
-
1801
-
1802
-    /**
1803
-     * incoming reg status change from reg details page.
1804
-     *
1805
-     * @return void
1806
-     * @throws EE_Error
1807
-     * @throws EntityNotFoundException
1808
-     * @throws InvalidArgumentException
1809
-     * @throws InvalidDataTypeException
1810
-     * @throws InvalidInterfaceException
1811
-     * @throws ReflectionException
1812
-     * @throws RuntimeException
1813
-     * @throws DomainException
1814
-     */
1815
-    protected function _change_reg_status()
1816
-    {
1817
-        $this->request->setRequestParam('return', 'view_registration');
1818
-        // set notify based on whether the send notifications toggle is set or not
1819
-        $notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1820
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1821
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1822
-        switch ($reg_status) {
1823
-            case EEM_Registration::status_id_approved:
1824
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1825
-                $this->approve_registration($notify);
1826
-                break;
1827
-            case EEM_Registration::status_id_pending_payment:
1828
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1829
-                $this->pending_registration($notify);
1830
-                break;
1831
-            case EEM_Registration::status_id_not_approved:
1832
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1833
-                $this->not_approve_registration($notify);
1834
-                break;
1835
-            case EEM_Registration::status_id_declined:
1836
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1837
-                $this->decline_registration($notify);
1838
-                break;
1839
-            case EEM_Registration::status_id_cancelled:
1840
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1841
-                $this->cancel_registration($notify);
1842
-                break;
1843
-            case EEM_Registration::status_id_wait_list:
1844
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1845
-                $this->wait_list_registration($notify);
1846
-                break;
1847
-            case EEM_Registration::status_id_incomplete:
1848
-            default:
1849
-                $this->request->unSetRequestParam('return');
1850
-                $this->_reg_status_change_return('');
1851
-                break;
1852
-        }
1853
-    }
1854
-
1855
-
1856
-    /**
1857
-     * Callback for bulk action routes.
1858
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1859
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1860
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1861
-     * when an action is happening on just a single registration).
1862
-     *
1863
-     * @param      $action
1864
-     * @param bool $notify
1865
-     */
1866
-    protected function bulk_action_on_registrations($action, $notify = false)
1867
-    {
1868
-        do_action(
1869
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1870
-            $this,
1871
-            $action,
1872
-            $notify
1873
-        );
1874
-        $method = $action . '_registration';
1875
-        if (method_exists($this, $method)) {
1876
-            $this->$method($notify);
1877
-        }
1878
-    }
1879
-
1880
-
1881
-    /**
1882
-     * approve_registration
1883
-     *
1884
-     * @param bool $notify whether or not to notify the registrant about their approval.
1885
-     * @return void
1886
-     * @throws EE_Error
1887
-     * @throws EntityNotFoundException
1888
-     * @throws InvalidArgumentException
1889
-     * @throws InvalidDataTypeException
1890
-     * @throws InvalidInterfaceException
1891
-     * @throws ReflectionException
1892
-     * @throws RuntimeException
1893
-     * @throws DomainException
1894
-     */
1895
-    protected function approve_registration($notify = false)
1896
-    {
1897
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1898
-    }
1899
-
1900
-
1901
-    /**
1902
-     * decline_registration
1903
-     *
1904
-     * @param bool $notify whether or not to notify the registrant about their status change.
1905
-     * @return void
1906
-     * @throws EE_Error
1907
-     * @throws EntityNotFoundException
1908
-     * @throws InvalidArgumentException
1909
-     * @throws InvalidDataTypeException
1910
-     * @throws InvalidInterfaceException
1911
-     * @throws ReflectionException
1912
-     * @throws RuntimeException
1913
-     * @throws DomainException
1914
-     */
1915
-    protected function decline_registration($notify = false)
1916
-    {
1917
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1918
-    }
1919
-
1920
-
1921
-    /**
1922
-     * cancel_registration
1923
-     *
1924
-     * @param bool $notify whether or not to notify the registrant about their status change.
1925
-     * @return void
1926
-     * @throws EE_Error
1927
-     * @throws EntityNotFoundException
1928
-     * @throws InvalidArgumentException
1929
-     * @throws InvalidDataTypeException
1930
-     * @throws InvalidInterfaceException
1931
-     * @throws ReflectionException
1932
-     * @throws RuntimeException
1933
-     * @throws DomainException
1934
-     */
1935
-    protected function cancel_registration($notify = false)
1936
-    {
1937
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1938
-    }
1939
-
1940
-
1941
-    /**
1942
-     * not_approve_registration
1943
-     *
1944
-     * @param bool $notify whether or not to notify the registrant about their status change.
1945
-     * @return void
1946
-     * @throws EE_Error
1947
-     * @throws EntityNotFoundException
1948
-     * @throws InvalidArgumentException
1949
-     * @throws InvalidDataTypeException
1950
-     * @throws InvalidInterfaceException
1951
-     * @throws ReflectionException
1952
-     * @throws RuntimeException
1953
-     * @throws DomainException
1954
-     */
1955
-    protected function not_approve_registration($notify = false)
1956
-    {
1957
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1958
-    }
1959
-
1960
-
1961
-    /**
1962
-     * decline_registration
1963
-     *
1964
-     * @param bool $notify whether or not to notify the registrant about their status change.
1965
-     * @return void
1966
-     * @throws EE_Error
1967
-     * @throws EntityNotFoundException
1968
-     * @throws InvalidArgumentException
1969
-     * @throws InvalidDataTypeException
1970
-     * @throws InvalidInterfaceException
1971
-     * @throws ReflectionException
1972
-     * @throws RuntimeException
1973
-     * @throws DomainException
1974
-     */
1975
-    protected function pending_registration($notify = false)
1976
-    {
1977
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1978
-    }
1979
-
1980
-
1981
-    /**
1982
-     * waitlist_registration
1983
-     *
1984
-     * @param bool $notify whether or not to notify the registrant about their status change.
1985
-     * @return void
1986
-     * @throws EE_Error
1987
-     * @throws EntityNotFoundException
1988
-     * @throws InvalidArgumentException
1989
-     * @throws InvalidDataTypeException
1990
-     * @throws InvalidInterfaceException
1991
-     * @throws ReflectionException
1992
-     * @throws RuntimeException
1993
-     * @throws DomainException
1994
-     */
1995
-    protected function wait_list_registration($notify = false)
1996
-    {
1997
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1998
-    }
1999
-
2000
-
2001
-    /**
2002
-     * generates HTML for the Registration main meta box
2003
-     *
2004
-     * @return void
2005
-     * @throws DomainException
2006
-     * @throws EE_Error
2007
-     * @throws InvalidArgumentException
2008
-     * @throws InvalidDataTypeException
2009
-     * @throws InvalidInterfaceException
2010
-     * @throws ReflectionException
2011
-     * @throws EntityNotFoundException
2012
-     */
2013
-    public function _reg_details_meta_box()
2014
-    {
2015
-        EEH_Autoloader::register_line_item_display_autoloaders();
2016
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2017
-        EE_Registry::instance()->load_helper('Line_Item');
2018
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2019
-            : EE_Transaction::new_instance();
2020
-        $this->_session = $transaction->session_data();
2021
-        $filters        = new EE_Line_Item_Filter_Collection();
2022
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2023
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2024
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2025
-            $filters,
2026
-            $transaction->total_line_item()
2027
-        );
2028
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2029
-        $line_item_display                       = new EE_Line_Item_Display(
2030
-            'reg_admin_table',
2031
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2032
-        );
2033
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2034
-            $filtered_line_item_tree,
2035
-            ['EE_Registration' => $this->_registration]
2036
-        );
2037
-        $attendee                                = $this->_registration->attendee();
2038
-        if (
2039
-            EE_Registry::instance()->CAP->current_user_can(
2040
-                'ee_read_transaction',
2041
-                'espresso_transactions_view_transaction'
2042
-            )
2043
-        ) {
2044
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2045
-                EE_Admin_Page::add_query_args_and_nonce(
2046
-                    [
2047
-                        'action' => 'view_transaction',
2048
-                        'TXN_ID' => $transaction->ID(),
2049
-                    ],
2050
-                    TXN_ADMIN_URL
2051
-                ),
2052
-                esc_html__(' View Transaction', 'event_espresso'),
2053
-                'button secondary-button right',
2054
-                'dashicons dashicons-cart'
2055
-            );
2056
-        } else {
2057
-            $this->_template_args['view_transaction_button'] = '';
2058
-        }
2059
-        if (
2060
-            $attendee instanceof EE_Attendee
2061
-            && EE_Registry::instance()->CAP->current_user_can(
2062
-                'ee_send_message',
2063
-                'espresso_registrations_resend_registration'
2064
-            )
2065
-        ) {
2066
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2067
-                EE_Admin_Page::add_query_args_and_nonce(
2068
-                    [
2069
-                        'action'      => 'resend_registration',
2070
-                        '_REG_ID'     => $this->_registration->ID(),
2071
-                        'redirect_to' => 'view_registration',
2072
-                    ],
2073
-                    REG_ADMIN_URL
2074
-                ),
2075
-                esc_html__(' Resend Registration', 'event_espresso'),
2076
-                'button secondary-button right',
2077
-                'dashicons dashicons-email-alt'
2078
-            );
2079
-        } else {
2080
-            $this->_template_args['resend_registration_button'] = '';
2081
-        }
2082
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2083
-        $payment                               = $transaction->get_first_related('Payment');
2084
-        $payment                               = ! $payment instanceof EE_Payment
2085
-            ? EE_Payment::new_instance()
2086
-            : $payment;
2087
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2088
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2089
-            ? EE_Payment_Method::new_instance()
2090
-            : $payment_method;
2091
-        $reg_details                           = [
2092
-            'payment_method'       => $payment_method->name(),
2093
-            'response_msg'         => $payment->gateway_response(),
2094
-            'registration_id'      => $this->_registration->get('REG_code'),
2095
-            'registration_session' => $this->_registration->session_ID(),
2096
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2097
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2098
-        ];
2099
-        if (isset($reg_details['registration_id'])) {
2100
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2101
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2102
-                'Registration ID',
2103
-                'event_espresso'
2104
-            );
2105
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2106
-        }
2107
-        if (isset($reg_details['payment_method'])) {
2108
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2109
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2110
-                'Most Recent Payment Method',
2111
-                'event_espresso'
2112
-            );
2113
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2114
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2115
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2116
-                'Payment method response',
2117
-                'event_espresso'
2118
-            );
2119
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2120
-        }
2121
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2122
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2123
-            'Registration Session',
2124
-            'event_espresso'
2125
-        );
2126
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2127
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2128
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2129
-            'Registration placed from IP',
2130
-            'event_espresso'
2131
-        );
2132
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2133
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2134
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2135
-            'Registrant User Agent',
2136
-            'event_espresso'
2137
-        );
2138
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2139
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2140
-            [
2141
-                'action'   => 'default',
2142
-                'event_id' => $this->_registration->event_ID(),
2143
-            ],
2144
-            REG_ADMIN_URL
2145
-        );
2146
-        $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2147
-        $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2148
-        $template_path                                                        =
2149
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2150
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2151
-    }
2152
-
2153
-
2154
-    /**
2155
-     * generates HTML for the Registration Questions meta box.
2156
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2157
-     * otherwise uses new forms system
2158
-     *
2159
-     * @return void
2160
-     * @throws DomainException
2161
-     * @throws EE_Error
2162
-     * @throws InvalidArgumentException
2163
-     * @throws InvalidDataTypeException
2164
-     * @throws InvalidInterfaceException
2165
-     * @throws ReflectionException
2166
-     */
2167
-    public function _reg_questions_meta_box()
2168
-    {
2169
-        // allow someone to override this method entirely
2170
-        if (
2171
-            apply_filters(
2172
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2173
-                true,
2174
-                $this,
2175
-                $this->_registration
2176
-            )
2177
-        ) {
2178
-            $form                                              = $this->_get_reg_custom_questions_form(
2179
-                $this->_registration->ID()
2180
-            );
2181
-            $this->_template_args['att_questions']             = count($form->subforms()) > 0
2182
-                ? $form->get_html_and_js()
2183
-                : '';
2184
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2185
-            $this->_template_args['REG_ID']                    = $this->_registration->ID();
2186
-            $template_path                                     =
2187
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2188
-            EEH_Template::display_template($template_path, $this->_template_args);
2189
-        }
2190
-    }
2191
-
2192
-
2193
-    /**
2194
-     * form_before_question_group
2195
-     *
2196
-     * @param string $output
2197
-     * @return        string
2198
-     * @deprecated    as of 4.8.32.rc.000
2199
-     */
2200
-    public function form_before_question_group($output)
2201
-    {
2202
-        EE_Error::doing_it_wrong(
2203
-            __CLASS__ . '::' . __FUNCTION__,
2204
-            esc_html__(
2205
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2206
-                'event_espresso'
2207
-            ),
2208
-            '4.8.32.rc.000'
2209
-        );
2210
-        return '
23
+	/**
24
+	 * @var EE_Registration
25
+	 */
26
+	private $_registration;
27
+
28
+	/**
29
+	 * @var EE_Event
30
+	 */
31
+	private $_reg_event;
32
+
33
+	/**
34
+	 * @var EE_Session
35
+	 */
36
+	private $_session;
37
+
38
+	/**
39
+	 * @var array
40
+	 */
41
+	private static $_reg_status;
42
+
43
+	/**
44
+	 * Form for displaying the custom questions for this registration.
45
+	 * This gets used a few times throughout the request so its best to cache it
46
+	 *
47
+	 * @var EE_Registration_Custom_Questions_Form
48
+	 */
49
+	protected $_reg_custom_questions_form = null;
50
+
51
+	/**
52
+	 * @var EEM_Registration $registration_model
53
+	 */
54
+	private $registration_model;
55
+
56
+	/**
57
+	 * @var EEM_Attendee $attendee_model
58
+	 */
59
+	private $attendee_model;
60
+
61
+	/**
62
+	 * @var EEM_Event $event_model
63
+	 */
64
+	private $event_model;
65
+
66
+	/**
67
+	 * @var EEM_Status $status_model
68
+	 */
69
+	private $status_model;
70
+
71
+
72
+	/**
73
+	 * @param bool $routing
74
+	 * @throws EE_Error
75
+	 * @throws InvalidArgumentException
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws InvalidInterfaceException
78
+	 * @throws ReflectionException
79
+	 */
80
+	public function __construct($routing = true)
81
+	{
82
+		parent::__construct($routing);
83
+		add_action('wp_loaded', [$this, 'wp_loaded']);
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return EEM_Registration
89
+	 * @throws InvalidArgumentException
90
+	 * @throws InvalidDataTypeException
91
+	 * @throws InvalidInterfaceException
92
+	 * @since 4.10.2.p
93
+	 */
94
+	protected function getRegistrationModel()
95
+	{
96
+		if (! $this->registration_model instanceof EEM_Registration) {
97
+			$this->registration_model = $this->getLoader()->getShared('EEM_Registration');
98
+		}
99
+		return $this->registration_model;
100
+	}
101
+
102
+
103
+	/**
104
+	 * @return EEM_Attendee
105
+	 * @throws InvalidArgumentException
106
+	 * @throws InvalidDataTypeException
107
+	 * @throws InvalidInterfaceException
108
+	 * @since 4.10.2.p
109
+	 */
110
+	protected function getAttendeeModel()
111
+	{
112
+		if (! $this->attendee_model instanceof EEM_Attendee) {
113
+			$this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
114
+		}
115
+		return $this->attendee_model;
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return EEM_Event
121
+	 * @throws InvalidArgumentException
122
+	 * @throws InvalidDataTypeException
123
+	 * @throws InvalidInterfaceException
124
+	 * @since 4.10.2.p
125
+	 */
126
+	protected function getEventModel()
127
+	{
128
+		if (! $this->event_model instanceof EEM_Event) {
129
+			$this->event_model = $this->getLoader()->getShared('EEM_Event');
130
+		}
131
+		return $this->event_model;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @return EEM_Status
137
+	 * @throws InvalidArgumentException
138
+	 * @throws InvalidDataTypeException
139
+	 * @throws InvalidInterfaceException
140
+	 * @since 4.10.2.p
141
+	 */
142
+	protected function getStatusModel()
143
+	{
144
+		if (! $this->status_model instanceof EEM_Status) {
145
+			$this->status_model = $this->getLoader()->getShared('EEM_Status');
146
+		}
147
+		return $this->status_model;
148
+	}
149
+
150
+
151
+	public function wp_loaded()
152
+	{
153
+		// when adding a new registration...
154
+		$action = $this->request->getRequestParam('action');
155
+		if ($action === 'new_registration') {
156
+			EE_System::do_not_cache();
157
+			if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
158
+				// and it's NOT the attendee information reg step
159
+				// force cookie expiration by setting time to last week
160
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
161
+				// and update the global
162
+				$_COOKIE['ee_registration_added'] = 0;
163
+			}
164
+		}
165
+	}
166
+
167
+
168
+	protected function _init_page_props()
169
+	{
170
+		$this->page_slug        = REG_PG_SLUG;
171
+		$this->_admin_base_url  = REG_ADMIN_URL;
172
+		$this->_admin_base_path = REG_ADMIN;
173
+		$this->page_label       = esc_html__('Registrations', 'event_espresso');
174
+		$this->_cpt_routes      = [
175
+			'add_new_attendee' => 'espresso_attendees',
176
+			'edit_attendee'    => 'espresso_attendees',
177
+			'insert_attendee'  => 'espresso_attendees',
178
+			'update_attendee'  => 'espresso_attendees',
179
+		];
180
+		$this->_cpt_model_names = [
181
+			'add_new_attendee' => 'EEM_Attendee',
182
+			'edit_attendee'    => 'EEM_Attendee',
183
+		];
184
+		$this->_cpt_edit_routes = [
185
+			'espresso_attendees' => 'edit_attendee',
186
+		];
187
+		$this->_pagenow_map     = [
188
+			'add_new_attendee' => 'post-new.php',
189
+			'edit_attendee'    => 'post.php',
190
+			'trash'            => 'post.php',
191
+		];
192
+		add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
193
+		// add filters so that the comment urls don't take users to a confusing 404 page
194
+		add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
195
+	}
196
+
197
+
198
+	/**
199
+	 * @param string     $link    The comment permalink with '#comment-$id' appended.
200
+	 * @param WP_Comment $comment The current comment object.
201
+	 * @return string
202
+	 */
203
+	public function clear_comment_link($link, WP_Comment $comment)
204
+	{
205
+		// gotta make sure this only happens on this route
206
+		$post_type = get_post_type($comment->comment_post_ID);
207
+		if ($post_type === 'espresso_attendees') {
208
+			return '#commentsdiv';
209
+		}
210
+		return $link;
211
+	}
212
+
213
+
214
+	protected function _ajax_hooks()
215
+	{
216
+		// todo: all hooks for registrations ajax goes in here
217
+		add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
218
+	}
219
+
220
+
221
+	protected function _define_page_props()
222
+	{
223
+		$this->_admin_page_title = $this->page_label;
224
+		$this->_labels           = [
225
+			'buttons'                      => [
226
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
227
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
228
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
229
+				'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
230
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
231
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
232
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
233
+				'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
234
+			],
235
+			'publishbox'                   => [
236
+				'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
237
+				'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
238
+			],
239
+			'hide_add_button_on_cpt_route' => [
240
+				'edit_attendee' => true,
241
+			],
242
+		];
243
+	}
244
+
245
+
246
+	/**
247
+	 * grab url requests and route them
248
+	 *
249
+	 * @return void
250
+	 * @throws EE_Error
251
+	 */
252
+	public function _set_page_routes()
253
+	{
254
+		$this->_get_registration_status_array();
255
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
256
+		$REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
257
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
258
+		$ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
259
+		$this->_page_routes = [
260
+			'default'                             => [
261
+				'func'       => '_registrations_overview_list_table',
262
+				'capability' => 'ee_read_registrations',
263
+			],
264
+			'view_registration'                   => [
265
+				'func'       => '_registration_details',
266
+				'capability' => 'ee_read_registration',
267
+				'obj_id'     => $REG_ID,
268
+			],
269
+			'edit_registration'                   => [
270
+				'func'               => '_update_attendee_registration_form',
271
+				'noheader'           => true,
272
+				'headers_sent_route' => 'view_registration',
273
+				'capability'         => 'ee_edit_registration',
274
+				'obj_id'             => $REG_ID,
275
+				'_REG_ID'            => $REG_ID,
276
+			],
277
+			'trash_registrations'                 => [
278
+				'func'       => '_trash_or_restore_registrations',
279
+				'args'       => ['trash' => true],
280
+				'noheader'   => true,
281
+				'capability' => 'ee_delete_registrations',
282
+			],
283
+			'restore_registrations'               => [
284
+				'func'       => '_trash_or_restore_registrations',
285
+				'args'       => ['trash' => false],
286
+				'noheader'   => true,
287
+				'capability' => 'ee_delete_registrations',
288
+			],
289
+			'delete_registrations'                => [
290
+				'func'       => '_delete_registrations',
291
+				'noheader'   => true,
292
+				'capability' => 'ee_delete_registrations',
293
+			],
294
+			'new_registration'                    => [
295
+				'func'       => 'new_registration',
296
+				'capability' => 'ee_edit_registrations',
297
+			],
298
+			'process_reg_step'                    => [
299
+				'func'       => 'process_reg_step',
300
+				'noheader'   => true,
301
+				'capability' => 'ee_edit_registrations',
302
+			],
303
+			'redirect_to_txn'                     => [
304
+				'func'       => 'redirect_to_txn',
305
+				'noheader'   => true,
306
+				'capability' => 'ee_edit_registrations',
307
+			],
308
+			'change_reg_status'                   => [
309
+				'func'       => '_change_reg_status',
310
+				'noheader'   => true,
311
+				'capability' => 'ee_edit_registration',
312
+				'obj_id'     => $REG_ID,
313
+			],
314
+			'approve_registration'                => [
315
+				'func'       => 'approve_registration',
316
+				'noheader'   => true,
317
+				'capability' => 'ee_edit_registration',
318
+				'obj_id'     => $REG_ID,
319
+			],
320
+			'approve_and_notify_registration'     => [
321
+				'func'       => 'approve_registration',
322
+				'noheader'   => true,
323
+				'args'       => [true],
324
+				'capability' => 'ee_edit_registration',
325
+				'obj_id'     => $REG_ID,
326
+			],
327
+			'approve_registrations'               => [
328
+				'func'       => 'bulk_action_on_registrations',
329
+				'noheader'   => true,
330
+				'capability' => 'ee_edit_registrations',
331
+				'args'       => ['approve'],
332
+			],
333
+			'approve_and_notify_registrations'    => [
334
+				'func'       => 'bulk_action_on_registrations',
335
+				'noheader'   => true,
336
+				'capability' => 'ee_edit_registrations',
337
+				'args'       => ['approve', true],
338
+			],
339
+			'decline_registration'                => [
340
+				'func'       => 'decline_registration',
341
+				'noheader'   => true,
342
+				'capability' => 'ee_edit_registration',
343
+				'obj_id'     => $REG_ID,
344
+			],
345
+			'decline_and_notify_registration'     => [
346
+				'func'       => 'decline_registration',
347
+				'noheader'   => true,
348
+				'args'       => [true],
349
+				'capability' => 'ee_edit_registration',
350
+				'obj_id'     => $REG_ID,
351
+			],
352
+			'decline_registrations'               => [
353
+				'func'       => 'bulk_action_on_registrations',
354
+				'noheader'   => true,
355
+				'capability' => 'ee_edit_registrations',
356
+				'args'       => ['decline'],
357
+			],
358
+			'decline_and_notify_registrations'    => [
359
+				'func'       => 'bulk_action_on_registrations',
360
+				'noheader'   => true,
361
+				'capability' => 'ee_edit_registrations',
362
+				'args'       => ['decline', true],
363
+			],
364
+			'pending_registration'                => [
365
+				'func'       => 'pending_registration',
366
+				'noheader'   => true,
367
+				'capability' => 'ee_edit_registration',
368
+				'obj_id'     => $REG_ID,
369
+			],
370
+			'pending_and_notify_registration'     => [
371
+				'func'       => 'pending_registration',
372
+				'noheader'   => true,
373
+				'args'       => [true],
374
+				'capability' => 'ee_edit_registration',
375
+				'obj_id'     => $REG_ID,
376
+			],
377
+			'pending_registrations'               => [
378
+				'func'       => 'bulk_action_on_registrations',
379
+				'noheader'   => true,
380
+				'capability' => 'ee_edit_registrations',
381
+				'args'       => ['pending'],
382
+			],
383
+			'pending_and_notify_registrations'    => [
384
+				'func'       => 'bulk_action_on_registrations',
385
+				'noheader'   => true,
386
+				'capability' => 'ee_edit_registrations',
387
+				'args'       => ['pending', true],
388
+			],
389
+			'no_approve_registration'             => [
390
+				'func'       => 'not_approve_registration',
391
+				'noheader'   => true,
392
+				'capability' => 'ee_edit_registration',
393
+				'obj_id'     => $REG_ID,
394
+			],
395
+			'no_approve_and_notify_registration'  => [
396
+				'func'       => 'not_approve_registration',
397
+				'noheader'   => true,
398
+				'args'       => [true],
399
+				'capability' => 'ee_edit_registration',
400
+				'obj_id'     => $REG_ID,
401
+			],
402
+			'no_approve_registrations'            => [
403
+				'func'       => 'bulk_action_on_registrations',
404
+				'noheader'   => true,
405
+				'capability' => 'ee_edit_registrations',
406
+				'args'       => ['not_approve'],
407
+			],
408
+			'no_approve_and_notify_registrations' => [
409
+				'func'       => 'bulk_action_on_registrations',
410
+				'noheader'   => true,
411
+				'capability' => 'ee_edit_registrations',
412
+				'args'       => ['not_approve', true],
413
+			],
414
+			'cancel_registration'                 => [
415
+				'func'       => 'cancel_registration',
416
+				'noheader'   => true,
417
+				'capability' => 'ee_edit_registration',
418
+				'obj_id'     => $REG_ID,
419
+			],
420
+			'cancel_and_notify_registration'      => [
421
+				'func'       => 'cancel_registration',
422
+				'noheader'   => true,
423
+				'args'       => [true],
424
+				'capability' => 'ee_edit_registration',
425
+				'obj_id'     => $REG_ID,
426
+			],
427
+			'cancel_registrations'                => [
428
+				'func'       => 'bulk_action_on_registrations',
429
+				'noheader'   => true,
430
+				'capability' => 'ee_edit_registrations',
431
+				'args'       => ['cancel'],
432
+			],
433
+			'cancel_and_notify_registrations'     => [
434
+				'func'       => 'bulk_action_on_registrations',
435
+				'noheader'   => true,
436
+				'capability' => 'ee_edit_registrations',
437
+				'args'       => ['cancel', true],
438
+			],
439
+			'wait_list_registration'              => [
440
+				'func'       => 'wait_list_registration',
441
+				'noheader'   => true,
442
+				'capability' => 'ee_edit_registration',
443
+				'obj_id'     => $REG_ID,
444
+			],
445
+			'wait_list_and_notify_registration'   => [
446
+				'func'       => 'wait_list_registration',
447
+				'noheader'   => true,
448
+				'args'       => [true],
449
+				'capability' => 'ee_edit_registration',
450
+				'obj_id'     => $REG_ID,
451
+			],
452
+			'contact_list'                        => [
453
+				'func'       => '_attendee_contact_list_table',
454
+				'capability' => 'ee_read_contacts',
455
+			],
456
+			'add_new_attendee'                    => [
457
+				'func' => '_create_new_cpt_item',
458
+				'args' => [
459
+					'new_attendee' => true,
460
+					'capability'   => 'ee_edit_contacts',
461
+				],
462
+			],
463
+			'edit_attendee'                       => [
464
+				'func'       => '_edit_cpt_item',
465
+				'capability' => 'ee_edit_contacts',
466
+				'obj_id'     => $ATT_ID,
467
+			],
468
+			'duplicate_attendee'                  => [
469
+				'func'       => '_duplicate_attendee',
470
+				'noheader'   => true,
471
+				'capability' => 'ee_edit_contacts',
472
+				'obj_id'     => $ATT_ID,
473
+			],
474
+			'insert_attendee'                     => [
475
+				'func'       => '_insert_or_update_attendee',
476
+				'args'       => [
477
+					'new_attendee' => true,
478
+				],
479
+				'noheader'   => true,
480
+				'capability' => 'ee_edit_contacts',
481
+			],
482
+			'update_attendee'                     => [
483
+				'func'       => '_insert_or_update_attendee',
484
+				'args'       => [
485
+					'new_attendee' => false,
486
+				],
487
+				'noheader'   => true,
488
+				'capability' => 'ee_edit_contacts',
489
+				'obj_id'     => $ATT_ID,
490
+			],
491
+			'trash_attendees'                     => [
492
+				'func'       => '_trash_or_restore_attendees',
493
+				'args'       => [
494
+					'trash' => 'true',
495
+				],
496
+				'noheader'   => true,
497
+				'capability' => 'ee_delete_contacts',
498
+			],
499
+			'trash_attendee'                      => [
500
+				'func'       => '_trash_or_restore_attendees',
501
+				'args'       => [
502
+					'trash' => true,
503
+				],
504
+				'noheader'   => true,
505
+				'capability' => 'ee_delete_contacts',
506
+				'obj_id'     => $ATT_ID,
507
+			],
508
+			'restore_attendees'                   => [
509
+				'func'       => '_trash_or_restore_attendees',
510
+				'args'       => [
511
+					'trash' => false,
512
+				],
513
+				'noheader'   => true,
514
+				'capability' => 'ee_delete_contacts',
515
+				'obj_id'     => $ATT_ID,
516
+			],
517
+			'resend_registration'                 => [
518
+				'func'       => '_resend_registration',
519
+				'noheader'   => true,
520
+				'capability' => 'ee_send_message',
521
+			],
522
+			'registrations_report'                => [
523
+				'func'       => '_registrations_report',
524
+				'noheader'   => true,
525
+				'capability' => 'ee_read_registrations',
526
+			],
527
+			'contact_list_export'                 => [
528
+				'func'       => '_contact_list_export',
529
+				'noheader'   => true,
530
+				'capability' => 'export',
531
+			],
532
+			'contact_list_report'                 => [
533
+				'func'       => '_contact_list_report',
534
+				'noheader'   => true,
535
+				'capability' => 'ee_read_contacts',
536
+			],
537
+		];
538
+	}
539
+
540
+
541
+	protected function _set_page_config()
542
+	{
543
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
544
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
545
+		$this->_page_config = [
546
+			'default'           => [
547
+				'nav'           => [
548
+					'label' => esc_html__('Overview', 'event_espresso'),
549
+					'order' => 5,
550
+				],
551
+				'help_tabs'     => [
552
+					'registrations_overview_help_tab'                       => [
553
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
554
+						'filename' => 'registrations_overview',
555
+					],
556
+					'registrations_overview_table_column_headings_help_tab' => [
557
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
558
+						'filename' => 'registrations_overview_table_column_headings',
559
+					],
560
+					'registrations_overview_filters_help_tab'               => [
561
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
562
+						'filename' => 'registrations_overview_filters',
563
+					],
564
+					'registrations_overview_views_help_tab'                 => [
565
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
566
+						'filename' => 'registrations_overview_views',
567
+					],
568
+					'registrations_regoverview_other_help_tab'              => [
569
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
570
+						'filename' => 'registrations_overview_other',
571
+					],
572
+				],
573
+				'qtips'         => ['Registration_List_Table_Tips'],
574
+				'list_table'    => 'EE_Registrations_List_Table',
575
+				'require_nonce' => false,
576
+			],
577
+			'view_registration' => [
578
+				'nav'           => [
579
+					'label'      => esc_html__('REG Details', 'event_espresso'),
580
+					'order'      => 15,
581
+					'url'        => $REG_ID
582
+						? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
583
+						: $this->_admin_base_url,
584
+					'persistent' => false,
585
+				],
586
+				'help_tabs'     => [
587
+					'registrations_details_help_tab'                    => [
588
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
589
+						'filename' => 'registrations_details',
590
+					],
591
+					'registrations_details_table_help_tab'              => [
592
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
593
+						'filename' => 'registrations_details_table',
594
+					],
595
+					'registrations_details_form_answers_help_tab'       => [
596
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
597
+						'filename' => 'registrations_details_form_answers',
598
+					],
599
+					'registrations_details_registrant_details_help_tab' => [
600
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
601
+						'filename' => 'registrations_details_registrant_details',
602
+					],
603
+				],
604
+				'metaboxes'     => array_merge(
605
+					$this->_default_espresso_metaboxes,
606
+					['_registration_details_metaboxes']
607
+				),
608
+				'require_nonce' => false,
609
+			],
610
+			'new_registration'  => [
611
+				'nav'           => [
612
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
613
+					'url'        => '#',
614
+					'order'      => 15,
615
+					'persistent' => false,
616
+				],
617
+				'metaboxes'     => $this->_default_espresso_metaboxes,
618
+				'labels'        => [
619
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
620
+				],
621
+				'require_nonce' => false,
622
+			],
623
+			'add_new_attendee'  => [
624
+				'nav'           => [
625
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
626
+					'order'      => 15,
627
+					'persistent' => false,
628
+				],
629
+				'metaboxes'     => array_merge(
630
+					$this->_default_espresso_metaboxes,
631
+					['_publish_post_box', 'attendee_editor_metaboxes']
632
+				),
633
+				'require_nonce' => false,
634
+			],
635
+			'edit_attendee'     => [
636
+				'nav'           => [
637
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
638
+					'order'      => 15,
639
+					'persistent' => false,
640
+					'url'        => $ATT_ID
641
+						? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
642
+						: $this->_admin_base_url,
643
+				],
644
+				'metaboxes'     => ['attendee_editor_metaboxes'],
645
+				'require_nonce' => false,
646
+			],
647
+			'contact_list'      => [
648
+				'nav'           => [
649
+					'label' => esc_html__('Contact List', 'event_espresso'),
650
+					'order' => 20,
651
+				],
652
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
653
+				'help_tabs'     => [
654
+					'registrations_contact_list_help_tab'                       => [
655
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
656
+						'filename' => 'registrations_contact_list',
657
+					],
658
+					'registrations_contact-list_table_column_headings_help_tab' => [
659
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
660
+						'filename' => 'registrations_contact_list_table_column_headings',
661
+					],
662
+					'registrations_contact_list_views_help_tab'                 => [
663
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
664
+						'filename' => 'registrations_contact_list_views',
665
+					],
666
+					'registrations_contact_list_other_help_tab'                 => [
667
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
668
+						'filename' => 'registrations_contact_list_other',
669
+					],
670
+				],
671
+				'metaboxes'     => [],
672
+				'require_nonce' => false,
673
+			],
674
+			// override default cpt routes
675
+			'create_new'        => '',
676
+			'edit'              => '',
677
+		];
678
+	}
679
+
680
+
681
+	/**
682
+	 * The below methods aren't used by this class currently
683
+	 */
684
+	protected function _add_screen_options()
685
+	{
686
+	}
687
+
688
+
689
+	protected function _add_feature_pointers()
690
+	{
691
+	}
692
+
693
+
694
+	public function admin_init()
695
+	{
696
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
697
+			'click "Update Registration Questions" to save your changes',
698
+			'event_espresso'
699
+		);
700
+	}
701
+
702
+
703
+	public function admin_notices()
704
+	{
705
+	}
706
+
707
+
708
+	public function admin_footer_scripts()
709
+	{
710
+	}
711
+
712
+
713
+	/**
714
+	 * get list of registration statuses
715
+	 *
716
+	 * @return void
717
+	 * @throws EE_Error
718
+	 */
719
+	private function _get_registration_status_array()
720
+	{
721
+		self::$_reg_status = EEM_Registration::reg_status_array([], true);
722
+	}
723
+
724
+
725
+	/**
726
+	 * @throws InvalidArgumentException
727
+	 * @throws InvalidDataTypeException
728
+	 * @throws InvalidInterfaceException
729
+	 * @since 4.10.2.p
730
+	 */
731
+	protected function _add_screen_options_default()
732
+	{
733
+		$this->_per_page_screen_option();
734
+	}
735
+
736
+
737
+	/**
738
+	 * @throws InvalidArgumentException
739
+	 * @throws InvalidDataTypeException
740
+	 * @throws InvalidInterfaceException
741
+	 * @since 4.10.2.p
742
+	 */
743
+	protected function _add_screen_options_contact_list()
744
+	{
745
+		$page_title              = $this->_admin_page_title;
746
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
747
+		$this->_per_page_screen_option();
748
+		$this->_admin_page_title = $page_title;
749
+	}
750
+
751
+
752
+	public function load_scripts_styles()
753
+	{
754
+		// style
755
+		wp_register_style(
756
+			'espresso_reg',
757
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
758
+			['ee-admin-css'],
759
+			EVENT_ESPRESSO_VERSION
760
+		);
761
+		wp_enqueue_style('espresso_reg');
762
+		// script
763
+		wp_register_script(
764
+			'espresso_reg',
765
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
766
+			['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
767
+			EVENT_ESPRESSO_VERSION,
768
+			true
769
+		);
770
+		wp_enqueue_script('espresso_reg');
771
+	}
772
+
773
+
774
+	/**
775
+	 * @throws EE_Error
776
+	 * @throws InvalidArgumentException
777
+	 * @throws InvalidDataTypeException
778
+	 * @throws InvalidInterfaceException
779
+	 * @throws ReflectionException
780
+	 * @since 4.10.2.p
781
+	 */
782
+	public function load_scripts_styles_edit_attendee()
783
+	{
784
+		// stuff to only show up on our attendee edit details page.
785
+		$attendee_details_translations = [
786
+			'att_publish_text' => sprintf(
787
+			/* translators: The date and time */
788
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
789
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
790
+			),
791
+		];
792
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
793
+		wp_enqueue_script('jquery-validate');
794
+	}
795
+
796
+
797
+	/**
798
+	 * @throws EE_Error
799
+	 * @throws InvalidArgumentException
800
+	 * @throws InvalidDataTypeException
801
+	 * @throws InvalidInterfaceException
802
+	 * @throws ReflectionException
803
+	 * @since 4.10.2.p
804
+	 */
805
+	public function load_scripts_styles_view_registration()
806
+	{
807
+		// styles
808
+		wp_enqueue_style('espresso-ui-theme');
809
+		// scripts
810
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
811
+		$this->_reg_custom_questions_form->wp_enqueue_scripts();
812
+	}
813
+
814
+
815
+	public function load_scripts_styles_contact_list()
816
+	{
817
+		wp_dequeue_style('espresso_reg');
818
+		wp_register_style(
819
+			'espresso_att',
820
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
821
+			['ee-admin-css'],
822
+			EVENT_ESPRESSO_VERSION
823
+		);
824
+		wp_enqueue_style('espresso_att');
825
+	}
826
+
827
+
828
+	public function load_scripts_styles_new_registration()
829
+	{
830
+		wp_register_script(
831
+			'ee-spco-for-admin',
832
+			REG_ASSETS_URL . 'spco_for_admin.js',
833
+			['underscore', 'jquery'],
834
+			EVENT_ESPRESSO_VERSION,
835
+			true
836
+		);
837
+		wp_enqueue_script('ee-spco-for-admin');
838
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
839
+		EE_Form_Section_Proper::wp_enqueue_scripts();
840
+		EED_Ticket_Selector::load_tckt_slctr_assets();
841
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
842
+	}
843
+
844
+
845
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
846
+	{
847
+		add_filter('FHEE_load_EE_messages', '__return_true');
848
+	}
849
+
850
+
851
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
852
+	{
853
+		add_filter('FHEE_load_EE_messages', '__return_true');
854
+	}
855
+
856
+
857
+	/**
858
+	 * @throws EE_Error
859
+	 * @throws InvalidArgumentException
860
+	 * @throws InvalidDataTypeException
861
+	 * @throws InvalidInterfaceException
862
+	 * @throws ReflectionException
863
+	 * @since 4.10.2.p
864
+	 */
865
+	protected function _set_list_table_views_default()
866
+	{
867
+		// for notification related bulk actions we need to make sure only active messengers have an option.
868
+		EED_Messages::set_autoloaders();
869
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
870
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
871
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
872
+		// key= bulk_action_slug, value= message type.
873
+		$match_array = [
874
+			'approve_registrations'    => 'registration',
875
+			'decline_registrations'    => 'declined_registration',
876
+			'pending_registrations'    => 'pending_approval',
877
+			'no_approve_registrations' => 'not_approved_registration',
878
+			'cancel_registrations'     => 'cancelled_registration',
879
+		];
880
+		$can_send    = EE_Registry::instance()->CAP->current_user_can(
881
+			'ee_send_message',
882
+			'batch_send_messages'
883
+		);
884
+		/** setup reg status bulk actions **/
885
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
886
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
887
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
888
+				'Approve and Notify Registrations',
889
+				'event_espresso'
890
+			);
891
+		}
892
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
893
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
894
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
895
+				'Decline and Notify Registrations',
896
+				'event_espresso'
897
+			);
898
+		}
899
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
900
+			'Set Registrations to Pending Payment',
901
+			'event_espresso'
902
+		);
903
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
904
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
905
+				'Set Registrations to Pending Payment and Notify',
906
+				'event_espresso'
907
+			);
908
+		}
909
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
910
+			'Set Registrations to Not Approved',
911
+			'event_espresso'
912
+		);
913
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
914
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
915
+				'Set Registrations to Not Approved and Notify',
916
+				'event_espresso'
917
+			);
918
+		}
919
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
920
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
921
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
922
+				'Cancel Registrations and Notify',
923
+				'event_espresso'
924
+			);
925
+		}
926
+		$def_reg_status_actions = apply_filters(
927
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
928
+			$def_reg_status_actions,
929
+			$active_mts,
930
+			$can_send
931
+		);
932
+
933
+		$this->_views = [
934
+			'all'   => [
935
+				'slug'        => 'all',
936
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
937
+				'count'       => 0,
938
+				'bulk_action' => array_merge(
939
+					$def_reg_status_actions,
940
+					[
941
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
942
+					]
943
+				),
944
+			],
945
+			'month' => [
946
+				'slug'        => 'month',
947
+				'label'       => esc_html__('This Month', 'event_espresso'),
948
+				'count'       => 0,
949
+				'bulk_action' => array_merge(
950
+					$def_reg_status_actions,
951
+					[
952
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
953
+					]
954
+				),
955
+			],
956
+			'today' => [
957
+				'slug'        => 'today',
958
+				'label'       => sprintf(
959
+					esc_html__('Today - %s', 'event_espresso'),
960
+					date('M d, Y', current_time('timestamp'))
961
+				),
962
+				'count'       => 0,
963
+				'bulk_action' => array_merge(
964
+					$def_reg_status_actions,
965
+					[
966
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
967
+					]
968
+				),
969
+			],
970
+		];
971
+		if (
972
+			EE_Registry::instance()->CAP->current_user_can(
973
+				'ee_delete_registrations',
974
+				'espresso_registrations_delete_registration'
975
+			)
976
+		) {
977
+			$this->_views['incomplete'] = [
978
+				'slug'        => 'incomplete',
979
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
980
+				'count'       => 0,
981
+				'bulk_action' => [
982
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
983
+				],
984
+			];
985
+			$this->_views['trash']      = [
986
+				'slug'        => 'trash',
987
+				'label'       => esc_html__('Trash', 'event_espresso'),
988
+				'count'       => 0,
989
+				'bulk_action' => [
990
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
991
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
992
+				],
993
+			];
994
+		}
995
+	}
996
+
997
+
998
+	protected function _set_list_table_views_contact_list()
999
+	{
1000
+		$this->_views = [
1001
+			'in_use' => [
1002
+				'slug'        => 'in_use',
1003
+				'label'       => esc_html__('In Use', 'event_espresso'),
1004
+				'count'       => 0,
1005
+				'bulk_action' => [
1006
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1007
+				],
1008
+			],
1009
+		];
1010
+		if (
1011
+			EE_Registry::instance()->CAP->current_user_can(
1012
+				'ee_delete_contacts',
1013
+				'espresso_registrations_trash_attendees'
1014
+			)
1015
+		) {
1016
+			$this->_views['trash'] = [
1017
+				'slug'        => 'trash',
1018
+				'label'       => esc_html__('Trash', 'event_espresso'),
1019
+				'count'       => 0,
1020
+				'bulk_action' => [
1021
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1022
+				],
1023
+			];
1024
+		}
1025
+	}
1026
+
1027
+
1028
+	/**
1029
+	 * @return array
1030
+	 * @throws EE_Error
1031
+	 */
1032
+	protected function _registration_legend_items()
1033
+	{
1034
+		$fc_items = [
1035
+			'star-icon'        => [
1036
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1037
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1038
+			],
1039
+			'view_details'     => [
1040
+				'class' => 'dashicons dashicons-clipboard',
1041
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1042
+			],
1043
+			'edit_attendee'    => [
1044
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1045
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1046
+			],
1047
+			'view_transaction' => [
1048
+				'class' => 'dashicons dashicons-cart',
1049
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1050
+			],
1051
+			'view_invoice'     => [
1052
+				'class' => 'dashicons dashicons-media-spreadsheet',
1053
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1054
+			],
1055
+		];
1056
+		if (
1057
+			EE_Registry::instance()->CAP->current_user_can(
1058
+				'ee_send_message',
1059
+				'espresso_registrations_resend_registration'
1060
+			)
1061
+		) {
1062
+			$fc_items['resend_registration'] = [
1063
+				'class' => 'dashicons dashicons-email-alt',
1064
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1065
+			];
1066
+		} else {
1067
+			$fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1068
+		}
1069
+		if (
1070
+			EE_Registry::instance()->CAP->current_user_can(
1071
+				'ee_read_global_messages',
1072
+				'view_filtered_messages'
1073
+			)
1074
+		) {
1075
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1076
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1077
+				$fc_items['view_related_messages'] = [
1078
+					'class' => $related_for_icon['css_class'],
1079
+					'desc'  => $related_for_icon['label'],
1080
+				];
1081
+			}
1082
+		}
1083
+		$sc_items = [
1084
+			'approved_status'   => [
1085
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1086
+				'desc'  => EEH_Template::pretty_status(
1087
+					EEM_Registration::status_id_approved,
1088
+					false,
1089
+					'sentence'
1090
+				),
1091
+			],
1092
+			'pending_status'    => [
1093
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1094
+				'desc'  => EEH_Template::pretty_status(
1095
+					EEM_Registration::status_id_pending_payment,
1096
+					false,
1097
+					'sentence'
1098
+				),
1099
+			],
1100
+			'wait_list'         => [
1101
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1102
+				'desc'  => EEH_Template::pretty_status(
1103
+					EEM_Registration::status_id_wait_list,
1104
+					false,
1105
+					'sentence'
1106
+				),
1107
+			],
1108
+			'incomplete_status' => [
1109
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1110
+				'desc'  => EEH_Template::pretty_status(
1111
+					EEM_Registration::status_id_incomplete,
1112
+					false,
1113
+					'sentence'
1114
+				),
1115
+			],
1116
+			'not_approved'      => [
1117
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1118
+				'desc'  => EEH_Template::pretty_status(
1119
+					EEM_Registration::status_id_not_approved,
1120
+					false,
1121
+					'sentence'
1122
+				),
1123
+			],
1124
+			'declined_status'   => [
1125
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1126
+				'desc'  => EEH_Template::pretty_status(
1127
+					EEM_Registration::status_id_declined,
1128
+					false,
1129
+					'sentence'
1130
+				),
1131
+			],
1132
+			'cancelled_status'  => [
1133
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1134
+				'desc'  => EEH_Template::pretty_status(
1135
+					EEM_Registration::status_id_cancelled,
1136
+					false,
1137
+					'sentence'
1138
+				),
1139
+			],
1140
+		];
1141
+		return array_merge($fc_items, $sc_items);
1142
+	}
1143
+
1144
+
1145
+
1146
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1147
+
1148
+
1149
+	/**
1150
+	 * @throws DomainException
1151
+	 * @throws EE_Error
1152
+	 * @throws InvalidArgumentException
1153
+	 * @throws InvalidDataTypeException
1154
+	 * @throws InvalidInterfaceException
1155
+	 */
1156
+	protected function _registrations_overview_list_table()
1157
+	{
1158
+		$this->appendAddNewRegistrationButtonToPageTitle();
1159
+		$header_text                  = '';
1160
+		$admin_page_header_decorators = [
1161
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1162
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1163
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1164
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1165
+		];
1166
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1167
+			$filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1168
+			$header_text             = $filter_header_decorator->getHeaderText($header_text);
1169
+		}
1170
+		$this->_template_args['admin_page_header'] = $header_text;
1171
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1172
+		$this->display_admin_list_table_page_with_no_sidebar();
1173
+	}
1174
+
1175
+
1176
+	/**
1177
+	 * @throws EE_Error
1178
+	 * @throws InvalidArgumentException
1179
+	 * @throws InvalidDataTypeException
1180
+	 * @throws InvalidInterfaceException
1181
+	 */
1182
+	private function appendAddNewRegistrationButtonToPageTitle()
1183
+	{
1184
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1185
+		if (
1186
+			$EVT_ID
1187
+			&& EE_Registry::instance()->CAP->current_user_can(
1188
+				'ee_edit_registrations',
1189
+				'espresso_registrations_new_registration',
1190
+				$EVT_ID
1191
+			)
1192
+		) {
1193
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1194
+				'new_registration',
1195
+				'add-registrant',
1196
+				['event_id' => $EVT_ID],
1197
+				'add-new-h2'
1198
+			);
1199
+		}
1200
+	}
1201
+
1202
+
1203
+	/**
1204
+	 * This sets the _registration property for the registration details screen
1205
+	 *
1206
+	 * @return void
1207
+	 * @throws EE_Error
1208
+	 * @throws InvalidArgumentException
1209
+	 * @throws InvalidDataTypeException
1210
+	 * @throws InvalidInterfaceException
1211
+	 */
1212
+	private function _set_registration_object()
1213
+	{
1214
+		// get out if we've already set the object
1215
+		if ($this->_registration instanceof EE_Registration) {
1216
+			return;
1217
+		}
1218
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1219
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1220
+			return;
1221
+		}
1222
+		$error_msg = sprintf(
1223
+			esc_html__(
1224
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1225
+				'event_espresso'
1226
+			),
1227
+			$REG_ID
1228
+		);
1229
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1230
+		$this->_registration = null;
1231
+	}
1232
+
1233
+
1234
+	/**
1235
+	 * Used to retrieve registrations for the list table.
1236
+	 *
1237
+	 * @param int  $per_page
1238
+	 * @param bool $count
1239
+	 * @param bool $this_month
1240
+	 * @param bool $today
1241
+	 * @return EE_Registration[]|int
1242
+	 * @throws EE_Error
1243
+	 * @throws InvalidArgumentException
1244
+	 * @throws InvalidDataTypeException
1245
+	 * @throws InvalidInterfaceException
1246
+	 */
1247
+	public function get_registrations(
1248
+		$per_page = 10,
1249
+		$count = false,
1250
+		$this_month = false,
1251
+		$today = false
1252
+	) {
1253
+		if ($this_month) {
1254
+			$this->request->setRequestParam('status', 'month');
1255
+		}
1256
+		if ($today) {
1257
+			$this->request->setRequestParam('status', 'today');
1258
+		}
1259
+		$query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1260
+		/**
1261
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1262
+		 *
1263
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1264
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1265
+		 *                      or if you have the development copy of EE you can view this at the path:
1266
+		 *                      /docs/G--Model-System/model-query-params.md
1267
+		 */
1268
+		$query_params['group_by'] = '';
1269
+
1270
+		return $count
1271
+			? $this->getRegistrationModel()->count($query_params)
1272
+			/** @type EE_Registration[] */
1273
+			: $this->getRegistrationModel()->get_all($query_params);
1274
+	}
1275
+
1276
+
1277
+	/**
1278
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1279
+	 * Note: this listens to values on the request for some of the query parameters.
1280
+	 *
1281
+	 * @param array $request
1282
+	 * @param int   $per_page
1283
+	 * @param bool  $count
1284
+	 * @return array
1285
+	 * @throws EE_Error
1286
+	 * @throws InvalidArgumentException
1287
+	 * @throws InvalidDataTypeException
1288
+	 * @throws InvalidInterfaceException
1289
+	 */
1290
+	protected function _get_registration_query_parameters(
1291
+		$request = [],
1292
+		$per_page = 10,
1293
+		$count = false
1294
+	) {
1295
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1296
+		$list_table_query_builder = $this->getLoader()->getNew(
1297
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1298
+			[null, null, $request]
1299
+		);
1300
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1301
+	}
1302
+
1303
+
1304
+	public function get_registration_status_array()
1305
+	{
1306
+		return self::$_reg_status;
1307
+	}
1308
+
1309
+
1310
+
1311
+
1312
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1313
+	/**
1314
+	 * generates HTML for the View Registration Details Admin page
1315
+	 *
1316
+	 * @return void
1317
+	 * @throws DomainException
1318
+	 * @throws EE_Error
1319
+	 * @throws InvalidArgumentException
1320
+	 * @throws InvalidDataTypeException
1321
+	 * @throws InvalidInterfaceException
1322
+	 * @throws EntityNotFoundException
1323
+	 * @throws ReflectionException
1324
+	 */
1325
+	protected function _registration_details()
1326
+	{
1327
+		$this->_template_args = [];
1328
+		$this->_set_registration_object();
1329
+		if (is_object($this->_registration)) {
1330
+			$transaction                                   = $this->_registration->transaction()
1331
+				? $this->_registration->transaction()
1332
+				: EE_Transaction::new_instance();
1333
+			$this->_session                                = $transaction->session_data();
1334
+			$event_id                                      = $this->_registration->event_ID();
1335
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1336
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1337
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1338
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1339
+			$this->_template_args['grand_total']           = $transaction->total();
1340
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1341
+			// link back to overview
1342
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1343
+			$this->_template_args['registration']                = $this->_registration;
1344
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1345
+				[
1346
+					'action'   => 'default',
1347
+					'event_id' => $event_id,
1348
+				],
1349
+				REG_ADMIN_URL
1350
+			);
1351
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1352
+				[
1353
+					'action' => 'default',
1354
+					'EVT_ID' => $event_id,
1355
+					'page'   => 'espresso_transactions',
1356
+				],
1357
+				admin_url('admin.php')
1358
+			);
1359
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1360
+				[
1361
+					'page'   => 'espresso_events',
1362
+					'action' => 'edit',
1363
+					'post'   => $event_id,
1364
+				],
1365
+				admin_url('admin.php')
1366
+			);
1367
+			// next and previous links
1368
+			$next_reg                                      = $this->_registration->next(
1369
+				null,
1370
+				[],
1371
+				'REG_ID'
1372
+			);
1373
+			$this->_template_args['next_registration']     = $next_reg
1374
+				? $this->_next_link(
1375
+					EE_Admin_Page::add_query_args_and_nonce(
1376
+						[
1377
+							'action'  => 'view_registration',
1378
+							'_REG_ID' => $next_reg['REG_ID'],
1379
+						],
1380
+						REG_ADMIN_URL
1381
+					),
1382
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1383
+				)
1384
+				: '';
1385
+			$previous_reg                                  = $this->_registration->previous(
1386
+				null,
1387
+				[],
1388
+				'REG_ID'
1389
+			);
1390
+			$this->_template_args['previous_registration'] = $previous_reg
1391
+				? $this->_previous_link(
1392
+					EE_Admin_Page::add_query_args_and_nonce(
1393
+						[
1394
+							'action'  => 'view_registration',
1395
+							'_REG_ID' => $previous_reg['REG_ID'],
1396
+						],
1397
+						REG_ADMIN_URL
1398
+					),
1399
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1400
+				)
1401
+				: '';
1402
+			// grab header
1403
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1404
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1405
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1406
+				$template_path,
1407
+				$this->_template_args,
1408
+				true
1409
+			);
1410
+		} else {
1411
+			$this->_template_args['admin_page_header'] = '';
1412
+			$this->_display_espresso_notices();
1413
+		}
1414
+		// the details template wrapper
1415
+		$this->display_admin_page_with_sidebar();
1416
+	}
1417
+
1418
+
1419
+	/**
1420
+	 * @throws EE_Error
1421
+	 * @throws InvalidArgumentException
1422
+	 * @throws InvalidDataTypeException
1423
+	 * @throws InvalidInterfaceException
1424
+	 * @throws ReflectionException
1425
+	 * @since 4.10.2.p
1426
+	 */
1427
+	protected function _registration_details_metaboxes()
1428
+	{
1429
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1430
+		$this->_set_registration_object();
1431
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1432
+		add_meta_box(
1433
+			'edit-reg-status-mbox',
1434
+			esc_html__('Registration Status', 'event_espresso'),
1435
+			[$this, 'set_reg_status_buttons_metabox'],
1436
+			$this->_wp_page_slug,
1437
+			'normal',
1438
+			'high'
1439
+		);
1440
+		add_meta_box(
1441
+			'edit-reg-details-mbox',
1442
+			esc_html__('Registration Details', 'event_espresso'),
1443
+			[$this, '_reg_details_meta_box'],
1444
+			$this->_wp_page_slug,
1445
+			'normal',
1446
+			'high'
1447
+		);
1448
+		if (
1449
+			$attendee instanceof EE_Attendee
1450
+			&& EE_Registry::instance()->CAP->current_user_can(
1451
+				'ee_read_registration',
1452
+				'edit-reg-questions-mbox',
1453
+				$this->_registration->ID()
1454
+			)
1455
+		) {
1456
+			add_meta_box(
1457
+				'edit-reg-questions-mbox',
1458
+				esc_html__('Registration Form Answers', 'event_espresso'),
1459
+				[$this, '_reg_questions_meta_box'],
1460
+				$this->_wp_page_slug,
1461
+				'normal',
1462
+				'high'
1463
+			);
1464
+		}
1465
+		add_meta_box(
1466
+			'edit-reg-registrant-mbox',
1467
+			esc_html__('Contact Details', 'event_espresso'),
1468
+			[$this, '_reg_registrant_side_meta_box'],
1469
+			$this->_wp_page_slug,
1470
+			'side',
1471
+			'high'
1472
+		);
1473
+		if ($this->_registration->group_size() > 1) {
1474
+			add_meta_box(
1475
+				'edit-reg-attendees-mbox',
1476
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1477
+				[$this, '_reg_attendees_meta_box'],
1478
+				$this->_wp_page_slug,
1479
+				'normal',
1480
+				'high'
1481
+			);
1482
+		}
1483
+	}
1484
+
1485
+
1486
+	/**
1487
+	 * set_reg_status_buttons_metabox
1488
+	 *
1489
+	 * @return void
1490
+	 * @throws EE_Error
1491
+	 * @throws EntityNotFoundException
1492
+	 * @throws InvalidArgumentException
1493
+	 * @throws InvalidDataTypeException
1494
+	 * @throws InvalidInterfaceException
1495
+	 * @throws ReflectionException
1496
+	 */
1497
+	public function set_reg_status_buttons_metabox()
1498
+	{
1499
+		$this->_set_registration_object();
1500
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1501
+		$output                 = $change_reg_status_form->form_open(
1502
+			self::add_query_args_and_nonce(
1503
+				[
1504
+					'action' => 'change_reg_status',
1505
+				],
1506
+				REG_ADMIN_URL
1507
+			)
1508
+		);
1509
+		$output                 .= $change_reg_status_form->get_html();
1510
+		$output                 .= $change_reg_status_form->form_close();
1511
+		echo wp_kses($output, AllowedTags::getWithFormTags());
1512
+	}
1513
+
1514
+
1515
+	/**
1516
+	 * @return EE_Form_Section_Proper
1517
+	 * @throws EE_Error
1518
+	 * @throws InvalidArgumentException
1519
+	 * @throws InvalidDataTypeException
1520
+	 * @throws InvalidInterfaceException
1521
+	 * @throws EntityNotFoundException
1522
+	 * @throws ReflectionException
1523
+	 */
1524
+	protected function _generate_reg_status_change_form()
1525
+	{
1526
+		$reg_status_change_form_array = [
1527
+			'name'            => 'reg_status_change_form',
1528
+			'html_id'         => 'reg-status-change-form',
1529
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1530
+			'subsections'     => [
1531
+				'return'         => new EE_Hidden_Input(
1532
+					[
1533
+						'name'    => 'return',
1534
+						'default' => 'view_registration',
1535
+					]
1536
+				),
1537
+				'REG_ID'         => new EE_Hidden_Input(
1538
+					[
1539
+						'name'    => 'REG_ID',
1540
+						'default' => $this->_registration->ID(),
1541
+					]
1542
+				),
1543
+				'current_status' => new EE_Form_Section_HTML(
1544
+					EEH_HTML::table(
1545
+						EEH_HTML::tr(
1546
+							EEH_HTML::th(
1547
+								EEH_HTML::label(
1548
+									EEH_HTML::strong(
1549
+										esc_html__('Current Registration Status', 'event_espresso')
1550
+									)
1551
+								)
1552
+							)
1553
+							. EEH_HTML::td(
1554
+								EEH_HTML::strong(
1555
+									$this->_registration->pretty_status(),
1556
+									'',
1557
+									'status-' . $this->_registration->status_ID(),
1558
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1559
+								)
1560
+							)
1561
+						)
1562
+					)
1563
+				),
1564
+			],
1565
+		];
1566
+		if (
1567
+			EE_Registry::instance()->CAP->current_user_can(
1568
+				'ee_edit_registration',
1569
+				'toggle_registration_status',
1570
+				$this->_registration->ID()
1571
+			)
1572
+		) {
1573
+			$reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1574
+				$this->_get_reg_statuses(),
1575
+				[
1576
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1577
+					'default'         => $this->_registration->status_ID(),
1578
+				]
1579
+			);
1580
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1581
+				[
1582
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1583
+					'default'         => false,
1584
+					'html_help_text'  => esc_html__(
1585
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1586
+						'event_espresso'
1587
+					),
1588
+				]
1589
+			);
1590
+			$reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1591
+				[
1592
+					'html_class'      => 'button-primary',
1593
+					'html_label_text' => '&nbsp;',
1594
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1595
+				]
1596
+			);
1597
+		}
1598
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1599
+	}
1600
+
1601
+
1602
+	/**
1603
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1604
+	 *
1605
+	 * @return array
1606
+	 * @throws EE_Error
1607
+	 * @throws InvalidArgumentException
1608
+	 * @throws InvalidDataTypeException
1609
+	 * @throws InvalidInterfaceException
1610
+	 * @throws EntityNotFoundException
1611
+	 */
1612
+	protected function _get_reg_statuses()
1613
+	{
1614
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1615
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1616
+		// get current reg status
1617
+		$current_status = $this->_registration->status_ID();
1618
+		// is registration for free event? This will determine whether to display the pending payment option
1619
+		if (
1620
+			$current_status !== EEM_Registration::status_id_pending_payment
1621
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1622
+		) {
1623
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1624
+		}
1625
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1626
+	}
1627
+
1628
+
1629
+	/**
1630
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1631
+	 *
1632
+	 * @param bool $status REG status given for changing registrations to.
1633
+	 * @param bool $notify Whether to send messages notifications or not.
1634
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1635
+	 * @throws DomainException
1636
+	 * @throws EE_Error
1637
+	 * @throws EntityNotFoundException
1638
+	 * @throws InvalidArgumentException
1639
+	 * @throws InvalidDataTypeException
1640
+	 * @throws InvalidInterfaceException
1641
+	 * @throws ReflectionException
1642
+	 * @throws RuntimeException
1643
+	 */
1644
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1645
+	{
1646
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1647
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1648
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1649
+
1650
+		// sanitize $REG_IDs
1651
+		$REG_IDs = array_map('absint', $REG_IDs);
1652
+		// and remove empty entries
1653
+		$REG_IDs = array_filter($REG_IDs);
1654
+
1655
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1656
+
1657
+		/**
1658
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1659
+		 * Currently this value is used downstream by the _process_resend_registration method.
1660
+		 *
1661
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1662
+		 * @param bool                     $status           The status registrations were changed to.
1663
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1664
+		 * @param Registrations_Admin_Page $admin_page_object
1665
+		 */
1666
+		$REG_ID = apply_filters(
1667
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1668
+			$result['REG_ID'],
1669
+			$status,
1670
+			$result['success'],
1671
+			$this
1672
+		);
1673
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1674
+
1675
+		// notify?
1676
+		if (
1677
+			$notify
1678
+			&& $result['success']
1679
+			&& ! empty($REG_ID)
1680
+			&& EE_Registry::instance()->CAP->current_user_can(
1681
+				'ee_send_message',
1682
+				'espresso_registrations_resend_registration'
1683
+			)
1684
+		) {
1685
+			$this->_process_resend_registration();
1686
+		}
1687
+		return $result;
1688
+	}
1689
+
1690
+
1691
+	/**
1692
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1693
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1694
+	 *
1695
+	 * @param array  $REG_IDs
1696
+	 * @param string $status
1697
+	 * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1698
+	 *                       slug sent with setting the registration status.
1699
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1700
+	 * @throws EE_Error
1701
+	 * @throws InvalidArgumentException
1702
+	 * @throws InvalidDataTypeException
1703
+	 * @throws InvalidInterfaceException
1704
+	 * @throws ReflectionException
1705
+	 * @throws RuntimeException
1706
+	 * @throws EntityNotFoundException
1707
+	 * @throws DomainException
1708
+	 */
1709
+	protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1710
+	{
1711
+		$success = false;
1712
+		// typecast $REG_IDs
1713
+		$REG_IDs = (array) $REG_IDs;
1714
+		if (! empty($REG_IDs)) {
1715
+			$success = true;
1716
+			// set default status if none is passed
1717
+			$status         = $status ?: EEM_Registration::status_id_pending_payment;
1718
+			$status_context = $notify
1719
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1720
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1721
+			// loop through REG_ID's and change status
1722
+			foreach ($REG_IDs as $REG_ID) {
1723
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1724
+				if ($registration instanceof EE_Registration) {
1725
+					$registration->set_status(
1726
+						$status,
1727
+						false,
1728
+						new Context(
1729
+							$status_context,
1730
+							esc_html__(
1731
+								'Manually triggered status change on a Registration Admin Page route.',
1732
+								'event_espresso'
1733
+							)
1734
+						)
1735
+					);
1736
+					$result = $registration->save();
1737
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1738
+					$success = $result !== false ? $success : false;
1739
+				}
1740
+			}
1741
+		}
1742
+
1743
+		// return $success and processed registrations
1744
+		return ['REG_ID' => $REG_IDs, 'success' => $success];
1745
+	}
1746
+
1747
+
1748
+	/**
1749
+	 * Common logic for setting up success message and redirecting to appropriate route
1750
+	 *
1751
+	 * @param string $STS_ID status id for the registration changed to
1752
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1753
+	 * @return void
1754
+	 * @throws DomainException
1755
+	 * @throws EE_Error
1756
+	 * @throws EntityNotFoundException
1757
+	 * @throws InvalidArgumentException
1758
+	 * @throws InvalidDataTypeException
1759
+	 * @throws InvalidInterfaceException
1760
+	 * @throws ReflectionException
1761
+	 * @throws RuntimeException
1762
+	 */
1763
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1764
+	{
1765
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1766
+			: ['success' => false];
1767
+		$success = isset($result['success']) && $result['success'];
1768
+		// setup success message
1769
+		if ($success) {
1770
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1771
+				$msg = sprintf(
1772
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1773
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1774
+				);
1775
+			} else {
1776
+				$msg = sprintf(
1777
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1778
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1779
+				);
1780
+			}
1781
+			EE_Error::add_success($msg);
1782
+		} else {
1783
+			EE_Error::add_error(
1784
+				esc_html__(
1785
+					'Something went wrong, and the status was not changed',
1786
+					'event_espresso'
1787
+				),
1788
+				__FILE__,
1789
+				__LINE__,
1790
+				__FUNCTION__
1791
+			);
1792
+		}
1793
+		$return = $this->request->getRequestParam('return');
1794
+		$route  = $return === 'view_registration'
1795
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1796
+			: ['action' => 'default'];
1797
+		$route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1798
+		$this->_redirect_after_action($success, '', '', $route, true);
1799
+	}
1800
+
1801
+
1802
+	/**
1803
+	 * incoming reg status change from reg details page.
1804
+	 *
1805
+	 * @return void
1806
+	 * @throws EE_Error
1807
+	 * @throws EntityNotFoundException
1808
+	 * @throws InvalidArgumentException
1809
+	 * @throws InvalidDataTypeException
1810
+	 * @throws InvalidInterfaceException
1811
+	 * @throws ReflectionException
1812
+	 * @throws RuntimeException
1813
+	 * @throws DomainException
1814
+	 */
1815
+	protected function _change_reg_status()
1816
+	{
1817
+		$this->request->setRequestParam('return', 'view_registration');
1818
+		// set notify based on whether the send notifications toggle is set or not
1819
+		$notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1820
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1821
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1822
+		switch ($reg_status) {
1823
+			case EEM_Registration::status_id_approved:
1824
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1825
+				$this->approve_registration($notify);
1826
+				break;
1827
+			case EEM_Registration::status_id_pending_payment:
1828
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1829
+				$this->pending_registration($notify);
1830
+				break;
1831
+			case EEM_Registration::status_id_not_approved:
1832
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1833
+				$this->not_approve_registration($notify);
1834
+				break;
1835
+			case EEM_Registration::status_id_declined:
1836
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1837
+				$this->decline_registration($notify);
1838
+				break;
1839
+			case EEM_Registration::status_id_cancelled:
1840
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1841
+				$this->cancel_registration($notify);
1842
+				break;
1843
+			case EEM_Registration::status_id_wait_list:
1844
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1845
+				$this->wait_list_registration($notify);
1846
+				break;
1847
+			case EEM_Registration::status_id_incomplete:
1848
+			default:
1849
+				$this->request->unSetRequestParam('return');
1850
+				$this->_reg_status_change_return('');
1851
+				break;
1852
+		}
1853
+	}
1854
+
1855
+
1856
+	/**
1857
+	 * Callback for bulk action routes.
1858
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1859
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1860
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1861
+	 * when an action is happening on just a single registration).
1862
+	 *
1863
+	 * @param      $action
1864
+	 * @param bool $notify
1865
+	 */
1866
+	protected function bulk_action_on_registrations($action, $notify = false)
1867
+	{
1868
+		do_action(
1869
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1870
+			$this,
1871
+			$action,
1872
+			$notify
1873
+		);
1874
+		$method = $action . '_registration';
1875
+		if (method_exists($this, $method)) {
1876
+			$this->$method($notify);
1877
+		}
1878
+	}
1879
+
1880
+
1881
+	/**
1882
+	 * approve_registration
1883
+	 *
1884
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1885
+	 * @return void
1886
+	 * @throws EE_Error
1887
+	 * @throws EntityNotFoundException
1888
+	 * @throws InvalidArgumentException
1889
+	 * @throws InvalidDataTypeException
1890
+	 * @throws InvalidInterfaceException
1891
+	 * @throws ReflectionException
1892
+	 * @throws RuntimeException
1893
+	 * @throws DomainException
1894
+	 */
1895
+	protected function approve_registration($notify = false)
1896
+	{
1897
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1898
+	}
1899
+
1900
+
1901
+	/**
1902
+	 * decline_registration
1903
+	 *
1904
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1905
+	 * @return void
1906
+	 * @throws EE_Error
1907
+	 * @throws EntityNotFoundException
1908
+	 * @throws InvalidArgumentException
1909
+	 * @throws InvalidDataTypeException
1910
+	 * @throws InvalidInterfaceException
1911
+	 * @throws ReflectionException
1912
+	 * @throws RuntimeException
1913
+	 * @throws DomainException
1914
+	 */
1915
+	protected function decline_registration($notify = false)
1916
+	{
1917
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1918
+	}
1919
+
1920
+
1921
+	/**
1922
+	 * cancel_registration
1923
+	 *
1924
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1925
+	 * @return void
1926
+	 * @throws EE_Error
1927
+	 * @throws EntityNotFoundException
1928
+	 * @throws InvalidArgumentException
1929
+	 * @throws InvalidDataTypeException
1930
+	 * @throws InvalidInterfaceException
1931
+	 * @throws ReflectionException
1932
+	 * @throws RuntimeException
1933
+	 * @throws DomainException
1934
+	 */
1935
+	protected function cancel_registration($notify = false)
1936
+	{
1937
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1938
+	}
1939
+
1940
+
1941
+	/**
1942
+	 * not_approve_registration
1943
+	 *
1944
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1945
+	 * @return void
1946
+	 * @throws EE_Error
1947
+	 * @throws EntityNotFoundException
1948
+	 * @throws InvalidArgumentException
1949
+	 * @throws InvalidDataTypeException
1950
+	 * @throws InvalidInterfaceException
1951
+	 * @throws ReflectionException
1952
+	 * @throws RuntimeException
1953
+	 * @throws DomainException
1954
+	 */
1955
+	protected function not_approve_registration($notify = false)
1956
+	{
1957
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1958
+	}
1959
+
1960
+
1961
+	/**
1962
+	 * decline_registration
1963
+	 *
1964
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1965
+	 * @return void
1966
+	 * @throws EE_Error
1967
+	 * @throws EntityNotFoundException
1968
+	 * @throws InvalidArgumentException
1969
+	 * @throws InvalidDataTypeException
1970
+	 * @throws InvalidInterfaceException
1971
+	 * @throws ReflectionException
1972
+	 * @throws RuntimeException
1973
+	 * @throws DomainException
1974
+	 */
1975
+	protected function pending_registration($notify = false)
1976
+	{
1977
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1978
+	}
1979
+
1980
+
1981
+	/**
1982
+	 * waitlist_registration
1983
+	 *
1984
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1985
+	 * @return void
1986
+	 * @throws EE_Error
1987
+	 * @throws EntityNotFoundException
1988
+	 * @throws InvalidArgumentException
1989
+	 * @throws InvalidDataTypeException
1990
+	 * @throws InvalidInterfaceException
1991
+	 * @throws ReflectionException
1992
+	 * @throws RuntimeException
1993
+	 * @throws DomainException
1994
+	 */
1995
+	protected function wait_list_registration($notify = false)
1996
+	{
1997
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1998
+	}
1999
+
2000
+
2001
+	/**
2002
+	 * generates HTML for the Registration main meta box
2003
+	 *
2004
+	 * @return void
2005
+	 * @throws DomainException
2006
+	 * @throws EE_Error
2007
+	 * @throws InvalidArgumentException
2008
+	 * @throws InvalidDataTypeException
2009
+	 * @throws InvalidInterfaceException
2010
+	 * @throws ReflectionException
2011
+	 * @throws EntityNotFoundException
2012
+	 */
2013
+	public function _reg_details_meta_box()
2014
+	{
2015
+		EEH_Autoloader::register_line_item_display_autoloaders();
2016
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2017
+		EE_Registry::instance()->load_helper('Line_Item');
2018
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2019
+			: EE_Transaction::new_instance();
2020
+		$this->_session = $transaction->session_data();
2021
+		$filters        = new EE_Line_Item_Filter_Collection();
2022
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2023
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2024
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2025
+			$filters,
2026
+			$transaction->total_line_item()
2027
+		);
2028
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2029
+		$line_item_display                       = new EE_Line_Item_Display(
2030
+			'reg_admin_table',
2031
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2032
+		);
2033
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2034
+			$filtered_line_item_tree,
2035
+			['EE_Registration' => $this->_registration]
2036
+		);
2037
+		$attendee                                = $this->_registration->attendee();
2038
+		if (
2039
+			EE_Registry::instance()->CAP->current_user_can(
2040
+				'ee_read_transaction',
2041
+				'espresso_transactions_view_transaction'
2042
+			)
2043
+		) {
2044
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2045
+				EE_Admin_Page::add_query_args_and_nonce(
2046
+					[
2047
+						'action' => 'view_transaction',
2048
+						'TXN_ID' => $transaction->ID(),
2049
+					],
2050
+					TXN_ADMIN_URL
2051
+				),
2052
+				esc_html__(' View Transaction', 'event_espresso'),
2053
+				'button secondary-button right',
2054
+				'dashicons dashicons-cart'
2055
+			);
2056
+		} else {
2057
+			$this->_template_args['view_transaction_button'] = '';
2058
+		}
2059
+		if (
2060
+			$attendee instanceof EE_Attendee
2061
+			&& EE_Registry::instance()->CAP->current_user_can(
2062
+				'ee_send_message',
2063
+				'espresso_registrations_resend_registration'
2064
+			)
2065
+		) {
2066
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2067
+				EE_Admin_Page::add_query_args_and_nonce(
2068
+					[
2069
+						'action'      => 'resend_registration',
2070
+						'_REG_ID'     => $this->_registration->ID(),
2071
+						'redirect_to' => 'view_registration',
2072
+					],
2073
+					REG_ADMIN_URL
2074
+				),
2075
+				esc_html__(' Resend Registration', 'event_espresso'),
2076
+				'button secondary-button right',
2077
+				'dashicons dashicons-email-alt'
2078
+			);
2079
+		} else {
2080
+			$this->_template_args['resend_registration_button'] = '';
2081
+		}
2082
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2083
+		$payment                               = $transaction->get_first_related('Payment');
2084
+		$payment                               = ! $payment instanceof EE_Payment
2085
+			? EE_Payment::new_instance()
2086
+			: $payment;
2087
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2088
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2089
+			? EE_Payment_Method::new_instance()
2090
+			: $payment_method;
2091
+		$reg_details                           = [
2092
+			'payment_method'       => $payment_method->name(),
2093
+			'response_msg'         => $payment->gateway_response(),
2094
+			'registration_id'      => $this->_registration->get('REG_code'),
2095
+			'registration_session' => $this->_registration->session_ID(),
2096
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2097
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2098
+		];
2099
+		if (isset($reg_details['registration_id'])) {
2100
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2101
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2102
+				'Registration ID',
2103
+				'event_espresso'
2104
+			);
2105
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2106
+		}
2107
+		if (isset($reg_details['payment_method'])) {
2108
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2109
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2110
+				'Most Recent Payment Method',
2111
+				'event_espresso'
2112
+			);
2113
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2114
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2115
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2116
+				'Payment method response',
2117
+				'event_espresso'
2118
+			);
2119
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2120
+		}
2121
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2122
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2123
+			'Registration Session',
2124
+			'event_espresso'
2125
+		);
2126
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2127
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2128
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2129
+			'Registration placed from IP',
2130
+			'event_espresso'
2131
+		);
2132
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2133
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2134
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2135
+			'Registrant User Agent',
2136
+			'event_espresso'
2137
+		);
2138
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2139
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2140
+			[
2141
+				'action'   => 'default',
2142
+				'event_id' => $this->_registration->event_ID(),
2143
+			],
2144
+			REG_ADMIN_URL
2145
+		);
2146
+		$this->_template_args['REG_ID']                                       = $this->_registration->ID();
2147
+		$this->_template_args['event_id']                                     = $this->_registration->event_ID();
2148
+		$template_path                                                        =
2149
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2150
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2151
+	}
2152
+
2153
+
2154
+	/**
2155
+	 * generates HTML for the Registration Questions meta box.
2156
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2157
+	 * otherwise uses new forms system
2158
+	 *
2159
+	 * @return void
2160
+	 * @throws DomainException
2161
+	 * @throws EE_Error
2162
+	 * @throws InvalidArgumentException
2163
+	 * @throws InvalidDataTypeException
2164
+	 * @throws InvalidInterfaceException
2165
+	 * @throws ReflectionException
2166
+	 */
2167
+	public function _reg_questions_meta_box()
2168
+	{
2169
+		// allow someone to override this method entirely
2170
+		if (
2171
+			apply_filters(
2172
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2173
+				true,
2174
+				$this,
2175
+				$this->_registration
2176
+			)
2177
+		) {
2178
+			$form                                              = $this->_get_reg_custom_questions_form(
2179
+				$this->_registration->ID()
2180
+			);
2181
+			$this->_template_args['att_questions']             = count($form->subforms()) > 0
2182
+				? $form->get_html_and_js()
2183
+				: '';
2184
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2185
+			$this->_template_args['REG_ID']                    = $this->_registration->ID();
2186
+			$template_path                                     =
2187
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2188
+			EEH_Template::display_template($template_path, $this->_template_args);
2189
+		}
2190
+	}
2191
+
2192
+
2193
+	/**
2194
+	 * form_before_question_group
2195
+	 *
2196
+	 * @param string $output
2197
+	 * @return        string
2198
+	 * @deprecated    as of 4.8.32.rc.000
2199
+	 */
2200
+	public function form_before_question_group($output)
2201
+	{
2202
+		EE_Error::doing_it_wrong(
2203
+			__CLASS__ . '::' . __FUNCTION__,
2204
+			esc_html__(
2205
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2206
+				'event_espresso'
2207
+			),
2208
+			'4.8.32.rc.000'
2209
+		);
2210
+		return '
2211 2211
 	<table class="form-table ee-width-100">
2212 2212
 		<tbody>
2213 2213
 			';
2214
-    }
2215
-
2216
-
2217
-    /**
2218
-     * form_after_question_group
2219
-     *
2220
-     * @param string $output
2221
-     * @return        string
2222
-     * @deprecated    as of 4.8.32.rc.000
2223
-     */
2224
-    public function form_after_question_group($output)
2225
-    {
2226
-        EE_Error::doing_it_wrong(
2227
-            __CLASS__ . '::' . __FUNCTION__,
2228
-            esc_html__(
2229
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2230
-                'event_espresso'
2231
-            ),
2232
-            '4.8.32.rc.000'
2233
-        );
2234
-        return '
2214
+	}
2215
+
2216
+
2217
+	/**
2218
+	 * form_after_question_group
2219
+	 *
2220
+	 * @param string $output
2221
+	 * @return        string
2222
+	 * @deprecated    as of 4.8.32.rc.000
2223
+	 */
2224
+	public function form_after_question_group($output)
2225
+	{
2226
+		EE_Error::doing_it_wrong(
2227
+			__CLASS__ . '::' . __FUNCTION__,
2228
+			esc_html__(
2229
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2230
+				'event_espresso'
2231
+			),
2232
+			'4.8.32.rc.000'
2233
+		);
2234
+		return '
2235 2235
 			<tr class="hide-if-no-js">
2236 2236
 				<th> </th>
2237 2237
 				<td class="reg-admin-edit-attendee-question-td">
2238 2238
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2239
-               . esc_attr__('click to edit question', 'event_espresso')
2240
-               . '">
2239
+			   . esc_attr__('click to edit question', 'event_espresso')
2240
+			   . '">
2241 2241
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2242
-               . esc_html__('edit the above question group', 'event_espresso')
2243
-               . '</span>
2242
+			   . esc_html__('edit the above question group', 'event_espresso')
2243
+			   . '</span>
2244 2244
 						<div class="dashicons dashicons-edit"></div>
2245 2245
 					</a>
2246 2246
 				</td>
@@ -2248,637 +2248,637 @@  discard block
 block discarded – undo
2248 2248
 		</tbody>
2249 2249
 	</table>
2250 2250
 ';
2251
-    }
2252
-
2253
-
2254
-    /**
2255
-     * form_form_field_label_wrap
2256
-     *
2257
-     * @param string $label
2258
-     * @return        string
2259
-     * @deprecated    as of 4.8.32.rc.000
2260
-     */
2261
-    public function form_form_field_label_wrap($label)
2262
-    {
2263
-        EE_Error::doing_it_wrong(
2264
-            __CLASS__ . '::' . __FUNCTION__,
2265
-            esc_html__(
2266
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2267
-                'event_espresso'
2268
-            ),
2269
-            '4.8.32.rc.000'
2270
-        );
2271
-        return '
2251
+	}
2252
+
2253
+
2254
+	/**
2255
+	 * form_form_field_label_wrap
2256
+	 *
2257
+	 * @param string $label
2258
+	 * @return        string
2259
+	 * @deprecated    as of 4.8.32.rc.000
2260
+	 */
2261
+	public function form_form_field_label_wrap($label)
2262
+	{
2263
+		EE_Error::doing_it_wrong(
2264
+			__CLASS__ . '::' . __FUNCTION__,
2265
+			esc_html__(
2266
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2267
+				'event_espresso'
2268
+			),
2269
+			'4.8.32.rc.000'
2270
+		);
2271
+		return '
2272 2272
 			<tr>
2273 2273
 				<th>
2274 2274
 					' . $label . '
2275 2275
 				</th>';
2276
-    }
2277
-
2278
-
2279
-    /**
2280
-     * form_form_field_input__wrap
2281
-     *
2282
-     * @param string $input
2283
-     * @return        string
2284
-     * @deprecated    as of 4.8.32.rc.000
2285
-     */
2286
-    public function form_form_field_input__wrap($input)
2287
-    {
2288
-        EE_Error::doing_it_wrong(
2289
-            __CLASS__ . '::' . __FUNCTION__,
2290
-            esc_html__(
2291
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2292
-                'event_espresso'
2293
-            ),
2294
-            '4.8.32.rc.000'
2295
-        );
2296
-        return '
2276
+	}
2277
+
2278
+
2279
+	/**
2280
+	 * form_form_field_input__wrap
2281
+	 *
2282
+	 * @param string $input
2283
+	 * @return        string
2284
+	 * @deprecated    as of 4.8.32.rc.000
2285
+	 */
2286
+	public function form_form_field_input__wrap($input)
2287
+	{
2288
+		EE_Error::doing_it_wrong(
2289
+			__CLASS__ . '::' . __FUNCTION__,
2290
+			esc_html__(
2291
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2292
+				'event_espresso'
2293
+			),
2294
+			'4.8.32.rc.000'
2295
+		);
2296
+		return '
2297 2297
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2298 2298
 					' . $input . '
2299 2299
 				</td>
2300 2300
 			</tr>';
2301
-    }
2302
-
2303
-
2304
-    /**
2305
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2306
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2307
-     * to display the page
2308
-     *
2309
-     * @return void
2310
-     * @throws EE_Error
2311
-     * @throws InvalidArgumentException
2312
-     * @throws InvalidDataTypeException
2313
-     * @throws InvalidInterfaceException
2314
-     * @throws ReflectionException
2315
-     */
2316
-    protected function _update_attendee_registration_form()
2317
-    {
2318
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2319
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2320
-            $REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2321
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2322
-            if ($success) {
2323
-                $what  = esc_html__('Registration Form', 'event_espresso');
2324
-                $route = $REG_ID
2325
-                    ? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2326
-                    : ['action' => 'default'];
2327
-                $this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2328
-            }
2329
-        }
2330
-    }
2331
-
2332
-
2333
-    /**
2334
-     * Gets the form for saving registrations custom questions (if done
2335
-     * previously retrieves the cached form object, which may have validation errors in it)
2336
-     *
2337
-     * @param int $REG_ID
2338
-     * @return EE_Registration_Custom_Questions_Form
2339
-     * @throws EE_Error
2340
-     * @throws InvalidArgumentException
2341
-     * @throws InvalidDataTypeException
2342
-     * @throws InvalidInterfaceException
2343
-     * @throws ReflectionException
2344
-     */
2345
-    protected function _get_reg_custom_questions_form($REG_ID)
2346
-    {
2347
-        if (! $this->_reg_custom_questions_form) {
2348
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2349
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2350
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2351
-            );
2352
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2353
-        }
2354
-        return $this->_reg_custom_questions_form;
2355
-    }
2356
-
2357
-
2358
-    /**
2359
-     * Saves
2360
-     *
2361
-     * @param bool $REG_ID
2362
-     * @return bool
2363
-     * @throws EE_Error
2364
-     * @throws InvalidArgumentException
2365
-     * @throws InvalidDataTypeException
2366
-     * @throws InvalidInterfaceException
2367
-     * @throws ReflectionException
2368
-     */
2369
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2370
-    {
2371
-        if (! $REG_ID) {
2372
-            EE_Error::add_error(
2373
-                esc_html__(
2374
-                    'An error occurred. No registration ID was received.',
2375
-                    'event_espresso'
2376
-                ),
2377
-                __FILE__,
2378
-                __FUNCTION__,
2379
-                __LINE__
2380
-            );
2381
-        }
2382
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2383
-        $form->receive_form_submission($this->request->requestParams());
2384
-        $success = false;
2385
-        if ($form->is_valid()) {
2386
-            foreach ($form->subforms() as $question_group_form) {
2387
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2388
-                    $where_conditions    = [
2389
-                        'QST_ID' => $question_id,
2390
-                        'REG_ID' => $REG_ID,
2391
-                    ];
2392
-                    $possibly_new_values = [
2393
-                        'ANS_value' => $input->normalized_value(),
2394
-                    ];
2395
-                    $answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2396
-                    if ($answer instanceof EE_Answer) {
2397
-                        $success = $answer->save($possibly_new_values);
2398
-                    } else {
2399
-                        // insert it then
2400
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2401
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2402
-                        $success     = $answer->save();
2403
-                    }
2404
-                }
2405
-            }
2406
-        } else {
2407
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2408
-        }
2409
-        return $success;
2410
-    }
2411
-
2412
-
2413
-    /**
2414
-     * generates HTML for the Registration main meta box
2415
-     *
2416
-     * @return void
2417
-     * @throws DomainException
2418
-     * @throws EE_Error
2419
-     * @throws InvalidArgumentException
2420
-     * @throws InvalidDataTypeException
2421
-     * @throws InvalidInterfaceException
2422
-     * @throws ReflectionException
2423
-     */
2424
-    public function _reg_attendees_meta_box()
2425
-    {
2426
-        $REG = $this->getRegistrationModel();
2427
-        // get all other registrations on this transaction, and cache
2428
-        // the attendees for them so we don't have to run another query using force_join
2429
-        $registrations                           = $REG->get_all(
2430
-            [
2431
-                [
2432
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2433
-                    'REG_ID' => ['!=', $this->_registration->ID()],
2434
-                ],
2435
-                'force_join'               => ['Attendee'],
2436
-                'default_where_conditions' => 'other_models_only',
2437
-            ]
2438
-        );
2439
-        $this->_template_args['attendees']       = [];
2440
-        $this->_template_args['attendee_notice'] = '';
2441
-        if (
2442
-            empty($registrations)
2443
-            || (is_array($registrations)
2444
-                && ! EEH_Array::get_one_item_from_array($registrations))
2445
-        ) {
2446
-            EE_Error::add_error(
2447
-                esc_html__(
2448
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2449
-                    'event_espresso'
2450
-                ),
2451
-                __FILE__,
2452
-                __FUNCTION__,
2453
-                __LINE__
2454
-            );
2455
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2456
-        } else {
2457
-            $att_nmbr = 1;
2458
-            foreach ($registrations as $registration) {
2459
-                /* @var $registration EE_Registration */
2460
-                $attendee                                                      = $registration->attendee()
2461
-                    ? $registration->attendee()
2462
-                    : $this->getAttendeeModel()->create_default_object();
2463
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2464
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2465
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2466
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2467
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2468
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2469
-                    ', ',
2470
-                    $attendee->full_address_as_array()
2471
-                );
2472
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2473
-                    [
2474
-                        'action' => 'edit_attendee',
2475
-                        'post'   => $attendee->ID(),
2476
-                    ],
2477
-                    REG_ADMIN_URL
2478
-                );
2479
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2480
-                    $registration->event_obj() instanceof EE_Event
2481
-                        ? $registration->event_obj()->name()
2482
-                        : '';
2483
-                $att_nmbr++;
2484
-            }
2485
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2486
-        }
2487
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2488
-        EEH_Template::display_template($template_path, $this->_template_args);
2489
-    }
2490
-
2491
-
2492
-    /**
2493
-     * generates HTML for the Edit Registration side meta box
2494
-     *
2495
-     * @return void
2496
-     * @throws DomainException
2497
-     * @throws EE_Error
2498
-     * @throws InvalidArgumentException
2499
-     * @throws InvalidDataTypeException
2500
-     * @throws InvalidInterfaceException
2501
-     * @throws ReflectionException
2502
-     */
2503
-    public function _reg_registrant_side_meta_box()
2504
-    {
2505
-        /*@var $attendee EE_Attendee */
2506
-        $att_check = $this->_registration->attendee();
2507
-        $attendee  = $att_check instanceof EE_Attendee
2508
-            ? $att_check
2509
-            : $this->getAttendeeModel()->create_default_object();
2510
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2511
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2512
-        // primary registration object (that way we know if we need to show create button or not)
2513
-        if (! $this->_registration->is_primary_registrant()) {
2514
-            $primary_registration = $this->_registration->get_primary_registration();
2515
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2516
-                : null;
2517
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2518
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2519
-                // custom attendee object so let's not worry about the primary reg.
2520
-                $primary_registration = null;
2521
-            }
2522
-        } else {
2523
-            $primary_registration = null;
2524
-        }
2525
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2526
-        $this->_template_args['fname']             = $attendee->fname();
2527
-        $this->_template_args['lname']             = $attendee->lname();
2528
-        $this->_template_args['email']             = $attendee->email();
2529
-        $this->_template_args['phone']             = $attendee->phone();
2530
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2531
-        // edit link
2532
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2533
-            [
2534
-                'action' => 'edit_attendee',
2535
-                'post'   => $attendee->ID(),
2536
-            ],
2537
-            REG_ADMIN_URL
2538
-        );
2539
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2540
-        // create link
2541
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2542
-            ? EE_Admin_Page::add_query_args_and_nonce(
2543
-                [
2544
-                    'action'  => 'duplicate_attendee',
2545
-                    '_REG_ID' => $this->_registration->ID(),
2546
-                ],
2547
-                REG_ADMIN_URL
2548
-            ) : '';
2549
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2550
-        $this->_template_args['att_check']    = $att_check;
2551
-        $template_path                        =
2552
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2553
-        EEH_Template::display_template($template_path, $this->_template_args);
2554
-    }
2555
-
2556
-
2557
-    /**
2558
-     * trash or restore registrations
2559
-     *
2560
-     * @param boolean $trash whether to archive or restore
2561
-     * @return void
2562
-     * @throws EE_Error
2563
-     * @throws InvalidArgumentException
2564
-     * @throws InvalidDataTypeException
2565
-     * @throws InvalidInterfaceException
2566
-     * @throws RuntimeException
2567
-     */
2568
-    protected function _trash_or_restore_registrations($trash = true)
2569
-    {
2570
-        // if empty _REG_ID then get out because there's nothing to do
2571
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2572
-        if (empty($REG_IDs)) {
2573
-            EE_Error::add_error(
2574
-                sprintf(
2575
-                    esc_html__(
2576
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2577
-                        'event_espresso'
2578
-                    ),
2579
-                    $trash ? 'trash' : 'restore'
2580
-                ),
2581
-                __FILE__,
2582
-                __LINE__,
2583
-                __FUNCTION__
2584
-            );
2585
-            $this->_redirect_after_action(false, '', '', [], true);
2586
-        }
2587
-        $success        = 0;
2588
-        $overwrite_msgs = false;
2589
-        // Checkboxes
2590
-        $reg_count = count($REG_IDs);
2591
-        // cycle thru checkboxes
2592
-        foreach ($REG_IDs as $REG_ID) {
2593
-            /** @var EE_Registration $REG */
2594
-            $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2595
-            $payments = $REG->registration_payments();
2596
-            if (! empty($payments)) {
2597
-                $name           = $REG->attendee() instanceof EE_Attendee
2598
-                    ? $REG->attendee()->full_name()
2599
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2600
-                $overwrite_msgs = true;
2601
-                EE_Error::add_error(
2602
-                    sprintf(
2603
-                        esc_html__(
2604
-                            'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2605
-                            'event_espresso'
2606
-                        ),
2607
-                        $name
2608
-                    ),
2609
-                    __FILE__,
2610
-                    __FUNCTION__,
2611
-                    __LINE__
2612
-                );
2613
-                // can't trash this registration because it has payments.
2614
-                continue;
2615
-            }
2616
-            $updated = $trash ? $REG->delete() : $REG->restore();
2617
-            if ($updated) {
2618
-                $success++;
2619
-            }
2620
-        }
2621
-        $this->_redirect_after_action(
2622
-            $success === $reg_count, // were ALL registrations affected?
2623
-            $success > 1
2624
-                ? esc_html__('Registrations', 'event_espresso')
2625
-                : esc_html__('Registration', 'event_espresso'),
2626
-            $trash
2627
-                ? esc_html__('moved to the trash', 'event_espresso')
2628
-                : esc_html__('restored', 'event_espresso'),
2629
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2630
-            $overwrite_msgs
2631
-        );
2632
-    }
2633
-
2634
-
2635
-    /**
2636
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2637
-     * registration but also.
2638
-     * 1. Removing relations to EE_Attendee
2639
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2640
-     * ALSO trashed.
2641
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2642
-     * 4. Removing relationships between all tickets and the related registrations
2643
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2644
-     * 6. Deleting permanently any related Checkins.
2645
-     *
2646
-     * @return void
2647
-     * @throws EE_Error
2648
-     * @throws InvalidArgumentException
2649
-     * @throws InvalidDataTypeException
2650
-     * @throws InvalidInterfaceException
2651
-     * @throws ReflectionException
2652
-     */
2653
-    protected function _delete_registrations()
2654
-    {
2655
-        $REG_MDL = $this->getRegistrationModel();
2656
-        $success = 0;
2657
-        // Checkboxes
2658
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2659
-
2660
-        if (! empty($REG_IDs)) {
2661
-            // if array has more than one element than success message should be plural
2662
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2663
-            // cycle thru checkboxes
2664
-            foreach ($REG_IDs as $REG_ID) {
2665
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2666
-                if (! $REG instanceof EE_Registration) {
2667
-                    continue;
2668
-                }
2669
-                $deleted = $this->_delete_registration($REG);
2670
-                if (! $deleted) {
2671
-                    $success = 0;
2672
-                }
2673
-            }
2674
-        }
2675
-
2676
-        $what        = $success > 1
2677
-            ? esc_html__('Registrations', 'event_espresso')
2678
-            : esc_html__('Registration', 'event_espresso');
2679
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2680
-        $this->_redirect_after_action(
2681
-            $success,
2682
-            $what,
2683
-            $action_desc,
2684
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2685
-            true
2686
-        );
2687
-    }
2688
-
2689
-
2690
-    /**
2691
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2692
-     * models get affected.
2693
-     *
2694
-     * @param EE_Registration $REG registration to be deleted permanently
2695
-     * @return bool true = successful deletion, false = fail.
2696
-     * @throws EE_Error
2697
-     * @throws InvalidArgumentException
2698
-     * @throws InvalidDataTypeException
2699
-     * @throws InvalidInterfaceException
2700
-     * @throws ReflectionException
2701
-     */
2702
-    protected function _delete_registration(EE_Registration $REG)
2703
-    {
2704
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2705
-        // registrations on the transaction that are NOT trashed.
2706
-        $TXN = $REG->get_first_related('Transaction');
2707
-        if (! $TXN instanceof EE_Transaction) {
2708
-            EE_Error::add_error(
2709
-                sprintf(
2710
-                    esc_html__(
2711
-                        'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2712
-                        'event_espresso'
2713
-                    ),
2714
-                    $REG->id()
2715
-                ),
2716
-                __FILE__,
2717
-                __FUNCTION__,
2718
-                __LINE__
2719
-            );
2720
-            return false;
2721
-        }
2722
-        $REGS        = $TXN->get_many_related('Registration');
2723
-        $all_trashed = true;
2724
-        foreach ($REGS as $registration) {
2725
-            if (! $registration->get('REG_deleted')) {
2726
-                $all_trashed = false;
2727
-            }
2728
-        }
2729
-        if (! $all_trashed) {
2730
-            EE_Error::add_error(
2731
-                esc_html__(
2732
-                    'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2733
-                    'event_espresso'
2734
-                ),
2735
-                __FILE__,
2736
-                __FUNCTION__,
2737
-                __LINE__
2738
-            );
2739
-            return false;
2740
-        }
2741
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2742
-        // separately from THIS one).
2743
-        foreach ($REGS as $registration) {
2744
-            // delete related answers
2745
-            $registration->delete_related_permanently('Answer');
2746
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2747
-            $attendee = $registration->get_first_related('Attendee');
2748
-            if ($attendee instanceof EE_Attendee) {
2749
-                $registration->_remove_relation_to($attendee, 'Attendee');
2750
-            }
2751
-            // now remove relationships to tickets on this registration.
2752
-            $registration->_remove_relations('Ticket');
2753
-            // now delete permanently the checkins related to this registration.
2754
-            $registration->delete_related_permanently('Checkin');
2755
-            if ($registration->ID() === $REG->ID()) {
2756
-                continue;
2757
-            } //we don't want to delete permanently the existing registration just yet.
2758
-            // remove relation to transaction for these registrations if NOT the existing registrations
2759
-            $registration->_remove_relations('Transaction');
2760
-            // delete permanently any related messages.
2761
-            $registration->delete_related_permanently('Message');
2762
-            // now delete this registration permanently
2763
-            $registration->delete_permanently();
2764
-        }
2765
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2766
-        // (the transaction and line items should be all that's left).
2767
-        // delete the line items related to the transaction for this registration.
2768
-        $TXN->delete_related_permanently('Line_Item');
2769
-        // we need to remove all the relationships on the transaction
2770
-        $TXN->delete_related_permanently('Payment');
2771
-        $TXN->delete_related_permanently('Extra_Meta');
2772
-        $TXN->delete_related_permanently('Message');
2773
-        // now we can delete this REG permanently (and the transaction of course)
2774
-        $REG->delete_related_permanently('Transaction');
2775
-        return $REG->delete_permanently();
2776
-    }
2777
-
2778
-
2779
-    /**
2780
-     *    generates HTML for the Register New Attendee Admin page
2781
-     *
2782
-     * @throws DomainException
2783
-     * @throws EE_Error
2784
-     * @throws InvalidArgumentException
2785
-     * @throws InvalidDataTypeException
2786
-     * @throws InvalidInterfaceException
2787
-     * @throws ReflectionException
2788
-     */
2789
-    public function new_registration()
2790
-    {
2791
-        if (! $this->_set_reg_event()) {
2792
-            throw new EE_Error(
2793
-                esc_html__(
2794
-                    'Unable to continue with registering because there is no Event ID in the request',
2795
-                    'event_espresso'
2796
-                )
2797
-            );
2798
-        }
2799
-        /** @var CurrentPage $current_page */
2800
-        $current_page = $this->loader->getShared(CurrentPage::class);
2801
-        $current_page->setEspressoPage(true);
2802
-        // gotta start with a clean slate if we're not coming here via ajax
2803
-        if (
2804
-            ! $this->request->isAjax()
2805
-            && (
2806
-                ! $this->request->requestParamIsSet('processing_registration')
2807
-                || $this->request->requestParamIsSet('step_error')
2808
-            )
2809
-        ) {
2810
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2811
-        }
2812
-        $this->_template_args['event_name'] = '';
2813
-        // event name
2814
-        if ($this->_reg_event) {
2815
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2816
-            $edit_event_url                     = self::add_query_args_and_nonce(
2817
-                [
2818
-                    'action' => 'edit',
2819
-                    'post'   => $this->_reg_event->ID(),
2820
-                ],
2821
-                EVENTS_ADMIN_URL
2822
-            );
2823
-            $edit_event_lnk                     = '<a href="'
2824
-                                                  . $edit_event_url
2825
-                                                  . '" title="'
2826
-                                                  . esc_attr__('Edit ', 'event_espresso')
2827
-                                                  . $this->_reg_event->name()
2828
-                                                  . '">'
2829
-                                                  . esc_html__('Edit Event', 'event_espresso')
2830
-                                                  . '</a>';
2831
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2832
-                                                   . $edit_event_lnk
2833
-                                                   . '</span>';
2834
-        }
2835
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2836
-        if ($this->request->isAjax()) {
2837
-            $this->_return_json();
2838
-        }
2839
-        // grab header
2840
-        $template_path                              =
2841
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2842
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2843
-            $template_path,
2844
-            $this->_template_args,
2845
-            true
2846
-        );
2847
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2848
-        // the details template wrapper
2849
-        $this->display_admin_page_with_sidebar();
2850
-    }
2851
-
2852
-
2853
-    /**
2854
-     * This returns the content for a registration step
2855
-     *
2856
-     * @return string html
2857
-     * @throws DomainException
2858
-     * @throws EE_Error
2859
-     * @throws InvalidArgumentException
2860
-     * @throws InvalidDataTypeException
2861
-     * @throws InvalidInterfaceException
2862
-     * @throws ReflectionException
2863
-     */
2864
-    protected function _get_registration_step_content()
2865
-    {
2866
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2867
-            $warning_msg = sprintf(
2868
-                esc_html__(
2869
-                    '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2870
-                    'event_espresso'
2871
-                ),
2872
-                '<br />',
2873
-                '<h3 class="important-notice">',
2874
-                '</h3>',
2875
-                '<div class="float-right">',
2876
-                '<span id="redirect_timer" class="important-notice">30</span>',
2877
-                '</div>',
2878
-                '<b>',
2879
-                '</b>'
2880
-            );
2881
-            return '
2301
+	}
2302
+
2303
+
2304
+	/**
2305
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2306
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2307
+	 * to display the page
2308
+	 *
2309
+	 * @return void
2310
+	 * @throws EE_Error
2311
+	 * @throws InvalidArgumentException
2312
+	 * @throws InvalidDataTypeException
2313
+	 * @throws InvalidInterfaceException
2314
+	 * @throws ReflectionException
2315
+	 */
2316
+	protected function _update_attendee_registration_form()
2317
+	{
2318
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2319
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2320
+			$REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2321
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2322
+			if ($success) {
2323
+				$what  = esc_html__('Registration Form', 'event_espresso');
2324
+				$route = $REG_ID
2325
+					? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2326
+					: ['action' => 'default'];
2327
+				$this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2328
+			}
2329
+		}
2330
+	}
2331
+
2332
+
2333
+	/**
2334
+	 * Gets the form for saving registrations custom questions (if done
2335
+	 * previously retrieves the cached form object, which may have validation errors in it)
2336
+	 *
2337
+	 * @param int $REG_ID
2338
+	 * @return EE_Registration_Custom_Questions_Form
2339
+	 * @throws EE_Error
2340
+	 * @throws InvalidArgumentException
2341
+	 * @throws InvalidDataTypeException
2342
+	 * @throws InvalidInterfaceException
2343
+	 * @throws ReflectionException
2344
+	 */
2345
+	protected function _get_reg_custom_questions_form($REG_ID)
2346
+	{
2347
+		if (! $this->_reg_custom_questions_form) {
2348
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2349
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2350
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2351
+			);
2352
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2353
+		}
2354
+		return $this->_reg_custom_questions_form;
2355
+	}
2356
+
2357
+
2358
+	/**
2359
+	 * Saves
2360
+	 *
2361
+	 * @param bool $REG_ID
2362
+	 * @return bool
2363
+	 * @throws EE_Error
2364
+	 * @throws InvalidArgumentException
2365
+	 * @throws InvalidDataTypeException
2366
+	 * @throws InvalidInterfaceException
2367
+	 * @throws ReflectionException
2368
+	 */
2369
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2370
+	{
2371
+		if (! $REG_ID) {
2372
+			EE_Error::add_error(
2373
+				esc_html__(
2374
+					'An error occurred. No registration ID was received.',
2375
+					'event_espresso'
2376
+				),
2377
+				__FILE__,
2378
+				__FUNCTION__,
2379
+				__LINE__
2380
+			);
2381
+		}
2382
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2383
+		$form->receive_form_submission($this->request->requestParams());
2384
+		$success = false;
2385
+		if ($form->is_valid()) {
2386
+			foreach ($form->subforms() as $question_group_form) {
2387
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2388
+					$where_conditions    = [
2389
+						'QST_ID' => $question_id,
2390
+						'REG_ID' => $REG_ID,
2391
+					];
2392
+					$possibly_new_values = [
2393
+						'ANS_value' => $input->normalized_value(),
2394
+					];
2395
+					$answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2396
+					if ($answer instanceof EE_Answer) {
2397
+						$success = $answer->save($possibly_new_values);
2398
+					} else {
2399
+						// insert it then
2400
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2401
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2402
+						$success     = $answer->save();
2403
+					}
2404
+				}
2405
+			}
2406
+		} else {
2407
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2408
+		}
2409
+		return $success;
2410
+	}
2411
+
2412
+
2413
+	/**
2414
+	 * generates HTML for the Registration main meta box
2415
+	 *
2416
+	 * @return void
2417
+	 * @throws DomainException
2418
+	 * @throws EE_Error
2419
+	 * @throws InvalidArgumentException
2420
+	 * @throws InvalidDataTypeException
2421
+	 * @throws InvalidInterfaceException
2422
+	 * @throws ReflectionException
2423
+	 */
2424
+	public function _reg_attendees_meta_box()
2425
+	{
2426
+		$REG = $this->getRegistrationModel();
2427
+		// get all other registrations on this transaction, and cache
2428
+		// the attendees for them so we don't have to run another query using force_join
2429
+		$registrations                           = $REG->get_all(
2430
+			[
2431
+				[
2432
+					'TXN_ID' => $this->_registration->transaction_ID(),
2433
+					'REG_ID' => ['!=', $this->_registration->ID()],
2434
+				],
2435
+				'force_join'               => ['Attendee'],
2436
+				'default_where_conditions' => 'other_models_only',
2437
+			]
2438
+		);
2439
+		$this->_template_args['attendees']       = [];
2440
+		$this->_template_args['attendee_notice'] = '';
2441
+		if (
2442
+			empty($registrations)
2443
+			|| (is_array($registrations)
2444
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2445
+		) {
2446
+			EE_Error::add_error(
2447
+				esc_html__(
2448
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2449
+					'event_espresso'
2450
+				),
2451
+				__FILE__,
2452
+				__FUNCTION__,
2453
+				__LINE__
2454
+			);
2455
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2456
+		} else {
2457
+			$att_nmbr = 1;
2458
+			foreach ($registrations as $registration) {
2459
+				/* @var $registration EE_Registration */
2460
+				$attendee                                                      = $registration->attendee()
2461
+					? $registration->attendee()
2462
+					: $this->getAttendeeModel()->create_default_object();
2463
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2464
+				$this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2465
+				$this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2466
+				$this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2467
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2468
+				$this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2469
+					', ',
2470
+					$attendee->full_address_as_array()
2471
+				);
2472
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2473
+					[
2474
+						'action' => 'edit_attendee',
2475
+						'post'   => $attendee->ID(),
2476
+					],
2477
+					REG_ADMIN_URL
2478
+				);
2479
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2480
+					$registration->event_obj() instanceof EE_Event
2481
+						? $registration->event_obj()->name()
2482
+						: '';
2483
+				$att_nmbr++;
2484
+			}
2485
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2486
+		}
2487
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2488
+		EEH_Template::display_template($template_path, $this->_template_args);
2489
+	}
2490
+
2491
+
2492
+	/**
2493
+	 * generates HTML for the Edit Registration side meta box
2494
+	 *
2495
+	 * @return void
2496
+	 * @throws DomainException
2497
+	 * @throws EE_Error
2498
+	 * @throws InvalidArgumentException
2499
+	 * @throws InvalidDataTypeException
2500
+	 * @throws InvalidInterfaceException
2501
+	 * @throws ReflectionException
2502
+	 */
2503
+	public function _reg_registrant_side_meta_box()
2504
+	{
2505
+		/*@var $attendee EE_Attendee */
2506
+		$att_check = $this->_registration->attendee();
2507
+		$attendee  = $att_check instanceof EE_Attendee
2508
+			? $att_check
2509
+			: $this->getAttendeeModel()->create_default_object();
2510
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2511
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2512
+		// primary registration object (that way we know if we need to show create button or not)
2513
+		if (! $this->_registration->is_primary_registrant()) {
2514
+			$primary_registration = $this->_registration->get_primary_registration();
2515
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2516
+				: null;
2517
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2518
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2519
+				// custom attendee object so let's not worry about the primary reg.
2520
+				$primary_registration = null;
2521
+			}
2522
+		} else {
2523
+			$primary_registration = null;
2524
+		}
2525
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2526
+		$this->_template_args['fname']             = $attendee->fname();
2527
+		$this->_template_args['lname']             = $attendee->lname();
2528
+		$this->_template_args['email']             = $attendee->email();
2529
+		$this->_template_args['phone']             = $attendee->phone();
2530
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2531
+		// edit link
2532
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2533
+			[
2534
+				'action' => 'edit_attendee',
2535
+				'post'   => $attendee->ID(),
2536
+			],
2537
+			REG_ADMIN_URL
2538
+		);
2539
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2540
+		// create link
2541
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2542
+			? EE_Admin_Page::add_query_args_and_nonce(
2543
+				[
2544
+					'action'  => 'duplicate_attendee',
2545
+					'_REG_ID' => $this->_registration->ID(),
2546
+				],
2547
+				REG_ADMIN_URL
2548
+			) : '';
2549
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2550
+		$this->_template_args['att_check']    = $att_check;
2551
+		$template_path                        =
2552
+			REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2553
+		EEH_Template::display_template($template_path, $this->_template_args);
2554
+	}
2555
+
2556
+
2557
+	/**
2558
+	 * trash or restore registrations
2559
+	 *
2560
+	 * @param boolean $trash whether to archive or restore
2561
+	 * @return void
2562
+	 * @throws EE_Error
2563
+	 * @throws InvalidArgumentException
2564
+	 * @throws InvalidDataTypeException
2565
+	 * @throws InvalidInterfaceException
2566
+	 * @throws RuntimeException
2567
+	 */
2568
+	protected function _trash_or_restore_registrations($trash = true)
2569
+	{
2570
+		// if empty _REG_ID then get out because there's nothing to do
2571
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2572
+		if (empty($REG_IDs)) {
2573
+			EE_Error::add_error(
2574
+				sprintf(
2575
+					esc_html__(
2576
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2577
+						'event_espresso'
2578
+					),
2579
+					$trash ? 'trash' : 'restore'
2580
+				),
2581
+				__FILE__,
2582
+				__LINE__,
2583
+				__FUNCTION__
2584
+			);
2585
+			$this->_redirect_after_action(false, '', '', [], true);
2586
+		}
2587
+		$success        = 0;
2588
+		$overwrite_msgs = false;
2589
+		// Checkboxes
2590
+		$reg_count = count($REG_IDs);
2591
+		// cycle thru checkboxes
2592
+		foreach ($REG_IDs as $REG_ID) {
2593
+			/** @var EE_Registration $REG */
2594
+			$REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2595
+			$payments = $REG->registration_payments();
2596
+			if (! empty($payments)) {
2597
+				$name           = $REG->attendee() instanceof EE_Attendee
2598
+					? $REG->attendee()->full_name()
2599
+					: esc_html__('Unknown Attendee', 'event_espresso');
2600
+				$overwrite_msgs = true;
2601
+				EE_Error::add_error(
2602
+					sprintf(
2603
+						esc_html__(
2604
+							'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2605
+							'event_espresso'
2606
+						),
2607
+						$name
2608
+					),
2609
+					__FILE__,
2610
+					__FUNCTION__,
2611
+					__LINE__
2612
+				);
2613
+				// can't trash this registration because it has payments.
2614
+				continue;
2615
+			}
2616
+			$updated = $trash ? $REG->delete() : $REG->restore();
2617
+			if ($updated) {
2618
+				$success++;
2619
+			}
2620
+		}
2621
+		$this->_redirect_after_action(
2622
+			$success === $reg_count, // were ALL registrations affected?
2623
+			$success > 1
2624
+				? esc_html__('Registrations', 'event_espresso')
2625
+				: esc_html__('Registration', 'event_espresso'),
2626
+			$trash
2627
+				? esc_html__('moved to the trash', 'event_espresso')
2628
+				: esc_html__('restored', 'event_espresso'),
2629
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2630
+			$overwrite_msgs
2631
+		);
2632
+	}
2633
+
2634
+
2635
+	/**
2636
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2637
+	 * registration but also.
2638
+	 * 1. Removing relations to EE_Attendee
2639
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2640
+	 * ALSO trashed.
2641
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2642
+	 * 4. Removing relationships between all tickets and the related registrations
2643
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2644
+	 * 6. Deleting permanently any related Checkins.
2645
+	 *
2646
+	 * @return void
2647
+	 * @throws EE_Error
2648
+	 * @throws InvalidArgumentException
2649
+	 * @throws InvalidDataTypeException
2650
+	 * @throws InvalidInterfaceException
2651
+	 * @throws ReflectionException
2652
+	 */
2653
+	protected function _delete_registrations()
2654
+	{
2655
+		$REG_MDL = $this->getRegistrationModel();
2656
+		$success = 0;
2657
+		// Checkboxes
2658
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2659
+
2660
+		if (! empty($REG_IDs)) {
2661
+			// if array has more than one element than success message should be plural
2662
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2663
+			// cycle thru checkboxes
2664
+			foreach ($REG_IDs as $REG_ID) {
2665
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2666
+				if (! $REG instanceof EE_Registration) {
2667
+					continue;
2668
+				}
2669
+				$deleted = $this->_delete_registration($REG);
2670
+				if (! $deleted) {
2671
+					$success = 0;
2672
+				}
2673
+			}
2674
+		}
2675
+
2676
+		$what        = $success > 1
2677
+			? esc_html__('Registrations', 'event_espresso')
2678
+			: esc_html__('Registration', 'event_espresso');
2679
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2680
+		$this->_redirect_after_action(
2681
+			$success,
2682
+			$what,
2683
+			$action_desc,
2684
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2685
+			true
2686
+		);
2687
+	}
2688
+
2689
+
2690
+	/**
2691
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2692
+	 * models get affected.
2693
+	 *
2694
+	 * @param EE_Registration $REG registration to be deleted permanently
2695
+	 * @return bool true = successful deletion, false = fail.
2696
+	 * @throws EE_Error
2697
+	 * @throws InvalidArgumentException
2698
+	 * @throws InvalidDataTypeException
2699
+	 * @throws InvalidInterfaceException
2700
+	 * @throws ReflectionException
2701
+	 */
2702
+	protected function _delete_registration(EE_Registration $REG)
2703
+	{
2704
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2705
+		// registrations on the transaction that are NOT trashed.
2706
+		$TXN = $REG->get_first_related('Transaction');
2707
+		if (! $TXN instanceof EE_Transaction) {
2708
+			EE_Error::add_error(
2709
+				sprintf(
2710
+					esc_html__(
2711
+						'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2712
+						'event_espresso'
2713
+					),
2714
+					$REG->id()
2715
+				),
2716
+				__FILE__,
2717
+				__FUNCTION__,
2718
+				__LINE__
2719
+			);
2720
+			return false;
2721
+		}
2722
+		$REGS        = $TXN->get_many_related('Registration');
2723
+		$all_trashed = true;
2724
+		foreach ($REGS as $registration) {
2725
+			if (! $registration->get('REG_deleted')) {
2726
+				$all_trashed = false;
2727
+			}
2728
+		}
2729
+		if (! $all_trashed) {
2730
+			EE_Error::add_error(
2731
+				esc_html__(
2732
+					'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2733
+					'event_espresso'
2734
+				),
2735
+				__FILE__,
2736
+				__FUNCTION__,
2737
+				__LINE__
2738
+			);
2739
+			return false;
2740
+		}
2741
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2742
+		// separately from THIS one).
2743
+		foreach ($REGS as $registration) {
2744
+			// delete related answers
2745
+			$registration->delete_related_permanently('Answer');
2746
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2747
+			$attendee = $registration->get_first_related('Attendee');
2748
+			if ($attendee instanceof EE_Attendee) {
2749
+				$registration->_remove_relation_to($attendee, 'Attendee');
2750
+			}
2751
+			// now remove relationships to tickets on this registration.
2752
+			$registration->_remove_relations('Ticket');
2753
+			// now delete permanently the checkins related to this registration.
2754
+			$registration->delete_related_permanently('Checkin');
2755
+			if ($registration->ID() === $REG->ID()) {
2756
+				continue;
2757
+			} //we don't want to delete permanently the existing registration just yet.
2758
+			// remove relation to transaction for these registrations if NOT the existing registrations
2759
+			$registration->_remove_relations('Transaction');
2760
+			// delete permanently any related messages.
2761
+			$registration->delete_related_permanently('Message');
2762
+			// now delete this registration permanently
2763
+			$registration->delete_permanently();
2764
+		}
2765
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2766
+		// (the transaction and line items should be all that's left).
2767
+		// delete the line items related to the transaction for this registration.
2768
+		$TXN->delete_related_permanently('Line_Item');
2769
+		// we need to remove all the relationships on the transaction
2770
+		$TXN->delete_related_permanently('Payment');
2771
+		$TXN->delete_related_permanently('Extra_Meta');
2772
+		$TXN->delete_related_permanently('Message');
2773
+		// now we can delete this REG permanently (and the transaction of course)
2774
+		$REG->delete_related_permanently('Transaction');
2775
+		return $REG->delete_permanently();
2776
+	}
2777
+
2778
+
2779
+	/**
2780
+	 *    generates HTML for the Register New Attendee Admin page
2781
+	 *
2782
+	 * @throws DomainException
2783
+	 * @throws EE_Error
2784
+	 * @throws InvalidArgumentException
2785
+	 * @throws InvalidDataTypeException
2786
+	 * @throws InvalidInterfaceException
2787
+	 * @throws ReflectionException
2788
+	 */
2789
+	public function new_registration()
2790
+	{
2791
+		if (! $this->_set_reg_event()) {
2792
+			throw new EE_Error(
2793
+				esc_html__(
2794
+					'Unable to continue with registering because there is no Event ID in the request',
2795
+					'event_espresso'
2796
+				)
2797
+			);
2798
+		}
2799
+		/** @var CurrentPage $current_page */
2800
+		$current_page = $this->loader->getShared(CurrentPage::class);
2801
+		$current_page->setEspressoPage(true);
2802
+		// gotta start with a clean slate if we're not coming here via ajax
2803
+		if (
2804
+			! $this->request->isAjax()
2805
+			&& (
2806
+				! $this->request->requestParamIsSet('processing_registration')
2807
+				|| $this->request->requestParamIsSet('step_error')
2808
+			)
2809
+		) {
2810
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2811
+		}
2812
+		$this->_template_args['event_name'] = '';
2813
+		// event name
2814
+		if ($this->_reg_event) {
2815
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2816
+			$edit_event_url                     = self::add_query_args_and_nonce(
2817
+				[
2818
+					'action' => 'edit',
2819
+					'post'   => $this->_reg_event->ID(),
2820
+				],
2821
+				EVENTS_ADMIN_URL
2822
+			);
2823
+			$edit_event_lnk                     = '<a href="'
2824
+												  . $edit_event_url
2825
+												  . '" title="'
2826
+												  . esc_attr__('Edit ', 'event_espresso')
2827
+												  . $this->_reg_event->name()
2828
+												  . '">'
2829
+												  . esc_html__('Edit Event', 'event_espresso')
2830
+												  . '</a>';
2831
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2832
+												   . $edit_event_lnk
2833
+												   . '</span>';
2834
+		}
2835
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2836
+		if ($this->request->isAjax()) {
2837
+			$this->_return_json();
2838
+		}
2839
+		// grab header
2840
+		$template_path                              =
2841
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2842
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2843
+			$template_path,
2844
+			$this->_template_args,
2845
+			true
2846
+		);
2847
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2848
+		// the details template wrapper
2849
+		$this->display_admin_page_with_sidebar();
2850
+	}
2851
+
2852
+
2853
+	/**
2854
+	 * This returns the content for a registration step
2855
+	 *
2856
+	 * @return string html
2857
+	 * @throws DomainException
2858
+	 * @throws EE_Error
2859
+	 * @throws InvalidArgumentException
2860
+	 * @throws InvalidDataTypeException
2861
+	 * @throws InvalidInterfaceException
2862
+	 * @throws ReflectionException
2863
+	 */
2864
+	protected function _get_registration_step_content()
2865
+	{
2866
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2867
+			$warning_msg = sprintf(
2868
+				esc_html__(
2869
+					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2870
+					'event_espresso'
2871
+				),
2872
+				'<br />',
2873
+				'<h3 class="important-notice">',
2874
+				'</h3>',
2875
+				'<div class="float-right">',
2876
+				'<span id="redirect_timer" class="important-notice">30</span>',
2877
+				'</div>',
2878
+				'<b>',
2879
+				'</b>'
2880
+			);
2881
+			return '
2882 2882
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2883 2883
 	<script >
2884 2884
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2891,851 +2891,851 @@  discard block
 block discarded – undo
2891 2891
 	        }
2892 2892
 	    }, 800 );
2893 2893
 	</script >';
2894
-        }
2895
-        $template_args = [
2896
-            'title'                    => '',
2897
-            'content'                  => '',
2898
-            'step_button_text'         => '',
2899
-            'show_notification_toggle' => false,
2900
-        ];
2901
-        // to indicate we're processing a new registration
2902
-        $hidden_fields = [
2903
-            'processing_registration' => [
2904
-                'type'  => 'hidden',
2905
-                'value' => 0,
2906
-            ],
2907
-            'event_id'                => [
2908
-                'type'  => 'hidden',
2909
-                'value' => $this->_reg_event->ID(),
2910
-            ],
2911
-        ];
2912
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2913
-        $cart = EE_Registry::instance()->SSN->cart();
2914
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2915
-        switch ($step) {
2916
-            case 'ticket':
2917
-                $hidden_fields['processing_registration']['value'] = 1;
2918
-                $template_args['title']                            = esc_html__(
2919
-                    'Step One: Select the Ticket for this registration',
2920
-                    'event_espresso'
2921
-                );
2922
-                $template_args['content']                          =
2923
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2924
-                $template_args['content']                          .= '</div>';
2925
-                $template_args['step_button_text']                 = esc_html__(
2926
-                    'Add Tickets and Continue to Registrant Details',
2927
-                    'event_espresso'
2928
-                );
2929
-                $template_args['show_notification_toggle']         = false;
2930
-                break;
2931
-            case 'questions':
2932
-                $hidden_fields['processing_registration']['value'] = 2;
2933
-                $template_args['title']                            = esc_html__(
2934
-                    'Step Two: Add Registrant Details for this Registration',
2935
-                    'event_espresso'
2936
-                );
2937
-                // in theory, we should be able to run EED_SPCO at this point
2938
-                // because the cart should have been set up properly by the first process_reg_step run.
2939
-                $template_args['content']                  =
2940
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
2941
-                $template_args['step_button_text']         = esc_html__(
2942
-                    'Save Registration and Continue to Details',
2943
-                    'event_espresso'
2944
-                );
2945
-                $template_args['show_notification_toggle'] = true;
2946
-                break;
2947
-        }
2948
-        // we come back to the process_registration_step route.
2949
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2950
-        return EEH_Template::display_template(
2951
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2952
-            $template_args,
2953
-            true
2954
-        );
2955
-    }
2956
-
2957
-
2958
-    /**
2959
-     * set_reg_event
2960
-     *
2961
-     * @return bool
2962
-     * @throws EE_Error
2963
-     * @throws InvalidArgumentException
2964
-     * @throws InvalidDataTypeException
2965
-     * @throws InvalidInterfaceException
2966
-     */
2967
-    private function _set_reg_event()
2968
-    {
2969
-        if (is_object($this->_reg_event)) {
2970
-            return true;
2971
-        }
2972
-
2973
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2974
-        if (! $EVT_ID) {
2975
-            return false;
2976
-        }
2977
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2978
-        return true;
2979
-    }
2980
-
2981
-
2982
-    /**
2983
-     * process_reg_step
2984
-     *
2985
-     * @return void
2986
-     * @throws DomainException
2987
-     * @throws EE_Error
2988
-     * @throws InvalidArgumentException
2989
-     * @throws InvalidDataTypeException
2990
-     * @throws InvalidInterfaceException
2991
-     * @throws ReflectionException
2992
-     * @throws RuntimeException
2993
-     */
2994
-    public function process_reg_step()
2995
-    {
2996
-        EE_System::do_not_cache();
2997
-        $this->_set_reg_event();
2998
-        /** @var CurrentPage $current_page */
2999
-        $current_page = $this->loader->getShared(CurrentPage::class);
3000
-        $current_page->setEspressoPage(true);
3001
-        $this->request->setRequestParam('uts', time());
3002
-        // what step are we on?
3003
-        $cart = EE_Registry::instance()->SSN->cart();
3004
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3005
-        // if doing ajax then we need to verify the nonce
3006
-        if ($this->request->isAjax()) {
3007
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
3008
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3009
-        }
3010
-        switch ($step) {
3011
-            case 'ticket':
3012
-                // process ticket selection
3013
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3014
-                if ($success) {
3015
-                    EE_Error::add_success(
3016
-                        esc_html__(
3017
-                            'Tickets Selected. Now complete the registration.',
3018
-                            'event_espresso'
3019
-                        )
3020
-                    );
3021
-                } else {
3022
-                    $this->request->setRequestParam('step_error', true);
3023
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3024
-                }
3025
-                if ($this->request->isAjax()) {
3026
-                    $this->new_registration(); // display next step
3027
-                } else {
3028
-                    $query_args = [
3029
-                        'action'                  => 'new_registration',
3030
-                        'processing_registration' => 1,
3031
-                        'event_id'                => $this->_reg_event->ID(),
3032
-                        'uts'                     => time(),
3033
-                    ];
3034
-                    $this->_redirect_after_action(
3035
-                        false,
3036
-                        '',
3037
-                        '',
3038
-                        $query_args,
3039
-                        true
3040
-                    );
3041
-                }
3042
-                break;
3043
-            case 'questions':
3044
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3045
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3046
-                }
3047
-                // process registration
3048
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3049
-                if ($cart instanceof EE_Cart) {
3050
-                    $grand_total = $cart->get_grand_total();
3051
-                    if ($grand_total instanceof EE_Line_Item) {
3052
-                        $grand_total->save_this_and_descendants_to_txn();
3053
-                    }
3054
-                }
3055
-                if (! $transaction instanceof EE_Transaction) {
3056
-                    $query_args = [
3057
-                        'action'                  => 'new_registration',
3058
-                        'processing_registration' => 2,
3059
-                        'event_id'                => $this->_reg_event->ID(),
3060
-                        'uts'                     => time(),
3061
-                    ];
3062
-                    if ($this->request->isAjax()) {
3063
-                        // display registration form again because there are errors (maybe validation?)
3064
-                        $this->new_registration();
3065
-                        return;
3066
-                    }
3067
-                    $this->_redirect_after_action(
3068
-                        false,
3069
-                        '',
3070
-                        '',
3071
-                        $query_args,
3072
-                        true
3073
-                    );
3074
-                    return;
3075
-                }
3076
-                // maybe update status, and make sure to save transaction if not done already
3077
-                if (! $transaction->update_status_based_on_total_paid()) {
3078
-                    $transaction->save();
3079
-                }
3080
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3081
-                $query_args = [
3082
-                    'action'        => 'redirect_to_txn',
3083
-                    'TXN_ID'        => $transaction->ID(),
3084
-                    'EVT_ID'        => $this->_reg_event->ID(),
3085
-                    'event_name'    => urlencode($this->_reg_event->name()),
3086
-                    'redirect_from' => 'new_registration',
3087
-                ];
3088
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3089
-                break;
3090
-        }
3091
-        // what are you looking here for?  Should be nothing to do at this point.
3092
-    }
3093
-
3094
-
3095
-    /**
3096
-     * redirect_to_txn
3097
-     *
3098
-     * @return void
3099
-     * @throws EE_Error
3100
-     * @throws InvalidArgumentException
3101
-     * @throws InvalidDataTypeException
3102
-     * @throws InvalidInterfaceException
3103
-     * @throws ReflectionException
3104
-     */
3105
-    public function redirect_to_txn()
3106
-    {
3107
-        EE_System::do_not_cache();
3108
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3109
-        $query_args = [
3110
-            'action' => 'view_transaction',
3111
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3112
-            'page'   => 'espresso_transactions',
3113
-        ];
3114
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3115
-            $query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3116
-            $query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3117
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3118
-        }
3119
-        EE_Error::add_success(
3120
-            esc_html__(
3121
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3122
-                'event_espresso'
3123
-            )
3124
-        );
3125
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3126
-    }
3127
-
3128
-
3129
-    /**
3130
-     * generates HTML for the Attendee Contact List
3131
-     *
3132
-     * @return void
3133
-     * @throws DomainException
3134
-     * @throws EE_Error
3135
-     */
3136
-    protected function _attendee_contact_list_table()
3137
-    {
3138
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3139
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3140
-        $this->display_admin_list_table_page_with_no_sidebar();
3141
-    }
3142
-
3143
-
3144
-    /**
3145
-     * get_attendees
3146
-     *
3147
-     * @param      $per_page
3148
-     * @param bool $count whether to return count or data.
3149
-     * @param bool $trash
3150
-     * @return array|int
3151
-     * @throws EE_Error
3152
-     * @throws InvalidArgumentException
3153
-     * @throws InvalidDataTypeException
3154
-     * @throws InvalidInterfaceException
3155
-     */
3156
-    public function get_attendees($per_page, $count = false, $trash = false)
3157
-    {
3158
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3159
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3160
-        $orderby = $this->request->getRequestParam('orderby');
3161
-        switch ($orderby) {
3162
-            case 'ATT_ID':
3163
-            case 'ATT_fname':
3164
-            case 'ATT_email':
3165
-            case 'ATT_city':
3166
-            case 'STA_ID':
3167
-            case 'CNT_ID':
3168
-                break;
3169
-            case 'Registration_Count':
3170
-                $orderby = 'Registration_Count';
3171
-                break;
3172
-            default:
3173
-                $orderby = 'ATT_lname';
3174
-        }
3175
-        $sort         = $this->request->getRequestParam('order', 'ASC');
3176
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3177
-        $per_page     = absint($per_page) ? $per_page : 10;
3178
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3179
-        $_where       = [];
3180
-        $search_term  = $this->request->getRequestParam('s');
3181
-        if ($search_term) {
3182
-            $search_term  = '%' . $search_term . '%';
3183
-            $_where['OR'] = [
3184
-                'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3185
-                'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3186
-                'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3187
-                'ATT_fname'                         => ['LIKE', $search_term],
3188
-                'ATT_lname'                         => ['LIKE', $search_term],
3189
-                'ATT_short_bio'                     => ['LIKE', $search_term],
3190
-                'ATT_email'                         => ['LIKE', $search_term],
3191
-                'ATT_address'                       => ['LIKE', $search_term],
3192
-                'ATT_address2'                      => ['LIKE', $search_term],
3193
-                'ATT_city'                          => ['LIKE', $search_term],
3194
-                'Country.CNT_name'                  => ['LIKE', $search_term],
3195
-                'State.STA_name'                    => ['LIKE', $search_term],
3196
-                'ATT_phone'                         => ['LIKE', $search_term],
3197
-                'Registration.REG_final_price'      => ['LIKE', $search_term],
3198
-                'Registration.REG_code'             => ['LIKE', $search_term],
3199
-                'Registration.REG_group_size'       => ['LIKE', $search_term],
3200
-            ];
3201
-        }
3202
-        $offset     = ($current_page - 1) * $per_page;
3203
-        $limit      = $count ? null : [$offset, $per_page];
3204
-        $query_args = [
3205
-            $_where,
3206
-            'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3207
-            'limit'         => $limit,
3208
-        ];
3209
-        if (! $count) {
3210
-            $query_args['order_by'] = [$orderby => $sort];
3211
-        }
3212
-        $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3213
-        return $count
3214
-            ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3215
-            : $this->getAttendeeModel()->get_all($query_args);
3216
-    }
3217
-
3218
-
3219
-    /**
3220
-     * This is just taking care of resending the registration confirmation
3221
-     *
3222
-     * @return void
3223
-     * @throws EE_Error
3224
-     * @throws InvalidArgumentException
3225
-     * @throws InvalidDataTypeException
3226
-     * @throws InvalidInterfaceException
3227
-     * @throws ReflectionException
3228
-     */
3229
-    protected function _resend_registration()
3230
-    {
3231
-        $this->_process_resend_registration();
3232
-        $REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3233
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3234
-        $query_args  = $redirect_to
3235
-            ? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3236
-            : ['action' => 'default'];
3237
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3238
-    }
3239
-
3240
-
3241
-    /**
3242
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3243
-     * to use when selecting registrations
3244
-     *
3245
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3246
-     *                                                     the query parameters from the request
3247
-     * @return void ends the request with a redirect or download
3248
-     */
3249
-    public function _registrations_report_base($method_name_for_getting_query_params)
3250
-    {
3251
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3252
-            ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3253
-            : null;
3254
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3255
-            $request_params = $this->request->requestParams();
3256
-            wp_redirect(
3257
-                EE_Admin_Page::add_query_args_and_nonce(
3258
-                    [
3259
-                        'page'        => 'espresso_batch',
3260
-                        'batch'       => 'file',
3261
-                        'EVT_ID'      => $EVT_ID,
3262
-                        'filters'     => urlencode(
3263
-                            serialize(
3264
-                                $this->$method_name_for_getting_query_params(
3265
-                                    EEH_Array::is_set($request_params, 'filters', [])
3266
-                                )
3267
-                            )
3268
-                        ),
3269
-                        'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3270
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3271
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3272
-                    ]
3273
-                )
3274
-            );
3275
-        } else {
3276
-            // Pull the current request params
3277
-            $request_args = $this->request->requestParams();
3278
-            // Set the required request_args to be passed to the export
3279
-            $required_request_args = [
3280
-                'export' => 'report',
3281
-                'action' => 'registrations_report_for_event',
3282
-                'EVT_ID' => $EVT_ID,
3283
-            ];
3284
-            // Merge required request args, overriding any currently set
3285
-            $request_args = array_merge($request_args, $required_request_args);
3286
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3287
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3288
-                $EE_Export = EE_Export::instance($request_args);
3289
-                $EE_Export->export();
3290
-            }
3291
-        }
3292
-    }
3293
-
3294
-
3295
-    /**
3296
-     * Creates a registration report using only query parameters in the request
3297
-     *
3298
-     * @return void
3299
-     */
3300
-    public function _registrations_report()
3301
-    {
3302
-        $this->_registrations_report_base('_get_registration_query_parameters');
3303
-    }
3304
-
3305
-
3306
-    public function _contact_list_export()
3307
-    {
3308
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3309
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3310
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3311
-            $EE_Export->export_attendees();
3312
-        }
3313
-    }
3314
-
3315
-
3316
-    public function _contact_list_report()
3317
-    {
3318
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3319
-            wp_redirect(
3320
-                EE_Admin_Page::add_query_args_and_nonce(
3321
-                    [
3322
-                        'page'        => 'espresso_batch',
3323
-                        'batch'       => 'file',
3324
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3325
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3326
-                    ]
3327
-                )
3328
-            );
3329
-        } else {
3330
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3331
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3332
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3333
-                $EE_Export->report_attendees();
3334
-            }
3335
-        }
3336
-    }
3337
-
3338
-
3339
-
3340
-
3341
-
3342
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3343
-    /**
3344
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3345
-     *
3346
-     * @return void
3347
-     * @throws EE_Error
3348
-     * @throws InvalidArgumentException
3349
-     * @throws InvalidDataTypeException
3350
-     * @throws InvalidInterfaceException
3351
-     * @throws ReflectionException
3352
-     */
3353
-    protected function _duplicate_attendee()
3354
-    {
3355
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3356
-        $action = $this->request->getRequestParam('return', 'default');
3357
-        // verify we have necessary info
3358
-        if (! $REG_ID) {
3359
-            EE_Error::add_error(
3360
-                esc_html__(
3361
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3362
-                    'event_espresso'
3363
-                ),
3364
-                __FILE__,
3365
-                __LINE__,
3366
-                __FUNCTION__
3367
-            );
3368
-            $query_args = ['action' => $action];
3369
-            $this->_redirect_after_action('', '', '', $query_args, true);
3370
-        }
3371
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3372
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3373
-        if (! $registration instanceof EE_Registration) {
3374
-            throw new RuntimeException(
3375
-                sprintf(
3376
-                    esc_html__(
3377
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3378
-                        'event_espresso'
3379
-                    ),
3380
-                    $REG_ID
3381
-                )
3382
-            );
3383
-        }
3384
-        $attendee = $registration->attendee();
3385
-        // remove relation of existing attendee on registration
3386
-        $registration->_remove_relation_to($attendee, 'Attendee');
3387
-        // new attendee
3388
-        $new_attendee = clone $attendee;
3389
-        $new_attendee->set('ATT_ID', 0);
3390
-        $new_attendee->save();
3391
-        // add new attendee to reg
3392
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3393
-        EE_Error::add_success(
3394
-            esc_html__(
3395
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3396
-                'event_espresso'
3397
-            )
3398
-        );
3399
-        // redirect to edit page for attendee
3400
-        $query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3401
-        $this->_redirect_after_action('', '', '', $query_args, true);
3402
-    }
3403
-
3404
-
3405
-    /**
3406
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3407
-     *
3408
-     * @param int     $post_id
3409
-     * @param WP_Post $post
3410
-     * @throws DomainException
3411
-     * @throws EE_Error
3412
-     * @throws InvalidArgumentException
3413
-     * @throws InvalidDataTypeException
3414
-     * @throws InvalidInterfaceException
3415
-     * @throws LogicException
3416
-     * @throws InvalidFormSubmissionException
3417
-     * @throws ReflectionException
3418
-     */
3419
-    protected function _insert_update_cpt_item($post_id, $post)
3420
-    {
3421
-        $success  = true;
3422
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3423
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3424
-            : null;
3425
-        // for attendee updates
3426
-        if ($attendee instanceof EE_Attendee) {
3427
-            // note we should only be UPDATING attendees at this point.
3428
-            $fname          = $this->request->getRequestParam('ATT_fname', '');
3429
-            $lname          = $this->request->getRequestParam('ATT_lname', '');
3430
-            $updated_fields = [
3431
-                'ATT_fname'     => $fname,
3432
-                'ATT_lname'     => $lname,
3433
-                'ATT_full_name' => "{$fname} {$lname}",
3434
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3435
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3436
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3437
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3438
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3439
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3440
-            ];
3441
-            foreach ($updated_fields as $field => $value) {
3442
-                $attendee->set($field, $value);
3443
-            }
3444
-
3445
-            // process contact details metabox form handler (which will also save the attendee)
3446
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3447
-            $success              = $contact_details_form->process($this->request->requestParams());
3448
-
3449
-            $attendee_update_callbacks = apply_filters(
3450
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3451
-                []
3452
-            );
3453
-            foreach ($attendee_update_callbacks as $a_callback) {
3454
-                if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3455
-                    throw new EE_Error(
3456
-                        sprintf(
3457
-                            esc_html__(
3458
-                                'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3459
-                                'event_espresso'
3460
-                            ),
3461
-                            $a_callback
3462
-                        )
3463
-                    );
3464
-                }
3465
-            }
3466
-        }
3467
-
3468
-        if ($success === false) {
3469
-            EE_Error::add_error(
3470
-                esc_html__(
3471
-                    'Something went wrong with updating the meta table data for the registration.',
3472
-                    'event_espresso'
3473
-                ),
3474
-                __FILE__,
3475
-                __FUNCTION__,
3476
-                __LINE__
3477
-            );
3478
-        }
3479
-    }
3480
-
3481
-
3482
-    public function trash_cpt_item($post_id)
3483
-    {
3484
-    }
3485
-
3486
-
3487
-    public function delete_cpt_item($post_id)
3488
-    {
3489
-    }
3490
-
3491
-
3492
-    public function restore_cpt_item($post_id)
3493
-    {
3494
-    }
3495
-
3496
-
3497
-    protected function _restore_cpt_item($post_id, $revision_id)
3498
-    {
3499
-    }
3500
-
3501
-
3502
-    /**
3503
-     * @throws EE_Error
3504
-     * @throws ReflectionException
3505
-     * @since 4.10.2.p
3506
-     */
3507
-    public function attendee_editor_metaboxes()
3508
-    {
3509
-        $this->verify_cpt_object();
3510
-        remove_meta_box(
3511
-            'postexcerpt',
3512
-            $this->_cpt_routes[ $this->_req_action ],
3513
-            'normal'
3514
-        );
3515
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3516
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3517
-            add_meta_box(
3518
-                'postexcerpt',
3519
-                esc_html__('Short Biography', 'event_espresso'),
3520
-                'post_excerpt_meta_box',
3521
-                $this->_cpt_routes[ $this->_req_action ],
3522
-                'normal'
3523
-            );
3524
-        }
3525
-        if (post_type_supports('espresso_attendees', 'comments')) {
3526
-            add_meta_box(
3527
-                'commentsdiv',
3528
-                esc_html__('Notes on the Contact', 'event_espresso'),
3529
-                'post_comment_meta_box',
3530
-                $this->_cpt_routes[ $this->_req_action ],
3531
-                'normal',
3532
-                'core'
3533
-            );
3534
-        }
3535
-        add_meta_box(
3536
-            'attendee_contact_info',
3537
-            esc_html__('Contact Info', 'event_espresso'),
3538
-            [$this, 'attendee_contact_info'],
3539
-            $this->_cpt_routes[ $this->_req_action ],
3540
-            'side',
3541
-            'core'
3542
-        );
3543
-        add_meta_box(
3544
-            'attendee_details_address',
3545
-            esc_html__('Address Details', 'event_espresso'),
3546
-            [$this, 'attendee_address_details'],
3547
-            $this->_cpt_routes[ $this->_req_action ],
3548
-            'normal',
3549
-            'core'
3550
-        );
3551
-        add_meta_box(
3552
-            'attendee_registrations',
3553
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3554
-            [$this, 'attendee_registrations_meta_box'],
3555
-            $this->_cpt_routes[ $this->_req_action ],
3556
-            'normal',
3557
-            'high'
3558
-        );
3559
-    }
3560
-
3561
-
3562
-    /**
3563
-     * Metabox for attendee contact info
3564
-     *
3565
-     * @param WP_Post $post wp post object
3566
-     * @return void attendee contact info ( and form )
3567
-     * @throws EE_Error
3568
-     * @throws InvalidArgumentException
3569
-     * @throws InvalidDataTypeException
3570
-     * @throws InvalidInterfaceException
3571
-     * @throws LogicException
3572
-     * @throws DomainException
3573
-     */
3574
-    public function attendee_contact_info($post)
3575
-    {
3576
-        // get attendee object ( should already have it )
3577
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3578
-        $form->enqueueStylesAndScripts();
3579
-        echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3580
-    }
3581
-
3582
-
3583
-    /**
3584
-     * Return form handler for the contact details metabox
3585
-     *
3586
-     * @param EE_Attendee $attendee
3587
-     * @return AttendeeContactDetailsMetaboxFormHandler
3588
-     * @throws DomainException
3589
-     * @throws InvalidArgumentException
3590
-     * @throws InvalidDataTypeException
3591
-     * @throws InvalidInterfaceException
3592
-     */
3593
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3594
-    {
3595
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3596
-    }
3597
-
3598
-
3599
-    /**
3600
-     * Metabox for attendee details
3601
-     *
3602
-     * @param WP_Post $post wp post object
3603
-     * @throws EE_Error
3604
-     * @throws ReflectionException
3605
-     */
3606
-    public function attendee_address_details($post)
3607
-    {
3608
-        // get attendee object (should already have it)
3609
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3610
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3611
-            new EE_Question_Form_Input(
3612
-                EE_Question::new_instance(
3613
-                    [
3614
-                        'QST_ID'           => 0,
3615
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3616
-                        'QST_system'       => 'admin-state',
3617
-                    ]
3618
-                ),
3619
-                EE_Answer::new_instance(
3620
-                    [
3621
-                        'ANS_ID'    => 0,
3622
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3623
-                    ]
3624
-                ),
3625
-                [
3626
-                    'input_id'       => 'STA_ID',
3627
-                    'input_name'     => 'STA_ID',
3628
-                    'input_prefix'   => '',
3629
-                    'append_qstn_id' => false,
3630
-                ]
3631
-            )
3632
-        );
3633
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3634
-            new EE_Question_Form_Input(
3635
-                EE_Question::new_instance(
3636
-                    [
3637
-                        'QST_ID'           => 0,
3638
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3639
-                        'QST_system'       => 'admin-country',
3640
-                    ]
3641
-                ),
3642
-                EE_Answer::new_instance(
3643
-                    [
3644
-                        'ANS_ID'    => 0,
3645
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3646
-                    ]
3647
-                ),
3648
-                [
3649
-                    'input_id'       => 'CNT_ISO',
3650
-                    'input_name'     => 'CNT_ISO',
3651
-                    'input_prefix'   => '',
3652
-                    'append_qstn_id' => false,
3653
-                ]
3654
-            )
3655
-        );
3656
-        $template                             =
3657
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3658
-        EEH_Template::display_template($template, $this->_template_args);
3659
-    }
3660
-
3661
-
3662
-    /**
3663
-     * _attendee_details
3664
-     *
3665
-     * @param $post
3666
-     * @return void
3667
-     * @throws DomainException
3668
-     * @throws EE_Error
3669
-     * @throws InvalidArgumentException
3670
-     * @throws InvalidDataTypeException
3671
-     * @throws InvalidInterfaceException
3672
-     * @throws ReflectionException
3673
-     */
3674
-    public function attendee_registrations_meta_box($post)
3675
-    {
3676
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3677
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3678
-        $template                              =
3679
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3680
-        EEH_Template::display_template($template, $this->_template_args);
3681
-    }
3682
-
3683
-
3684
-    /**
3685
-     * add in the form fields for the attendee edit
3686
-     *
3687
-     * @param WP_Post $post wp post object
3688
-     * @return void echos html for new form.
3689
-     * @throws DomainException
3690
-     */
3691
-    public function after_title_form_fields($post)
3692
-    {
3693
-        if ($post->post_type === 'espresso_attendees') {
3694
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3695
-            $template_args['attendee'] = $this->_cpt_model_obj;
3696
-            EEH_Template::display_template($template, $template_args);
3697
-        }
3698
-    }
3699
-
3700
-
3701
-    /**
3702
-     * _trash_or_restore_attendee
3703
-     *
3704
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3705
-     * @return void
3706
-     * @throws EE_Error
3707
-     * @throws InvalidArgumentException
3708
-     * @throws InvalidDataTypeException
3709
-     * @throws InvalidInterfaceException
3710
-     */
3711
-    protected function _trash_or_restore_attendees($trash = true)
3712
-    {
3713
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3714
-        $status = $trash ? 'trash' : 'publish';
3715
-        // Checkboxes
3716
-        if ($this->request->requestParamIsSet('checkbox')) {
3717
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3718
-            // if array has more than one element than success message should be plural
3719
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3720
-            // cycle thru checkboxes
3721
-            foreach ($ATT_IDs as $ATT_ID) {
3722
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3723
-                if (! $updated) {
3724
-                    $success = 0;
3725
-                }
3726
-            }
3727
-        } else {
3728
-            // grab single id and delete
3729
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3730
-            // update attendee
3731
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3732
-        }
3733
-        $what        = $success > 1
3734
-            ? esc_html__('Contacts', 'event_espresso')
3735
-            : esc_html__('Contact', 'event_espresso');
3736
-        $action_desc = $trash
3737
-            ? esc_html__('moved to the trash', 'event_espresso')
3738
-            : esc_html__('restored', 'event_espresso');
3739
-        $this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3740
-    }
2894
+		}
2895
+		$template_args = [
2896
+			'title'                    => '',
2897
+			'content'                  => '',
2898
+			'step_button_text'         => '',
2899
+			'show_notification_toggle' => false,
2900
+		];
2901
+		// to indicate we're processing a new registration
2902
+		$hidden_fields = [
2903
+			'processing_registration' => [
2904
+				'type'  => 'hidden',
2905
+				'value' => 0,
2906
+			],
2907
+			'event_id'                => [
2908
+				'type'  => 'hidden',
2909
+				'value' => $this->_reg_event->ID(),
2910
+			],
2911
+		];
2912
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2913
+		$cart = EE_Registry::instance()->SSN->cart();
2914
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2915
+		switch ($step) {
2916
+			case 'ticket':
2917
+				$hidden_fields['processing_registration']['value'] = 1;
2918
+				$template_args['title']                            = esc_html__(
2919
+					'Step One: Select the Ticket for this registration',
2920
+					'event_espresso'
2921
+				);
2922
+				$template_args['content']                          =
2923
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2924
+				$template_args['content']                          .= '</div>';
2925
+				$template_args['step_button_text']                 = esc_html__(
2926
+					'Add Tickets and Continue to Registrant Details',
2927
+					'event_espresso'
2928
+				);
2929
+				$template_args['show_notification_toggle']         = false;
2930
+				break;
2931
+			case 'questions':
2932
+				$hidden_fields['processing_registration']['value'] = 2;
2933
+				$template_args['title']                            = esc_html__(
2934
+					'Step Two: Add Registrant Details for this Registration',
2935
+					'event_espresso'
2936
+				);
2937
+				// in theory, we should be able to run EED_SPCO at this point
2938
+				// because the cart should have been set up properly by the first process_reg_step run.
2939
+				$template_args['content']                  =
2940
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
2941
+				$template_args['step_button_text']         = esc_html__(
2942
+					'Save Registration and Continue to Details',
2943
+					'event_espresso'
2944
+				);
2945
+				$template_args['show_notification_toggle'] = true;
2946
+				break;
2947
+		}
2948
+		// we come back to the process_registration_step route.
2949
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2950
+		return EEH_Template::display_template(
2951
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2952
+			$template_args,
2953
+			true
2954
+		);
2955
+	}
2956
+
2957
+
2958
+	/**
2959
+	 * set_reg_event
2960
+	 *
2961
+	 * @return bool
2962
+	 * @throws EE_Error
2963
+	 * @throws InvalidArgumentException
2964
+	 * @throws InvalidDataTypeException
2965
+	 * @throws InvalidInterfaceException
2966
+	 */
2967
+	private function _set_reg_event()
2968
+	{
2969
+		if (is_object($this->_reg_event)) {
2970
+			return true;
2971
+		}
2972
+
2973
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2974
+		if (! $EVT_ID) {
2975
+			return false;
2976
+		}
2977
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2978
+		return true;
2979
+	}
2980
+
2981
+
2982
+	/**
2983
+	 * process_reg_step
2984
+	 *
2985
+	 * @return void
2986
+	 * @throws DomainException
2987
+	 * @throws EE_Error
2988
+	 * @throws InvalidArgumentException
2989
+	 * @throws InvalidDataTypeException
2990
+	 * @throws InvalidInterfaceException
2991
+	 * @throws ReflectionException
2992
+	 * @throws RuntimeException
2993
+	 */
2994
+	public function process_reg_step()
2995
+	{
2996
+		EE_System::do_not_cache();
2997
+		$this->_set_reg_event();
2998
+		/** @var CurrentPage $current_page */
2999
+		$current_page = $this->loader->getShared(CurrentPage::class);
3000
+		$current_page->setEspressoPage(true);
3001
+		$this->request->setRequestParam('uts', time());
3002
+		// what step are we on?
3003
+		$cart = EE_Registry::instance()->SSN->cart();
3004
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3005
+		// if doing ajax then we need to verify the nonce
3006
+		if ($this->request->isAjax()) {
3007
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
3008
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3009
+		}
3010
+		switch ($step) {
3011
+			case 'ticket':
3012
+				// process ticket selection
3013
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3014
+				if ($success) {
3015
+					EE_Error::add_success(
3016
+						esc_html__(
3017
+							'Tickets Selected. Now complete the registration.',
3018
+							'event_espresso'
3019
+						)
3020
+					);
3021
+				} else {
3022
+					$this->request->setRequestParam('step_error', true);
3023
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3024
+				}
3025
+				if ($this->request->isAjax()) {
3026
+					$this->new_registration(); // display next step
3027
+				} else {
3028
+					$query_args = [
3029
+						'action'                  => 'new_registration',
3030
+						'processing_registration' => 1,
3031
+						'event_id'                => $this->_reg_event->ID(),
3032
+						'uts'                     => time(),
3033
+					];
3034
+					$this->_redirect_after_action(
3035
+						false,
3036
+						'',
3037
+						'',
3038
+						$query_args,
3039
+						true
3040
+					);
3041
+				}
3042
+				break;
3043
+			case 'questions':
3044
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3045
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3046
+				}
3047
+				// process registration
3048
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3049
+				if ($cart instanceof EE_Cart) {
3050
+					$grand_total = $cart->get_grand_total();
3051
+					if ($grand_total instanceof EE_Line_Item) {
3052
+						$grand_total->save_this_and_descendants_to_txn();
3053
+					}
3054
+				}
3055
+				if (! $transaction instanceof EE_Transaction) {
3056
+					$query_args = [
3057
+						'action'                  => 'new_registration',
3058
+						'processing_registration' => 2,
3059
+						'event_id'                => $this->_reg_event->ID(),
3060
+						'uts'                     => time(),
3061
+					];
3062
+					if ($this->request->isAjax()) {
3063
+						// display registration form again because there are errors (maybe validation?)
3064
+						$this->new_registration();
3065
+						return;
3066
+					}
3067
+					$this->_redirect_after_action(
3068
+						false,
3069
+						'',
3070
+						'',
3071
+						$query_args,
3072
+						true
3073
+					);
3074
+					return;
3075
+				}
3076
+				// maybe update status, and make sure to save transaction if not done already
3077
+				if (! $transaction->update_status_based_on_total_paid()) {
3078
+					$transaction->save();
3079
+				}
3080
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3081
+				$query_args = [
3082
+					'action'        => 'redirect_to_txn',
3083
+					'TXN_ID'        => $transaction->ID(),
3084
+					'EVT_ID'        => $this->_reg_event->ID(),
3085
+					'event_name'    => urlencode($this->_reg_event->name()),
3086
+					'redirect_from' => 'new_registration',
3087
+				];
3088
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3089
+				break;
3090
+		}
3091
+		// what are you looking here for?  Should be nothing to do at this point.
3092
+	}
3093
+
3094
+
3095
+	/**
3096
+	 * redirect_to_txn
3097
+	 *
3098
+	 * @return void
3099
+	 * @throws EE_Error
3100
+	 * @throws InvalidArgumentException
3101
+	 * @throws InvalidDataTypeException
3102
+	 * @throws InvalidInterfaceException
3103
+	 * @throws ReflectionException
3104
+	 */
3105
+	public function redirect_to_txn()
3106
+	{
3107
+		EE_System::do_not_cache();
3108
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3109
+		$query_args = [
3110
+			'action' => 'view_transaction',
3111
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3112
+			'page'   => 'espresso_transactions',
3113
+		];
3114
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3115
+			$query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3116
+			$query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3117
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3118
+		}
3119
+		EE_Error::add_success(
3120
+			esc_html__(
3121
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3122
+				'event_espresso'
3123
+			)
3124
+		);
3125
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3126
+	}
3127
+
3128
+
3129
+	/**
3130
+	 * generates HTML for the Attendee Contact List
3131
+	 *
3132
+	 * @return void
3133
+	 * @throws DomainException
3134
+	 * @throws EE_Error
3135
+	 */
3136
+	protected function _attendee_contact_list_table()
3137
+	{
3138
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3139
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3140
+		$this->display_admin_list_table_page_with_no_sidebar();
3141
+	}
3142
+
3143
+
3144
+	/**
3145
+	 * get_attendees
3146
+	 *
3147
+	 * @param      $per_page
3148
+	 * @param bool $count whether to return count or data.
3149
+	 * @param bool $trash
3150
+	 * @return array|int
3151
+	 * @throws EE_Error
3152
+	 * @throws InvalidArgumentException
3153
+	 * @throws InvalidDataTypeException
3154
+	 * @throws InvalidInterfaceException
3155
+	 */
3156
+	public function get_attendees($per_page, $count = false, $trash = false)
3157
+	{
3158
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3159
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3160
+		$orderby = $this->request->getRequestParam('orderby');
3161
+		switch ($orderby) {
3162
+			case 'ATT_ID':
3163
+			case 'ATT_fname':
3164
+			case 'ATT_email':
3165
+			case 'ATT_city':
3166
+			case 'STA_ID':
3167
+			case 'CNT_ID':
3168
+				break;
3169
+			case 'Registration_Count':
3170
+				$orderby = 'Registration_Count';
3171
+				break;
3172
+			default:
3173
+				$orderby = 'ATT_lname';
3174
+		}
3175
+		$sort         = $this->request->getRequestParam('order', 'ASC');
3176
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3177
+		$per_page     = absint($per_page) ? $per_page : 10;
3178
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3179
+		$_where       = [];
3180
+		$search_term  = $this->request->getRequestParam('s');
3181
+		if ($search_term) {
3182
+			$search_term  = '%' . $search_term . '%';
3183
+			$_where['OR'] = [
3184
+				'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3185
+				'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3186
+				'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3187
+				'ATT_fname'                         => ['LIKE', $search_term],
3188
+				'ATT_lname'                         => ['LIKE', $search_term],
3189
+				'ATT_short_bio'                     => ['LIKE', $search_term],
3190
+				'ATT_email'                         => ['LIKE', $search_term],
3191
+				'ATT_address'                       => ['LIKE', $search_term],
3192
+				'ATT_address2'                      => ['LIKE', $search_term],
3193
+				'ATT_city'                          => ['LIKE', $search_term],
3194
+				'Country.CNT_name'                  => ['LIKE', $search_term],
3195
+				'State.STA_name'                    => ['LIKE', $search_term],
3196
+				'ATT_phone'                         => ['LIKE', $search_term],
3197
+				'Registration.REG_final_price'      => ['LIKE', $search_term],
3198
+				'Registration.REG_code'             => ['LIKE', $search_term],
3199
+				'Registration.REG_group_size'       => ['LIKE', $search_term],
3200
+			];
3201
+		}
3202
+		$offset     = ($current_page - 1) * $per_page;
3203
+		$limit      = $count ? null : [$offset, $per_page];
3204
+		$query_args = [
3205
+			$_where,
3206
+			'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3207
+			'limit'         => $limit,
3208
+		];
3209
+		if (! $count) {
3210
+			$query_args['order_by'] = [$orderby => $sort];
3211
+		}
3212
+		$query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3213
+		return $count
3214
+			? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3215
+			: $this->getAttendeeModel()->get_all($query_args);
3216
+	}
3217
+
3218
+
3219
+	/**
3220
+	 * This is just taking care of resending the registration confirmation
3221
+	 *
3222
+	 * @return void
3223
+	 * @throws EE_Error
3224
+	 * @throws InvalidArgumentException
3225
+	 * @throws InvalidDataTypeException
3226
+	 * @throws InvalidInterfaceException
3227
+	 * @throws ReflectionException
3228
+	 */
3229
+	protected function _resend_registration()
3230
+	{
3231
+		$this->_process_resend_registration();
3232
+		$REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3233
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3234
+		$query_args  = $redirect_to
3235
+			? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3236
+			: ['action' => 'default'];
3237
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3238
+	}
3239
+
3240
+
3241
+	/**
3242
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3243
+	 * to use when selecting registrations
3244
+	 *
3245
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3246
+	 *                                                     the query parameters from the request
3247
+	 * @return void ends the request with a redirect or download
3248
+	 */
3249
+	public function _registrations_report_base($method_name_for_getting_query_params)
3250
+	{
3251
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3252
+			? $this->request->getRequestParam('EVT_ID', 0, 'int')
3253
+			: null;
3254
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3255
+			$request_params = $this->request->requestParams();
3256
+			wp_redirect(
3257
+				EE_Admin_Page::add_query_args_and_nonce(
3258
+					[
3259
+						'page'        => 'espresso_batch',
3260
+						'batch'       => 'file',
3261
+						'EVT_ID'      => $EVT_ID,
3262
+						'filters'     => urlencode(
3263
+							serialize(
3264
+								$this->$method_name_for_getting_query_params(
3265
+									EEH_Array::is_set($request_params, 'filters', [])
3266
+								)
3267
+							)
3268
+						),
3269
+						'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3270
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3271
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3272
+					]
3273
+				)
3274
+			);
3275
+		} else {
3276
+			// Pull the current request params
3277
+			$request_args = $this->request->requestParams();
3278
+			// Set the required request_args to be passed to the export
3279
+			$required_request_args = [
3280
+				'export' => 'report',
3281
+				'action' => 'registrations_report_for_event',
3282
+				'EVT_ID' => $EVT_ID,
3283
+			];
3284
+			// Merge required request args, overriding any currently set
3285
+			$request_args = array_merge($request_args, $required_request_args);
3286
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3287
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3288
+				$EE_Export = EE_Export::instance($request_args);
3289
+				$EE_Export->export();
3290
+			}
3291
+		}
3292
+	}
3293
+
3294
+
3295
+	/**
3296
+	 * Creates a registration report using only query parameters in the request
3297
+	 *
3298
+	 * @return void
3299
+	 */
3300
+	public function _registrations_report()
3301
+	{
3302
+		$this->_registrations_report_base('_get_registration_query_parameters');
3303
+	}
3304
+
3305
+
3306
+	public function _contact_list_export()
3307
+	{
3308
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3309
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3310
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3311
+			$EE_Export->export_attendees();
3312
+		}
3313
+	}
3314
+
3315
+
3316
+	public function _contact_list_report()
3317
+	{
3318
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3319
+			wp_redirect(
3320
+				EE_Admin_Page::add_query_args_and_nonce(
3321
+					[
3322
+						'page'        => 'espresso_batch',
3323
+						'batch'       => 'file',
3324
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3325
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3326
+					]
3327
+				)
3328
+			);
3329
+		} else {
3330
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3331
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3332
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3333
+				$EE_Export->report_attendees();
3334
+			}
3335
+		}
3336
+	}
3337
+
3338
+
3339
+
3340
+
3341
+
3342
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3343
+	/**
3344
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3345
+	 *
3346
+	 * @return void
3347
+	 * @throws EE_Error
3348
+	 * @throws InvalidArgumentException
3349
+	 * @throws InvalidDataTypeException
3350
+	 * @throws InvalidInterfaceException
3351
+	 * @throws ReflectionException
3352
+	 */
3353
+	protected function _duplicate_attendee()
3354
+	{
3355
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3356
+		$action = $this->request->getRequestParam('return', 'default');
3357
+		// verify we have necessary info
3358
+		if (! $REG_ID) {
3359
+			EE_Error::add_error(
3360
+				esc_html__(
3361
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3362
+					'event_espresso'
3363
+				),
3364
+				__FILE__,
3365
+				__LINE__,
3366
+				__FUNCTION__
3367
+			);
3368
+			$query_args = ['action' => $action];
3369
+			$this->_redirect_after_action('', '', '', $query_args, true);
3370
+		}
3371
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3372
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3373
+		if (! $registration instanceof EE_Registration) {
3374
+			throw new RuntimeException(
3375
+				sprintf(
3376
+					esc_html__(
3377
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3378
+						'event_espresso'
3379
+					),
3380
+					$REG_ID
3381
+				)
3382
+			);
3383
+		}
3384
+		$attendee = $registration->attendee();
3385
+		// remove relation of existing attendee on registration
3386
+		$registration->_remove_relation_to($attendee, 'Attendee');
3387
+		// new attendee
3388
+		$new_attendee = clone $attendee;
3389
+		$new_attendee->set('ATT_ID', 0);
3390
+		$new_attendee->save();
3391
+		// add new attendee to reg
3392
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3393
+		EE_Error::add_success(
3394
+			esc_html__(
3395
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3396
+				'event_espresso'
3397
+			)
3398
+		);
3399
+		// redirect to edit page for attendee
3400
+		$query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3401
+		$this->_redirect_after_action('', '', '', $query_args, true);
3402
+	}
3403
+
3404
+
3405
+	/**
3406
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3407
+	 *
3408
+	 * @param int     $post_id
3409
+	 * @param WP_Post $post
3410
+	 * @throws DomainException
3411
+	 * @throws EE_Error
3412
+	 * @throws InvalidArgumentException
3413
+	 * @throws InvalidDataTypeException
3414
+	 * @throws InvalidInterfaceException
3415
+	 * @throws LogicException
3416
+	 * @throws InvalidFormSubmissionException
3417
+	 * @throws ReflectionException
3418
+	 */
3419
+	protected function _insert_update_cpt_item($post_id, $post)
3420
+	{
3421
+		$success  = true;
3422
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3423
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3424
+			: null;
3425
+		// for attendee updates
3426
+		if ($attendee instanceof EE_Attendee) {
3427
+			// note we should only be UPDATING attendees at this point.
3428
+			$fname          = $this->request->getRequestParam('ATT_fname', '');
3429
+			$lname          = $this->request->getRequestParam('ATT_lname', '');
3430
+			$updated_fields = [
3431
+				'ATT_fname'     => $fname,
3432
+				'ATT_lname'     => $lname,
3433
+				'ATT_full_name' => "{$fname} {$lname}",
3434
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3435
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3436
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3437
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3438
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3439
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3440
+			];
3441
+			foreach ($updated_fields as $field => $value) {
3442
+				$attendee->set($field, $value);
3443
+			}
3444
+
3445
+			// process contact details metabox form handler (which will also save the attendee)
3446
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3447
+			$success              = $contact_details_form->process($this->request->requestParams());
3448
+
3449
+			$attendee_update_callbacks = apply_filters(
3450
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3451
+				[]
3452
+			);
3453
+			foreach ($attendee_update_callbacks as $a_callback) {
3454
+				if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3455
+					throw new EE_Error(
3456
+						sprintf(
3457
+							esc_html__(
3458
+								'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3459
+								'event_espresso'
3460
+							),
3461
+							$a_callback
3462
+						)
3463
+					);
3464
+				}
3465
+			}
3466
+		}
3467
+
3468
+		if ($success === false) {
3469
+			EE_Error::add_error(
3470
+				esc_html__(
3471
+					'Something went wrong with updating the meta table data for the registration.',
3472
+					'event_espresso'
3473
+				),
3474
+				__FILE__,
3475
+				__FUNCTION__,
3476
+				__LINE__
3477
+			);
3478
+		}
3479
+	}
3480
+
3481
+
3482
+	public function trash_cpt_item($post_id)
3483
+	{
3484
+	}
3485
+
3486
+
3487
+	public function delete_cpt_item($post_id)
3488
+	{
3489
+	}
3490
+
3491
+
3492
+	public function restore_cpt_item($post_id)
3493
+	{
3494
+	}
3495
+
3496
+
3497
+	protected function _restore_cpt_item($post_id, $revision_id)
3498
+	{
3499
+	}
3500
+
3501
+
3502
+	/**
3503
+	 * @throws EE_Error
3504
+	 * @throws ReflectionException
3505
+	 * @since 4.10.2.p
3506
+	 */
3507
+	public function attendee_editor_metaboxes()
3508
+	{
3509
+		$this->verify_cpt_object();
3510
+		remove_meta_box(
3511
+			'postexcerpt',
3512
+			$this->_cpt_routes[ $this->_req_action ],
3513
+			'normal'
3514
+		);
3515
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3516
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3517
+			add_meta_box(
3518
+				'postexcerpt',
3519
+				esc_html__('Short Biography', 'event_espresso'),
3520
+				'post_excerpt_meta_box',
3521
+				$this->_cpt_routes[ $this->_req_action ],
3522
+				'normal'
3523
+			);
3524
+		}
3525
+		if (post_type_supports('espresso_attendees', 'comments')) {
3526
+			add_meta_box(
3527
+				'commentsdiv',
3528
+				esc_html__('Notes on the Contact', 'event_espresso'),
3529
+				'post_comment_meta_box',
3530
+				$this->_cpt_routes[ $this->_req_action ],
3531
+				'normal',
3532
+				'core'
3533
+			);
3534
+		}
3535
+		add_meta_box(
3536
+			'attendee_contact_info',
3537
+			esc_html__('Contact Info', 'event_espresso'),
3538
+			[$this, 'attendee_contact_info'],
3539
+			$this->_cpt_routes[ $this->_req_action ],
3540
+			'side',
3541
+			'core'
3542
+		);
3543
+		add_meta_box(
3544
+			'attendee_details_address',
3545
+			esc_html__('Address Details', 'event_espresso'),
3546
+			[$this, 'attendee_address_details'],
3547
+			$this->_cpt_routes[ $this->_req_action ],
3548
+			'normal',
3549
+			'core'
3550
+		);
3551
+		add_meta_box(
3552
+			'attendee_registrations',
3553
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3554
+			[$this, 'attendee_registrations_meta_box'],
3555
+			$this->_cpt_routes[ $this->_req_action ],
3556
+			'normal',
3557
+			'high'
3558
+		);
3559
+	}
3560
+
3561
+
3562
+	/**
3563
+	 * Metabox for attendee contact info
3564
+	 *
3565
+	 * @param WP_Post $post wp post object
3566
+	 * @return void attendee contact info ( and form )
3567
+	 * @throws EE_Error
3568
+	 * @throws InvalidArgumentException
3569
+	 * @throws InvalidDataTypeException
3570
+	 * @throws InvalidInterfaceException
3571
+	 * @throws LogicException
3572
+	 * @throws DomainException
3573
+	 */
3574
+	public function attendee_contact_info($post)
3575
+	{
3576
+		// get attendee object ( should already have it )
3577
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3578
+		$form->enqueueStylesAndScripts();
3579
+		echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3580
+	}
3581
+
3582
+
3583
+	/**
3584
+	 * Return form handler for the contact details metabox
3585
+	 *
3586
+	 * @param EE_Attendee $attendee
3587
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3588
+	 * @throws DomainException
3589
+	 * @throws InvalidArgumentException
3590
+	 * @throws InvalidDataTypeException
3591
+	 * @throws InvalidInterfaceException
3592
+	 */
3593
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3594
+	{
3595
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3596
+	}
3597
+
3598
+
3599
+	/**
3600
+	 * Metabox for attendee details
3601
+	 *
3602
+	 * @param WP_Post $post wp post object
3603
+	 * @throws EE_Error
3604
+	 * @throws ReflectionException
3605
+	 */
3606
+	public function attendee_address_details($post)
3607
+	{
3608
+		// get attendee object (should already have it)
3609
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3610
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3611
+			new EE_Question_Form_Input(
3612
+				EE_Question::new_instance(
3613
+					[
3614
+						'QST_ID'           => 0,
3615
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3616
+						'QST_system'       => 'admin-state',
3617
+					]
3618
+				),
3619
+				EE_Answer::new_instance(
3620
+					[
3621
+						'ANS_ID'    => 0,
3622
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3623
+					]
3624
+				),
3625
+				[
3626
+					'input_id'       => 'STA_ID',
3627
+					'input_name'     => 'STA_ID',
3628
+					'input_prefix'   => '',
3629
+					'append_qstn_id' => false,
3630
+				]
3631
+			)
3632
+		);
3633
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3634
+			new EE_Question_Form_Input(
3635
+				EE_Question::new_instance(
3636
+					[
3637
+						'QST_ID'           => 0,
3638
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3639
+						'QST_system'       => 'admin-country',
3640
+					]
3641
+				),
3642
+				EE_Answer::new_instance(
3643
+					[
3644
+						'ANS_ID'    => 0,
3645
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3646
+					]
3647
+				),
3648
+				[
3649
+					'input_id'       => 'CNT_ISO',
3650
+					'input_name'     => 'CNT_ISO',
3651
+					'input_prefix'   => '',
3652
+					'append_qstn_id' => false,
3653
+				]
3654
+			)
3655
+		);
3656
+		$template                             =
3657
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3658
+		EEH_Template::display_template($template, $this->_template_args);
3659
+	}
3660
+
3661
+
3662
+	/**
3663
+	 * _attendee_details
3664
+	 *
3665
+	 * @param $post
3666
+	 * @return void
3667
+	 * @throws DomainException
3668
+	 * @throws EE_Error
3669
+	 * @throws InvalidArgumentException
3670
+	 * @throws InvalidDataTypeException
3671
+	 * @throws InvalidInterfaceException
3672
+	 * @throws ReflectionException
3673
+	 */
3674
+	public function attendee_registrations_meta_box($post)
3675
+	{
3676
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3677
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3678
+		$template                              =
3679
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3680
+		EEH_Template::display_template($template, $this->_template_args);
3681
+	}
3682
+
3683
+
3684
+	/**
3685
+	 * add in the form fields for the attendee edit
3686
+	 *
3687
+	 * @param WP_Post $post wp post object
3688
+	 * @return void echos html for new form.
3689
+	 * @throws DomainException
3690
+	 */
3691
+	public function after_title_form_fields($post)
3692
+	{
3693
+		if ($post->post_type === 'espresso_attendees') {
3694
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3695
+			$template_args['attendee'] = $this->_cpt_model_obj;
3696
+			EEH_Template::display_template($template, $template_args);
3697
+		}
3698
+	}
3699
+
3700
+
3701
+	/**
3702
+	 * _trash_or_restore_attendee
3703
+	 *
3704
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3705
+	 * @return void
3706
+	 * @throws EE_Error
3707
+	 * @throws InvalidArgumentException
3708
+	 * @throws InvalidDataTypeException
3709
+	 * @throws InvalidInterfaceException
3710
+	 */
3711
+	protected function _trash_or_restore_attendees($trash = true)
3712
+	{
3713
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3714
+		$status = $trash ? 'trash' : 'publish';
3715
+		// Checkboxes
3716
+		if ($this->request->requestParamIsSet('checkbox')) {
3717
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3718
+			// if array has more than one element than success message should be plural
3719
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3720
+			// cycle thru checkboxes
3721
+			foreach ($ATT_IDs as $ATT_ID) {
3722
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3723
+				if (! $updated) {
3724
+					$success = 0;
3725
+				}
3726
+			}
3727
+		} else {
3728
+			// grab single id and delete
3729
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3730
+			// update attendee
3731
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3732
+		}
3733
+		$what        = $success > 1
3734
+			? esc_html__('Contacts', 'event_espresso')
3735
+			: esc_html__('Contact', 'event_espresso');
3736
+		$action_desc = $trash
3737
+			? esc_html__('moved to the trash', 'event_espresso')
3738
+			: esc_html__('restored', 'event_espresso');
3739
+		$this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3740
+	}
3741 3741
 }
Please login to merge, or discard this patch.