Completed
Branch BUG/escape-localized-variables (bce518)
by
unknown
10:32 queued 01:38
created
caffeinated/modules/mijireh_slurper/EED_Mijireh_Slurper.module.php 2 patches
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -15,249 +15,249 @@
 block discarded – undo
15 15
  */
16 16
 class EED_Mijireh_Slurper extends EED_Module
17 17
 {
18
-    const slurp_started_transient_name = 'ee_mijireh_slurp_started';
19
-    const mijireh_slurper_shortcode = '{{mj-checkout-form}}';
18
+	const slurp_started_transient_name = 'ee_mijireh_slurp_started';
19
+	const mijireh_slurper_shortcode = '{{mj-checkout-form}}';
20 20
 
21
-    /**
22
-     *    set_hooks - for hooking into EE Core, other modules, etc
23
-     *
24
-     * @access    public
25
-     * @return    void
26
-     */
27
-    public static function set_hooks()
28
-    {
29
-    }
21
+	/**
22
+	 *    set_hooks - for hooking into EE Core, other modules, etc
23
+	 *
24
+	 * @access    public
25
+	 * @return    void
26
+	 */
27
+	public static function set_hooks()
28
+	{
29
+	}
30 30
 
31
-    /**
32
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
33
-     *    MIjireh Slurper module mostly just detects a special request on the EE payment methods page
34
-     *    to perform a redirect to a slurping page; detects a special request on the post.php editing page to
35
-     *    initiate slurping into mijireh; and adds a metabox to the post.php editing page when mijireh's special
36
-     *    shortcode is present
37
-     *
38
-     * @access    public
39
-     * @return    void
40
-     */
41
-    public static function set_hooks_admin()
42
-    {
43
-        define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH . 'modules/' . 'mijireh_slurper/');
44
-        add_action('load-post.php', array('EED_Mijireh_Slurper', 'set_edit_post_page_hooks'));
45
-        add_action('load-admin.php', array('EED_Mijireh_Slurper', 'check_for_edit_slurp_page'));
46
-        add_action('AHEE__EE_Mijireh__settings_end', array('EED_Mijireh_Slurper', 'add_slurp_link_to_gateway'));
47
-    }
31
+	/**
32
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
33
+	 *    MIjireh Slurper module mostly just detects a special request on the EE payment methods page
34
+	 *    to perform a redirect to a slurping page; detects a special request on the post.php editing page to
35
+	 *    initiate slurping into mijireh; and adds a metabox to the post.php editing page when mijireh's special
36
+	 *    shortcode is present
37
+	 *
38
+	 * @access    public
39
+	 * @return    void
40
+	 */
41
+	public static function set_hooks_admin()
42
+	{
43
+		define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH . 'modules/' . 'mijireh_slurper/');
44
+		add_action('load-post.php', array('EED_Mijireh_Slurper', 'set_edit_post_page_hooks'));
45
+		add_action('load-admin.php', array('EED_Mijireh_Slurper', 'check_for_edit_slurp_page'));
46
+		add_action('AHEE__EE_Mijireh__settings_end', array('EED_Mijireh_Slurper', 'add_slurp_link_to_gateway'));
47
+	}
48 48
 
49
-    /**
50
-     * Merely used to avoid even bothering to add these hooks on pages besides admin's post.php
51
-     */
52
-    public static function set_edit_post_page_hooks()
53
-    {
54
-        add_action('add_meta_boxes', array('EED_Mijireh_Slurper', 'add_slurp_page_metabox'));
55
-        add_action('posts_selection', array('EED_Mijireh_Slurper', 'slurp_or_not'));
56
-        if (get_transient(EED_Mijireh_Slurper::slurp_started_transient_name)) {
57
-            add_action('admin_notices', array('EED_Mijireh_Slurper', 'slurping_in_progress_notice'));
58
-            delete_transient(EED_Mijireh_Slurper::slurp_started_transient_name);
59
-        }
60
-    }
49
+	/**
50
+	 * Merely used to avoid even bothering to add these hooks on pages besides admin's post.php
51
+	 */
52
+	public static function set_edit_post_page_hooks()
53
+	{
54
+		add_action('add_meta_boxes', array('EED_Mijireh_Slurper', 'add_slurp_page_metabox'));
55
+		add_action('posts_selection', array('EED_Mijireh_Slurper', 'slurp_or_not'));
56
+		if (get_transient(EED_Mijireh_Slurper::slurp_started_transient_name)) {
57
+			add_action('admin_notices', array('EED_Mijireh_Slurper', 'slurping_in_progress_notice'));
58
+			delete_transient(EED_Mijireh_Slurper::slurp_started_transient_name);
59
+		}
60
+	}
61 61
 
62
-    /**
63
-     * Adds the slurping content to the gateway's settings page, because I thought this was best suited to remain in
64
-     * the module's code (because the gateway works fine independent of this module)
65
-     */
66
-    public static function add_slurp_link_to_gateway($existing_content)
67
-    {
68
-        echo EEH_Template::display_template(
69
-            EED_MIJIREH_SLURPER_PATH . 'templates/additional_content_on_gateway.template.php',
70
-            array(),
71
-            true
72
-        ) . $existing_content;
73
-    }
62
+	/**
63
+	 * Adds the slurping content to the gateway's settings page, because I thought this was best suited to remain in
64
+	 * the module's code (because the gateway works fine independent of this module)
65
+	 */
66
+	public static function add_slurp_link_to_gateway($existing_content)
67
+	{
68
+		echo EEH_Template::display_template(
69
+			EED_MIJIREH_SLURPER_PATH . 'templates/additional_content_on_gateway.template.php',
70
+			array(),
71
+			true
72
+		) . $existing_content;
73
+	}
74 74
 
75
-    public static function slurping_in_progress_notice()
76
-    {
77
-        EEH_Template::display_template(
78
-            EED_MIJIREH_SLURPER_PATH . 'templates/slurping_in_progress_notice.template.php',
79
-            array()
80
-        );
81
-    }
75
+	public static function slurping_in_progress_notice()
76
+	{
77
+		EEH_Template::display_template(
78
+			EED_MIJIREH_SLURPER_PATH . 'templates/slurping_in_progress_notice.template.php',
79
+			array()
80
+		);
81
+	}
82 82
 
83
-    /**
84
-     * Inspects the request's querystring for a special arg indicating to forward the user onto the mijireh slurp page
85
-     * (we do it this way, instead of just directly putting a link to the page in the anchor tag, because the page
86
-     * might not exist yet, in whcih case we need to first make it). If the special arg is present, redirects the user
87
-     * to the slurp page's edit page
88
-     *
89
-     * @return void
90
-     */
91
-    public static function check_for_edit_slurp_page()
92
-    {
93
-        if (isset($_GET['mijireh_edit_slurp_page']) && $_GET['mijireh_edit_slurp_page'] == 'true') {
94
-            // check if we already have a slurping page
95
-            if (! $slurp_page_id = self::find_slurp_page()) {
96
-                // if no slurp page yet, make one
97
-                $slurp_page_id = wp_insert_post(
98
-                    array(
99
-                        'post_title'   => __("Mijireh Slurping Page", 'event_espresso'),
100
-                        'post_content' => EED_Mijireh_Slurper::mijireh_slurper_shortcode,
101
-                        'post_type'    => 'page',
102
-                    )
103
-                );
104
-            }
105
-            wp_redirect(add_query_arg(array('post' => $slurp_page_id, 'action' => 'edit'), admin_url('post.php')));
106
-        }
107
-    }
83
+	/**
84
+	 * Inspects the request's querystring for a special arg indicating to forward the user onto the mijireh slurp page
85
+	 * (we do it this way, instead of just directly putting a link to the page in the anchor tag, because the page
86
+	 * might not exist yet, in whcih case we need to first make it). If the special arg is present, redirects the user
87
+	 * to the slurp page's edit page
88
+	 *
89
+	 * @return void
90
+	 */
91
+	public static function check_for_edit_slurp_page()
92
+	{
93
+		if (isset($_GET['mijireh_edit_slurp_page']) && $_GET['mijireh_edit_slurp_page'] == 'true') {
94
+			// check if we already have a slurping page
95
+			if (! $slurp_page_id = self::find_slurp_page()) {
96
+				// if no slurp page yet, make one
97
+				$slurp_page_id = wp_insert_post(
98
+					array(
99
+						'post_title'   => __("Mijireh Slurping Page", 'event_espresso'),
100
+						'post_content' => EED_Mijireh_Slurper::mijireh_slurper_shortcode,
101
+						'post_type'    => 'page',
102
+					)
103
+				);
104
+			}
105
+			wp_redirect(add_query_arg(array('post' => $slurp_page_id, 'action' => 'edit'), admin_url('post.php')));
106
+		}
107
+	}
108 108
 
109
-    /**
110
-     * Gets the post id which has the {{mj-checkout-form}} "shortcode" in it, otherwise null
111
-     *
112
-     * @return int
113
-     */
114
-    public static function find_slurp_page()
115
-    {
116
-        global $wpdb;
117
-        return $wpdb->get_var(
118
-            "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%" . EED_Mijireh_Slurper::mijireh_slurper_shortcode . "%'"
119
-        );
120
-    }
109
+	/**
110
+	 * Gets the post id which has the {{mj-checkout-form}} "shortcode" in it, otherwise null
111
+	 *
112
+	 * @return int
113
+	 */
114
+	public static function find_slurp_page()
115
+	{
116
+		global $wpdb;
117
+		return $wpdb->get_var(
118
+			"SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%" . EED_Mijireh_Slurper::mijireh_slurper_shortcode . "%'"
119
+		);
120
+	}
121 121
 
122
-    /**
123
-     * Return true if the current page is the mijireh checkout page, otherwise return false.
124
-     *
125
-     * @return boolean
126
-     */
127
-    public static function is_slurp_page()
128
-    {
129
-        global $post;
130
-        $isSlurp = false;
131
-        if (isset($post) && is_object($post)) {
132
-            $content = $post->post_content;
133
-            if (strpos($content, EED_Mijireh_Slurper::mijireh_slurper_shortcode) !== false) {
134
-                $isSlurp = true;
135
-            }
136
-        } else {
137
-            // echo '[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Check Slurp Page Failed: " . print_r($post, 1);
138
-        }
139
-        return $isSlurp;
140
-    }
122
+	/**
123
+	 * Return true if the current page is the mijireh checkout page, otherwise return false.
124
+	 *
125
+	 * @return boolean
126
+	 */
127
+	public static function is_slurp_page()
128
+	{
129
+		global $post;
130
+		$isSlurp = false;
131
+		if (isset($post) && is_object($post)) {
132
+			$content = $post->post_content;
133
+			if (strpos($content, EED_Mijireh_Slurper::mijireh_slurper_shortcode) !== false) {
134
+				$isSlurp = true;
135
+			}
136
+		} else {
137
+			// echo '[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Check Slurp Page Failed: " . print_r($post, 1);
138
+		}
139
+		return $isSlurp;
140
+	}
141 141
 
142
-    /**
143
-     * adds the callback to adding the slurp page metabox, which shoudl only appear on a page with the
144
-     * {{mj-checkout-form}} "shortcode"
145
-     *
146
-     * @return void
147
-     */
148
-    public static function add_slurp_page_metabox()
149
-    {
150
-        if (self::is_slurp_page()
151
-            && EEM_Payment_Method::instance()->get_one_active(
152
-                EEM_Payment_Method::scope_cart,
153
-                array(array('PMD_type' => 'Mijireh'))
154
-            )) {
155
-            add_meta_box(
156
-                'slurp_meta_box', // $id
157
-                'Mijireh Page Slurp', // $title
158
-                array('EED_Mijireh_Slurper', 'slurp_page_metabox'), // $callback
159
-                'page', // $page
160
-                'normal', // $context
161
-                'high'
162
-            ); // $priority
163
-        }
164
-    }
142
+	/**
143
+	 * adds the callback to adding the slurp page metabox, which shoudl only appear on a page with the
144
+	 * {{mj-checkout-form}} "shortcode"
145
+	 *
146
+	 * @return void
147
+	 */
148
+	public static function add_slurp_page_metabox()
149
+	{
150
+		if (self::is_slurp_page()
151
+			&& EEM_Payment_Method::instance()->get_one_active(
152
+				EEM_Payment_Method::scope_cart,
153
+				array(array('PMD_type' => 'Mijireh'))
154
+			)) {
155
+			add_meta_box(
156
+				'slurp_meta_box', // $id
157
+				'Mijireh Page Slurp', // $title
158
+				array('EED_Mijireh_Slurper', 'slurp_page_metabox'), // $callback
159
+				'page', // $page
160
+				'normal', // $context
161
+				'high'
162
+			); // $priority
163
+		}
164
+	}
165 165
 
166
-    /**
167
-     * outputs HTML for displaying the slurping metabox
168
-     *
169
-     * @param WP_Post $post
170
-     * @return void echoes out html
171
-     */
172
-    public static function slurp_page_metabox($post)
173
-    {
174
-        global $wp;
175
-        $mijireh_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Mijireh');
176
-        if ($mijireh_payment_method) {
177
-            $access_key = $mijireh_payment_method->get_extra_meta('access_key', true);
178
-            EEH_Template::display_template(
179
-                EED_MIJIREH_SLURPER_PATH . 'templates/mijireh_slurp_page_metabox.template.php',
180
-                array(
181
-                    'mijireh_image_url' => $mijireh_payment_method->button_url(),
182
-                    'access_key'        => $access_key,
183
-                    'slurp_action_link' => esc_url_raw(
184
-                        add_query_arg(
185
-                            'mijireh_slurp_now',
186
-                            'true',
187
-                            add_query_arg($wp->query_string, '', '?' . $_SERVER['QUERY_STRING'])
188
-                        )
189
-                    ),
190
-                )
191
-            );
192
-        }
193
-    }
166
+	/**
167
+	 * outputs HTML for displaying the slurping metabox
168
+	 *
169
+	 * @param WP_Post $post
170
+	 * @return void echoes out html
171
+	 */
172
+	public static function slurp_page_metabox($post)
173
+	{
174
+		global $wp;
175
+		$mijireh_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Mijireh');
176
+		if ($mijireh_payment_method) {
177
+			$access_key = $mijireh_payment_method->get_extra_meta('access_key', true);
178
+			EEH_Template::display_template(
179
+				EED_MIJIREH_SLURPER_PATH . 'templates/mijireh_slurp_page_metabox.template.php',
180
+				array(
181
+					'mijireh_image_url' => $mijireh_payment_method->button_url(),
182
+					'access_key'        => $access_key,
183
+					'slurp_action_link' => esc_url_raw(
184
+						add_query_arg(
185
+							'mijireh_slurp_now',
186
+							'true',
187
+							add_query_arg($wp->query_string, '', '?' . $_SERVER['QUERY_STRING'])
188
+						)
189
+					),
190
+				)
191
+			);
192
+		}
193
+	}
194 194
 
195
-    /**
196
-     * decides whether to slurp the post indicated by the $post global or not, based entirely
197
-     * on a special arg being in the querystring
198
-     *
199
-     * @return void
200
-     */
201
-    public static function slurp_or_not()
202
-    {
203
-        // check if this page has the right mijire 'shortcode' and if they've specified to slurp it
204
-        if (isset($_GET['mijireh_slurp_now'])
205
-            && $_GET['mijireh_slurp_now'] == 'true'
206
-            && EED_Mijireh_Slurper::is_slurp_page()
207
-        ) {
208
-            EED_Mijireh_Slurper::slurp_now();
209
-        }
210
-    }
195
+	/**
196
+	 * decides whether to slurp the post indicated by the $post global or not, based entirely
197
+	 * on a special arg being in the querystring
198
+	 *
199
+	 * @return void
200
+	 */
201
+	public static function slurp_or_not()
202
+	{
203
+		// check if this page has the right mijire 'shortcode' and if they've specified to slurp it
204
+		if (isset($_GET['mijireh_slurp_now'])
205
+			&& $_GET['mijireh_slurp_now'] == 'true'
206
+			&& EED_Mijireh_Slurper::is_slurp_page()
207
+		) {
208
+			EED_Mijireh_Slurper::slurp_now();
209
+		}
210
+	}
211 211
 
212
-    /**
213
-     * Sends a request to mijireh to slurp the current $post, and then redirects the user back to the current page
214
-     * without the special querystring arg indicating to slurp. Also, should temporarily make the current post
215
-     * published, then revert it to its previous status
216
-     */
217
-    public static function slurp_now()
218
-    {
219
-        global $post;
220
-        if ($post->post_status != 'publish') {
221
-            // make sure the post is published at least while slurping
222
-            $post->post_status = 'publish';
223
-            wp_update_post($post);
224
-        }
225
-        $mijireh_gateway = EEM_Payment_Method::instance()->get_one_of_type('Mijireh');
226
-        $access_key = $mijireh_gateway->get_extra_meta('access_key', true);
227
-        // 'slurp_url'=>get_permalink($post),
228
-        // 'page_id'=>$post->ID,
229
-        // 'return_url'=>$return_url
230
-        $url = 'https://secure.mijireh.com/api/1/slurps';
231
-        $args = array(
232
-            'headers' => array(
233
-                'Authorization' => 'Basic ' . base64_encode($access_key . ':'),
234
-                'Accept'        => 'application/json',
235
-            ),
236
-            'body'    => wp_json_encode(
237
-                array(
238
-                    'url'        => get_permalink($post->ID),
239
-                    'page_id'    => $post->ID,
240
-                    'return_url' => '',
241
-                )
242
-            ),
243
-        );
244
-        $response = wp_remote_post($url, $args);
245
-        // now redirect the user back to the same page
246
-        $redirect_args = $_GET;
247
-        unset($redirect_args['mijireh_slurp_now']);
248
-        $url = add_query_arg($redirect_args, admin_url('post.php'));
249
-        set_transient(EED_Mijireh_Slurper::slurp_started_transient_name, true);
250
-        // echo "redirect to $url";
251
-        wp_redirect($url);
252
-    }
212
+	/**
213
+	 * Sends a request to mijireh to slurp the current $post, and then redirects the user back to the current page
214
+	 * without the special querystring arg indicating to slurp. Also, should temporarily make the current post
215
+	 * published, then revert it to its previous status
216
+	 */
217
+	public static function slurp_now()
218
+	{
219
+		global $post;
220
+		if ($post->post_status != 'publish') {
221
+			// make sure the post is published at least while slurping
222
+			$post->post_status = 'publish';
223
+			wp_update_post($post);
224
+		}
225
+		$mijireh_gateway = EEM_Payment_Method::instance()->get_one_of_type('Mijireh');
226
+		$access_key = $mijireh_gateway->get_extra_meta('access_key', true);
227
+		// 'slurp_url'=>get_permalink($post),
228
+		// 'page_id'=>$post->ID,
229
+		// 'return_url'=>$return_url
230
+		$url = 'https://secure.mijireh.com/api/1/slurps';
231
+		$args = array(
232
+			'headers' => array(
233
+				'Authorization' => 'Basic ' . base64_encode($access_key . ':'),
234
+				'Accept'        => 'application/json',
235
+			),
236
+			'body'    => wp_json_encode(
237
+				array(
238
+					'url'        => get_permalink($post->ID),
239
+					'page_id'    => $post->ID,
240
+					'return_url' => '',
241
+				)
242
+			),
243
+		);
244
+		$response = wp_remote_post($url, $args);
245
+		// now redirect the user back to the same page
246
+		$redirect_args = $_GET;
247
+		unset($redirect_args['mijireh_slurp_now']);
248
+		$url = add_query_arg($redirect_args, admin_url('post.php'));
249
+		set_transient(EED_Mijireh_Slurper::slurp_started_transient_name, true);
250
+		// echo "redirect to $url";
251
+		wp_redirect($url);
252
+	}
253 253
 
254
-    /**
255
-     *    run - initial module setup
256
-     *
257
-     * @access    public
258
-     * @return    void
259
-     */
260
-    public function run($WP)
261
-    {
262
-    }
254
+	/**
255
+	 *    run - initial module setup
256
+	 *
257
+	 * @access    public
258
+	 * @return    void
259
+	 */
260
+	public function run($WP)
261
+	{
262
+	}
263 263
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public static function set_hooks_admin()
42 42
     {
43
-        define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH . 'modules/' . 'mijireh_slurper/');
43
+        define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH.'modules/'.'mijireh_slurper/');
44 44
         add_action('load-post.php', array('EED_Mijireh_Slurper', 'set_edit_post_page_hooks'));
45 45
         add_action('load-admin.php', array('EED_Mijireh_Slurper', 'check_for_edit_slurp_page'));
46 46
         add_action('AHEE__EE_Mijireh__settings_end', array('EED_Mijireh_Slurper', 'add_slurp_link_to_gateway'));
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
     public static function add_slurp_link_to_gateway($existing_content)
67 67
     {
68 68
         echo EEH_Template::display_template(
69
-            EED_MIJIREH_SLURPER_PATH . 'templates/additional_content_on_gateway.template.php',
69
+            EED_MIJIREH_SLURPER_PATH.'templates/additional_content_on_gateway.template.php',
70 70
             array(),
71 71
             true
72
-        ) . $existing_content;
72
+        ).$existing_content;
73 73
     }
74 74
 
75 75
     public static function slurping_in_progress_notice()
76 76
     {
77 77
         EEH_Template::display_template(
78
-            EED_MIJIREH_SLURPER_PATH . 'templates/slurping_in_progress_notice.template.php',
78
+            EED_MIJIREH_SLURPER_PATH.'templates/slurping_in_progress_notice.template.php',
79 79
             array()
80 80
         );
81 81
     }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     {
93 93
         if (isset($_GET['mijireh_edit_slurp_page']) && $_GET['mijireh_edit_slurp_page'] == 'true') {
94 94
             // check if we already have a slurping page
95
-            if (! $slurp_page_id = self::find_slurp_page()) {
95
+            if ( ! $slurp_page_id = self::find_slurp_page()) {
96 96
                 // if no slurp page yet, make one
97 97
                 $slurp_page_id = wp_insert_post(
98 98
                     array(
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     {
116 116
         global $wpdb;
117 117
         return $wpdb->get_var(
118
-            "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%" . EED_Mijireh_Slurper::mijireh_slurper_shortcode . "%'"
118
+            "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%".EED_Mijireh_Slurper::mijireh_slurper_shortcode."%'"
119 119
         );
120 120
     }
121 121
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         if ($mijireh_payment_method) {
177 177
             $access_key = $mijireh_payment_method->get_extra_meta('access_key', true);
178 178
             EEH_Template::display_template(
179
-                EED_MIJIREH_SLURPER_PATH . 'templates/mijireh_slurp_page_metabox.template.php',
179
+                EED_MIJIREH_SLURPER_PATH.'templates/mijireh_slurp_page_metabox.template.php',
180 180
                 array(
181 181
                     'mijireh_image_url' => $mijireh_payment_method->button_url(),
182 182
                     'access_key'        => $access_key,
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                         add_query_arg(
185 185
                             'mijireh_slurp_now',
186 186
                             'true',
187
-                            add_query_arg($wp->query_string, '', '?' . $_SERVER['QUERY_STRING'])
187
+                            add_query_arg($wp->query_string, '', '?'.$_SERVER['QUERY_STRING'])
188 188
                         )
189 189
                     ),
190 190
                 )
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
         $url = 'https://secure.mijireh.com/api/1/slurps';
231 231
         $args = array(
232 232
             'headers' => array(
233
-                'Authorization' => 'Basic ' . base64_encode($access_key . ':'),
233
+                'Authorization' => 'Basic '.base64_encode($access_key.':'),
234 234
                 'Accept'        => 'application/json',
235 235
             ),
236 236
             'body'    => wp_json_encode(
Please login to merge, or discard this patch.
caffeinated/brewing_regular.php 2 patches
Indentation   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -27,322 +27,322 @@
 block discarded – undo
27 27
 class EE_Brewing_Regular extends EE_BASE implements InterminableInterface
28 28
 {
29 29
 
30
-    /**
31
-     * @var TableAnalysis $table_analysis
32
-     */
33
-    protected $_table_analysis;
34
-
35
-
36
-    /**
37
-     * EE_Brewing_Regular constructor.
38
-     *
39
-     * @param TableAnalysis $table_analysis
40
-     */
41
-    public function __construct(TableAnalysis $table_analysis)
42
-    {
43
-        $this->_table_analysis = $table_analysis;
44
-        if (defined('EE_CAFF_PATH')) {
45
-            $this->setInitializationHooks();
46
-            $this->setApiRegistrationHooks();
47
-            $this->setSwitchHooks();
48
-            $this->setDefaultFilterHooks();
49
-            // caffeinated constructed
50
-            do_action('AHEE__EE_Brewing_Regular__construct__complete');
51
-        }
52
-    }
53
-
54
-
55
-    /**
56
-     * Various hooks used for extending features via registration of modules or extensions.
57
-     */
58
-    private function setApiRegistrationHooks()
59
-    {
60
-        add_filter(
61
-            'FHEE__EE_Config__register_modules__modules_to_register',
62
-            array($this, 'caffeinated_modules_to_register')
63
-        );
64
-        add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
65
-        add_filter(
66
-            'AHEE__EE_System__load_core_configuration__complete',
67
-            function () {
68
-                EE_Register_Payment_Method::register(
69
-                    'caffeinated_payment_methods',
70
-                    array(
71
-                        'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR),
72
-                    )
73
-                );
74
-            }
75
-        );
76
-    }
77
-
78
-
79
-    /**
80
-     * Various hooks used for modifying initialization or activation processes.
81
-     */
82
-    private function setInitializationHooks()
83
-    {
84
-        // activation
85
-        add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
86
-        // load caff init
87
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
88
-        // load caff scripts
89
-        add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
90
-    }
91
-
92
-
93
-    /**
94
-     * Various hooks used for switch (on/off) type filters.
95
-     */
96
-    private function setSwitchHooks()
97
-    {
98
-        // remove the "powered by" credit link from receipts and invoices
99
-        add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
100
-        // seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
101
-        add_filter('FHEE__ee_show_affiliate_links', '__return_false');
102
-    }
103
-
104
-
105
-    /**
106
-     * Various filters for affecting default configuration values in the caffeinated
107
-     * context.
108
-     */
109
-    private function setDefaultFilterHooks()
110
-    {
111
-        add_filter(
112
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
113
-            '__return_true'
114
-        );
115
-    }
116
-
117
-
118
-    /**
119
-     * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
120
-     *
121
-     * @param array $paths original helper paths array
122
-     * @return array             new array of paths
123
-     */
124
-    public function caf_helper_paths($paths)
125
-    {
126
-        $paths[] = EE_CAF_CORE . 'helpers/';
127
-        return $paths;
128
-    }
129
-
130
-
131
-    /**
132
-     * Upon brand-new activation, if this is a new activation of CAF, we want to add
133
-     * some global prices that will show off EE4's capabilities. However, if they're upgrading
134
-     * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
135
-     * This action should only be called when EE 4.x.0.P is initially activated.
136
-     * Right now the only CAF content are these global prices. If there's more in the future, then
137
-     * we should probably create a caf file to contain it all instead just a function like this.
138
-     * Right now, we ASSUME the only price types in the system are default ones
139
-     *
140
-     * @global wpdb $wpdb
141
-     */
142
-    public function initialize_caf_db_content()
143
-    {
144
-        global $wpdb;
145
-        // use same method of getting creator id as the version introducing the change
146
-        $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
147
-        $price_type_table = $wpdb->prefix . "esp_price_type";
148
-        $price_table = $wpdb->prefix . "esp_price";
149
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
150
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types
151
-            $tax_price_type_count = $wpdb->get_var($SQL);
152
-            if ($tax_price_type_count <= 1) {
153
-                $wpdb->insert(
154
-                    $price_type_table,
155
-                    array(
156
-                        'PRT_name'       => __("Regional Tax", "event_espresso"),
157
-                        'PBT_ID'         => 4,
158
-                        'PRT_is_percent' => true,
159
-                        'PRT_order'      => 60,
160
-                        'PRT_deleted'    => false,
161
-                        'PRT_wp_user'    => $default_creator_id,
162
-                    ),
163
-                    array(
164
-                        '%s',// PRT_name
165
-                        '%d',// PBT_id
166
-                        '%d',// PRT_is_percent
167
-                        '%d',// PRT_order
168
-                        '%d',// PRT_deleted
169
-                        '%d', // PRT_wp_user
170
-                    )
171
-                );
172
-                // federal tax
173
-                $result = $wpdb->insert(
174
-                    $price_type_table,
175
-                    array(
176
-                        'PRT_name'       => __("Federal Tax", "event_espresso"),
177
-                        'PBT_ID'         => 4,
178
-                        'PRT_is_percent' => true,
179
-                        'PRT_order'      => 70,
180
-                        'PRT_deleted'    => false,
181
-                        'PRT_wp_user'    => $default_creator_id,
182
-                    ),
183
-                    array(
184
-                        '%s',// PRT_name
185
-                        '%d',// PBT_id
186
-                        '%d',// PRT_is_percent
187
-                        '%d',// PRT_order
188
-                        '%d',// PRT_deleted
189
-                        '%d' // PRT_wp_user
190
-                    )
191
-                );
192
-                if ($result) {
193
-                    $wpdb->insert(
194
-                        $price_table,
195
-                        array(
196
-                            'PRT_ID'         => $wpdb->insert_id,
197
-                            'PRC_amount'     => 15.00,
198
-                            'PRC_name'       => __("Sales Tax", "event_espresso"),
199
-                            'PRC_desc'       => '',
200
-                            'PRC_is_default' => true,
201
-                            'PRC_overrides'  => null,
202
-                            'PRC_deleted'    => false,
203
-                            'PRC_order'      => 50,
204
-                            'PRC_parent'     => null,
205
-                            'PRC_wp_user'    => $default_creator_id,
206
-                        ),
207
-                        array(
208
-                            '%d',// PRT_id
209
-                            '%f',// PRC_amount
210
-                            '%s',// PRC_name
211
-                            '%s',// PRC_desc
212
-                            '%d',// PRC_is_default
213
-                            '%d',// PRC_overrides
214
-                            '%d',// PRC_deleted
215
-                            '%d',// PRC_order
216
-                            '%d',// PRC_parent
217
-                            '%d' // PRC_wp_user
218
-                        )
219
-                    );
220
-                }
221
-            }
222
-        }
223
-    }
224
-
225
-
226
-    /**
227
-     *    caffeinated_modules_to_register
228
-     *
229
-     * @access public
230
-     * @param array $modules_to_register
231
-     * @return array
232
-     */
233
-    public function caffeinated_modules_to_register($modules_to_register = array())
234
-    {
235
-        if (is_readable(EE_CAFF_PATH . 'modules')) {
236
-            $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules/*', GLOB_ONLYDIR);
237
-            if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
238
-                $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
239
-            }
240
-        }
241
-        return $modules_to_register;
242
-    }
243
-
244
-
245
-    /**
246
-     * @throws EE_Error
247
-     * @throws InvalidArgumentException
248
-     * @throws ReflectionException
249
-     * @throws InvalidDataTypeException
250
-     * @throws InvalidInterfaceException
251
-     */
252
-    public function caffeinated_init()
253
-    {
254
-        // Custom Post Type hooks
255
-        add_filter(
256
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
257
-            array($this, 'filter_taxonomies')
258
-        );
259
-        add_filter(
260
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
261
-            array($this, 'filter_cpts')
262
-        );
263
-        add_filter(
264
-            'FHEE__EE_Admin__get_extra_nav_menu_pages_items',
265
-            array($this, 'nav_metabox_items')
266
-        );
267
-        EE_Registry::instance()->load_file(
268
-            EE_CAFF_PATH,
269
-            'EE_Caf_Messages',
270
-            'class',
271
-            array(),
272
-            false
273
-        );
274
-        // caffeinated_init__complete hook
275
-        do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
276
-    }
277
-
278
-
279
-    public function enqueue_caffeinated_scripts()
280
-    {
281
-        // sound of crickets...
282
-    }
283
-
284
-
285
-    /**
286
-     * callbacks below here
287
-     *
288
-     * @param array $taxonomy_array
289
-     * @return array
290
-     */
291
-    public function filter_taxonomies(array $taxonomy_array)
292
-    {
293
-        $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
294
-        return $taxonomy_array;
295
-    }
296
-
297
-
298
-    /**
299
-     * @param array $cpt_array
300
-     * @return mixed
301
-     */
302
-    public function filter_cpts(array $cpt_array)
303
-    {
304
-        $cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true;
305
-        return $cpt_array;
306
-    }
307
-
308
-
309
-    /**
310
-     * @param array $menuitems
311
-     * @return array
312
-     */
313
-    public function nav_metabox_items(array $menuitems)
314
-    {
315
-        $menuitems[] = array(
316
-            'title'       => __('Venue List', 'event_espresso'),
317
-            'url'         => get_post_type_archive_link('espresso_venues'),
318
-            'description' => __('Archive page for all venues.', 'event_espresso'),
319
-        );
320
-        return $menuitems;
321
-    }
322
-
323
-
324
-    /**
325
-     * Gets the injected table analyzer, or throws an exception
326
-     *
327
-     * @return TableAnalysis
328
-     * @throws \EE_Error
329
-     */
330
-    protected function _get_table_analysis()
331
-    {
332
-        if ($this->_table_analysis instanceof TableAnalysis) {
333
-            return $this->_table_analysis;
334
-        } else {
335
-            throw new \EE_Error(
336
-                sprintf(
337
-                    __('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
338
-                    get_class($this)
339
-                )
340
-            );
341
-        }
342
-    }
30
+	/**
31
+	 * @var TableAnalysis $table_analysis
32
+	 */
33
+	protected $_table_analysis;
34
+
35
+
36
+	/**
37
+	 * EE_Brewing_Regular constructor.
38
+	 *
39
+	 * @param TableAnalysis $table_analysis
40
+	 */
41
+	public function __construct(TableAnalysis $table_analysis)
42
+	{
43
+		$this->_table_analysis = $table_analysis;
44
+		if (defined('EE_CAFF_PATH')) {
45
+			$this->setInitializationHooks();
46
+			$this->setApiRegistrationHooks();
47
+			$this->setSwitchHooks();
48
+			$this->setDefaultFilterHooks();
49
+			// caffeinated constructed
50
+			do_action('AHEE__EE_Brewing_Regular__construct__complete');
51
+		}
52
+	}
53
+
54
+
55
+	/**
56
+	 * Various hooks used for extending features via registration of modules or extensions.
57
+	 */
58
+	private function setApiRegistrationHooks()
59
+	{
60
+		add_filter(
61
+			'FHEE__EE_Config__register_modules__modules_to_register',
62
+			array($this, 'caffeinated_modules_to_register')
63
+		);
64
+		add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
65
+		add_filter(
66
+			'AHEE__EE_System__load_core_configuration__complete',
67
+			function () {
68
+				EE_Register_Payment_Method::register(
69
+					'caffeinated_payment_methods',
70
+					array(
71
+						'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR),
72
+					)
73
+				);
74
+			}
75
+		);
76
+	}
77
+
78
+
79
+	/**
80
+	 * Various hooks used for modifying initialization or activation processes.
81
+	 */
82
+	private function setInitializationHooks()
83
+	{
84
+		// activation
85
+		add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
86
+		// load caff init
87
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
88
+		// load caff scripts
89
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
90
+	}
91
+
92
+
93
+	/**
94
+	 * Various hooks used for switch (on/off) type filters.
95
+	 */
96
+	private function setSwitchHooks()
97
+	{
98
+		// remove the "powered by" credit link from receipts and invoices
99
+		add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
100
+		// seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
101
+		add_filter('FHEE__ee_show_affiliate_links', '__return_false');
102
+	}
103
+
104
+
105
+	/**
106
+	 * Various filters for affecting default configuration values in the caffeinated
107
+	 * context.
108
+	 */
109
+	private function setDefaultFilterHooks()
110
+	{
111
+		add_filter(
112
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
113
+			'__return_true'
114
+		);
115
+	}
116
+
117
+
118
+	/**
119
+	 * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
120
+	 *
121
+	 * @param array $paths original helper paths array
122
+	 * @return array             new array of paths
123
+	 */
124
+	public function caf_helper_paths($paths)
125
+	{
126
+		$paths[] = EE_CAF_CORE . 'helpers/';
127
+		return $paths;
128
+	}
129
+
130
+
131
+	/**
132
+	 * Upon brand-new activation, if this is a new activation of CAF, we want to add
133
+	 * some global prices that will show off EE4's capabilities. However, if they're upgrading
134
+	 * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
135
+	 * This action should only be called when EE 4.x.0.P is initially activated.
136
+	 * Right now the only CAF content are these global prices. If there's more in the future, then
137
+	 * we should probably create a caf file to contain it all instead just a function like this.
138
+	 * Right now, we ASSUME the only price types in the system are default ones
139
+	 *
140
+	 * @global wpdb $wpdb
141
+	 */
142
+	public function initialize_caf_db_content()
143
+	{
144
+		global $wpdb;
145
+		// use same method of getting creator id as the version introducing the change
146
+		$default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
147
+		$price_type_table = $wpdb->prefix . "esp_price_type";
148
+		$price_table = $wpdb->prefix . "esp_price";
149
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
150
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types
151
+			$tax_price_type_count = $wpdb->get_var($SQL);
152
+			if ($tax_price_type_count <= 1) {
153
+				$wpdb->insert(
154
+					$price_type_table,
155
+					array(
156
+						'PRT_name'       => __("Regional Tax", "event_espresso"),
157
+						'PBT_ID'         => 4,
158
+						'PRT_is_percent' => true,
159
+						'PRT_order'      => 60,
160
+						'PRT_deleted'    => false,
161
+						'PRT_wp_user'    => $default_creator_id,
162
+					),
163
+					array(
164
+						'%s',// PRT_name
165
+						'%d',// PBT_id
166
+						'%d',// PRT_is_percent
167
+						'%d',// PRT_order
168
+						'%d',// PRT_deleted
169
+						'%d', // PRT_wp_user
170
+					)
171
+				);
172
+				// federal tax
173
+				$result = $wpdb->insert(
174
+					$price_type_table,
175
+					array(
176
+						'PRT_name'       => __("Federal Tax", "event_espresso"),
177
+						'PBT_ID'         => 4,
178
+						'PRT_is_percent' => true,
179
+						'PRT_order'      => 70,
180
+						'PRT_deleted'    => false,
181
+						'PRT_wp_user'    => $default_creator_id,
182
+					),
183
+					array(
184
+						'%s',// PRT_name
185
+						'%d',// PBT_id
186
+						'%d',// PRT_is_percent
187
+						'%d',// PRT_order
188
+						'%d',// PRT_deleted
189
+						'%d' // PRT_wp_user
190
+					)
191
+				);
192
+				if ($result) {
193
+					$wpdb->insert(
194
+						$price_table,
195
+						array(
196
+							'PRT_ID'         => $wpdb->insert_id,
197
+							'PRC_amount'     => 15.00,
198
+							'PRC_name'       => __("Sales Tax", "event_espresso"),
199
+							'PRC_desc'       => '',
200
+							'PRC_is_default' => true,
201
+							'PRC_overrides'  => null,
202
+							'PRC_deleted'    => false,
203
+							'PRC_order'      => 50,
204
+							'PRC_parent'     => null,
205
+							'PRC_wp_user'    => $default_creator_id,
206
+						),
207
+						array(
208
+							'%d',// PRT_id
209
+							'%f',// PRC_amount
210
+							'%s',// PRC_name
211
+							'%s',// PRC_desc
212
+							'%d',// PRC_is_default
213
+							'%d',// PRC_overrides
214
+							'%d',// PRC_deleted
215
+							'%d',// PRC_order
216
+							'%d',// PRC_parent
217
+							'%d' // PRC_wp_user
218
+						)
219
+					);
220
+				}
221
+			}
222
+		}
223
+	}
224
+
225
+
226
+	/**
227
+	 *    caffeinated_modules_to_register
228
+	 *
229
+	 * @access public
230
+	 * @param array $modules_to_register
231
+	 * @return array
232
+	 */
233
+	public function caffeinated_modules_to_register($modules_to_register = array())
234
+	{
235
+		if (is_readable(EE_CAFF_PATH . 'modules')) {
236
+			$caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules/*', GLOB_ONLYDIR);
237
+			if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
238
+				$modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
239
+			}
240
+		}
241
+		return $modules_to_register;
242
+	}
243
+
244
+
245
+	/**
246
+	 * @throws EE_Error
247
+	 * @throws InvalidArgumentException
248
+	 * @throws ReflectionException
249
+	 * @throws InvalidDataTypeException
250
+	 * @throws InvalidInterfaceException
251
+	 */
252
+	public function caffeinated_init()
253
+	{
254
+		// Custom Post Type hooks
255
+		add_filter(
256
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
257
+			array($this, 'filter_taxonomies')
258
+		);
259
+		add_filter(
260
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
261
+			array($this, 'filter_cpts')
262
+		);
263
+		add_filter(
264
+			'FHEE__EE_Admin__get_extra_nav_menu_pages_items',
265
+			array($this, 'nav_metabox_items')
266
+		);
267
+		EE_Registry::instance()->load_file(
268
+			EE_CAFF_PATH,
269
+			'EE_Caf_Messages',
270
+			'class',
271
+			array(),
272
+			false
273
+		);
274
+		// caffeinated_init__complete hook
275
+		do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
276
+	}
277
+
278
+
279
+	public function enqueue_caffeinated_scripts()
280
+	{
281
+		// sound of crickets...
282
+	}
283
+
284
+
285
+	/**
286
+	 * callbacks below here
287
+	 *
288
+	 * @param array $taxonomy_array
289
+	 * @return array
290
+	 */
291
+	public function filter_taxonomies(array $taxonomy_array)
292
+	{
293
+		$taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
294
+		return $taxonomy_array;
295
+	}
296
+
297
+
298
+	/**
299
+	 * @param array $cpt_array
300
+	 * @return mixed
301
+	 */
302
+	public function filter_cpts(array $cpt_array)
303
+	{
304
+		$cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true;
305
+		return $cpt_array;
306
+	}
307
+
308
+
309
+	/**
310
+	 * @param array $menuitems
311
+	 * @return array
312
+	 */
313
+	public function nav_metabox_items(array $menuitems)
314
+	{
315
+		$menuitems[] = array(
316
+			'title'       => __('Venue List', 'event_espresso'),
317
+			'url'         => get_post_type_archive_link('espresso_venues'),
318
+			'description' => __('Archive page for all venues.', 'event_espresso'),
319
+		);
320
+		return $menuitems;
321
+	}
322
+
323
+
324
+	/**
325
+	 * Gets the injected table analyzer, or throws an exception
326
+	 *
327
+	 * @return TableAnalysis
328
+	 * @throws \EE_Error
329
+	 */
330
+	protected function _get_table_analysis()
331
+	{
332
+		if ($this->_table_analysis instanceof TableAnalysis) {
333
+			return $this->_table_analysis;
334
+		} else {
335
+			throw new \EE_Error(
336
+				sprintf(
337
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
338
+					get_class($this)
339
+				)
340
+			);
341
+		}
342
+	}
343 343
 }
344 344
 
345 345
 
346 346
 $brewing = new EE_Brewing_Regular(
347
-    EE_Registry::instance()->create('TableAnalysis', array(), true)
347
+	EE_Registry::instance()->create('TableAnalysis', array(), true)
348 348
 );
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
  * define and use the hook in a specific caffeinated/whatever class or file.
12 12
  */
13 13
 // defined some new constants related to caffeinated folder
14
-define('EE_CAF_URL', EE_PLUGIN_DIR_URL . 'caffeinated/');
15
-define('EE_CAF_CORE', EE_CAFF_PATH . 'core/');
16
-define('EE_CAF_LIBRARIES', EE_CAF_CORE . 'libraries/');
17
-define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH . 'payment_methods/');
14
+define('EE_CAF_URL', EE_PLUGIN_DIR_URL.'caffeinated/');
15
+define('EE_CAF_CORE', EE_CAFF_PATH.'core/');
16
+define('EE_CAF_LIBRARIES', EE_CAF_CORE.'libraries/');
17
+define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH.'payment_methods/');
18 18
 
19 19
 
20 20
 /**
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
         add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
65 65
         add_filter(
66 66
             'AHEE__EE_System__load_core_configuration__complete',
67
-            function () {
67
+            function() {
68 68
                 EE_Register_Payment_Method::register(
69 69
                     'caffeinated_payment_methods',
70 70
                     array(
71
-                        'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR),
71
+                        'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS.'*', GLOB_ONLYDIR),
72 72
                     )
73 73
                 );
74 74
             }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function caf_helper_paths($paths)
125 125
     {
126
-        $paths[] = EE_CAF_CORE . 'helpers/';
126
+        $paths[] = EE_CAF_CORE.'helpers/';
127 127
         return $paths;
128 128
     }
129 129
 
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
         global $wpdb;
145 145
         // use same method of getting creator id as the version introducing the change
146 146
         $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
147
-        $price_type_table = $wpdb->prefix . "esp_price_type";
148
-        $price_table = $wpdb->prefix . "esp_price";
147
+        $price_type_table = $wpdb->prefix."esp_price_type";
148
+        $price_table = $wpdb->prefix."esp_price";
149 149
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
150
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types
150
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table.' WHERE PBT_ID=4'; // include trashed price types
151 151
             $tax_price_type_count = $wpdb->get_var($SQL);
152 152
             if ($tax_price_type_count <= 1) {
153 153
                 $wpdb->insert(
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
                         'PRT_wp_user'    => $default_creator_id,
162 162
                     ),
163 163
                     array(
164
-                        '%s',// PRT_name
165
-                        '%d',// PBT_id
166
-                        '%d',// PRT_is_percent
167
-                        '%d',// PRT_order
168
-                        '%d',// PRT_deleted
164
+                        '%s', // PRT_name
165
+                        '%d', // PBT_id
166
+                        '%d', // PRT_is_percent
167
+                        '%d', // PRT_order
168
+                        '%d', // PRT_deleted
169 169
                         '%d', // PRT_wp_user
170 170
                     )
171 171
                 );
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
                         'PRT_wp_user'    => $default_creator_id,
182 182
                     ),
183 183
                     array(
184
-                        '%s',// PRT_name
185
-                        '%d',// PBT_id
186
-                        '%d',// PRT_is_percent
187
-                        '%d',// PRT_order
188
-                        '%d',// PRT_deleted
184
+                        '%s', // PRT_name
185
+                        '%d', // PBT_id
186
+                        '%d', // PRT_is_percent
187
+                        '%d', // PRT_order
188
+                        '%d', // PRT_deleted
189 189
                         '%d' // PRT_wp_user
190 190
                     )
191 191
                 );
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
                             'PRC_wp_user'    => $default_creator_id,
206 206
                         ),
207 207
                         array(
208
-                            '%d',// PRT_id
209
-                            '%f',// PRC_amount
210
-                            '%s',// PRC_name
211
-                            '%s',// PRC_desc
212
-                            '%d',// PRC_is_default
213
-                            '%d',// PRC_overrides
214
-                            '%d',// PRC_deleted
215
-                            '%d',// PRC_order
216
-                            '%d',// PRC_parent
208
+                            '%d', // PRT_id
209
+                            '%f', // PRC_amount
210
+                            '%s', // PRC_name
211
+                            '%s', // PRC_desc
212
+                            '%d', // PRC_is_default
213
+                            '%d', // PRC_overrides
214
+                            '%d', // PRC_deleted
215
+                            '%d', // PRC_order
216
+                            '%d', // PRC_parent
217 217
                             '%d' // PRC_wp_user
218 218
                         )
219 219
                     );
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public function caffeinated_modules_to_register($modules_to_register = array())
234 234
     {
235
-        if (is_readable(EE_CAFF_PATH . 'modules')) {
236
-            $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules/*', GLOB_ONLYDIR);
235
+        if (is_readable(EE_CAFF_PATH.'modules')) {
236
+            $caffeinated_modules_to_register = glob(EE_CAFF_PATH.'modules/*', GLOB_ONLYDIR);
237 237
             if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
238 238
                 $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
239 239
             }
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Pricing_Admin_Page_Init.core.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,52 +14,52 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /**
18
-     *        constructor
19
-     *
20
-     * @Constructor
21
-     * @access public
22
-     * @return Pricing_Admin_Page_Init
23
-     */
24
-    public function __construct()
25
-    {
17
+	/**
18
+	 *        constructor
19
+	 *
20
+	 * @Constructor
21
+	 * @access public
22
+	 * @return Pricing_Admin_Page_Init
23
+	 */
24
+	public function __construct()
25
+	{
26 26
 
27
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
27
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
28 28
 
29
-        define('PRICING_PG_SLUG', 'pricing');
30
-        define('PRICING_LABEL', __('Pricing', 'event_espresso'));
31
-        define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG)));
32
-        define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/');
33
-        define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG));
34
-        define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/');
35
-        define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/');
36
-        define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/');
37
-        define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/');
29
+		define('PRICING_PG_SLUG', 'pricing');
30
+		define('PRICING_LABEL', __('Pricing', 'event_espresso'));
31
+		define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG)));
32
+		define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/');
33
+		define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG));
34
+		define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/');
35
+		define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/');
36
+		define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/');
37
+		define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/');
38 38
 
39
-        parent::__construct();
40
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/';
41
-    }
39
+		parent::__construct();
40
+		$this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/';
41
+	}
42 42
 
43 43
 
44
-    protected function _set_init_properties()
45
-    {
46
-        $this->label = PRICING_LABEL;
47
-    }
44
+	protected function _set_init_properties()
45
+	{
46
+		$this->label = PRICING_LABEL;
47
+	}
48 48
 
49 49
 
50
-    protected function _set_menu_map()
51
-    {
52
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
53
-            array(
54
-                'menu_group'      => 'management',
55
-                'menu_order'      => 20,
56
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
57
-                'parent_slug'     => 'espresso_events',
58
-                'menu_slug'       => PRICING_PG_SLUG,
59
-                'menu_label'      => PRICING_LABEL,
60
-                'capability'      => 'ee_read_default_prices',
61
-                'admin_init_page' => $this,
62
-            )
63
-        );
64
-    }
50
+	protected function _set_menu_map()
51
+	{
52
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
53
+			array(
54
+				'menu_group'      => 'management',
55
+				'menu_order'      => 20,
56
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
57
+				'parent_slug'     => 'espresso_events',
58
+				'menu_slug'       => PRICING_PG_SLUG,
59
+				'menu_label'      => PRICING_LABEL,
60
+				'capability'      => 'ee_read_default_prices',
61
+				'admin_init_page' => $this,
62
+			)
63
+		);
64
+	}
65 65
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
         define('PRICING_PG_SLUG', 'pricing');
30 30
         define('PRICING_LABEL', __('Pricing', 'event_espresso'));
31 31
         define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG)));
32
-        define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/');
33
-        define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG));
34
-        define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/');
35
-        define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/');
36
-        define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/');
37
-        define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/');
32
+        define('PRICING_ADMIN', EE_CORE_CAF_ADMIN.'new/'.PRICING_PG_SLUG.'/');
33
+        define('PRICING_ADMIN_URL', admin_url('admin.php?page='.PRICING_PG_SLUG));
34
+        define('PRICING_ASSETS_PATH', PRICING_ADMIN.'assets/');
35
+        define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL.'new/'.PRICING_PG_SLUG.'/assets/');
36
+        define('PRICING_TEMPLATE_PATH', PRICING_ADMIN.'templates/');
37
+        define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL.'new/'.PRICING_PG_SLUG.'/templates/');
38 38
 
39 39
         parent::__construct();
40
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/';
40
+        $this->_folder_path = EE_CORE_CAF_ADMIN.'new/'.$this->_folder_name.'/';
41 41
     }
42 42
 
43 43
 
Please login to merge, or discard this patch.
caffeinated/admin/new/tickets/Tickets_Admin_Page_Init.core.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -28,51 +28,51 @@
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    /**
32
-     *        constructor
33
-     *
34
-     * @Constructor
35
-     * @access public
36
-     * @return void
37
-     */
38
-    public function __construct()
39
-    {
31
+	/**
32
+	 *        constructor
33
+	 *
34
+	 * @Constructor
35
+	 * @access public
36
+	 * @return void
37
+	 */
38
+	public function __construct()
39
+	{
40 40
 
41
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
41
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
42 42
 
43
-        define('TICKETS_PG_SLUG', 'tickets');
44
-        define('TICKETS_LABEL', __('Default Tickets', 'event_espresso'));
45
-        define('TICKETS_ADMIN', EE_CORE_CAF_ADMIN . 'new/'. TICKETS_PG_SLUG . '/');
46
-        define('TICKETS_ADMIN_URL', admin_url('admin.php?page=' . TICKETS_PG_SLUG));
47
-        define('TICKETS_ASSETS_PATH', TICKETS_ADMIN . 'assets/');
48
-        define('TICKETS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/'. TICKETS_PG_SLUG . '/assets/');
49
-        define('TICKETS_TEMPLATE_PATH', TICKETS_ADMIN . 'templates/');
50
-        define('TICKETS_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/'. TICKETS_PG_SLUG . '/templates/');
43
+		define('TICKETS_PG_SLUG', 'tickets');
44
+		define('TICKETS_LABEL', __('Default Tickets', 'event_espresso'));
45
+		define('TICKETS_ADMIN', EE_CORE_CAF_ADMIN . 'new/'. TICKETS_PG_SLUG . '/');
46
+		define('TICKETS_ADMIN_URL', admin_url('admin.php?page=' . TICKETS_PG_SLUG));
47
+		define('TICKETS_ASSETS_PATH', TICKETS_ADMIN . 'assets/');
48
+		define('TICKETS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/'. TICKETS_PG_SLUG . '/assets/');
49
+		define('TICKETS_TEMPLATE_PATH', TICKETS_ADMIN . 'templates/');
50
+		define('TICKETS_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/'. TICKETS_PG_SLUG . '/templates/');
51 51
 
52
-        parent::__construct();
53
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/'. $this->_folder_name . DS;
54
-    }
52
+		parent::__construct();
53
+		$this->_folder_path = EE_CORE_CAF_ADMIN . 'new/'. $this->_folder_name . DS;
54
+	}
55 55
 
56 56
 
57
-    protected function _set_init_properties()
58
-    {
59
-        $this->label = TICKETS_LABEL;
60
-    }
57
+	protected function _set_init_properties()
58
+	{
59
+		$this->label = TICKETS_LABEL;
60
+	}
61 61
 
62 62
 
63
-    protected function _set_menu_map()
64
-    {
65
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
66
-            array(
67
-                'menu_group'      => 'management',
68
-                'menu_order'      => 15,
69
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
70
-                'parent_slug'     => 'espresso_events',
71
-                'menu_slug'       => TICKETS_PG_SLUG,
72
-                'menu_label'      => TICKETS_LABEL,
73
-                'capability'      => 'ee_read_default_tickets',
74
-                'admin_init_page' => $this,
75
-            )
76
-        );
77
-    }
63
+	protected function _set_menu_map()
64
+	{
65
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
66
+			array(
67
+				'menu_group'      => 'management',
68
+				'menu_order'      => 15,
69
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
70
+				'parent_slug'     => 'espresso_events',
71
+				'menu_slug'       => TICKETS_PG_SLUG,
72
+				'menu_label'      => TICKETS_LABEL,
73
+				'capability'      => 'ee_read_default_tickets',
74
+				'admin_init_page' => $this,
75
+			)
76
+		);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@
 block discarded – undo
42 42
 
43 43
         define('TICKETS_PG_SLUG', 'tickets');
44 44
         define('TICKETS_LABEL', __('Default Tickets', 'event_espresso'));
45
-        define('TICKETS_ADMIN', EE_CORE_CAF_ADMIN . 'new/'. TICKETS_PG_SLUG . '/');
46
-        define('TICKETS_ADMIN_URL', admin_url('admin.php?page=' . TICKETS_PG_SLUG));
47
-        define('TICKETS_ASSETS_PATH', TICKETS_ADMIN . 'assets/');
48
-        define('TICKETS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/'. TICKETS_PG_SLUG . '/assets/');
49
-        define('TICKETS_TEMPLATE_PATH', TICKETS_ADMIN . 'templates/');
50
-        define('TICKETS_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/'. TICKETS_PG_SLUG . '/templates/');
45
+        define('TICKETS_ADMIN', EE_CORE_CAF_ADMIN.'new/'.TICKETS_PG_SLUG.'/');
46
+        define('TICKETS_ADMIN_URL', admin_url('admin.php?page='.TICKETS_PG_SLUG));
47
+        define('TICKETS_ASSETS_PATH', TICKETS_ADMIN.'assets/');
48
+        define('TICKETS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL.'new/'.TICKETS_PG_SLUG.'/assets/');
49
+        define('TICKETS_TEMPLATE_PATH', TICKETS_ADMIN.'templates/');
50
+        define('TICKETS_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL.'new/'.TICKETS_PG_SLUG.'/templates/');
51 51
 
52 52
         parent::__construct();
53
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/'. $this->_folder_name . DS;
53
+        $this->_folder_path = EE_CORE_CAF_ADMIN.'new/'.$this->_folder_name.DS;
54 54
     }
55 55
 
56 56
 
Please login to merge, or discard this patch.
admin/extend/registration_form/Extend_Registration_Form_Admin_Page.core.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public function __construct($routing = true)
21 21
     {
22
-        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/');
23
-        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/');
24
-        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
25
-        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/');
26
-        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
22
+        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form/');
23
+        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets/');
24
+        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/');
25
+        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates/');
26
+        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/');
27 27
         parent::__construct($routing);
28 28
     }
29 29
 
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     {
363 363
         wp_register_script(
364 364
             'ee-question-sortable',
365
-            REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
365
+            REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js',
366 366
             array('jquery-ui-sortable'),
367 367
             EVENT_ESPRESSO_VERSION,
368 368
             true
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
      */
449 449
     protected function _questions_overview_list_table()
450 450
     {
451
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
451
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
452 452
             'add_question',
453 453
             'add_question',
454 454
             array(),
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
     protected function _question_groups_overview_list_table()
470 470
     {
471 471
         $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
472
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
472
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
473 473
             'add_question_group',
474 474
             'add_question_group',
475 475
             array(),
@@ -531,18 +531,18 @@  discard block
 block discarded – undo
531 531
     {
532 532
         $success = 0;
533 533
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
534
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
534
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
535 535
             // if array has more than one element than success message should be plural
536 536
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
537 537
             // cycle thru bulk action checkboxes
538 538
             while (list($ID, $value) = each($this->_req_data['checkbox'])) {
539
-                if (! $this->_delete_item($ID, $model)) {
539
+                if ( ! $this->_delete_item($ID, $model)) {
540 540
                     $success = 0;
541 541
                 }
542 542
             }
543
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
543
+        } elseif ( ! empty($this->_req_data['QSG_ID'])) {
544 544
             $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
545
-        } elseif (! empty($this->_req_data['QST_ID'])) {
545
+        } elseif ( ! empty($this->_req_data['QST_ID'])) {
546 546
             $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
547 547
         } else {
548 548
             EE_Error::add_error(
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
612 612
         }
613 613
         // add ID to title if editing
614
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
614
+        $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
615 615
         if ($ID) {
616 616
             /** @var EE_Question_Group $questionGroup */
617 617
             $questionGroup = $this->_question_group_model->get_one_by_ID($ID);
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
         $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
632 632
         $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
633 633
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
634
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
634
+            REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php',
635 635
             $this->_template_args,
636 636
             true
637 637
         );
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
         // update the existing related questions
710 710
         // BUT FIRST...  delete the phone question from the Question_Group_Question
711 711
         // if it is being added to this question group (therefore removed from the existing group)
712
-        if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
712
+        if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) {
713 713
             // delete where QST ID = system phone question ID and Question Group ID is NOT this group
714 714
             EEM_Question_Group_Question::instance()->delete(
715 715
                 array(
@@ -724,22 +724,22 @@  discard block
 block discarded – undo
724 724
         $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
725 725
         $questions = $question_group->questions();
726 726
         // make sure system phone question is added to list of questions for this group
727
-        if (! isset($questions[ $phone_question_id ])) {
728
-            $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
727
+        if ( ! isset($questions[$phone_question_id])) {
728
+            $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
729 729
         }
730 730
 
731 731
         foreach ($questions as $question_ID => $question) {
732 732
             // first we always check for order.
733
-            if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
733
+            if ( ! empty($this->_req_data['question_orders'][$question_ID])) {
734 734
                 // update question order
735 735
                 $question_group->update_question_order(
736 736
                     $question_ID,
737
-                    $this->_req_data['question_orders'][ $question_ID ]
737
+                    $this->_req_data['question_orders'][$question_ID]
738 738
                 );
739 739
             }
740 740
 
741 741
             // then we always check if adding or removing.
742
-            if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
742
+            if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) {
743 743
                 $question_group->add_question($question_ID);
744 744
             } else {
745 745
                 // not found, remove it (but only if not a system question for the personal group
@@ -760,8 +760,8 @@  discard block
 block discarded – undo
760 760
         if (isset($this->_req_data['questions'])) {
761 761
             foreach ($this->_req_data['questions'] as $QST_ID) {
762 762
                 $question_group->add_question($QST_ID);
763
-                if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
764
-                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
763
+                if (isset($this->_req_data['question_orders'][$QST_ID])) {
764
+                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]);
765 765
                 }
766 766
             }
767 767
         }
@@ -902,33 +902,33 @@  discard block
 block discarded – undo
902 902
         // echo "trash $trash";
903 903
         // var_dump($this->_req_data['checkbox']);die;
904 904
         if (isset($this->_req_data['checkbox'])) {
905
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
905
+            if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
906 906
                 // if array has more than one element than success message should be plural
907 907
                 $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
908 908
                 // cycle thru bulk action checkboxes
909 909
                 while (list($ID, $value) = each($this->_req_data['checkbox'])) {
910
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
910
+                    if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) {
911 911
                         $success = 0;
912 912
                     }
913 913
                 }
914 914
             } else {
915 915
                 // grab single id and delete
916 916
                 $ID = absint($this->_req_data['checkbox']);
917
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
917
+                if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
918 918
                     $success = 0;
919 919
                 }
920 920
             }
921 921
         } else {
922 922
             // delete via trash link
923 923
             // grab single id and delete
924
-            $ID = absint($this->_req_data[ $model->primary_key_name() ]);
925
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
924
+            $ID = absint($this->_req_data[$model->primary_key_name()]);
925
+            if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
926 926
                 $success = 0;
927 927
             }
928 928
         }
929 929
 
930 930
 
931
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
931
+        $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; // strtolower( $model->item_name(2) );
932 932
         // echo "action :$action";
933 933
         // $action = 'questions' ? 'default' : $action;
934 934
         if ($trash) {
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
             ? (int) $this->_req_data['curpage']
1049 1049
             : null;
1050 1050
 
1051
-        if (! empty($row_ids)) {
1051
+        if ( ! empty($row_ids)) {
1052 1052
             // figure out where we start the row_id count at for the current page.
1053 1053
             $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1054 1054
 
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
                 // Update the questions when re-ordering
1058 1058
                 $updated = EEM_Question_Group::instance()->update(
1059 1059
                     array('QSG_order' => $qsgcount),
1060
-                    array(array('QSG_ID' => $row_ids[ $i ]))
1060
+                    array(array('QSG_ID' => $row_ids[$i]))
1061 1061
                 );
1062 1062
                 if ($updated === false) {
1063 1063
                     $success = false;
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
         $this->_set_add_edit_form_tags('update_reg_form_settings');
1104 1104
         $this->_set_publish_post_box_vars(null, false, false, null, false);
1105 1105
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1106
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1106
+            REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php',
1107 1107
             $this->_template_args,
1108 1108
             true
1109 1109
         );
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
                                 $prev_email_validation_level = 'basic';
1241 1241
                             }
1242 1242
                             // confirm our i18n email validation will work on the server
1243
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1243
+                            if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1244 1244
                                 // or reset email validation level to previous value
1245 1245
                                 $email_validation_level = $prev_email_validation_level;
1246 1246
                             }
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
     private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1287 1287
     {
1288 1288
         // first check that PCRE is enabled
1289
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1289
+        if ( ! defined('PREG_BAD_UTF8_ERROR')) {
1290 1290
             EE_Error::add_error(
1291 1291
                 sprintf(
1292 1292
                     esc_html__(
Please login to merge, or discard this patch.
Indentation   +1433 added lines, -1433 removed lines patch added patch discarded remove patch
@@ -14,1437 +14,1437 @@
 block discarded – undo
14 14
 class Extend_Registration_Form_Admin_Page extends Registration_Form_Admin_Page
15 15
 {
16 16
 
17
-    /**
18
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
19
-     */
20
-    public function __construct($routing = true)
21
-    {
22
-        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/');
23
-        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/');
24
-        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
25
-        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/');
26
-        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
27
-        parent::__construct($routing);
28
-    }
29
-
30
-
31
-    /**
32
-     * @return void
33
-     */
34
-    protected function _extend_page_config()
35
-    {
36
-        $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
37
-        $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID'])
38
-            ? $this->_req_data['QST_ID'] : 0;
39
-        $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID'])
40
-            ? $this->_req_data['QSG_ID'] : 0;
41
-
42
-        $new_page_routes = array(
43
-            'question_groups'    => array(
44
-                'func'       => '_question_groups_overview_list_table',
45
-                'capability' => 'ee_read_question_groups',
46
-            ),
47
-            'add_question'       => array(
48
-                'func'       => '_edit_question',
49
-                'capability' => 'ee_edit_questions',
50
-            ),
51
-            'insert_question'    => array(
52
-                'func'       => '_insert_or_update_question',
53
-                'args'       => array('new_question' => true),
54
-                'capability' => 'ee_edit_questions',
55
-                'noheader'   => true,
56
-            ),
57
-            'duplicate_question' => array(
58
-                'func'       => '_duplicate_question',
59
-                'capability' => 'ee_edit_questions',
60
-                'noheader'   => true,
61
-            ),
62
-            'trash_question'     => array(
63
-                'func'       => '_trash_question',
64
-                'capability' => 'ee_delete_question',
65
-                'obj_id'     => $qst_id,
66
-                'noheader'   => true,
67
-            ),
68
-
69
-            'restore_question' => array(
70
-                'func'       => '_trash_or_restore_questions',
71
-                'capability' => 'ee_delete_question',
72
-                'obj_id'     => $qst_id,
73
-                'args'       => array('trash' => false),
74
-                'noheader'   => true,
75
-            ),
76
-
77
-            'delete_question' => array(
78
-                'func'       => '_delete_question',
79
-                'capability' => 'ee_delete_question',
80
-                'obj_id'     => $qst_id,
81
-                'noheader'   => true,
82
-            ),
83
-
84
-            'trash_questions' => array(
85
-                'func'       => '_trash_or_restore_questions',
86
-                'capability' => 'ee_delete_questions',
87
-                'args'       => array('trash' => true),
88
-                'noheader'   => true,
89
-            ),
90
-
91
-            'restore_questions' => array(
92
-                'func'       => '_trash_or_restore_questions',
93
-                'capability' => 'ee_delete_questions',
94
-                'args'       => array('trash' => false),
95
-                'noheader'   => true,
96
-            ),
97
-
98
-            'delete_questions' => array(
99
-                'func'       => '_delete_questions',
100
-                'args'       => array(),
101
-                'capability' => 'ee_delete_questions',
102
-                'noheader'   => true,
103
-            ),
104
-
105
-            'add_question_group' => array(
106
-                'func'       => '_edit_question_group',
107
-                'capability' => 'ee_edit_question_groups',
108
-            ),
109
-
110
-            'edit_question_group' => array(
111
-                'func'       => '_edit_question_group',
112
-                'capability' => 'ee_edit_question_group',
113
-                'obj_id'     => $qsg_id,
114
-                'args'       => array('edit'),
115
-            ),
116
-
117
-            'delete_question_groups' => array(
118
-                'func'       => '_delete_question_groups',
119
-                'capability' => 'ee_delete_question_groups',
120
-                'noheader'   => true,
121
-            ),
122
-
123
-            'delete_question_group' => array(
124
-                'func'       => '_delete_question_groups',
125
-                'capability' => 'ee_delete_question_group',
126
-                'obj_id'     => $qsg_id,
127
-                'noheader'   => true,
128
-            ),
129
-
130
-            'trash_question_group' => array(
131
-                'func'       => '_trash_or_restore_question_groups',
132
-                'args'       => array('trash' => true),
133
-                'capability' => 'ee_delete_question_group',
134
-                'obj_id'     => $qsg_id,
135
-                'noheader'   => true,
136
-            ),
137
-
138
-            'restore_question_group' => array(
139
-                'func'       => '_trash_or_restore_question_groups',
140
-                'args'       => array('trash' => false),
141
-                'capability' => 'ee_delete_question_group',
142
-                'obj_id'     => $qsg_id,
143
-                'noheader'   => true,
144
-            ),
145
-
146
-            'insert_question_group' => array(
147
-                'func'       => '_insert_or_update_question_group',
148
-                'args'       => array('new_question_group' => true),
149
-                'capability' => 'ee_edit_question_groups',
150
-                'noheader'   => true,
151
-            ),
152
-
153
-            'update_question_group' => array(
154
-                'func'       => '_insert_or_update_question_group',
155
-                'args'       => array('new_question_group' => false),
156
-                'capability' => 'ee_edit_question_group',
157
-                'obj_id'     => $qsg_id,
158
-                'noheader'   => true,
159
-            ),
160
-
161
-            'trash_question_groups' => array(
162
-                'func'       => '_trash_or_restore_question_groups',
163
-                'args'       => array('trash' => true),
164
-                'capability' => 'ee_delete_question_groups',
165
-                'noheader'   => array('trash' => false),
166
-            ),
167
-
168
-            'restore_question_groups' => array(
169
-                'func'       => '_trash_or_restore_question_groups',
170
-                'args'       => array('trash' => false),
171
-                'capability' => 'ee_delete_question_groups',
172
-                'noheader'   => true,
173
-            ),
174
-
175
-
176
-            'espresso_update_question_group_order' => array(
177
-                'func'       => 'update_question_group_order',
178
-                'capability' => 'ee_edit_question_groups',
179
-                'noheader'   => true,
180
-            ),
181
-
182
-            'view_reg_form_settings' => array(
183
-                'func'       => '_reg_form_settings',
184
-                'capability' => 'manage_options',
185
-            ),
186
-
187
-            'update_reg_form_settings' => array(
188
-                'func'       => '_update_reg_form_settings',
189
-                'capability' => 'manage_options',
190
-                'noheader'   => true,
191
-            ),
192
-        );
193
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
194
-
195
-        $new_page_config = array(
196
-
197
-            'question_groups' => array(
198
-                'nav'           => array(
199
-                    'label' => esc_html__('Question Groups', 'event_espresso'),
200
-                    'order' => 20,
201
-                ),
202
-                'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
203
-                'help_tabs'     => array(
204
-                    'registration_form_question_groups_help_tab'                           => array(
205
-                        'title'    => esc_html__('Question Groups', 'event_espresso'),
206
-                        'filename' => 'registration_form_question_groups',
207
-                    ),
208
-                    'registration_form_question_groups_table_column_headings_help_tab'     => array(
209
-                        'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
210
-                        'filename' => 'registration_form_question_groups_table_column_headings',
211
-                    ),
212
-                    'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
213
-                        'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
214
-                        'filename' => 'registration_form_question_groups_views_bulk_actions_search',
215
-                    ),
216
-                ),
217
-                'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
218
-                'metaboxes'     => $this->_default_espresso_metaboxes,
219
-                'require_nonce' => false,
220
-                'qtips'         => array(
221
-                    'EE_Registration_Form_Tips',
222
-                ),
223
-            ),
224
-
225
-            'add_question' => array(
226
-                'nav'           => array(
227
-                    'label'      => esc_html__('Add Question', 'event_espresso'),
228
-                    'order'      => 5,
229
-                    'persistent' => false,
230
-                ),
231
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
232
-                'help_tabs'     => array(
233
-                    'registration_form_add_question_help_tab' => array(
234
-                        'title'    => esc_html__('Add Question', 'event_espresso'),
235
-                        'filename' => 'registration_form_add_question',
236
-                    ),
237
-                ),
238
-                'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
239
-                'require_nonce' => false,
240
-            ),
241
-
242
-            'add_question_group' => array(
243
-                'nav'           => array(
244
-                    'label'      => esc_html__('Add Question Group', 'event_espresso'),
245
-                    'order'      => 5,
246
-                    'persistent' => false,
247
-                ),
248
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
249
-                'help_tabs'     => array(
250
-                    'registration_form_add_question_group_help_tab' => array(
251
-                        'title'    => esc_html__('Add Question Group', 'event_espresso'),
252
-                        'filename' => 'registration_form_add_question_group',
253
-                    ),
254
-                ),
255
-                'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
256
-                'require_nonce' => false,
257
-            ),
258
-
259
-            'edit_question_group' => array(
260
-                'nav'           => array(
261
-                    'label'      => esc_html__('Edit Question Group', 'event_espresso'),
262
-                    'order'      => 5,
263
-                    'persistent' => false,
264
-                    'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
265
-                        array('question_group_id' => $this->_req_data['question_group_id']),
266
-                        $this->_current_page_view_url
267
-                    ) : $this->_admin_base_url,
268
-                ),
269
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
270
-                'help_tabs'     => array(
271
-                    'registration_form_edit_question_group_help_tab' => array(
272
-                        'title'    => esc_html__('Edit Question Group', 'event_espresso'),
273
-                        'filename' => 'registration_form_edit_question_group',
274
-                    ),
275
-                ),
276
-                'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
277
-                'require_nonce' => false,
278
-            ),
279
-
280
-            'view_reg_form_settings' => array(
281
-                'nav'           => array(
282
-                    'label' => esc_html__('Reg Form Settings', 'event_espresso'),
283
-                    'order' => 40,
284
-                ),
285
-                'labels'        => array(
286
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
287
-                ),
288
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
289
-                'help_tabs'     => array(
290
-                    'registration_form_reg_form_settings_help_tab' => array(
291
-                        'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
292
-                        'filename' => 'registration_form_reg_form_settings',
293
-                    ),
294
-                ),
295
-                'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
296
-                'require_nonce' => false,
297
-            ),
298
-
299
-        );
300
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
301
-
302
-        // change the list table we're going to use so it's the NEW list table!
303
-        $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
304
-
305
-
306
-        // additional labels
307
-        $new_labels = array(
308
-            'add_question'          => esc_html__('Add New Question', 'event_espresso'),
309
-            'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
310
-            'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
311
-            'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
312
-            'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
313
-        );
314
-        $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
315
-    }
316
-
317
-
318
-    /**
319
-     * @return void
320
-     */
321
-    protected function _ajax_hooks()
322
-    {
323
-        add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
324
-    }
325
-
326
-
327
-    /**
328
-     * @return void
329
-     */
330
-    public function load_scripts_styles_question_groups()
331
-    {
332
-        wp_enqueue_script('espresso_ajax_table_sorting');
333
-    }
334
-
335
-
336
-    /**
337
-     * @return void
338
-     */
339
-    public function load_scripts_styles_add_question_group()
340
-    {
341
-        $this->load_scripts_styles_forms();
342
-        $this->load_sortable_question_script();
343
-    }
344
-
345
-
346
-    /**
347
-     * @return void
348
-     */
349
-    public function load_scripts_styles_edit_question_group()
350
-    {
351
-        $this->load_scripts_styles_forms();
352
-        $this->load_sortable_question_script();
353
-    }
354
-
355
-
356
-    /**
357
-     * registers and enqueues script for questions
358
-     *
359
-     * @return void
360
-     */
361
-    public function load_sortable_question_script()
362
-    {
363
-        wp_register_script(
364
-            'ee-question-sortable',
365
-            REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
366
-            array('jquery-ui-sortable'),
367
-            EVENT_ESPRESSO_VERSION,
368
-            true
369
-        );
370
-        wp_enqueue_script('ee-question-sortable');
371
-    }
372
-
373
-
374
-    /**
375
-     * @return void
376
-     */
377
-    protected function _set_list_table_views_default()
378
-    {
379
-        $this->_views = array(
380
-            'all' => array(
381
-                'slug'        => 'all',
382
-                'label'       => esc_html__('View All Questions', 'event_espresso'),
383
-                'count'       => 0,
384
-                'bulk_action' => array(
385
-                    'trash_questions' => esc_html__('Trash', 'event_espresso'),
386
-                ),
387
-            ),
388
-        );
389
-
390
-        if (EE_Registry::instance()->CAP->current_user_can(
391
-            'ee_delete_questions',
392
-            'espresso_registration_form_trash_questions'
393
-        )
394
-        ) {
395
-            $this->_views['trash'] = array(
396
-                'slug'        => 'trash',
397
-                'label'       => esc_html__('Trash', 'event_espresso'),
398
-                'count'       => 0,
399
-                'bulk_action' => array(
400
-                    'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
401
-                    'restore_questions' => esc_html__('Restore', 'event_espresso'),
402
-                ),
403
-            );
404
-        }
405
-    }
406
-
407
-
408
-    /**
409
-     * @return void
410
-     */
411
-    protected function _set_list_table_views_question_groups()
412
-    {
413
-        $this->_views = array(
414
-            'all' => array(
415
-                'slug'        => 'all',
416
-                'label'       => esc_html__('All', 'event_espresso'),
417
-                'count'       => 0,
418
-                'bulk_action' => array(
419
-                    'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
420
-                ),
421
-            ),
422
-        );
423
-
424
-        if (EE_Registry::instance()->CAP->current_user_can(
425
-            'ee_delete_question_groups',
426
-            'espresso_registration_form_trash_question_groups'
427
-        )
428
-        ) {
429
-            $this->_views['trash'] = array(
430
-                'slug'        => 'trash',
431
-                'label'       => esc_html__('Trash', 'event_espresso'),
432
-                'count'       => 0,
433
-                'bulk_action' => array(
434
-                    'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
435
-                    'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
436
-                ),
437
-            );
438
-        }
439
-    }
440
-
441
-
442
-    /**
443
-     * @return void
444
-     * @throws EE_Error
445
-     * @throws InvalidArgumentException
446
-     * @throws InvalidDataTypeException
447
-     * @throws InvalidInterfaceException
448
-     */
449
-    protected function _questions_overview_list_table()
450
-    {
451
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
452
-            'add_question',
453
-            'add_question',
454
-            array(),
455
-            'add-new-h2'
456
-        );
457
-        parent::_questions_overview_list_table();
458
-    }
459
-
460
-
461
-    /**
462
-     * @return void
463
-     * @throws DomainException
464
-     * @throws EE_Error
465
-     * @throws InvalidArgumentException
466
-     * @throws InvalidDataTypeException
467
-     * @throws InvalidInterfaceException
468
-     */
469
-    protected function _question_groups_overview_list_table()
470
-    {
471
-        $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
472
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
473
-            'add_question_group',
474
-            'add_question_group',
475
-            array(),
476
-            'add-new-h2'
477
-        );
478
-        $this->display_admin_list_table_page_with_sidebar();
479
-    }
480
-
481
-
482
-    /**
483
-     * @return void
484
-     * @throws EE_Error
485
-     * @throws InvalidArgumentException
486
-     * @throws InvalidDataTypeException
487
-     * @throws InvalidInterfaceException
488
-     */
489
-    protected function _delete_question()
490
-    {
491
-        $success = $this->_delete_items($this->_question_model);
492
-        $this->_redirect_after_action(
493
-            $success,
494
-            $this->_question_model->item_name($success),
495
-            'deleted',
496
-            array('action' => 'default', 'status' => 'all')
497
-        );
498
-    }
499
-
500
-
501
-    /**
502
-     * @return void
503
-     * @throws EE_Error
504
-     * @throws InvalidArgumentException
505
-     * @throws InvalidDataTypeException
506
-     * @throws InvalidInterfaceException
507
-     */
508
-    protected function _delete_questions()
509
-    {
510
-        $success = $this->_delete_items($this->_question_model);
511
-        $this->_redirect_after_action(
512
-            $success,
513
-            $this->_question_model->item_name($success),
514
-            'deleted permanently',
515
-            array('action' => 'default', 'status' => 'trash')
516
-        );
517
-    }
518
-
519
-
520
-    /**
521
-     * Performs the deletion of a single or multiple questions or question groups.
522
-     *
523
-     * @param EEM_Soft_Delete_Base $model
524
-     * @return int number of items deleted permanently
525
-     * @throws EE_Error
526
-     * @throws InvalidArgumentException
527
-     * @throws InvalidDataTypeException
528
-     * @throws InvalidInterfaceException
529
-     */
530
-    private function _delete_items(EEM_Soft_Delete_Base $model)
531
-    {
532
-        $success = 0;
533
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
534
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
535
-            // if array has more than one element than success message should be plural
536
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
537
-            // cycle thru bulk action checkboxes
538
-            while (list($ID, $value) = each($this->_req_data['checkbox'])) {
539
-                if (! $this->_delete_item($ID, $model)) {
540
-                    $success = 0;
541
-                }
542
-            }
543
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
544
-            $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
545
-        } elseif (! empty($this->_req_data['QST_ID'])) {
546
-            $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
547
-        } else {
548
-            EE_Error::add_error(
549
-                sprintf(
550
-                    esc_html__(
551
-                        "No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
552
-                        "event_espresso"
553
-                    )
554
-                ),
555
-                __FILE__,
556
-                __FUNCTION__,
557
-                __LINE__
558
-            );
559
-        }
560
-        return $success;
561
-    }
562
-
563
-
564
-    /**
565
-     * Deletes the specified question (and its associated question options) or question group
566
-     *
567
-     * @param int                  $id
568
-     * @param EEM_Soft_Delete_Base $model
569
-     * @return boolean
570
-     * @throws EE_Error
571
-     * @throws InvalidArgumentException
572
-     * @throws InvalidDataTypeException
573
-     * @throws InvalidInterfaceException
574
-     */
575
-    protected function _delete_item($id, $model)
576
-    {
577
-        if ($model instanceof EEM_Question) {
578
-            EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
579
-        }
580
-        return $model->delete_permanently_by_ID(absint($id));
581
-    }
582
-
583
-
584
-    /******************************    QUESTION GROUPS    ******************************/
585
-
586
-
587
-    /**
588
-     * @param string $type
589
-     * @return void
590
-     * @throws DomainException
591
-     * @throws EE_Error
592
-     * @throws InvalidArgumentException
593
-     * @throws InvalidDataTypeException
594
-     * @throws InvalidInterfaceException
595
-     */
596
-    protected function _edit_question_group($type = 'add')
597
-    {
598
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
599
-        $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
600
-            ? absint($this->_req_data['QSG_ID'])
601
-            : false;
602
-
603
-        switch ($this->_req_action) {
604
-            case 'add_question_group':
605
-                $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
606
-                break;
607
-            case 'edit_question_group':
608
-                $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
609
-                break;
610
-            default:
611
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
612
-        }
613
-        // add ID to title if editing
614
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
615
-        if ($ID) {
616
-            /** @var EE_Question_Group $questionGroup */
617
-            $questionGroup = $this->_question_group_model->get_one_by_ID($ID);
618
-            $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
619
-            $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
620
-        } else {
621
-            /** @var EE_Question_Group $questionGroup */
622
-            $questionGroup = EEM_Question_Group::instance()->create_default_object();
623
-            $questionGroup->set_order_to_latest();
624
-            $this->_set_add_edit_form_tags('insert_question_group');
625
-        }
626
-        $this->_template_args['values'] = $this->_yes_no_values;
627
-        $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
628
-        $this->_template_args['QSG_ID'] = $ID ? $ID : true;
629
-        $this->_template_args['question_group'] = $questionGroup;
630
-
631
-        $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
632
-        $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
633
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
634
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
635
-            $this->_template_args,
636
-            true
637
-        );
638
-
639
-        // the details template wrapper
640
-        $this->display_admin_page_with_sidebar();
641
-    }
642
-
643
-
644
-    /**
645
-     * @return void
646
-     * @throws EE_Error
647
-     * @throws InvalidArgumentException
648
-     * @throws InvalidDataTypeException
649
-     * @throws InvalidInterfaceException
650
-     */
651
-    protected function _delete_question_groups()
652
-    {
653
-        $success = $this->_delete_items($this->_question_group_model);
654
-        $this->_redirect_after_action(
655
-            $success,
656
-            $this->_question_group_model->item_name($success),
657
-            'deleted permanently',
658
-            array('action' => 'question_groups', 'status' => 'trash')
659
-        );
660
-    }
661
-
662
-
663
-    /**
664
-     * @param bool $new_question_group
665
-     * @throws EE_Error
666
-     * @throws InvalidArgumentException
667
-     * @throws InvalidDataTypeException
668
-     * @throws InvalidInterfaceException
669
-     */
670
-    protected function _insert_or_update_question_group($new_question_group = true)
671
-    {
672
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
673
-        $set_column_values = $this->_set_column_values_for($this->_question_group_model);
674
-        if ($new_question_group) {
675
-            // make sure identifier is unique
676
-            $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
677
-            $identifier_exists = ! empty($identifier_value)
678
-                ? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0
679
-                : false;
680
-            if ($identifier_exists) {
681
-                $set_column_values['QSG_identifier'] .= uniqid('id', true);
682
-            }
683
-            $QSG_ID = $this->_question_group_model->insert($set_column_values);
684
-            $success = $QSG_ID ? 1 : 0;
685
-            if ($success === 0) {
686
-                EE_Error::add_error(
687
-                    esc_html__('Something went wrong saving the question group.', 'event_espresso'),
688
-                    __FILE__,
689
-                    __FUNCTION__,
690
-                    __LINE__
691
-                );
692
-                $this->_redirect_after_action(
693
-                    false,
694
-                    '',
695
-                    '',
696
-                    array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
697
-                    true
698
-                );
699
-            }
700
-        } else {
701
-            $QSG_ID = absint($this->_req_data['QSG_ID']);
702
-            unset($set_column_values['QSG_ID']);
703
-            $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
704
-        }
705
-
706
-        $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
707
-            EEM_Attendee::system_question_phone
708
-        );
709
-        // update the existing related questions
710
-        // BUT FIRST...  delete the phone question from the Question_Group_Question
711
-        // if it is being added to this question group (therefore removed from the existing group)
712
-        if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
713
-            // delete where QST ID = system phone question ID and Question Group ID is NOT this group
714
-            EEM_Question_Group_Question::instance()->delete(
715
-                array(
716
-                    array(
717
-                        'QST_ID' => $phone_question_id,
718
-                        'QSG_ID' => array('!=', $QSG_ID),
719
-                    ),
720
-                )
721
-            );
722
-        }
723
-        /** @type EE_Question_Group $question_group */
724
-        $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
725
-        $questions = $question_group->questions();
726
-        // make sure system phone question is added to list of questions for this group
727
-        if (! isset($questions[ $phone_question_id ])) {
728
-            $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
729
-        }
730
-
731
-        foreach ($questions as $question_ID => $question) {
732
-            // first we always check for order.
733
-            if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
734
-                // update question order
735
-                $question_group->update_question_order(
736
-                    $question_ID,
737
-                    $this->_req_data['question_orders'][ $question_ID ]
738
-                );
739
-            }
740
-
741
-            // then we always check if adding or removing.
742
-            if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
743
-                $question_group->add_question($question_ID);
744
-            } else {
745
-                // not found, remove it (but only if not a system question for the personal group
746
-                // with the exception of lname system question - we allow removal of it)
747
-                if (in_array(
748
-                    $question->system_ID(),
749
-                    EEM_Question::instance()->required_system_questions_in_system_question_group(
750
-                        $question_group->system_group()
751
-                    )
752
-                )) {
753
-                    continue;
754
-                } else {
755
-                    $question_group->remove_question($question_ID);
756
-                }
757
-            }
758
-        }
759
-        // save new related questions
760
-        if (isset($this->_req_data['questions'])) {
761
-            foreach ($this->_req_data['questions'] as $QST_ID) {
762
-                $question_group->add_question($QST_ID);
763
-                if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
764
-                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
765
-                }
766
-            }
767
-        }
768
-
769
-        if ($success !== false) {
770
-            $msg = $new_question_group
771
-                ? sprintf(
772
-                    esc_html__('The %s has been created', 'event_espresso'),
773
-                    $this->_question_group_model->item_name()
774
-                )
775
-                : sprintf(
776
-                    esc_html__(
777
-                        'The %s has been updated',
778
-                        'event_espresso'
779
-                    ),
780
-                    $this->_question_group_model->item_name()
781
-                );
782
-            EE_Error::add_success($msg);
783
-        }
784
-        $this->_redirect_after_action(
785
-            false,
786
-            '',
787
-            '',
788
-            array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
789
-            true
790
-        );
791
-    }
792
-
793
-
794
-    /**
795
-     * duplicates a question and all its question options and redirects to the new question.
796
-     *
797
-     * @return void
798
-     * @throws EE_Error
799
-     * @throws InvalidArgumentException
800
-     * @throws ReflectionException
801
-     * @throws InvalidDataTypeException
802
-     * @throws InvalidInterfaceException
803
-     */
804
-    public function _duplicate_question()
805
-    {
806
-        $question_ID = (int) $this->_req_data['QST_ID'];
807
-        $question = EEM_Question::instance()->get_one_by_ID($question_ID);
808
-        if ($question instanceof EE_Question) {
809
-            $new_question = $question->duplicate();
810
-            if ($new_question instanceof EE_Question) {
811
-                $this->_redirect_after_action(
812
-                    true,
813
-                    esc_html__('Question', 'event_espresso'),
814
-                    esc_html__('Duplicated', 'event_espresso'),
815
-                    array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
816
-                    true
817
-                );
818
-            } else {
819
-                global $wpdb;
820
-                EE_Error::add_error(
821
-                    sprintf(
822
-                        esc_html__(
823
-                            'Could not duplicate question with ID %1$d because: %2$s',
824
-                            'event_espresso'
825
-                        ),
826
-                        $question_ID,
827
-                        $wpdb->last_error
828
-                    ),
829
-                    __FILE__,
830
-                    __FUNCTION__,
831
-                    __LINE__
832
-                );
833
-                $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
834
-            }
835
-        } else {
836
-            EE_Error::add_error(
837
-                sprintf(
838
-                    esc_html__(
839
-                        'Could not duplicate question with ID %d because it didn\'t exist!',
840
-                        'event_espresso'
841
-                    ),
842
-                    $question_ID
843
-                ),
844
-                __FILE__,
845
-                __FUNCTION__,
846
-                __LINE__
847
-            );
848
-            $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
849
-        }
850
-    }
851
-
852
-
853
-    /**
854
-     * @param bool $trash
855
-     * @throws EE_Error
856
-     */
857
-    protected function _trash_or_restore_question_groups($trash = true)
858
-    {
859
-        $this->_trash_or_restore_items($this->_question_group_model, $trash);
860
-    }
861
-
862
-
863
-    /**
864
-     *_trash_question
865
-     *
866
-     * @return void
867
-     * @throws EE_Error
868
-     */
869
-    protected function _trash_question()
870
-    {
871
-        $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
872
-        $query_args = array('action' => 'default', 'status' => 'all');
873
-        $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
874
-    }
875
-
876
-
877
-    /**
878
-     * @param bool $trash
879
-     * @throws EE_Error
880
-     */
881
-    protected function _trash_or_restore_questions($trash = true)
882
-    {
883
-        $this->_trash_or_restore_items($this->_question_model, $trash);
884
-    }
885
-
886
-
887
-    /**
888
-     * Internally used to delete or restore items, using the request data. Meant to be
889
-     * flexible between question or question groups
890
-     *
891
-     * @param EEM_Soft_Delete_Base $model
892
-     * @param boolean              $trash whether to trash or restore
893
-     * @throws EE_Error
894
-     */
895
-    private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
896
-    {
897
-
898
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
899
-
900
-        $success = 1;
901
-        // Checkboxes
902
-        // echo "trash $trash";
903
-        // var_dump($this->_req_data['checkbox']);die;
904
-        if (isset($this->_req_data['checkbox'])) {
905
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
906
-                // if array has more than one element than success message should be plural
907
-                $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
908
-                // cycle thru bulk action checkboxes
909
-                while (list($ID, $value) = each($this->_req_data['checkbox'])) {
910
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
911
-                        $success = 0;
912
-                    }
913
-                }
914
-            } else {
915
-                // grab single id and delete
916
-                $ID = absint($this->_req_data['checkbox']);
917
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
918
-                    $success = 0;
919
-                }
920
-            }
921
-        } else {
922
-            // delete via trash link
923
-            // grab single id and delete
924
-            $ID = absint($this->_req_data[ $model->primary_key_name() ]);
925
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
926
-                $success = 0;
927
-            }
928
-        }
929
-
930
-
931
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
932
-        // echo "action :$action";
933
-        // $action = 'questions' ? 'default' : $action;
934
-        if ($trash) {
935
-            $action_desc = 'trashed';
936
-            $status = 'trash';
937
-        } else {
938
-            $action_desc = 'restored';
939
-            $status = 'all';
940
-        }
941
-        $this->_redirect_after_action(
942
-            $success,
943
-            $model->item_name($success),
944
-            $action_desc,
945
-            array('action' => $action, 'status' => $status)
946
-        );
947
-    }
948
-
949
-
950
-    /**
951
-     * @param            $per_page
952
-     * @param int        $current_page
953
-     * @param bool|false $count
954
-     * @return EE_Soft_Delete_Base_Class[]|int
955
-     * @throws EE_Error
956
-     * @throws InvalidArgumentException
957
-     * @throws InvalidDataTypeException
958
-     * @throws InvalidInterfaceException
959
-     */
960
-    public function get_trashed_questions($per_page, $current_page = 1, $count = false)
961
-    {
962
-        $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
963
-
964
-        if ($count) {
965
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
966
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
967
-            $results = $this->_question_model->count_deleted($where);
968
-        } else {
969
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
970
-            $results = $this->_question_model->get_all_deleted($query_params);
971
-        }
972
-        return $results;
973
-    }
974
-
975
-
976
-    /**
977
-     * @param            $per_page
978
-     * @param int        $current_page
979
-     * @param bool|false $count
980
-     * @return EE_Soft_Delete_Base_Class[]|int
981
-     * @throws EE_Error
982
-     * @throws InvalidArgumentException
983
-     * @throws InvalidDataTypeException
984
-     * @throws InvalidInterfaceException
985
-     */
986
-    public function get_question_groups($per_page, $current_page = 1, $count = false)
987
-    {
988
-        $questionGroupModel = EEM_Question_Group::instance();
989
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
990
-        if ($count) {
991
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
992
-            $results = $questionGroupModel->count($where);
993
-        } else {
994
-            $results = $questionGroupModel->get_all($query_params);
995
-        }
996
-        return $results;
997
-    }
998
-
999
-
1000
-    /**
1001
-     * @param      $per_page
1002
-     * @param int  $current_page
1003
-     * @param bool $count
1004
-     * @return EE_Soft_Delete_Base_Class[]|int
1005
-     * @throws EE_Error
1006
-     * @throws InvalidArgumentException
1007
-     * @throws InvalidDataTypeException
1008
-     * @throws InvalidInterfaceException
1009
-     */
1010
-    public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1011
-    {
1012
-        $questionGroupModel = EEM_Question_Group::instance();
1013
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1014
-        if ($count) {
1015
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
1016
-            $query_params['limit'] = null;
1017
-            $results = $questionGroupModel->count_deleted($where);
1018
-        } else {
1019
-            $results = $questionGroupModel->get_all_deleted($query_params);
1020
-        }
1021
-        return $results;
1022
-    }
1023
-
1024
-
1025
-    /**
1026
-     * method for performing updates to question order
1027
-     *
1028
-     * @return void results array
1029
-     * @throws EE_Error
1030
-     * @throws InvalidArgumentException
1031
-     * @throws InvalidDataTypeException
1032
-     * @throws InvalidInterfaceException
1033
-     */
1034
-    public function update_question_group_order()
1035
-    {
1036
-
1037
-        $success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1038
-
1039
-        // grab our row IDs
1040
-        $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1041
-            ? explode(',', rtrim($this->_req_data['row_ids'], ','))
1042
-            : array();
1043
-
1044
-        $perpage = ! empty($this->_req_data['perpage'])
1045
-            ? (int) $this->_req_data['perpage']
1046
-            : null;
1047
-        $curpage = ! empty($this->_req_data['curpage'])
1048
-            ? (int) $this->_req_data['curpage']
1049
-            : null;
1050
-
1051
-        if (! empty($row_ids)) {
1052
-            // figure out where we start the row_id count at for the current page.
1053
-            $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1054
-
1055
-            $row_count = count($row_ids);
1056
-            for ($i = 0; $i < $row_count; $i++) {
1057
-                // Update the questions when re-ordering
1058
-                $updated = EEM_Question_Group::instance()->update(
1059
-                    array('QSG_order' => $qsgcount),
1060
-                    array(array('QSG_ID' => $row_ids[ $i ]))
1061
-                );
1062
-                if ($updated === false) {
1063
-                    $success = false;
1064
-                }
1065
-                $qsgcount++;
1066
-            }
1067
-        } else {
1068
-            $success = false;
1069
-        }
1070
-
1071
-        $errors = ! $success
1072
-            ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1073
-            : false;
1074
-
1075
-        echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1076
-        die();
1077
-    }
1078
-
1079
-
1080
-
1081
-    /***************************************       REGISTRATION SETTINGS       ***************************************/
1082
-
1083
-
1084
-    /**
1085
-     * @throws DomainException
1086
-     * @throws EE_Error
1087
-     * @throws InvalidArgumentException
1088
-     * @throws InvalidDataTypeException
1089
-     * @throws InvalidInterfaceException
1090
-     */
1091
-    protected function _reg_form_settings()
1092
-    {
1093
-        $this->_template_args['values'] = $this->_yes_no_values;
1094
-        add_action(
1095
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1096
-            array($this, 'email_validation_settings_form'),
1097
-            2
1098
-        );
1099
-        add_action(
1100
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1101
-            array($this, 'copy_attendee_info_settings_form'),
1102
-            4
1103
-        );
1104
-        $this->_template_args = (array) apply_filters(
1105
-            'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1106
-            $this->_template_args
1107
-        );
1108
-        $this->_set_add_edit_form_tags('update_reg_form_settings');
1109
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1110
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1111
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1112
-            $this->_template_args,
1113
-            true
1114
-        );
1115
-        $this->display_admin_page_with_sidebar();
1116
-    }
1117
-
1118
-
1119
-    /**
1120
-     * @return void
1121
-     * @throws EE_Error
1122
-     * @throws InvalidArgumentException
1123
-     * @throws ReflectionException
1124
-     * @throws InvalidDataTypeException
1125
-     * @throws InvalidInterfaceException
1126
-     */
1127
-    protected function _update_reg_form_settings()
1128
-    {
1129
-        EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1130
-            EE_Registry::instance()->CFG->registration
1131
-        );
1132
-        EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form(
1133
-            EE_Registry::instance()->CFG->registration
1134
-        );
1135
-        EE_Registry::instance()->CFG->registration = apply_filters(
1136
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1137
-            EE_Registry::instance()->CFG->registration
1138
-        );
1139
-        $success = $this->_update_espresso_configuration(
1140
-            esc_html__('Registration Form Options', 'event_espresso'),
1141
-            EE_Registry::instance()->CFG,
1142
-            __FILE__,
1143
-            __FUNCTION__,
1144
-            __LINE__
1145
-        );
1146
-        $this->_redirect_after_action(
1147
-            $success,
1148
-            esc_html__('Registration Form Options', 'event_espresso'),
1149
-            'updated',
1150
-            array('action' => 'view_reg_form_settings')
1151
-        );
1152
-    }
1153
-
1154
-
1155
-    /**
1156
-     * @return void
1157
-     * @throws EE_Error
1158
-     * @throws InvalidArgumentException
1159
-     * @throws InvalidDataTypeException
1160
-     * @throws InvalidInterfaceException
1161
-     */
1162
-    public function copy_attendee_info_settings_form()
1163
-    {
1164
-        echo $this->_copy_attendee_info_settings_form()->get_html();
1165
-    }
1166
-
1167
-    /**
1168
-     * _copy_attendee_info_settings_form
1169
-     *
1170
-     * @access protected
1171
-     * @return EE_Form_Section_Proper
1172
-     * @throws \EE_Error
1173
-     */
1174
-    protected function _copy_attendee_info_settings_form()
1175
-    {
1176
-        return new EE_Form_Section_Proper(
1177
-            array(
1178
-                'name'            => 'copy_attendee_info_settings',
1179
-                'html_id'         => 'copy_attendee_info_settings',
1180
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1181
-                'subsections'     => apply_filters(
1182
-                    'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections',
1183
-                    array(
1184
-                        'copy_attendee_info_hdr'   => new EE_Form_Section_HTML(
1185
-                            EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso'))
1186
-                        ),
1187
-                        'copy_attendee_info' => new EE_Yes_No_Input(
1188
-                            array(
1189
-                                'html_label_text' => esc_html__(
1190
-                                    'Allow copy #1 attendee info to extra attendees?',
1191
-                                    'event_espresso'
1192
-                                ),
1193
-                                'html_help_text'  => esc_html__(
1194
-                                    'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.',
1195
-                                    'event_espresso'
1196
-                                ),
1197
-                                'default'         => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(),
1198
-                                'required'        => false,
1199
-                                'display_html_label_text' => false,
1200
-                            )
1201
-                        ),
1202
-                    )
1203
-                ),
1204
-            )
1205
-        );
1206
-    }
1207
-
1208
-    /**
1209
-     * @param EE_Registration_Config $EE_Registration_Config
1210
-     * @return EE_Registration_Config
1211
-     * @throws EE_Error
1212
-     * @throws InvalidArgumentException
1213
-     * @throws ReflectionException
1214
-     * @throws InvalidDataTypeException
1215
-     * @throws InvalidInterfaceException
1216
-     */
1217
-    public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config)
1218
-    {
1219
-        $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo();
1220
-        try {
1221
-            $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form();
1222
-            // if not displaying a form, then check for form submission
1223
-            if ($copy_attendee_info_settings_form->was_submitted()) {
1224
-                // capture form data
1225
-                $copy_attendee_info_settings_form->receive_form_submission();
1226
-                // validate form data
1227
-                if ($copy_attendee_info_settings_form->is_valid()) {
1228
-                    // grab validated data from form
1229
-                    $valid_data = $copy_attendee_info_settings_form->valid_data();
1230
-                    if (isset($valid_data['copy_attendee_info'])) {
1231
-                        $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']);
1232
-                    } else {
1233
-                        EE_Error::add_error(
1234
-                            esc_html__(
1235
-                                'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.',
1236
-                                'event_espresso'
1237
-                            ),
1238
-                            __FILE__,
1239
-                            __FUNCTION__,
1240
-                            __LINE__
1241
-                        );
1242
-                    }
1243
-                } else {
1244
-                    if ($copy_attendee_info_settings_form->submission_error_message() !== '') {
1245
-                        EE_Error::add_error(
1246
-                            $copy_attendee_info_settings_form->submission_error_message(),
1247
-                            __FILE__,
1248
-                            __FUNCTION__,
1249
-                            __LINE__
1250
-                        );
1251
-                    }
1252
-                }
1253
-            }
1254
-        } catch (EE_Error $e) {
1255
-            $e->get_error();
1256
-        }
1257
-        return $EE_Registration_Config;
1258
-    }
1259
-
1260
-
1261
-    /**
1262
-     * @return void
1263
-     * @throws EE_Error
1264
-     * @throws InvalidArgumentException
1265
-     * @throws InvalidDataTypeException
1266
-     * @throws InvalidInterfaceException
1267
-     */
1268
-    public function email_validation_settings_form()
1269
-    {
1270
-        echo $this->_email_validation_settings_form()->get_html();
1271
-    }
1272
-
1273
-
1274
-    /**
1275
-     * _email_validation_settings_form
1276
-     *
1277
-     * @access protected
1278
-     * @return EE_Form_Section_Proper
1279
-     * @throws \EE_Error
1280
-     */
1281
-    protected function _email_validation_settings_form()
1282
-    {
1283
-        return new EE_Form_Section_Proper(
1284
-            array(
1285
-                'name'            => 'email_validation_settings',
1286
-                'html_id'         => 'email_validation_settings',
1287
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1288
-                'subsections'     => apply_filters(
1289
-                    'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1290
-                    array(
1291
-                        'email_validation_hdr'   => new EE_Form_Section_HTML(
1292
-                            EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1293
-                        ),
1294
-                        'email_validation_level' => new EE_Select_Input(
1295
-                            array(
1296
-                                'basic'      => esc_html__('Basic', 'event_espresso'),
1297
-                                'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1298
-                                'i18n'       => esc_html__('International', 'event_espresso'),
1299
-                                'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1300
-                            ),
1301
-                            array(
1302
-                                'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1303
-                                                     . EEH_Template::get_help_tab_link('email_validation_info'),
1304
-                                'html_help_text'  => esc_html__(
1305
-                                    'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
1306
-                                    'event_espresso'
1307
-                                ),
1308
-                                'default'         => isset(
1309
-                                    EE_Registry::instance()->CFG->registration->email_validation_level
1310
-                                )
1311
-                                    ? EE_Registry::instance()->CFG->registration->email_validation_level
1312
-                                    : 'wp_default',
1313
-                                'required'        => false,
1314
-                            )
1315
-                        ),
1316
-                    )
1317
-                ),
1318
-            )
1319
-        );
1320
-    }
1321
-
1322
-
1323
-    /**
1324
-     * @param EE_Registration_Config $EE_Registration_Config
1325
-     * @return EE_Registration_Config
1326
-     * @throws EE_Error
1327
-     * @throws InvalidArgumentException
1328
-     * @throws ReflectionException
1329
-     * @throws InvalidDataTypeException
1330
-     * @throws InvalidInterfaceException
1331
-     */
1332
-    public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1333
-    {
1334
-        $prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1335
-        try {
1336
-            $email_validation_settings_form = $this->_email_validation_settings_form();
1337
-            // if not displaying a form, then check for form submission
1338
-            if ($email_validation_settings_form->was_submitted()) {
1339
-                // capture form data
1340
-                $email_validation_settings_form->receive_form_submission();
1341
-                // validate form data
1342
-                if ($email_validation_settings_form->is_valid()) {
1343
-                    // grab validated data from form
1344
-                    $valid_data = $email_validation_settings_form->valid_data();
1345
-                    if (isset($valid_data['email_validation_level'])) {
1346
-                        $email_validation_level = $valid_data['email_validation_level'];
1347
-                        // now if they want to use international email addresses
1348
-                        if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1349
-                            // in case we need to reset their email validation level,
1350
-                            // make sure that the previous value wasn't already set to one of the i18n options.
1351
-                            if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1352
-                                // if so, then reset it back to "basic" since that is the only other option that,
1353
-                                // despite offering poor validation, supports i18n email addresses
1354
-                                $prev_email_validation_level = 'basic';
1355
-                            }
1356
-                            // confirm our i18n email validation will work on the server
1357
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1358
-                                // or reset email validation level to previous value
1359
-                                $email_validation_level = $prev_email_validation_level;
1360
-                            }
1361
-                        }
1362
-                        $EE_Registration_Config->email_validation_level = $email_validation_level;
1363
-                    } else {
1364
-                        EE_Error::add_error(
1365
-                            esc_html__(
1366
-                                'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1367
-                                'event_espresso'
1368
-                            ),
1369
-                            __FILE__,
1370
-                            __FUNCTION__,
1371
-                            __LINE__
1372
-                        );
1373
-                    }
1374
-                } else {
1375
-                    if ($email_validation_settings_form->submission_error_message() !== '') {
1376
-                        EE_Error::add_error(
1377
-                            $email_validation_settings_form->submission_error_message(),
1378
-                            __FILE__,
1379
-                            __FUNCTION__,
1380
-                            __LINE__
1381
-                        );
1382
-                    }
1383
-                }
1384
-            }
1385
-        } catch (EE_Error $e) {
1386
-            $e->get_error();
1387
-        }
1388
-        return $EE_Registration_Config;
1389
-    }
1390
-
1391
-
1392
-    /**
1393
-     * confirms that the server's PHP version has the PCRE module enabled,
1394
-     * and that the PCRE version works with our i18n email validation
1395
-     *
1396
-     * @param EE_Registration_Config $EE_Registration_Config
1397
-     * @param string                 $email_validation_level
1398
-     * @return bool
1399
-     */
1400
-    private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1401
-    {
1402
-        // first check that PCRE is enabled
1403
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1404
-            EE_Error::add_error(
1405
-                sprintf(
1406
-                    esc_html__(
1407
-                        'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1408
-                        'event_espresso'
1409
-                    ),
1410
-                    '<br />'
1411
-                ),
1412
-                __FILE__,
1413
-                __FUNCTION__,
1414
-                __LINE__
1415
-            );
1416
-            return false;
1417
-        } else {
1418
-            // PCRE support is enabled, but let's still
1419
-            // perform a test to see if the server will support it.
1420
-            // but first, save the updated validation level to the config,
1421
-            // so that the validation strategy picks it up.
1422
-            // this will get bumped back down if it doesn't work
1423
-            $EE_Registration_Config->email_validation_level = $email_validation_level;
1424
-            try {
1425
-                $email_validator = new EE_Email_Validation_Strategy();
1426
-                $i18n_email_address = apply_filters(
1427
-                    'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1428
-                    'jägerjü[email protected]'
1429
-                );
1430
-                $email_validator->validate($i18n_email_address);
1431
-            } catch (Exception $e) {
1432
-                EE_Error::add_error(
1433
-                    sprintf(
1434
-                        esc_html__(
1435
-                            'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1436
-                            'event_espresso'
1437
-                        ),
1438
-                        '<br />',
1439
-                        '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1440
-                    ),
1441
-                    __FILE__,
1442
-                    __FUNCTION__,
1443
-                    __LINE__
1444
-                );
1445
-                return false;
1446
-            }
1447
-        }
1448
-        return true;
1449
-    }
17
+	/**
18
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
19
+	 */
20
+	public function __construct($routing = true)
21
+	{
22
+		define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/');
23
+		define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/');
24
+		define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
25
+		define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/');
26
+		define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
27
+		parent::__construct($routing);
28
+	}
29
+
30
+
31
+	/**
32
+	 * @return void
33
+	 */
34
+	protected function _extend_page_config()
35
+	{
36
+		$this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
37
+		$qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID'])
38
+			? $this->_req_data['QST_ID'] : 0;
39
+		$qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID'])
40
+			? $this->_req_data['QSG_ID'] : 0;
41
+
42
+		$new_page_routes = array(
43
+			'question_groups'    => array(
44
+				'func'       => '_question_groups_overview_list_table',
45
+				'capability' => 'ee_read_question_groups',
46
+			),
47
+			'add_question'       => array(
48
+				'func'       => '_edit_question',
49
+				'capability' => 'ee_edit_questions',
50
+			),
51
+			'insert_question'    => array(
52
+				'func'       => '_insert_or_update_question',
53
+				'args'       => array('new_question' => true),
54
+				'capability' => 'ee_edit_questions',
55
+				'noheader'   => true,
56
+			),
57
+			'duplicate_question' => array(
58
+				'func'       => '_duplicate_question',
59
+				'capability' => 'ee_edit_questions',
60
+				'noheader'   => true,
61
+			),
62
+			'trash_question'     => array(
63
+				'func'       => '_trash_question',
64
+				'capability' => 'ee_delete_question',
65
+				'obj_id'     => $qst_id,
66
+				'noheader'   => true,
67
+			),
68
+
69
+			'restore_question' => array(
70
+				'func'       => '_trash_or_restore_questions',
71
+				'capability' => 'ee_delete_question',
72
+				'obj_id'     => $qst_id,
73
+				'args'       => array('trash' => false),
74
+				'noheader'   => true,
75
+			),
76
+
77
+			'delete_question' => array(
78
+				'func'       => '_delete_question',
79
+				'capability' => 'ee_delete_question',
80
+				'obj_id'     => $qst_id,
81
+				'noheader'   => true,
82
+			),
83
+
84
+			'trash_questions' => array(
85
+				'func'       => '_trash_or_restore_questions',
86
+				'capability' => 'ee_delete_questions',
87
+				'args'       => array('trash' => true),
88
+				'noheader'   => true,
89
+			),
90
+
91
+			'restore_questions' => array(
92
+				'func'       => '_trash_or_restore_questions',
93
+				'capability' => 'ee_delete_questions',
94
+				'args'       => array('trash' => false),
95
+				'noheader'   => true,
96
+			),
97
+
98
+			'delete_questions' => array(
99
+				'func'       => '_delete_questions',
100
+				'args'       => array(),
101
+				'capability' => 'ee_delete_questions',
102
+				'noheader'   => true,
103
+			),
104
+
105
+			'add_question_group' => array(
106
+				'func'       => '_edit_question_group',
107
+				'capability' => 'ee_edit_question_groups',
108
+			),
109
+
110
+			'edit_question_group' => array(
111
+				'func'       => '_edit_question_group',
112
+				'capability' => 'ee_edit_question_group',
113
+				'obj_id'     => $qsg_id,
114
+				'args'       => array('edit'),
115
+			),
116
+
117
+			'delete_question_groups' => array(
118
+				'func'       => '_delete_question_groups',
119
+				'capability' => 'ee_delete_question_groups',
120
+				'noheader'   => true,
121
+			),
122
+
123
+			'delete_question_group' => array(
124
+				'func'       => '_delete_question_groups',
125
+				'capability' => 'ee_delete_question_group',
126
+				'obj_id'     => $qsg_id,
127
+				'noheader'   => true,
128
+			),
129
+
130
+			'trash_question_group' => array(
131
+				'func'       => '_trash_or_restore_question_groups',
132
+				'args'       => array('trash' => true),
133
+				'capability' => 'ee_delete_question_group',
134
+				'obj_id'     => $qsg_id,
135
+				'noheader'   => true,
136
+			),
137
+
138
+			'restore_question_group' => array(
139
+				'func'       => '_trash_or_restore_question_groups',
140
+				'args'       => array('trash' => false),
141
+				'capability' => 'ee_delete_question_group',
142
+				'obj_id'     => $qsg_id,
143
+				'noheader'   => true,
144
+			),
145
+
146
+			'insert_question_group' => array(
147
+				'func'       => '_insert_or_update_question_group',
148
+				'args'       => array('new_question_group' => true),
149
+				'capability' => 'ee_edit_question_groups',
150
+				'noheader'   => true,
151
+			),
152
+
153
+			'update_question_group' => array(
154
+				'func'       => '_insert_or_update_question_group',
155
+				'args'       => array('new_question_group' => false),
156
+				'capability' => 'ee_edit_question_group',
157
+				'obj_id'     => $qsg_id,
158
+				'noheader'   => true,
159
+			),
160
+
161
+			'trash_question_groups' => array(
162
+				'func'       => '_trash_or_restore_question_groups',
163
+				'args'       => array('trash' => true),
164
+				'capability' => 'ee_delete_question_groups',
165
+				'noheader'   => array('trash' => false),
166
+			),
167
+
168
+			'restore_question_groups' => array(
169
+				'func'       => '_trash_or_restore_question_groups',
170
+				'args'       => array('trash' => false),
171
+				'capability' => 'ee_delete_question_groups',
172
+				'noheader'   => true,
173
+			),
174
+
175
+
176
+			'espresso_update_question_group_order' => array(
177
+				'func'       => 'update_question_group_order',
178
+				'capability' => 'ee_edit_question_groups',
179
+				'noheader'   => true,
180
+			),
181
+
182
+			'view_reg_form_settings' => array(
183
+				'func'       => '_reg_form_settings',
184
+				'capability' => 'manage_options',
185
+			),
186
+
187
+			'update_reg_form_settings' => array(
188
+				'func'       => '_update_reg_form_settings',
189
+				'capability' => 'manage_options',
190
+				'noheader'   => true,
191
+			),
192
+		);
193
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
194
+
195
+		$new_page_config = array(
196
+
197
+			'question_groups' => array(
198
+				'nav'           => array(
199
+					'label' => esc_html__('Question Groups', 'event_espresso'),
200
+					'order' => 20,
201
+				),
202
+				'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
203
+				'help_tabs'     => array(
204
+					'registration_form_question_groups_help_tab'                           => array(
205
+						'title'    => esc_html__('Question Groups', 'event_espresso'),
206
+						'filename' => 'registration_form_question_groups',
207
+					),
208
+					'registration_form_question_groups_table_column_headings_help_tab'     => array(
209
+						'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
210
+						'filename' => 'registration_form_question_groups_table_column_headings',
211
+					),
212
+					'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
213
+						'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
214
+						'filename' => 'registration_form_question_groups_views_bulk_actions_search',
215
+					),
216
+				),
217
+				'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
218
+				'metaboxes'     => $this->_default_espresso_metaboxes,
219
+				'require_nonce' => false,
220
+				'qtips'         => array(
221
+					'EE_Registration_Form_Tips',
222
+				),
223
+			),
224
+
225
+			'add_question' => array(
226
+				'nav'           => array(
227
+					'label'      => esc_html__('Add Question', 'event_espresso'),
228
+					'order'      => 5,
229
+					'persistent' => false,
230
+				),
231
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
232
+				'help_tabs'     => array(
233
+					'registration_form_add_question_help_tab' => array(
234
+						'title'    => esc_html__('Add Question', 'event_espresso'),
235
+						'filename' => 'registration_form_add_question',
236
+					),
237
+				),
238
+				'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
239
+				'require_nonce' => false,
240
+			),
241
+
242
+			'add_question_group' => array(
243
+				'nav'           => array(
244
+					'label'      => esc_html__('Add Question Group', 'event_espresso'),
245
+					'order'      => 5,
246
+					'persistent' => false,
247
+				),
248
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
249
+				'help_tabs'     => array(
250
+					'registration_form_add_question_group_help_tab' => array(
251
+						'title'    => esc_html__('Add Question Group', 'event_espresso'),
252
+						'filename' => 'registration_form_add_question_group',
253
+					),
254
+				),
255
+				'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
256
+				'require_nonce' => false,
257
+			),
258
+
259
+			'edit_question_group' => array(
260
+				'nav'           => array(
261
+					'label'      => esc_html__('Edit Question Group', 'event_espresso'),
262
+					'order'      => 5,
263
+					'persistent' => false,
264
+					'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
265
+						array('question_group_id' => $this->_req_data['question_group_id']),
266
+						$this->_current_page_view_url
267
+					) : $this->_admin_base_url,
268
+				),
269
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
270
+				'help_tabs'     => array(
271
+					'registration_form_edit_question_group_help_tab' => array(
272
+						'title'    => esc_html__('Edit Question Group', 'event_espresso'),
273
+						'filename' => 'registration_form_edit_question_group',
274
+					),
275
+				),
276
+				'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
277
+				'require_nonce' => false,
278
+			),
279
+
280
+			'view_reg_form_settings' => array(
281
+				'nav'           => array(
282
+					'label' => esc_html__('Reg Form Settings', 'event_espresso'),
283
+					'order' => 40,
284
+				),
285
+				'labels'        => array(
286
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
287
+				),
288
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
289
+				'help_tabs'     => array(
290
+					'registration_form_reg_form_settings_help_tab' => array(
291
+						'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
292
+						'filename' => 'registration_form_reg_form_settings',
293
+					),
294
+				),
295
+				'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
296
+				'require_nonce' => false,
297
+			),
298
+
299
+		);
300
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
301
+
302
+		// change the list table we're going to use so it's the NEW list table!
303
+		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
304
+
305
+
306
+		// additional labels
307
+		$new_labels = array(
308
+			'add_question'          => esc_html__('Add New Question', 'event_espresso'),
309
+			'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
310
+			'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
311
+			'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
312
+			'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
313
+		);
314
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
315
+	}
316
+
317
+
318
+	/**
319
+	 * @return void
320
+	 */
321
+	protected function _ajax_hooks()
322
+	{
323
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
324
+	}
325
+
326
+
327
+	/**
328
+	 * @return void
329
+	 */
330
+	public function load_scripts_styles_question_groups()
331
+	{
332
+		wp_enqueue_script('espresso_ajax_table_sorting');
333
+	}
334
+
335
+
336
+	/**
337
+	 * @return void
338
+	 */
339
+	public function load_scripts_styles_add_question_group()
340
+	{
341
+		$this->load_scripts_styles_forms();
342
+		$this->load_sortable_question_script();
343
+	}
344
+
345
+
346
+	/**
347
+	 * @return void
348
+	 */
349
+	public function load_scripts_styles_edit_question_group()
350
+	{
351
+		$this->load_scripts_styles_forms();
352
+		$this->load_sortable_question_script();
353
+	}
354
+
355
+
356
+	/**
357
+	 * registers and enqueues script for questions
358
+	 *
359
+	 * @return void
360
+	 */
361
+	public function load_sortable_question_script()
362
+	{
363
+		wp_register_script(
364
+			'ee-question-sortable',
365
+			REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
366
+			array('jquery-ui-sortable'),
367
+			EVENT_ESPRESSO_VERSION,
368
+			true
369
+		);
370
+		wp_enqueue_script('ee-question-sortable');
371
+	}
372
+
373
+
374
+	/**
375
+	 * @return void
376
+	 */
377
+	protected function _set_list_table_views_default()
378
+	{
379
+		$this->_views = array(
380
+			'all' => array(
381
+				'slug'        => 'all',
382
+				'label'       => esc_html__('View All Questions', 'event_espresso'),
383
+				'count'       => 0,
384
+				'bulk_action' => array(
385
+					'trash_questions' => esc_html__('Trash', 'event_espresso'),
386
+				),
387
+			),
388
+		);
389
+
390
+		if (EE_Registry::instance()->CAP->current_user_can(
391
+			'ee_delete_questions',
392
+			'espresso_registration_form_trash_questions'
393
+		)
394
+		) {
395
+			$this->_views['trash'] = array(
396
+				'slug'        => 'trash',
397
+				'label'       => esc_html__('Trash', 'event_espresso'),
398
+				'count'       => 0,
399
+				'bulk_action' => array(
400
+					'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
401
+					'restore_questions' => esc_html__('Restore', 'event_espresso'),
402
+				),
403
+			);
404
+		}
405
+	}
406
+
407
+
408
+	/**
409
+	 * @return void
410
+	 */
411
+	protected function _set_list_table_views_question_groups()
412
+	{
413
+		$this->_views = array(
414
+			'all' => array(
415
+				'slug'        => 'all',
416
+				'label'       => esc_html__('All', 'event_espresso'),
417
+				'count'       => 0,
418
+				'bulk_action' => array(
419
+					'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
420
+				),
421
+			),
422
+		);
423
+
424
+		if (EE_Registry::instance()->CAP->current_user_can(
425
+			'ee_delete_question_groups',
426
+			'espresso_registration_form_trash_question_groups'
427
+		)
428
+		) {
429
+			$this->_views['trash'] = array(
430
+				'slug'        => 'trash',
431
+				'label'       => esc_html__('Trash', 'event_espresso'),
432
+				'count'       => 0,
433
+				'bulk_action' => array(
434
+					'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
435
+					'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
436
+				),
437
+			);
438
+		}
439
+	}
440
+
441
+
442
+	/**
443
+	 * @return void
444
+	 * @throws EE_Error
445
+	 * @throws InvalidArgumentException
446
+	 * @throws InvalidDataTypeException
447
+	 * @throws InvalidInterfaceException
448
+	 */
449
+	protected function _questions_overview_list_table()
450
+	{
451
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
452
+			'add_question',
453
+			'add_question',
454
+			array(),
455
+			'add-new-h2'
456
+		);
457
+		parent::_questions_overview_list_table();
458
+	}
459
+
460
+
461
+	/**
462
+	 * @return void
463
+	 * @throws DomainException
464
+	 * @throws EE_Error
465
+	 * @throws InvalidArgumentException
466
+	 * @throws InvalidDataTypeException
467
+	 * @throws InvalidInterfaceException
468
+	 */
469
+	protected function _question_groups_overview_list_table()
470
+	{
471
+		$this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
472
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
473
+			'add_question_group',
474
+			'add_question_group',
475
+			array(),
476
+			'add-new-h2'
477
+		);
478
+		$this->display_admin_list_table_page_with_sidebar();
479
+	}
480
+
481
+
482
+	/**
483
+	 * @return void
484
+	 * @throws EE_Error
485
+	 * @throws InvalidArgumentException
486
+	 * @throws InvalidDataTypeException
487
+	 * @throws InvalidInterfaceException
488
+	 */
489
+	protected function _delete_question()
490
+	{
491
+		$success = $this->_delete_items($this->_question_model);
492
+		$this->_redirect_after_action(
493
+			$success,
494
+			$this->_question_model->item_name($success),
495
+			'deleted',
496
+			array('action' => 'default', 'status' => 'all')
497
+		);
498
+	}
499
+
500
+
501
+	/**
502
+	 * @return void
503
+	 * @throws EE_Error
504
+	 * @throws InvalidArgumentException
505
+	 * @throws InvalidDataTypeException
506
+	 * @throws InvalidInterfaceException
507
+	 */
508
+	protected function _delete_questions()
509
+	{
510
+		$success = $this->_delete_items($this->_question_model);
511
+		$this->_redirect_after_action(
512
+			$success,
513
+			$this->_question_model->item_name($success),
514
+			'deleted permanently',
515
+			array('action' => 'default', 'status' => 'trash')
516
+		);
517
+	}
518
+
519
+
520
+	/**
521
+	 * Performs the deletion of a single or multiple questions or question groups.
522
+	 *
523
+	 * @param EEM_Soft_Delete_Base $model
524
+	 * @return int number of items deleted permanently
525
+	 * @throws EE_Error
526
+	 * @throws InvalidArgumentException
527
+	 * @throws InvalidDataTypeException
528
+	 * @throws InvalidInterfaceException
529
+	 */
530
+	private function _delete_items(EEM_Soft_Delete_Base $model)
531
+	{
532
+		$success = 0;
533
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
534
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
535
+			// if array has more than one element than success message should be plural
536
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
537
+			// cycle thru bulk action checkboxes
538
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
539
+				if (! $this->_delete_item($ID, $model)) {
540
+					$success = 0;
541
+				}
542
+			}
543
+		} elseif (! empty($this->_req_data['QSG_ID'])) {
544
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
545
+		} elseif (! empty($this->_req_data['QST_ID'])) {
546
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
547
+		} else {
548
+			EE_Error::add_error(
549
+				sprintf(
550
+					esc_html__(
551
+						"No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
552
+						"event_espresso"
553
+					)
554
+				),
555
+				__FILE__,
556
+				__FUNCTION__,
557
+				__LINE__
558
+			);
559
+		}
560
+		return $success;
561
+	}
562
+
563
+
564
+	/**
565
+	 * Deletes the specified question (and its associated question options) or question group
566
+	 *
567
+	 * @param int                  $id
568
+	 * @param EEM_Soft_Delete_Base $model
569
+	 * @return boolean
570
+	 * @throws EE_Error
571
+	 * @throws InvalidArgumentException
572
+	 * @throws InvalidDataTypeException
573
+	 * @throws InvalidInterfaceException
574
+	 */
575
+	protected function _delete_item($id, $model)
576
+	{
577
+		if ($model instanceof EEM_Question) {
578
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
579
+		}
580
+		return $model->delete_permanently_by_ID(absint($id));
581
+	}
582
+
583
+
584
+	/******************************    QUESTION GROUPS    ******************************/
585
+
586
+
587
+	/**
588
+	 * @param string $type
589
+	 * @return void
590
+	 * @throws DomainException
591
+	 * @throws EE_Error
592
+	 * @throws InvalidArgumentException
593
+	 * @throws InvalidDataTypeException
594
+	 * @throws InvalidInterfaceException
595
+	 */
596
+	protected function _edit_question_group($type = 'add')
597
+	{
598
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
599
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
600
+			? absint($this->_req_data['QSG_ID'])
601
+			: false;
602
+
603
+		switch ($this->_req_action) {
604
+			case 'add_question_group':
605
+				$this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
606
+				break;
607
+			case 'edit_question_group':
608
+				$this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
609
+				break;
610
+			default:
611
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
612
+		}
613
+		// add ID to title if editing
614
+		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
615
+		if ($ID) {
616
+			/** @var EE_Question_Group $questionGroup */
617
+			$questionGroup = $this->_question_group_model->get_one_by_ID($ID);
618
+			$additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
619
+			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
620
+		} else {
621
+			/** @var EE_Question_Group $questionGroup */
622
+			$questionGroup = EEM_Question_Group::instance()->create_default_object();
623
+			$questionGroup->set_order_to_latest();
624
+			$this->_set_add_edit_form_tags('insert_question_group');
625
+		}
626
+		$this->_template_args['values'] = $this->_yes_no_values;
627
+		$this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
628
+		$this->_template_args['QSG_ID'] = $ID ? $ID : true;
629
+		$this->_template_args['question_group'] = $questionGroup;
630
+
631
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
632
+		$this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
633
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
634
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
635
+			$this->_template_args,
636
+			true
637
+		);
638
+
639
+		// the details template wrapper
640
+		$this->display_admin_page_with_sidebar();
641
+	}
642
+
643
+
644
+	/**
645
+	 * @return void
646
+	 * @throws EE_Error
647
+	 * @throws InvalidArgumentException
648
+	 * @throws InvalidDataTypeException
649
+	 * @throws InvalidInterfaceException
650
+	 */
651
+	protected function _delete_question_groups()
652
+	{
653
+		$success = $this->_delete_items($this->_question_group_model);
654
+		$this->_redirect_after_action(
655
+			$success,
656
+			$this->_question_group_model->item_name($success),
657
+			'deleted permanently',
658
+			array('action' => 'question_groups', 'status' => 'trash')
659
+		);
660
+	}
661
+
662
+
663
+	/**
664
+	 * @param bool $new_question_group
665
+	 * @throws EE_Error
666
+	 * @throws InvalidArgumentException
667
+	 * @throws InvalidDataTypeException
668
+	 * @throws InvalidInterfaceException
669
+	 */
670
+	protected function _insert_or_update_question_group($new_question_group = true)
671
+	{
672
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
673
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
674
+		if ($new_question_group) {
675
+			// make sure identifier is unique
676
+			$identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
677
+			$identifier_exists = ! empty($identifier_value)
678
+				? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0
679
+				: false;
680
+			if ($identifier_exists) {
681
+				$set_column_values['QSG_identifier'] .= uniqid('id', true);
682
+			}
683
+			$QSG_ID = $this->_question_group_model->insert($set_column_values);
684
+			$success = $QSG_ID ? 1 : 0;
685
+			if ($success === 0) {
686
+				EE_Error::add_error(
687
+					esc_html__('Something went wrong saving the question group.', 'event_espresso'),
688
+					__FILE__,
689
+					__FUNCTION__,
690
+					__LINE__
691
+				);
692
+				$this->_redirect_after_action(
693
+					false,
694
+					'',
695
+					'',
696
+					array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
697
+					true
698
+				);
699
+			}
700
+		} else {
701
+			$QSG_ID = absint($this->_req_data['QSG_ID']);
702
+			unset($set_column_values['QSG_ID']);
703
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
704
+		}
705
+
706
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
707
+			EEM_Attendee::system_question_phone
708
+		);
709
+		// update the existing related questions
710
+		// BUT FIRST...  delete the phone question from the Question_Group_Question
711
+		// if it is being added to this question group (therefore removed from the existing group)
712
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
713
+			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
714
+			EEM_Question_Group_Question::instance()->delete(
715
+				array(
716
+					array(
717
+						'QST_ID' => $phone_question_id,
718
+						'QSG_ID' => array('!=', $QSG_ID),
719
+					),
720
+				)
721
+			);
722
+		}
723
+		/** @type EE_Question_Group $question_group */
724
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
725
+		$questions = $question_group->questions();
726
+		// make sure system phone question is added to list of questions for this group
727
+		if (! isset($questions[ $phone_question_id ])) {
728
+			$questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
729
+		}
730
+
731
+		foreach ($questions as $question_ID => $question) {
732
+			// first we always check for order.
733
+			if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
734
+				// update question order
735
+				$question_group->update_question_order(
736
+					$question_ID,
737
+					$this->_req_data['question_orders'][ $question_ID ]
738
+				);
739
+			}
740
+
741
+			// then we always check if adding or removing.
742
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
743
+				$question_group->add_question($question_ID);
744
+			} else {
745
+				// not found, remove it (but only if not a system question for the personal group
746
+				// with the exception of lname system question - we allow removal of it)
747
+				if (in_array(
748
+					$question->system_ID(),
749
+					EEM_Question::instance()->required_system_questions_in_system_question_group(
750
+						$question_group->system_group()
751
+					)
752
+				)) {
753
+					continue;
754
+				} else {
755
+					$question_group->remove_question($question_ID);
756
+				}
757
+			}
758
+		}
759
+		// save new related questions
760
+		if (isset($this->_req_data['questions'])) {
761
+			foreach ($this->_req_data['questions'] as $QST_ID) {
762
+				$question_group->add_question($QST_ID);
763
+				if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
764
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
765
+				}
766
+			}
767
+		}
768
+
769
+		if ($success !== false) {
770
+			$msg = $new_question_group
771
+				? sprintf(
772
+					esc_html__('The %s has been created', 'event_espresso'),
773
+					$this->_question_group_model->item_name()
774
+				)
775
+				: sprintf(
776
+					esc_html__(
777
+						'The %s has been updated',
778
+						'event_espresso'
779
+					),
780
+					$this->_question_group_model->item_name()
781
+				);
782
+			EE_Error::add_success($msg);
783
+		}
784
+		$this->_redirect_after_action(
785
+			false,
786
+			'',
787
+			'',
788
+			array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
789
+			true
790
+		);
791
+	}
792
+
793
+
794
+	/**
795
+	 * duplicates a question and all its question options and redirects to the new question.
796
+	 *
797
+	 * @return void
798
+	 * @throws EE_Error
799
+	 * @throws InvalidArgumentException
800
+	 * @throws ReflectionException
801
+	 * @throws InvalidDataTypeException
802
+	 * @throws InvalidInterfaceException
803
+	 */
804
+	public function _duplicate_question()
805
+	{
806
+		$question_ID = (int) $this->_req_data['QST_ID'];
807
+		$question = EEM_Question::instance()->get_one_by_ID($question_ID);
808
+		if ($question instanceof EE_Question) {
809
+			$new_question = $question->duplicate();
810
+			if ($new_question instanceof EE_Question) {
811
+				$this->_redirect_after_action(
812
+					true,
813
+					esc_html__('Question', 'event_espresso'),
814
+					esc_html__('Duplicated', 'event_espresso'),
815
+					array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
816
+					true
817
+				);
818
+			} else {
819
+				global $wpdb;
820
+				EE_Error::add_error(
821
+					sprintf(
822
+						esc_html__(
823
+							'Could not duplicate question with ID %1$d because: %2$s',
824
+							'event_espresso'
825
+						),
826
+						$question_ID,
827
+						$wpdb->last_error
828
+					),
829
+					__FILE__,
830
+					__FUNCTION__,
831
+					__LINE__
832
+				);
833
+				$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
834
+			}
835
+		} else {
836
+			EE_Error::add_error(
837
+				sprintf(
838
+					esc_html__(
839
+						'Could not duplicate question with ID %d because it didn\'t exist!',
840
+						'event_espresso'
841
+					),
842
+					$question_ID
843
+				),
844
+				__FILE__,
845
+				__FUNCTION__,
846
+				__LINE__
847
+			);
848
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
849
+		}
850
+	}
851
+
852
+
853
+	/**
854
+	 * @param bool $trash
855
+	 * @throws EE_Error
856
+	 */
857
+	protected function _trash_or_restore_question_groups($trash = true)
858
+	{
859
+		$this->_trash_or_restore_items($this->_question_group_model, $trash);
860
+	}
861
+
862
+
863
+	/**
864
+	 *_trash_question
865
+	 *
866
+	 * @return void
867
+	 * @throws EE_Error
868
+	 */
869
+	protected function _trash_question()
870
+	{
871
+		$success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
872
+		$query_args = array('action' => 'default', 'status' => 'all');
873
+		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
874
+	}
875
+
876
+
877
+	/**
878
+	 * @param bool $trash
879
+	 * @throws EE_Error
880
+	 */
881
+	protected function _trash_or_restore_questions($trash = true)
882
+	{
883
+		$this->_trash_or_restore_items($this->_question_model, $trash);
884
+	}
885
+
886
+
887
+	/**
888
+	 * Internally used to delete or restore items, using the request data. Meant to be
889
+	 * flexible between question or question groups
890
+	 *
891
+	 * @param EEM_Soft_Delete_Base $model
892
+	 * @param boolean              $trash whether to trash or restore
893
+	 * @throws EE_Error
894
+	 */
895
+	private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
896
+	{
897
+
898
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
899
+
900
+		$success = 1;
901
+		// Checkboxes
902
+		// echo "trash $trash";
903
+		// var_dump($this->_req_data['checkbox']);die;
904
+		if (isset($this->_req_data['checkbox'])) {
905
+			if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
906
+				// if array has more than one element than success message should be plural
907
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
908
+				// cycle thru bulk action checkboxes
909
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
910
+					if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
911
+						$success = 0;
912
+					}
913
+				}
914
+			} else {
915
+				// grab single id and delete
916
+				$ID = absint($this->_req_data['checkbox']);
917
+				if (! $model->delete_or_restore_by_ID($trash, $ID)) {
918
+					$success = 0;
919
+				}
920
+			}
921
+		} else {
922
+			// delete via trash link
923
+			// grab single id and delete
924
+			$ID = absint($this->_req_data[ $model->primary_key_name() ]);
925
+			if (! $model->delete_or_restore_by_ID($trash, $ID)) {
926
+				$success = 0;
927
+			}
928
+		}
929
+
930
+
931
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
932
+		// echo "action :$action";
933
+		// $action = 'questions' ? 'default' : $action;
934
+		if ($trash) {
935
+			$action_desc = 'trashed';
936
+			$status = 'trash';
937
+		} else {
938
+			$action_desc = 'restored';
939
+			$status = 'all';
940
+		}
941
+		$this->_redirect_after_action(
942
+			$success,
943
+			$model->item_name($success),
944
+			$action_desc,
945
+			array('action' => $action, 'status' => $status)
946
+		);
947
+	}
948
+
949
+
950
+	/**
951
+	 * @param            $per_page
952
+	 * @param int        $current_page
953
+	 * @param bool|false $count
954
+	 * @return EE_Soft_Delete_Base_Class[]|int
955
+	 * @throws EE_Error
956
+	 * @throws InvalidArgumentException
957
+	 * @throws InvalidDataTypeException
958
+	 * @throws InvalidInterfaceException
959
+	 */
960
+	public function get_trashed_questions($per_page, $current_page = 1, $count = false)
961
+	{
962
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
963
+
964
+		if ($count) {
965
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
966
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
967
+			$results = $this->_question_model->count_deleted($where);
968
+		} else {
969
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
970
+			$results = $this->_question_model->get_all_deleted($query_params);
971
+		}
972
+		return $results;
973
+	}
974
+
975
+
976
+	/**
977
+	 * @param            $per_page
978
+	 * @param int        $current_page
979
+	 * @param bool|false $count
980
+	 * @return EE_Soft_Delete_Base_Class[]|int
981
+	 * @throws EE_Error
982
+	 * @throws InvalidArgumentException
983
+	 * @throws InvalidDataTypeException
984
+	 * @throws InvalidInterfaceException
985
+	 */
986
+	public function get_question_groups($per_page, $current_page = 1, $count = false)
987
+	{
988
+		$questionGroupModel = EEM_Question_Group::instance();
989
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
990
+		if ($count) {
991
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
992
+			$results = $questionGroupModel->count($where);
993
+		} else {
994
+			$results = $questionGroupModel->get_all($query_params);
995
+		}
996
+		return $results;
997
+	}
998
+
999
+
1000
+	/**
1001
+	 * @param      $per_page
1002
+	 * @param int  $current_page
1003
+	 * @param bool $count
1004
+	 * @return EE_Soft_Delete_Base_Class[]|int
1005
+	 * @throws EE_Error
1006
+	 * @throws InvalidArgumentException
1007
+	 * @throws InvalidDataTypeException
1008
+	 * @throws InvalidInterfaceException
1009
+	 */
1010
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1011
+	{
1012
+		$questionGroupModel = EEM_Question_Group::instance();
1013
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1014
+		if ($count) {
1015
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
1016
+			$query_params['limit'] = null;
1017
+			$results = $questionGroupModel->count_deleted($where);
1018
+		} else {
1019
+			$results = $questionGroupModel->get_all_deleted($query_params);
1020
+		}
1021
+		return $results;
1022
+	}
1023
+
1024
+
1025
+	/**
1026
+	 * method for performing updates to question order
1027
+	 *
1028
+	 * @return void results array
1029
+	 * @throws EE_Error
1030
+	 * @throws InvalidArgumentException
1031
+	 * @throws InvalidDataTypeException
1032
+	 * @throws InvalidInterfaceException
1033
+	 */
1034
+	public function update_question_group_order()
1035
+	{
1036
+
1037
+		$success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1038
+
1039
+		// grab our row IDs
1040
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1041
+			? explode(',', rtrim($this->_req_data['row_ids'], ','))
1042
+			: array();
1043
+
1044
+		$perpage = ! empty($this->_req_data['perpage'])
1045
+			? (int) $this->_req_data['perpage']
1046
+			: null;
1047
+		$curpage = ! empty($this->_req_data['curpage'])
1048
+			? (int) $this->_req_data['curpage']
1049
+			: null;
1050
+
1051
+		if (! empty($row_ids)) {
1052
+			// figure out where we start the row_id count at for the current page.
1053
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1054
+
1055
+			$row_count = count($row_ids);
1056
+			for ($i = 0; $i < $row_count; $i++) {
1057
+				// Update the questions when re-ordering
1058
+				$updated = EEM_Question_Group::instance()->update(
1059
+					array('QSG_order' => $qsgcount),
1060
+					array(array('QSG_ID' => $row_ids[ $i ]))
1061
+				);
1062
+				if ($updated === false) {
1063
+					$success = false;
1064
+				}
1065
+				$qsgcount++;
1066
+			}
1067
+		} else {
1068
+			$success = false;
1069
+		}
1070
+
1071
+		$errors = ! $success
1072
+			? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1073
+			: false;
1074
+
1075
+		echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1076
+		die();
1077
+	}
1078
+
1079
+
1080
+
1081
+	/***************************************       REGISTRATION SETTINGS       ***************************************/
1082
+
1083
+
1084
+	/**
1085
+	 * @throws DomainException
1086
+	 * @throws EE_Error
1087
+	 * @throws InvalidArgumentException
1088
+	 * @throws InvalidDataTypeException
1089
+	 * @throws InvalidInterfaceException
1090
+	 */
1091
+	protected function _reg_form_settings()
1092
+	{
1093
+		$this->_template_args['values'] = $this->_yes_no_values;
1094
+		add_action(
1095
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1096
+			array($this, 'email_validation_settings_form'),
1097
+			2
1098
+		);
1099
+		add_action(
1100
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1101
+			array($this, 'copy_attendee_info_settings_form'),
1102
+			4
1103
+		);
1104
+		$this->_template_args = (array) apply_filters(
1105
+			'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1106
+			$this->_template_args
1107
+		);
1108
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
1109
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1110
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1111
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1112
+			$this->_template_args,
1113
+			true
1114
+		);
1115
+		$this->display_admin_page_with_sidebar();
1116
+	}
1117
+
1118
+
1119
+	/**
1120
+	 * @return void
1121
+	 * @throws EE_Error
1122
+	 * @throws InvalidArgumentException
1123
+	 * @throws ReflectionException
1124
+	 * @throws InvalidDataTypeException
1125
+	 * @throws InvalidInterfaceException
1126
+	 */
1127
+	protected function _update_reg_form_settings()
1128
+	{
1129
+		EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1130
+			EE_Registry::instance()->CFG->registration
1131
+		);
1132
+		EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form(
1133
+			EE_Registry::instance()->CFG->registration
1134
+		);
1135
+		EE_Registry::instance()->CFG->registration = apply_filters(
1136
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1137
+			EE_Registry::instance()->CFG->registration
1138
+		);
1139
+		$success = $this->_update_espresso_configuration(
1140
+			esc_html__('Registration Form Options', 'event_espresso'),
1141
+			EE_Registry::instance()->CFG,
1142
+			__FILE__,
1143
+			__FUNCTION__,
1144
+			__LINE__
1145
+		);
1146
+		$this->_redirect_after_action(
1147
+			$success,
1148
+			esc_html__('Registration Form Options', 'event_espresso'),
1149
+			'updated',
1150
+			array('action' => 'view_reg_form_settings')
1151
+		);
1152
+	}
1153
+
1154
+
1155
+	/**
1156
+	 * @return void
1157
+	 * @throws EE_Error
1158
+	 * @throws InvalidArgumentException
1159
+	 * @throws InvalidDataTypeException
1160
+	 * @throws InvalidInterfaceException
1161
+	 */
1162
+	public function copy_attendee_info_settings_form()
1163
+	{
1164
+		echo $this->_copy_attendee_info_settings_form()->get_html();
1165
+	}
1166
+
1167
+	/**
1168
+	 * _copy_attendee_info_settings_form
1169
+	 *
1170
+	 * @access protected
1171
+	 * @return EE_Form_Section_Proper
1172
+	 * @throws \EE_Error
1173
+	 */
1174
+	protected function _copy_attendee_info_settings_form()
1175
+	{
1176
+		return new EE_Form_Section_Proper(
1177
+			array(
1178
+				'name'            => 'copy_attendee_info_settings',
1179
+				'html_id'         => 'copy_attendee_info_settings',
1180
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1181
+				'subsections'     => apply_filters(
1182
+					'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections',
1183
+					array(
1184
+						'copy_attendee_info_hdr'   => new EE_Form_Section_HTML(
1185
+							EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso'))
1186
+						),
1187
+						'copy_attendee_info' => new EE_Yes_No_Input(
1188
+							array(
1189
+								'html_label_text' => esc_html__(
1190
+									'Allow copy #1 attendee info to extra attendees?',
1191
+									'event_espresso'
1192
+								),
1193
+								'html_help_text'  => esc_html__(
1194
+									'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.',
1195
+									'event_espresso'
1196
+								),
1197
+								'default'         => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(),
1198
+								'required'        => false,
1199
+								'display_html_label_text' => false,
1200
+							)
1201
+						),
1202
+					)
1203
+				),
1204
+			)
1205
+		);
1206
+	}
1207
+
1208
+	/**
1209
+	 * @param EE_Registration_Config $EE_Registration_Config
1210
+	 * @return EE_Registration_Config
1211
+	 * @throws EE_Error
1212
+	 * @throws InvalidArgumentException
1213
+	 * @throws ReflectionException
1214
+	 * @throws InvalidDataTypeException
1215
+	 * @throws InvalidInterfaceException
1216
+	 */
1217
+	public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config)
1218
+	{
1219
+		$prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo();
1220
+		try {
1221
+			$copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form();
1222
+			// if not displaying a form, then check for form submission
1223
+			if ($copy_attendee_info_settings_form->was_submitted()) {
1224
+				// capture form data
1225
+				$copy_attendee_info_settings_form->receive_form_submission();
1226
+				// validate form data
1227
+				if ($copy_attendee_info_settings_form->is_valid()) {
1228
+					// grab validated data from form
1229
+					$valid_data = $copy_attendee_info_settings_form->valid_data();
1230
+					if (isset($valid_data['copy_attendee_info'])) {
1231
+						$EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']);
1232
+					} else {
1233
+						EE_Error::add_error(
1234
+							esc_html__(
1235
+								'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.',
1236
+								'event_espresso'
1237
+							),
1238
+							__FILE__,
1239
+							__FUNCTION__,
1240
+							__LINE__
1241
+						);
1242
+					}
1243
+				} else {
1244
+					if ($copy_attendee_info_settings_form->submission_error_message() !== '') {
1245
+						EE_Error::add_error(
1246
+							$copy_attendee_info_settings_form->submission_error_message(),
1247
+							__FILE__,
1248
+							__FUNCTION__,
1249
+							__LINE__
1250
+						);
1251
+					}
1252
+				}
1253
+			}
1254
+		} catch (EE_Error $e) {
1255
+			$e->get_error();
1256
+		}
1257
+		return $EE_Registration_Config;
1258
+	}
1259
+
1260
+
1261
+	/**
1262
+	 * @return void
1263
+	 * @throws EE_Error
1264
+	 * @throws InvalidArgumentException
1265
+	 * @throws InvalidDataTypeException
1266
+	 * @throws InvalidInterfaceException
1267
+	 */
1268
+	public function email_validation_settings_form()
1269
+	{
1270
+		echo $this->_email_validation_settings_form()->get_html();
1271
+	}
1272
+
1273
+
1274
+	/**
1275
+	 * _email_validation_settings_form
1276
+	 *
1277
+	 * @access protected
1278
+	 * @return EE_Form_Section_Proper
1279
+	 * @throws \EE_Error
1280
+	 */
1281
+	protected function _email_validation_settings_form()
1282
+	{
1283
+		return new EE_Form_Section_Proper(
1284
+			array(
1285
+				'name'            => 'email_validation_settings',
1286
+				'html_id'         => 'email_validation_settings',
1287
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1288
+				'subsections'     => apply_filters(
1289
+					'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1290
+					array(
1291
+						'email_validation_hdr'   => new EE_Form_Section_HTML(
1292
+							EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1293
+						),
1294
+						'email_validation_level' => new EE_Select_Input(
1295
+							array(
1296
+								'basic'      => esc_html__('Basic', 'event_espresso'),
1297
+								'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1298
+								'i18n'       => esc_html__('International', 'event_espresso'),
1299
+								'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1300
+							),
1301
+							array(
1302
+								'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1303
+													 . EEH_Template::get_help_tab_link('email_validation_info'),
1304
+								'html_help_text'  => esc_html__(
1305
+									'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
1306
+									'event_espresso'
1307
+								),
1308
+								'default'         => isset(
1309
+									EE_Registry::instance()->CFG->registration->email_validation_level
1310
+								)
1311
+									? EE_Registry::instance()->CFG->registration->email_validation_level
1312
+									: 'wp_default',
1313
+								'required'        => false,
1314
+							)
1315
+						),
1316
+					)
1317
+				),
1318
+			)
1319
+		);
1320
+	}
1321
+
1322
+
1323
+	/**
1324
+	 * @param EE_Registration_Config $EE_Registration_Config
1325
+	 * @return EE_Registration_Config
1326
+	 * @throws EE_Error
1327
+	 * @throws InvalidArgumentException
1328
+	 * @throws ReflectionException
1329
+	 * @throws InvalidDataTypeException
1330
+	 * @throws InvalidInterfaceException
1331
+	 */
1332
+	public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1333
+	{
1334
+		$prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1335
+		try {
1336
+			$email_validation_settings_form = $this->_email_validation_settings_form();
1337
+			// if not displaying a form, then check for form submission
1338
+			if ($email_validation_settings_form->was_submitted()) {
1339
+				// capture form data
1340
+				$email_validation_settings_form->receive_form_submission();
1341
+				// validate form data
1342
+				if ($email_validation_settings_form->is_valid()) {
1343
+					// grab validated data from form
1344
+					$valid_data = $email_validation_settings_form->valid_data();
1345
+					if (isset($valid_data['email_validation_level'])) {
1346
+						$email_validation_level = $valid_data['email_validation_level'];
1347
+						// now if they want to use international email addresses
1348
+						if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1349
+							// in case we need to reset their email validation level,
1350
+							// make sure that the previous value wasn't already set to one of the i18n options.
1351
+							if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1352
+								// if so, then reset it back to "basic" since that is the only other option that,
1353
+								// despite offering poor validation, supports i18n email addresses
1354
+								$prev_email_validation_level = 'basic';
1355
+							}
1356
+							// confirm our i18n email validation will work on the server
1357
+							if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1358
+								// or reset email validation level to previous value
1359
+								$email_validation_level = $prev_email_validation_level;
1360
+							}
1361
+						}
1362
+						$EE_Registration_Config->email_validation_level = $email_validation_level;
1363
+					} else {
1364
+						EE_Error::add_error(
1365
+							esc_html__(
1366
+								'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1367
+								'event_espresso'
1368
+							),
1369
+							__FILE__,
1370
+							__FUNCTION__,
1371
+							__LINE__
1372
+						);
1373
+					}
1374
+				} else {
1375
+					if ($email_validation_settings_form->submission_error_message() !== '') {
1376
+						EE_Error::add_error(
1377
+							$email_validation_settings_form->submission_error_message(),
1378
+							__FILE__,
1379
+							__FUNCTION__,
1380
+							__LINE__
1381
+						);
1382
+					}
1383
+				}
1384
+			}
1385
+		} catch (EE_Error $e) {
1386
+			$e->get_error();
1387
+		}
1388
+		return $EE_Registration_Config;
1389
+	}
1390
+
1391
+
1392
+	/**
1393
+	 * confirms that the server's PHP version has the PCRE module enabled,
1394
+	 * and that the PCRE version works with our i18n email validation
1395
+	 *
1396
+	 * @param EE_Registration_Config $EE_Registration_Config
1397
+	 * @param string                 $email_validation_level
1398
+	 * @return bool
1399
+	 */
1400
+	private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1401
+	{
1402
+		// first check that PCRE is enabled
1403
+		if (! defined('PREG_BAD_UTF8_ERROR')) {
1404
+			EE_Error::add_error(
1405
+				sprintf(
1406
+					esc_html__(
1407
+						'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1408
+						'event_espresso'
1409
+					),
1410
+					'<br />'
1411
+				),
1412
+				__FILE__,
1413
+				__FUNCTION__,
1414
+				__LINE__
1415
+			);
1416
+			return false;
1417
+		} else {
1418
+			// PCRE support is enabled, but let's still
1419
+			// perform a test to see if the server will support it.
1420
+			// but first, save the updated validation level to the config,
1421
+			// so that the validation strategy picks it up.
1422
+			// this will get bumped back down if it doesn't work
1423
+			$EE_Registration_Config->email_validation_level = $email_validation_level;
1424
+			try {
1425
+				$email_validator = new EE_Email_Validation_Strategy();
1426
+				$i18n_email_address = apply_filters(
1427
+					'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1428
+					'jägerjü[email protected]'
1429
+				);
1430
+				$email_validator->validate($i18n_email_address);
1431
+			} catch (Exception $e) {
1432
+				EE_Error::add_error(
1433
+					sprintf(
1434
+						esc_html__(
1435
+							'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1436
+							'event_espresso'
1437
+						),
1438
+						'<br />',
1439
+						'<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1440
+					),
1441
+					__FILE__,
1442
+					__FUNCTION__,
1443
+					__LINE__
1444
+				);
1445
+				return false;
1446
+			}
1447
+		}
1448
+		return true;
1449
+	}
1450 1450
 }
Please login to merge, or discard this patch.
core/bootstrap_espresso.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@  discard block
 block discarded – undo
6 6
  */
7 7
 function espresso_load_error_handling()
8 8
 {
9
-    static $error_handling_loaded = false;
10
-    if ($error_handling_loaded) {
11
-        return;
12
-    }
13
-    // load debugging tools
14
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
15
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
16
-        \EEH_Debug_Tools::instance();
17
-    }
18
-    // load error handling
19
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
20
-        require_once EE_CORE . 'EE_Error.core.php';
21
-    } else {
22
-        wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
23
-    }
24
-    $error_handling_loaded = true;
9
+	static $error_handling_loaded = false;
10
+	if ($error_handling_loaded) {
11
+		return;
12
+	}
13
+	// load debugging tools
14
+	if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
15
+		require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
16
+		\EEH_Debug_Tools::instance();
17
+	}
18
+	// load error handling
19
+	if (is_readable(EE_CORE . 'EE_Error.core.php')) {
20
+		require_once EE_CORE . 'EE_Error.core.php';
21
+	} else {
22
+		wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
23
+	}
24
+	$error_handling_loaded = true;
25 25
 }
26 26
 
27 27
 
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function espresso_load_required($classname, $full_path_to_file)
37 37
 {
38
-    if (is_readable($full_path_to_file)) {
39
-        require_once $full_path_to_file;
40
-    } else {
41
-        throw new \EE_Error(
42
-            sprintf(
43
-                esc_html__(
44
-                    'The %s class file could not be located or is not readable due to file permissions.',
45
-                    'event_espresso'
46
-                ),
47
-                $classname
48
-            )
49
-        );
50
-    }
38
+	if (is_readable($full_path_to_file)) {
39
+		require_once $full_path_to_file;
40
+	} else {
41
+		throw new \EE_Error(
42
+			sprintf(
43
+				esc_html__(
44
+					'The %s class file could not be located or is not readable due to file permissions.',
45
+					'event_espresso'
46
+				),
47
+				$classname
48
+			)
49
+		);
50
+	}
51 51
 }
52 52
 
53 53
 
@@ -66,52 +66,52 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function bootstrap_espresso()
68 68
 {
69
-    require_once __DIR__ . '/espresso_definitions.php';
70
-    try {
71
-        espresso_load_error_handling();
72
-        // include WordPress shims for functions introduced in later versions of WordPress
73
-        espresso_load_required(
74
-            '',
75
-            EE_CORE . 'wordpress-shims.php'
76
-        );
77
-        espresso_load_required(
78
-            '',
79
-            EE_CORE . 'third-party-compatibility.php'
80
-        );
81
-        espresso_load_required(
82
-            'EEH_Base',
83
-            EE_CORE . 'helpers/EEH_Base.helper.php'
84
-        );
85
-        espresso_load_required(
86
-            'EEH_File',
87
-            EE_CORE . 'interfaces/EEHI_File.interface.php'
88
-        );
89
-        espresso_load_required(
90
-            'EEH_File',
91
-            EE_CORE . 'helpers/EEH_File.helper.php'
92
-        );
93
-        espresso_load_required(
94
-            'EEH_Array',
95
-            EE_CORE . 'helpers/EEH_Array.helper.php'
96
-        );
97
-        espresso_load_required(
98
-            'EE_Base',
99
-            EE_CORE . 'EE_Base.core.php'
100
-        );
101
-        // instantiate and configure PSR4 autoloader
102
-        espresso_load_required(
103
-            'Psr4Autoloader',
104
-            EE_CORE . 'Psr4Autoloader.php'
105
-        );
106
-        espresso_load_required(
107
-            'EE_Psr4AutoloaderInit',
108
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
109
-        );
110
-        $AutoloaderInit = new EE_Psr4AutoloaderInit();
111
-        $AutoloaderInit->initializeAutoloader();
112
-        new EventEspresso\core\services\bootstrap\BootstrapCore();
113
-    } catch (Exception $e) {
114
-        require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php';
115
-        new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
116
-    }
69
+	require_once __DIR__ . '/espresso_definitions.php';
70
+	try {
71
+		espresso_load_error_handling();
72
+		// include WordPress shims for functions introduced in later versions of WordPress
73
+		espresso_load_required(
74
+			'',
75
+			EE_CORE . 'wordpress-shims.php'
76
+		);
77
+		espresso_load_required(
78
+			'',
79
+			EE_CORE . 'third-party-compatibility.php'
80
+		);
81
+		espresso_load_required(
82
+			'EEH_Base',
83
+			EE_CORE . 'helpers/EEH_Base.helper.php'
84
+		);
85
+		espresso_load_required(
86
+			'EEH_File',
87
+			EE_CORE . 'interfaces/EEHI_File.interface.php'
88
+		);
89
+		espresso_load_required(
90
+			'EEH_File',
91
+			EE_CORE . 'helpers/EEH_File.helper.php'
92
+		);
93
+		espresso_load_required(
94
+			'EEH_Array',
95
+			EE_CORE . 'helpers/EEH_Array.helper.php'
96
+		);
97
+		espresso_load_required(
98
+			'EE_Base',
99
+			EE_CORE . 'EE_Base.core.php'
100
+		);
101
+		// instantiate and configure PSR4 autoloader
102
+		espresso_load_required(
103
+			'Psr4Autoloader',
104
+			EE_CORE . 'Psr4Autoloader.php'
105
+		);
106
+		espresso_load_required(
107
+			'EE_Psr4AutoloaderInit',
108
+			EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
109
+		);
110
+		$AutoloaderInit = new EE_Psr4AutoloaderInit();
111
+		$AutoloaderInit->initializeAutoloader();
112
+		new EventEspresso\core\services\bootstrap\BootstrapCore();
113
+	} catch (Exception $e) {
114
+		require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php';
115
+		new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
116
+	}
117 117
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
         return;
12 12
     }
13 13
     // load debugging tools
14
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
15
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
14
+    if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
15
+        require_once EE_HELPERS.'EEH_Debug_Tools.helper.php';
16 16
         \EEH_Debug_Tools::instance();
17 17
     }
18 18
     // load error handling
19
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
20
-        require_once EE_CORE . 'EE_Error.core.php';
19
+    if (is_readable(EE_CORE.'EE_Error.core.php')) {
20
+        require_once EE_CORE.'EE_Error.core.php';
21 21
     } else {
22 22
         wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
23 23
     }
@@ -66,52 +66,52 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function bootstrap_espresso()
68 68
 {
69
-    require_once __DIR__ . '/espresso_definitions.php';
69
+    require_once __DIR__.'/espresso_definitions.php';
70 70
     try {
71 71
         espresso_load_error_handling();
72 72
         // include WordPress shims for functions introduced in later versions of WordPress
73 73
         espresso_load_required(
74 74
             '',
75
-            EE_CORE . 'wordpress-shims.php'
75
+            EE_CORE.'wordpress-shims.php'
76 76
         );
77 77
         espresso_load_required(
78 78
             '',
79
-            EE_CORE . 'third-party-compatibility.php'
79
+            EE_CORE.'third-party-compatibility.php'
80 80
         );
81 81
         espresso_load_required(
82 82
             'EEH_Base',
83
-            EE_CORE . 'helpers/EEH_Base.helper.php'
83
+            EE_CORE.'helpers/EEH_Base.helper.php'
84 84
         );
85 85
         espresso_load_required(
86 86
             'EEH_File',
87
-            EE_CORE . 'interfaces/EEHI_File.interface.php'
87
+            EE_CORE.'interfaces/EEHI_File.interface.php'
88 88
         );
89 89
         espresso_load_required(
90 90
             'EEH_File',
91
-            EE_CORE . 'helpers/EEH_File.helper.php'
91
+            EE_CORE.'helpers/EEH_File.helper.php'
92 92
         );
93 93
         espresso_load_required(
94 94
             'EEH_Array',
95
-            EE_CORE . 'helpers/EEH_Array.helper.php'
95
+            EE_CORE.'helpers/EEH_Array.helper.php'
96 96
         );
97 97
         espresso_load_required(
98 98
             'EE_Base',
99
-            EE_CORE . 'EE_Base.core.php'
99
+            EE_CORE.'EE_Base.core.php'
100 100
         );
101 101
         // instantiate and configure PSR4 autoloader
102 102
         espresso_load_required(
103 103
             'Psr4Autoloader',
104
-            EE_CORE . 'Psr4Autoloader.php'
104
+            EE_CORE.'Psr4Autoloader.php'
105 105
         );
106 106
         espresso_load_required(
107 107
             'EE_Psr4AutoloaderInit',
108
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
108
+            EE_CORE.'EE_Psr4AutoloaderInit.core.php'
109 109
         );
110 110
         $AutoloaderInit = new EE_Psr4AutoloaderInit();
111 111
         $AutoloaderInit->initializeAutoloader();
112 112
         new EventEspresso\core\services\bootstrap\BootstrapCore();
113 113
     } catch (Exception $e) {
114
-        require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php';
114
+        require_once EE_CORE.'exceptions/ExceptionStackTraceDisplay.php';
115 115
         new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
116 116
     }
117 117
 }
Please login to merge, or discard this patch.
core/services/locators/FqcnLocator.php 2 patches
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -18,156 +18,156 @@
 block discarded – undo
18 18
 class FqcnLocator extends Locator
19 19
 {
20 20
 
21
-    /**
22
-     * @var array $FQCNs
23
-     */
24
-    protected $FQCNs = array();
25
-
26
-    /**
27
-     * @var array $namespaces
28
-     */
29
-    protected $namespaces = array();
30
-
31
-
32
-    /**
33
-     * @access protected
34
-     * @param string $namespace
35
-     * @param string $namespace_base_dir
36
-     * @throws InvalidDataTypeException
37
-     */
38
-    protected function setNamespace($namespace, $namespace_base_dir)
39
-    {
40
-        if (! is_string($namespace)) {
41
-            throw new InvalidDataTypeException('$namespace', $namespace, 'string');
42
-        }
43
-        if (! is_string($namespace_base_dir)) {
44
-            throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
45
-        }
46
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
47
-    }
48
-
49
-
50
-    /**
51
-     * @access public
52
-     * @return array
53
-     */
54
-    public function getFQCNs()
55
-    {
56
-        return $this->FQCNs;
57
-    }
58
-
59
-
60
-    /**
61
-     * @access public
62
-     * @return int
63
-     */
64
-    public function count()
65
-    {
66
-        return count($this->FQCNs);
67
-    }
68
-
69
-
70
-    /**
71
-     * given a valid namespace, will find all files that match the provided mask
72
-     *
73
-     * @access public
74
-     * @param string|array $namespaces
75
-     * @return array
76
-     * @throws InvalidClassException
77
-     * @throws InvalidDataTypeException
78
-     */
79
-    public function locate($namespaces)
80
-    {
81
-        if (! (is_string($namespaces) || is_array($namespaces))) {
82
-            throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
83
-        }
84
-        foreach ((array) $namespaces as $namespace) {
85
-            foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
86
-                $this->FQCNs[ $key ] = $file;
87
-            }
88
-        }
89
-        return $this->FQCNs;
90
-    }
91
-
92
-
93
-    /**
94
-     * given a partial namespace, will find all files in that folder
95
-     * ** PLZ NOTE **
96
-     * This assumes that all files within the specified folder should be loaded
97
-     *
98
-     * @access protected
99
-     * @param string $partial_namespace
100
-     * @return array
101
-     * @throws InvalidClassException
102
-     * @throws InvalidDataTypeException
103
-     */
104
-    protected function findFQCNsByNamespace($partial_namespace)
105
-    {
106
-        $iterator = new FilesystemIterator(
107
-            $this->getDirectoryFromPartialNamespace($partial_namespace)
108
-        );
109
-        $iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO);
110
-        $iterator->setFlags(FilesystemIterator::UNIX_PATHS);
111
-        if (iterator_count($iterator) === 0) {
112
-            return array();
113
-        }
114
-        foreach ($iterator as $file) {
115
-            if ($file->isFile() && $file->getExtension() === 'php') {
116
-                $file = $file->getPath() . '/' . $file->getBasename('.php');
117
-                foreach ($this->namespaces as $namespace => $base_dir) {
118
-                    $namespace .= Psr4Autoloader::NS;
119
-                    if (strpos($file, $base_dir) === 0) {
120
-                        $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
121
-                            array($base_dir, '/'),
122
-                            array($namespace, Psr4Autoloader::NS),
123
-                            $file
124
-                        );
125
-                    }
126
-                }
127
-            }
128
-        }
129
-        return $this->FQCNs;
130
-    }
131
-
132
-
133
-    /**
134
-     * getDirectoryFromPartialNamespace
135
-     *
136
-     * @access protected
137
-     * @param  string $partial_namespace almost fully qualified class name ?
138
-     * @return string
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidClassException
141
-     */
142
-    protected function getDirectoryFromPartialNamespace($partial_namespace)
143
-    {
144
-        if (empty($partial_namespace)) {
145
-            throw new InvalidClassException($partial_namespace);
146
-        }
147
-        // load our PSR-4 Autoloader so we can get the list of registered namespaces from it
148
-        $psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader();
149
-        // breakup the incoming namespace into segments so we can loop thru them
150
-        $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
151
-        // we're only interested in the Vendor and secondary base, so pull those from the array
152
-        $vendor_base = array_slice($namespace_segments, 0, 2);
153
-        $namespace = $prefix = null;
154
-        while (! empty($vendor_base)) {
155
-            $namespace = implode(Psr4Autoloader::NS, $vendor_base);
156
-            // check if there's a base directory registered for that namespace
157
-            $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
158
-            if (! empty($prefix) && ! empty($prefix[0])) {
159
-                // found one!
160
-                break;
161
-            }
162
-            // remove base and try vendor only portion of namespace
163
-            array_pop($vendor_base);
164
-        }
165
-        // nope? then the incoming namespace is invalid
166
-        if (empty($prefix) || empty($prefix[0])) {
167
-            throw new InvalidClassException($partial_namespace);
168
-        }
169
-        $this->setNamespace($namespace, $prefix[0]);
170
-        // but if it's good, add that base directory to the rest of the path, and return it
171
-        return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
172
-    }
21
+	/**
22
+	 * @var array $FQCNs
23
+	 */
24
+	protected $FQCNs = array();
25
+
26
+	/**
27
+	 * @var array $namespaces
28
+	 */
29
+	protected $namespaces = array();
30
+
31
+
32
+	/**
33
+	 * @access protected
34
+	 * @param string $namespace
35
+	 * @param string $namespace_base_dir
36
+	 * @throws InvalidDataTypeException
37
+	 */
38
+	protected function setNamespace($namespace, $namespace_base_dir)
39
+	{
40
+		if (! is_string($namespace)) {
41
+			throw new InvalidDataTypeException('$namespace', $namespace, 'string');
42
+		}
43
+		if (! is_string($namespace_base_dir)) {
44
+			throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
45
+		}
46
+		$this->namespaces[ $namespace ] = $namespace_base_dir;
47
+	}
48
+
49
+
50
+	/**
51
+	 * @access public
52
+	 * @return array
53
+	 */
54
+	public function getFQCNs()
55
+	{
56
+		return $this->FQCNs;
57
+	}
58
+
59
+
60
+	/**
61
+	 * @access public
62
+	 * @return int
63
+	 */
64
+	public function count()
65
+	{
66
+		return count($this->FQCNs);
67
+	}
68
+
69
+
70
+	/**
71
+	 * given a valid namespace, will find all files that match the provided mask
72
+	 *
73
+	 * @access public
74
+	 * @param string|array $namespaces
75
+	 * @return array
76
+	 * @throws InvalidClassException
77
+	 * @throws InvalidDataTypeException
78
+	 */
79
+	public function locate($namespaces)
80
+	{
81
+		if (! (is_string($namespaces) || is_array($namespaces))) {
82
+			throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
83
+		}
84
+		foreach ((array) $namespaces as $namespace) {
85
+			foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
86
+				$this->FQCNs[ $key ] = $file;
87
+			}
88
+		}
89
+		return $this->FQCNs;
90
+	}
91
+
92
+
93
+	/**
94
+	 * given a partial namespace, will find all files in that folder
95
+	 * ** PLZ NOTE **
96
+	 * This assumes that all files within the specified folder should be loaded
97
+	 *
98
+	 * @access protected
99
+	 * @param string $partial_namespace
100
+	 * @return array
101
+	 * @throws InvalidClassException
102
+	 * @throws InvalidDataTypeException
103
+	 */
104
+	protected function findFQCNsByNamespace($partial_namespace)
105
+	{
106
+		$iterator = new FilesystemIterator(
107
+			$this->getDirectoryFromPartialNamespace($partial_namespace)
108
+		);
109
+		$iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO);
110
+		$iterator->setFlags(FilesystemIterator::UNIX_PATHS);
111
+		if (iterator_count($iterator) === 0) {
112
+			return array();
113
+		}
114
+		foreach ($iterator as $file) {
115
+			if ($file->isFile() && $file->getExtension() === 'php') {
116
+				$file = $file->getPath() . '/' . $file->getBasename('.php');
117
+				foreach ($this->namespaces as $namespace => $base_dir) {
118
+					$namespace .= Psr4Autoloader::NS;
119
+					if (strpos($file, $base_dir) === 0) {
120
+						$this->FQCNs[] = Psr4Autoloader::NS . str_replace(
121
+							array($base_dir, '/'),
122
+							array($namespace, Psr4Autoloader::NS),
123
+							$file
124
+						);
125
+					}
126
+				}
127
+			}
128
+		}
129
+		return $this->FQCNs;
130
+	}
131
+
132
+
133
+	/**
134
+	 * getDirectoryFromPartialNamespace
135
+	 *
136
+	 * @access protected
137
+	 * @param  string $partial_namespace almost fully qualified class name ?
138
+	 * @return string
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidClassException
141
+	 */
142
+	protected function getDirectoryFromPartialNamespace($partial_namespace)
143
+	{
144
+		if (empty($partial_namespace)) {
145
+			throw new InvalidClassException($partial_namespace);
146
+		}
147
+		// load our PSR-4 Autoloader so we can get the list of registered namespaces from it
148
+		$psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader();
149
+		// breakup the incoming namespace into segments so we can loop thru them
150
+		$namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
151
+		// we're only interested in the Vendor and secondary base, so pull those from the array
152
+		$vendor_base = array_slice($namespace_segments, 0, 2);
153
+		$namespace = $prefix = null;
154
+		while (! empty($vendor_base)) {
155
+			$namespace = implode(Psr4Autoloader::NS, $vendor_base);
156
+			// check if there's a base directory registered for that namespace
157
+			$prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
158
+			if (! empty($prefix) && ! empty($prefix[0])) {
159
+				// found one!
160
+				break;
161
+			}
162
+			// remove base and try vendor only portion of namespace
163
+			array_pop($vendor_base);
164
+		}
165
+		// nope? then the incoming namespace is invalid
166
+		if (empty($prefix) || empty($prefix[0])) {
167
+			throw new InvalidClassException($partial_namespace);
168
+		}
169
+		$this->setNamespace($namespace, $prefix[0]);
170
+		// but if it's good, add that base directory to the rest of the path, and return it
171
+		return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
172
+	}
173 173
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
      */
38 38
     protected function setNamespace($namespace, $namespace_base_dir)
39 39
     {
40
-        if (! is_string($namespace)) {
40
+        if ( ! is_string($namespace)) {
41 41
             throw new InvalidDataTypeException('$namespace', $namespace, 'string');
42 42
         }
43
-        if (! is_string($namespace_base_dir)) {
43
+        if ( ! is_string($namespace_base_dir)) {
44 44
             throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
45 45
         }
46
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
46
+        $this->namespaces[$namespace] = $namespace_base_dir;
47 47
     }
48 48
 
49 49
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function locate($namespaces)
80 80
     {
81
-        if (! (is_string($namespaces) || is_array($namespaces))) {
81
+        if ( ! (is_string($namespaces) || is_array($namespaces))) {
82 82
             throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
83 83
         }
84 84
         foreach ((array) $namespaces as $namespace) {
85 85
             foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
86
-                $this->FQCNs[ $key ] = $file;
86
+                $this->FQCNs[$key] = $file;
87 87
             }
88 88
         }
89 89
         return $this->FQCNs;
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
         }
114 114
         foreach ($iterator as $file) {
115 115
             if ($file->isFile() && $file->getExtension() === 'php') {
116
-                $file = $file->getPath() . '/' . $file->getBasename('.php');
116
+                $file = $file->getPath().'/'.$file->getBasename('.php');
117 117
                 foreach ($this->namespaces as $namespace => $base_dir) {
118 118
                     $namespace .= Psr4Autoloader::NS;
119 119
                     if (strpos($file, $base_dir) === 0) {
120
-                        $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
120
+                        $this->FQCNs[] = Psr4Autoloader::NS.str_replace(
121 121
                             array($base_dir, '/'),
122 122
                             array($namespace, Psr4Autoloader::NS),
123 123
                             $file
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
         // we're only interested in the Vendor and secondary base, so pull those from the array
152 152
         $vendor_base = array_slice($namespace_segments, 0, 2);
153 153
         $namespace = $prefix = null;
154
-        while (! empty($vendor_base)) {
154
+        while ( ! empty($vendor_base)) {
155 155
             $namespace = implode(Psr4Autoloader::NS, $vendor_base);
156 156
             // check if there's a base directory registered for that namespace
157
-            $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
158
-            if (! empty($prefix) && ! empty($prefix[0])) {
157
+            $prefix = $psr4_loader->prefixes($namespace.Psr4Autoloader::NS);
158
+            if ( ! empty($prefix) && ! empty($prefix[0])) {
159 159
                 // found one!
160 160
                 break;
161 161
             }
@@ -168,6 +168,6 @@  discard block
 block discarded – undo
168 168
         }
169 169
         $this->setNamespace($namespace, $prefix[0]);
170 170
         // but if it's good, add that base directory to the rest of the path, and return it
171
-        return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
171
+        return $prefix[0].implode('/', array_diff($namespace_segments, $vendor_base)).'/';
172 172
     }
173 173
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapRequestResponseObjects.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -25,80 +25,80 @@
 block discarded – undo
25 25
 class BootstrapRequestResponseObjects
26 26
 {
27 27
 
28
-    /**
29
-     * @type LegacyRequestInterface $legacy_request
30
-     */
31
-    protected $legacy_request;
28
+	/**
29
+	 * @type LegacyRequestInterface $legacy_request
30
+	 */
31
+	protected $legacy_request;
32 32
 
33
-    /**
34
-     * @type LoaderInterface $loader
35
-     */
36
-    protected $loader;
33
+	/**
34
+	 * @type LoaderInterface $loader
35
+	 */
36
+	protected $loader;
37 37
 
38
-    /**
39
-     * @var RequestInterface $request
40
-     */
41
-    protected $request;
38
+	/**
39
+	 * @var RequestInterface $request
40
+	 */
41
+	protected $request;
42 42
 
43
-    /**
44
-     * @var ResponseInterface $response
45
-     */
46
-    protected $response;
43
+	/**
44
+	 * @var ResponseInterface $response
45
+	 */
46
+	protected $response;
47 47
 
48 48
 
49
-    /**
50
-     * BootstrapRequestResponseObjects constructor.
51
-     *
52
-     * @param LoaderInterface $loader
53
-     */
54
-    public function __construct(LoaderInterface $loader)
55
-    {
56
-        $this->loader = $loader;
57
-    }
49
+	/**
50
+	 * BootstrapRequestResponseObjects constructor.
51
+	 *
52
+	 * @param LoaderInterface $loader
53
+	 */
54
+	public function __construct(LoaderInterface $loader)
55
+	{
56
+		$this->loader = $loader;
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * @return void
62
-     */
63
-    public function buildRequestResponse()
64
-    {
65
-        // load our Request and Response objects
66
-        $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES);
67
-        $this->response = new Response();
68
-    }
60
+	/**
61
+	 * @return void
62
+	 */
63
+	public function buildRequestResponse()
64
+	{
65
+		// load our Request and Response objects
66
+		$this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES);
67
+		$this->response = new Response();
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @return void
73
-     * @throws InvalidArgumentException
74
-     */
75
-    public function shareRequestResponse()
76
-    {
77
-        $this->loader->share('EventEspresso\core\services\request\Request', $this->request);
78
-        $this->loader->share('EventEspresso\core\services\request\Response', $this->response);
79
-        EE_Dependency_Map::instance()->setRequest($this->request);
80
-        EE_Dependency_Map::instance()->setResponse($this->response);
81
-    }
71
+	/**
72
+	 * @return void
73
+	 * @throws InvalidArgumentException
74
+	 */
75
+	public function shareRequestResponse()
76
+	{
77
+		$this->loader->share('EventEspresso\core\services\request\Request', $this->request);
78
+		$this->loader->share('EventEspresso\core\services\request\Response', $this->response);
79
+		EE_Dependency_Map::instance()->setRequest($this->request);
80
+		EE_Dependency_Map::instance()->setResponse($this->response);
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * @return void
86
-     * @throws InvalidArgumentException
87
-     * @throws EE_Error
88
-     */
89
-    public function setupLegacyRequest()
90
-    {
91
-        espresso_load_required(
92
-            'EE_Request',
93
-            EE_CORE . 'request_stack/EE_Request.core.php'
94
-        );
95
-        $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96
-        $this->legacy_request->setRequest($this->request);
97
-        $this->legacy_request->admin = $this->request->isAdmin();
98
-        $this->legacy_request->ajax = $this->request->isAjax();
99
-        $this->legacy_request->front_ajax = $this->request->isFrontAjax();
100
-        EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
101
-        $this->loader->share('EE_Request', $this->legacy_request);
102
-        $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
103
-    }
84
+	/**
85
+	 * @return void
86
+	 * @throws InvalidArgumentException
87
+	 * @throws EE_Error
88
+	 */
89
+	public function setupLegacyRequest()
90
+	{
91
+		espresso_load_required(
92
+			'EE_Request',
93
+			EE_CORE . 'request_stack/EE_Request.core.php'
94
+		);
95
+		$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96
+		$this->legacy_request->setRequest($this->request);
97
+		$this->legacy_request->admin = $this->request->isAdmin();
98
+		$this->legacy_request->ajax = $this->request->isAjax();
99
+		$this->legacy_request->front_ajax = $this->request->isFrontAjax();
100
+		EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
101
+		$this->loader->share('EE_Request', $this->legacy_request);
102
+		$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
103
+	}
104 104
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     {
91 91
         espresso_load_required(
92 92
             'EE_Request',
93
-            EE_CORE . 'request_stack/EE_Request.core.php'
93
+            EE_CORE.'request_stack/EE_Request.core.php'
94 94
         );
95 95
         $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96 96
         $this->legacy_request->setRequest($this->request);
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapCore.php 2 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -47,225 +47,225 @@
 block discarded – undo
47 47
 class BootstrapCore
48 48
 {
49 49
 
50
-    /**
51
-     * @type LoaderInterface $loader
52
-     */
53
-    private $loader;
50
+	/**
51
+	 * @type LoaderInterface $loader
52
+	 */
53
+	private $loader;
54 54
 
55
-    /**
56
-     * @var RequestInterface $request
57
-     */
58
-    protected $request;
55
+	/**
56
+	 * @var RequestInterface $request
57
+	 */
58
+	protected $request;
59 59
 
60
-    /**
61
-     * @var ResponseInterface $response
62
-     */
63
-    protected $response;
60
+	/**
61
+	 * @var ResponseInterface $response
62
+	 */
63
+	protected $response;
64 64
 
65
-    /**
66
-     * @var RequestStackBuilder $request_stack_builder
67
-     */
68
-    protected $request_stack_builder;
65
+	/**
66
+	 * @var RequestStackBuilder $request_stack_builder
67
+	 */
68
+	protected $request_stack_builder;
69 69
 
70
-    /**
71
-     * @var RequestStack $request_stack
72
-     */
73
-    protected $request_stack;
70
+	/**
71
+	 * @var RequestStack $request_stack
72
+	 */
73
+	protected $request_stack;
74 74
 
75 75
 
76
-    /**
77
-     * BootstrapCore constructor.
78
-     */
79
-    public function __construct()
80
-    {
81
-        do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
82
-        // construct request stack and run middleware apps as soon as all WP plugins are loaded
83
-        add_action('plugins_loaded', array($this, 'initialize'), 0);
84
-    }
76
+	/**
77
+	 * BootstrapCore constructor.
78
+	 */
79
+	public function __construct()
80
+	{
81
+		do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
82
+		// construct request stack and run middleware apps as soon as all WP plugins are loaded
83
+		add_action('plugins_loaded', array($this, 'initialize'), 0);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * @throws DomainException
89
-     * @throws EE_Error
90
-     * @throws Exception
91
-     * @throws InvalidArgumentException
92
-     * @throws InvalidClassException
93
-     * @throws InvalidDataTypeException
94
-     * @throws InvalidFilePathException
95
-     * @throws InvalidInterfaceException
96
-     * @throws InvalidRequestStackMiddlewareException
97
-     * @throws OutOfBoundsException
98
-     * @throws ReflectionException
99
-     */
100
-    public function initialize()
101
-    {
102
-        $this->bootstrapDependencyInjectionContainer();
103
-        $this->bootstrapDomain();
104
-        $bootstrap_request = $this->bootstrapRequestResponseObjects();
105
-        add_action(
106
-            'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
107
-            array($bootstrap_request, 'setupLegacyRequest')
108
-        );
109
-        $this->runRequestStack();
110
-    }
87
+	/**
88
+	 * @throws DomainException
89
+	 * @throws EE_Error
90
+	 * @throws Exception
91
+	 * @throws InvalidArgumentException
92
+	 * @throws InvalidClassException
93
+	 * @throws InvalidDataTypeException
94
+	 * @throws InvalidFilePathException
95
+	 * @throws InvalidInterfaceException
96
+	 * @throws InvalidRequestStackMiddlewareException
97
+	 * @throws OutOfBoundsException
98
+	 * @throws ReflectionException
99
+	 */
100
+	public function initialize()
101
+	{
102
+		$this->bootstrapDependencyInjectionContainer();
103
+		$this->bootstrapDomain();
104
+		$bootstrap_request = $this->bootstrapRequestResponseObjects();
105
+		add_action(
106
+			'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
107
+			array($bootstrap_request, 'setupLegacyRequest')
108
+		);
109
+		$this->runRequestStack();
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * @throws ReflectionException
115
-     * @throws EE_Error
116
-     * @throws InvalidArgumentException
117
-     * @throws InvalidDataTypeException
118
-     * @throws InvalidInterfaceException
119
-     * @throws OutOfBoundsException
120
-     */
121
-    private function bootstrapDependencyInjectionContainer()
122
-    {
123
-        $bootstrap_di = new BootstrapDependencyInjectionContainer();
124
-        $bootstrap_di->buildLegacyDependencyInjectionContainer();
125
-        $bootstrap_di->buildLoader();
126
-        $registry = $bootstrap_di->getRegistry();
127
-        $dependency_map = $bootstrap_di->getDependencyMap();
128
-        $dependency_map->initialize();
129
-        $registry->initialize();
130
-        $this->loader = $bootstrap_di->getLoader();
131
-    }
113
+	/**
114
+	 * @throws ReflectionException
115
+	 * @throws EE_Error
116
+	 * @throws InvalidArgumentException
117
+	 * @throws InvalidDataTypeException
118
+	 * @throws InvalidInterfaceException
119
+	 * @throws OutOfBoundsException
120
+	 */
121
+	private function bootstrapDependencyInjectionContainer()
122
+	{
123
+		$bootstrap_di = new BootstrapDependencyInjectionContainer();
124
+		$bootstrap_di->buildLegacyDependencyInjectionContainer();
125
+		$bootstrap_di->buildLoader();
126
+		$registry = $bootstrap_di->getRegistry();
127
+		$dependency_map = $bootstrap_di->getDependencyMap();
128
+		$dependency_map->initialize();
129
+		$registry->initialize();
130
+		$this->loader = $bootstrap_di->getLoader();
131
+	}
132 132
 
133 133
 
134
-    /**
135
-     * configures the Domain object for core
136
-     *
137
-     * @return void
138
-     * @throws DomainException
139
-     * @throws InvalidArgumentException
140
-     * @throws InvalidDataTypeException
141
-     * @throws InvalidClassException
142
-     * @throws InvalidFilePathException
143
-     * @throws InvalidInterfaceException
144
-     */
145
-    private function bootstrapDomain()
146
-    {
147
-        DomainFactory::getEventEspressoCoreDomain();
148
-    }
134
+	/**
135
+	 * configures the Domain object for core
136
+	 *
137
+	 * @return void
138
+	 * @throws DomainException
139
+	 * @throws InvalidArgumentException
140
+	 * @throws InvalidDataTypeException
141
+	 * @throws InvalidClassException
142
+	 * @throws InvalidFilePathException
143
+	 * @throws InvalidInterfaceException
144
+	 */
145
+	private function bootstrapDomain()
146
+	{
147
+		DomainFactory::getEventEspressoCoreDomain();
148
+	}
149 149
 
150 150
 
151
-    /**
152
-     * sets up the request and response objects
153
-     *
154
-     * @return BootstrapRequestResponseObjects
155
-     * @throws InvalidArgumentException
156
-     */
157
-    private function bootstrapRequestResponseObjects()
158
-    {
159
-        /** @var BootstrapRequestResponseObjects $bootstrap_request */
160
-        $bootstrap_request = $this->loader->getShared(
161
-            'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
162
-            array($this->loader)
163
-        );
164
-        $bootstrap_request->buildRequestResponse();
165
-        $bootstrap_request->shareRequestResponse();
166
-        $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
167
-        $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
168
-        return $bootstrap_request;
169
-    }
151
+	/**
152
+	 * sets up the request and response objects
153
+	 *
154
+	 * @return BootstrapRequestResponseObjects
155
+	 * @throws InvalidArgumentException
156
+	 */
157
+	private function bootstrapRequestResponseObjects()
158
+	{
159
+		/** @var BootstrapRequestResponseObjects $bootstrap_request */
160
+		$bootstrap_request = $this->loader->getShared(
161
+			'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
162
+			array($this->loader)
163
+		);
164
+		$bootstrap_request->buildRequestResponse();
165
+		$bootstrap_request->shareRequestResponse();
166
+		$this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
167
+		$this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
168
+		return $bootstrap_request;
169
+	}
170 170
 
171 171
 
172
-    /**
173
-     * run_request_stack
174
-     * construct request stack and run middleware apps
175
-     *
176
-     * @throws EE_Error
177
-     * @throws Exception
178
-     */
179
-    public function runRequestStack()
180
-    {
181
-        $this->loadAutoloader();
182
-        $this->setAutoloadersForRequiredFiles();
183
-        $this->request_stack_builder = $this->buildRequestStack();
184
-        $this->request_stack = $this->request_stack_builder->resolve(
185
-            new RequestStackCoreApp()
186
-        );
187
-        $this->request_stack->handleRequest($this->request, $this->response);
188
-        $this->request_stack->handleResponse();
189
-    }
172
+	/**
173
+	 * run_request_stack
174
+	 * construct request stack and run middleware apps
175
+	 *
176
+	 * @throws EE_Error
177
+	 * @throws Exception
178
+	 */
179
+	public function runRequestStack()
180
+	{
181
+		$this->loadAutoloader();
182
+		$this->setAutoloadersForRequiredFiles();
183
+		$this->request_stack_builder = $this->buildRequestStack();
184
+		$this->request_stack = $this->request_stack_builder->resolve(
185
+			new RequestStackCoreApp()
186
+		);
187
+		$this->request_stack->handleRequest($this->request, $this->response);
188
+		$this->request_stack->handleResponse();
189
+	}
190 190
 
191 191
 
192
-    /**
193
-     * load_autoloader
194
-     *
195
-     * @throws EE_Error
196
-     */
197
-    protected function loadAutoloader()
198
-    {
199
-        // load interfaces
200
-        espresso_load_required(
201
-            'EEH_Autoloader',
202
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
203
-        );
204
-        EEH_Autoloader::instance();
205
-    }
192
+	/**
193
+	 * load_autoloader
194
+	 *
195
+	 * @throws EE_Error
196
+	 */
197
+	protected function loadAutoloader()
198
+	{
199
+		// load interfaces
200
+		espresso_load_required(
201
+			'EEH_Autoloader',
202
+			EE_CORE . 'helpers/EEH_Autoloader.helper.php'
203
+		);
204
+		EEH_Autoloader::instance();
205
+	}
206 206
 
207 207
 
208
-    /**
209
-     * load_required_files
210
-     *
211
-     * @throws EE_Error
212
-     */
213
-    protected function setAutoloadersForRequiredFiles()
214
-    {
215
-        // load interfaces
216
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
217
-        // load helpers
218
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219
-        // register legacy request stack classes just in case
220
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
221
-        // register legacy middleware classes just in case
222
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
223
-    }
208
+	/**
209
+	 * load_required_files
210
+	 *
211
+	 * @throws EE_Error
212
+	 */
213
+	protected function setAutoloadersForRequiredFiles()
214
+	{
215
+		// load interfaces
216
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
217
+		// load helpers
218
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219
+		// register legacy request stack classes just in case
220
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
221
+		// register legacy middleware classes just in case
222
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
223
+	}
224 224
 
225 225
 
226
-    /**
227
-     * build_request_stack
228
-     *
229
-     * @return RequestStackBuilder
230
-     */
231
-    public function buildRequestStack()
232
-    {
233
-        $request_stack_builder = new RequestStackBuilder($this->loader);
234
-        /**
235
-         * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
236
-         * so items at the beginning of the final middleware stack will run last.
237
-         * First parameter is the middleware classname, second is an array of arguments
238
-         */
239
-        $stack_apps = apply_filters(
240
-            'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
241
-            array(
242
-                // first in last out
243
-                'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
244
-                'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
245
-                'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
246
-                'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
247
-                // last in first out
248
-                'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
249
-            )
250
-        );
251
-        // legacy filter for backwards compatibility
252
-        $stack_apps = apply_filters(
253
-            'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
254
-            $stack_apps
255
-        );
256
-        // load middleware onto stack : FILO (First In Last Out)
257
-        // items at the beginning of the $stack_apps array will run last
258
-        foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
259
-            $request_stack_builder->push(array($stack_app, $stack_app_args));
260
-        }
261
-        // finally, we'll add this on its own because we need it to always be part of the stack
262
-        // and we also need it to always run first because the rest of the system relies on it
263
-        $request_stack_builder->push(
264
-            array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
265
-        );
266
-        return apply_filters(
267
-            'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
268
-            $request_stack_builder
269
-        );
270
-    }
226
+	/**
227
+	 * build_request_stack
228
+	 *
229
+	 * @return RequestStackBuilder
230
+	 */
231
+	public function buildRequestStack()
232
+	{
233
+		$request_stack_builder = new RequestStackBuilder($this->loader);
234
+		/**
235
+		 * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
236
+		 * so items at the beginning of the final middleware stack will run last.
237
+		 * First parameter is the middleware classname, second is an array of arguments
238
+		 */
239
+		$stack_apps = apply_filters(
240
+			'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
241
+			array(
242
+				// first in last out
243
+				'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
244
+				'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
245
+				'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
246
+				'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
247
+				// last in first out
248
+				'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
249
+			)
250
+		);
251
+		// legacy filter for backwards compatibility
252
+		$stack_apps = apply_filters(
253
+			'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
254
+			$stack_apps
255
+		);
256
+		// load middleware onto stack : FILO (First In Last Out)
257
+		// items at the beginning of the $stack_apps array will run last
258
+		foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
259
+			$request_stack_builder->push(array($stack_app, $stack_app_args));
260
+		}
261
+		// finally, we'll add this on its own because we need it to always be part of the stack
262
+		// and we also need it to always run first because the rest of the system relies on it
263
+		$request_stack_builder->push(
264
+			array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
265
+		);
266
+		return apply_filters(
267
+			'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
268
+			$request_stack_builder
269
+		);
270
+	}
271 271
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         // load interfaces
200 200
         espresso_load_required(
201 201
             'EEH_Autoloader',
202
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
202
+            EE_CORE.'helpers/EEH_Autoloader.helper.php'
203 203
         );
204 204
         EEH_Autoloader::instance();
205 205
     }
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
     protected function setAutoloadersForRequiredFiles()
214 214
     {
215 215
         // load interfaces
216
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
216
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces', true);
217 217
         // load helpers
218 218
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219 219
         // register legacy request stack classes just in case
220
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
220
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack/');
221 221
         // register legacy middleware classes just in case
222
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
222
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware/');
223 223
     }
224 224
 
225 225
 
Please login to merge, or discard this patch.