Completed
Branch BUG/reg-status-change-recursio... (906aa5)
by
unknown
09:44 queued 27s
created
core/libraries/messages/messenger/EE_Pdf_messenger.class.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation),
260 260
             'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation),
261 261
             'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation),
262
-            'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
262
+            'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css',
263 263
             'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content)
264 264
         );
265 265
         $this->_deregister_wp_hooks();
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
         $invoice_name = $this->_subject;
324 324
 
325 325
         // only load dompdf if nobody else has yet...
326
-        if (! class_exists('Dompdf\Dompdf')) {
327
-            require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
326
+        if ( ! class_exists('Dompdf\Dompdf')) {
327
+            require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php');
328 328
             Dompdf\Autoloader::register();
329 329
         }
330 330
         $options = new Dompdf\Options();
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         $dompdf->loadHtml($content);
337 337
         $dompdf->render();
338 338
         // forcing the browser to open a download dialog.
339
-        $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true));
339
+        $dompdf->stream($invoice_name.".pdf", array('Attachment' => true));
340 340
     }
341 341
 
342 342
 
Please login to merge, or discard this patch.
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -15,345 +15,345 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * The following are the properties that this messenger requires for generating pdf
20
-     */
21
-
22
-    /**
23
-     * This is the pdf body generated by the template via the message type.
24
-     *
25
-     * @var string
26
-     */
27
-    protected $_content;
28
-
29
-
30
-    /**
31
-     * This is for the page title that gets displayed.  This will end up being the filename for the generated pdf.
32
-     *
33
-     * @var string
34
-     */
35
-    protected $_subject;
36
-
37
-
38
-    /**
39
-     * @return EE_Pdf_messenger
40
-     */
41
-    public function __construct()
42
-    {
43
-        // set properties
44
-        $this->name = 'pdf';
45
-        $this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso');
46
-        $this->label = array(
47
-            'singular' => __('PDF', 'event_espresso'),
48
-            'plural' => __('PDFs', 'event_espresso')
49
-        );
50
-        $this->activate_on_install = true;
51
-
52
-        parent::__construct();
53
-    }
54
-
55
-
56
-    /**
57
-     * PDF Messenger desires execution immediately.
58
-     * @see  parent::send_now() for documentation.
59
-     * @since  4.9.0
60
-     * @return bool
61
-     */
62
-    public function send_now()
63
-    {
64
-        return true;
65
-    }
66
-
67
-
68
-    /**
69
-     * HTML Messenger allows an empty to field.
70
-     * @see parent::allow_empty_to_field() for documentation
71
-     * @since  4.9.0
72
-     * @return bool
73
-     */
74
-    public function allow_empty_to_field()
75
-    {
76
-        return true;
77
-    }
78
-
79
-
80
-    /**
81
-     * @see abstract declaration in EE_messenger for details.
82
-     */
83
-    protected function _set_admin_pages()
84
-    {
85
-        $this->admin_registered_pages = array('events_edit' => false);
86
-    }
87
-
88
-
89
-    /**
90
-     * @see abstract declaration in EE_messenger for details.
91
-     */
92
-    protected function _set_valid_shortcodes()
93
-    {
94
-        $this->_valid_shortcodes = array();
95
-    }
96
-
97
-
98
-    /**
99
-     * @see abstract declaration in EE_messenger for details.
100
-     */
101
-    protected function _set_validator_config()
102
-    {
103
-        $this->_validator_config = array(
104
-            'subject' => array(
105
-                'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
106
-            ),
107
-            'content' => array(
108
-                'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
109
-            ),
110
-            'attendee_list' => array(
111
-                'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
112
-                'required' => array('[ATTENDEE_LIST]')
113
-            ),
114
-            'event_list' => array(
115
-                'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'),
116
-                'required' => array('[EVENT_LIST]')
117
-            ),
118
-            'ticket_list' => array(
119
-                'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'),
120
-                'required' => array('[TICKET_LIST]')
121
-            ),
122
-            'datetime_list' => array(
123
-                'shortcodes' => array('datetime'),
124
-                'required' => array('[DATETIME_LIST]')
125
-            ),
126
-        );
127
-    }
128
-
129
-
130
-    /**
131
-     * Takes care of enqueuing any necessary scripts or styles for the page.  A do_action() so message types using this messenger can add their own js.
132
-     *
133
-     * @return void.
134
-     */
135
-    public function enqueue_scripts_styles()
136
-    {
137
-        parent::enqueue_scripts_styles();
138
-        do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles');
139
-    }
140
-
141
-
142
-    /**
143
-     * _set_template_fields
144
-     * This sets up the fields that a messenger requires for the message to go out.
145
-     *
146
-     * @access  protected
147
-     * @return void
148
-     */
149
-    protected function _set_template_fields()
150
-    {
151
-        // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to.  This is important for the Messages_admin to know what fields to display to the user.  Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed.
152
-        $this->_template_fields = array(
153
-            'subject' => array(
154
-                'input' => 'text',
155
-                'label' => __('Page Title', 'event_espresso'),
156
-                'type' => 'string',
157
-                'required' => true,
158
-                'validation' => true,
159
-                'css_class' => 'large-text',
160
-                'format' => '%s'
161
-            ),
162
-            'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
163
-            'extra' => array(
164
-                'content' => array(
165
-                    'main' => array(
166
-                        'input' => 'wp_editor',
167
-                        'label' => __('Main Content', 'event_espresso'),
168
-                        'type' => 'string',
169
-                        'required' => true,
170
-                        'validation' => true,
171
-                        'format' => '%s',
172
-                        'rows' => '15'
173
-                    ),
174
-                    'event_list' => array(
175
-                        'input' => 'wp_editor',
176
-                        'label' => '[EVENT_LIST]',
177
-                        'type' => 'string',
178
-                        'required' => true,
179
-                        'validation' => true,
180
-                        'format' => '%s',
181
-                        'rows' => '15',
182
-                        'shortcodes_required' => array('[EVENT_LIST]')
183
-                    ),
184
-                    'attendee_list' => array(
185
-                        'input' => 'textarea',
186
-                        'label' => '[ATTENDEE_LIST]',
187
-                        'type' => 'string',
188
-                        'required' => true,
189
-                        'validation' => true,
190
-                        'format' => '%s',
191
-                        'css_class' => 'large-text',
192
-                        'rows' => '5',
193
-                        'shortcodes_required' => array('[ATTENDEE_LIST]')
194
-                    ),
195
-                    'ticket_list' => array(
196
-                        'input' => 'textarea',
197
-                        'label' => '[TICKET_LIST]',
198
-                        'type' => 'string',
199
-                        'required' => true,
200
-                        'validation' => true,
201
-                        'format' => '%s',
202
-                        'css_class' => 'large-text',
203
-                        'rows' => '10',
204
-                        'shortcodes_required' => array('[TICKET_LIST]')
205
-                    ),
206
-                    'datetime_list' => array(
207
-                        'input' => 'textarea',
208
-                        'label' => '[DATETIME_LIST]',
209
-                        'type' => 'string',
210
-                        'required' => true,
211
-                        'validation' => true,
212
-                        'format' => '%s',
213
-                        'css_class' => 'large-text',
214
-                        'rows' => '10',
215
-                        'shortcodes_required' => array('[DATETIME_LIST]')
216
-                    )
217
-                )
218
-            )
219
-        );
220
-    }
221
-
222
-
223
-    /**
224
-     * @see definition of this method in parent
225
-     *
226
-     * @since 4.5.0
227
-     *
228
-     */
229
-    protected function _set_default_message_types()
230
-    {
231
-        // note currently PDF is only a secondary messenger so it never has any associated message types.
232
-        $this->_default_message_types = array();
233
-    }
234
-
235
-
236
-    /**
237
-     * @see definition of this method in parent
238
-     *
239
-     * @since 4.5.0
240
-     */
241
-    protected function _set_valid_message_types()
242
-    {
243
-        $this->_valid_message_types = array();
244
-    }
245
-
246
-
247
-    /**
248
-     * Generates html version of the message content and then sends it to the pdf generator.
249
-     *
250
-     *
251
-     * @since 4.5.0
252
-     *
253
-     * @return string.
254
-     */
255
-    protected function _send_message()
256
-    {
257
-        $this->_template_args = array(
258
-            'page_title' => $this->_subject,
259
-            'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation),
260
-            'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation),
261
-            'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation),
262
-            'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
263
-            'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content)
264
-        );
265
-        $this->_deregister_wp_hooks();
266
-        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
267
-        $content = $this->_get_main_template();
18
+	/**
19
+	 * The following are the properties that this messenger requires for generating pdf
20
+	 */
21
+
22
+	/**
23
+	 * This is the pdf body generated by the template via the message type.
24
+	 *
25
+	 * @var string
26
+	 */
27
+	protected $_content;
28
+
29
+
30
+	/**
31
+	 * This is for the page title that gets displayed.  This will end up being the filename for the generated pdf.
32
+	 *
33
+	 * @var string
34
+	 */
35
+	protected $_subject;
36
+
37
+
38
+	/**
39
+	 * @return EE_Pdf_messenger
40
+	 */
41
+	public function __construct()
42
+	{
43
+		// set properties
44
+		$this->name = 'pdf';
45
+		$this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso');
46
+		$this->label = array(
47
+			'singular' => __('PDF', 'event_espresso'),
48
+			'plural' => __('PDFs', 'event_espresso')
49
+		);
50
+		$this->activate_on_install = true;
51
+
52
+		parent::__construct();
53
+	}
54
+
55
+
56
+	/**
57
+	 * PDF Messenger desires execution immediately.
58
+	 * @see  parent::send_now() for documentation.
59
+	 * @since  4.9.0
60
+	 * @return bool
61
+	 */
62
+	public function send_now()
63
+	{
64
+		return true;
65
+	}
66
+
67
+
68
+	/**
69
+	 * HTML Messenger allows an empty to field.
70
+	 * @see parent::allow_empty_to_field() for documentation
71
+	 * @since  4.9.0
72
+	 * @return bool
73
+	 */
74
+	public function allow_empty_to_field()
75
+	{
76
+		return true;
77
+	}
78
+
79
+
80
+	/**
81
+	 * @see abstract declaration in EE_messenger for details.
82
+	 */
83
+	protected function _set_admin_pages()
84
+	{
85
+		$this->admin_registered_pages = array('events_edit' => false);
86
+	}
87
+
88
+
89
+	/**
90
+	 * @see abstract declaration in EE_messenger for details.
91
+	 */
92
+	protected function _set_valid_shortcodes()
93
+	{
94
+		$this->_valid_shortcodes = array();
95
+	}
96
+
97
+
98
+	/**
99
+	 * @see abstract declaration in EE_messenger for details.
100
+	 */
101
+	protected function _set_validator_config()
102
+	{
103
+		$this->_validator_config = array(
104
+			'subject' => array(
105
+				'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
106
+			),
107
+			'content' => array(
108
+				'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
109
+			),
110
+			'attendee_list' => array(
111
+				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
112
+				'required' => array('[ATTENDEE_LIST]')
113
+			),
114
+			'event_list' => array(
115
+				'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'),
116
+				'required' => array('[EVENT_LIST]')
117
+			),
118
+			'ticket_list' => array(
119
+				'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'),
120
+				'required' => array('[TICKET_LIST]')
121
+			),
122
+			'datetime_list' => array(
123
+				'shortcodes' => array('datetime'),
124
+				'required' => array('[DATETIME_LIST]')
125
+			),
126
+		);
127
+	}
128
+
129
+
130
+	/**
131
+	 * Takes care of enqueuing any necessary scripts or styles for the page.  A do_action() so message types using this messenger can add their own js.
132
+	 *
133
+	 * @return void.
134
+	 */
135
+	public function enqueue_scripts_styles()
136
+	{
137
+		parent::enqueue_scripts_styles();
138
+		do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles');
139
+	}
140
+
141
+
142
+	/**
143
+	 * _set_template_fields
144
+	 * This sets up the fields that a messenger requires for the message to go out.
145
+	 *
146
+	 * @access  protected
147
+	 * @return void
148
+	 */
149
+	protected function _set_template_fields()
150
+	{
151
+		// any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to.  This is important for the Messages_admin to know what fields to display to the user.  Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed.
152
+		$this->_template_fields = array(
153
+			'subject' => array(
154
+				'input' => 'text',
155
+				'label' => __('Page Title', 'event_espresso'),
156
+				'type' => 'string',
157
+				'required' => true,
158
+				'validation' => true,
159
+				'css_class' => 'large-text',
160
+				'format' => '%s'
161
+			),
162
+			'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
163
+			'extra' => array(
164
+				'content' => array(
165
+					'main' => array(
166
+						'input' => 'wp_editor',
167
+						'label' => __('Main Content', 'event_espresso'),
168
+						'type' => 'string',
169
+						'required' => true,
170
+						'validation' => true,
171
+						'format' => '%s',
172
+						'rows' => '15'
173
+					),
174
+					'event_list' => array(
175
+						'input' => 'wp_editor',
176
+						'label' => '[EVENT_LIST]',
177
+						'type' => 'string',
178
+						'required' => true,
179
+						'validation' => true,
180
+						'format' => '%s',
181
+						'rows' => '15',
182
+						'shortcodes_required' => array('[EVENT_LIST]')
183
+					),
184
+					'attendee_list' => array(
185
+						'input' => 'textarea',
186
+						'label' => '[ATTENDEE_LIST]',
187
+						'type' => 'string',
188
+						'required' => true,
189
+						'validation' => true,
190
+						'format' => '%s',
191
+						'css_class' => 'large-text',
192
+						'rows' => '5',
193
+						'shortcodes_required' => array('[ATTENDEE_LIST]')
194
+					),
195
+					'ticket_list' => array(
196
+						'input' => 'textarea',
197
+						'label' => '[TICKET_LIST]',
198
+						'type' => 'string',
199
+						'required' => true,
200
+						'validation' => true,
201
+						'format' => '%s',
202
+						'css_class' => 'large-text',
203
+						'rows' => '10',
204
+						'shortcodes_required' => array('[TICKET_LIST]')
205
+					),
206
+					'datetime_list' => array(
207
+						'input' => 'textarea',
208
+						'label' => '[DATETIME_LIST]',
209
+						'type' => 'string',
210
+						'required' => true,
211
+						'validation' => true,
212
+						'format' => '%s',
213
+						'css_class' => 'large-text',
214
+						'rows' => '10',
215
+						'shortcodes_required' => array('[DATETIME_LIST]')
216
+					)
217
+				)
218
+			)
219
+		);
220
+	}
221
+
222
+
223
+	/**
224
+	 * @see definition of this method in parent
225
+	 *
226
+	 * @since 4.5.0
227
+	 *
228
+	 */
229
+	protected function _set_default_message_types()
230
+	{
231
+		// note currently PDF is only a secondary messenger so it never has any associated message types.
232
+		$this->_default_message_types = array();
233
+	}
234
+
235
+
236
+	/**
237
+	 * @see definition of this method in parent
238
+	 *
239
+	 * @since 4.5.0
240
+	 */
241
+	protected function _set_valid_message_types()
242
+	{
243
+		$this->_valid_message_types = array();
244
+	}
245
+
246
+
247
+	/**
248
+	 * Generates html version of the message content and then sends it to the pdf generator.
249
+	 *
250
+	 *
251
+	 * @since 4.5.0
252
+	 *
253
+	 * @return string.
254
+	 */
255
+	protected function _send_message()
256
+	{
257
+		$this->_template_args = array(
258
+			'page_title' => $this->_subject,
259
+			'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation),
260
+			'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation),
261
+			'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation),
262
+			'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
263
+			'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content)
264
+		);
265
+		$this->_deregister_wp_hooks();
266
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
267
+		$content = $this->_get_main_template();
268 268
 //      die( $content );
269
-        $this->_do_pdf($content);
270
-        exit(0);
271
-    }
272
-
273
-
274
-    /**
275
-     * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates.  If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook.
276
-     *
277
-     * @since 4.5.0
278
-     *
279
-     * @return void
280
-     */
281
-    protected function _deregister_wp_hooks()
282
-    {
283
-        remove_all_actions('wp_head');
284
-        remove_all_actions('wp_footer');
285
-        remove_all_actions('wp_print_footer_scripts');
286
-        remove_all_actions('wp_enqueue_scripts');
287
-        global $wp_scripts, $wp_styles;
288
-        $wp_scripts = $wp_styles = array();
289
-
290
-        // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
291
-        add_action('wp_head', 'wp_enqueue_scripts');
292
-        add_action('wp_footer', 'wp_print_footer_scripts');
293
-        add_action('wp_print_footer_scripts', '_wp_footer_scripts');
294
-    }
295
-
296
-
297
-    /**
298
-     * Overwrite parent _get_main_template for pdf purposes.
299
-     *
300
-     * @since  4.5.0
301
-     *
302
-     * @param bool $preview
303
-     * @return string
304
-     */
305
-    protected function _get_main_template($preview = false)
306
-    {
307
-        $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main');
308
-        // add message type to template_args
309
-        $this->_template_args['message_type'] = $this->_incoming_message_type;
310
-        return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
311
-    }
312
-
313
-
314
-    /**
315
-     * This takes care of loading the dompdf library and generating the actual pdf
316
-     *
317
-     * @param string $content This is the generated html content being converted into a pdf.
318
-     *
319
-     * @return void
320
-     */
321
-    protected function _do_pdf($content = '')
322
-    {
323
-        $invoice_name = $this->_subject;
324
-
325
-        // only load dompdf if nobody else has yet...
326
-        if (! class_exists('Dompdf\Dompdf')) {
327
-            require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
328
-            Dompdf\Autoloader::register();
329
-        }
330
-        $options = new Dompdf\Options();
331
-        $options->set('isRemoteEnabled', true);
332
-        $options->set('isJavascriptEnabled', false);
333
-        if (defined('DOMPDF_FONT_DIR')) {
334
-            $options->setFontDir(DOMPDF_FONT_DIR);
335
-            $options->setFontCache(DOMPDF_FONT_DIR);
336
-        }
337
-        $dompdf = new Dompdf\Dompdf($options);
338
-        // Remove all spaces between HTML tags
339
-        $content = preg_replace('/>\s+</', '><', $content);
340
-        $dompdf->loadHtml($content);
341
-        $dompdf->render();
342
-        // forcing the browser to open a download dialog.
343
-        $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true));
344
-    }
345
-
346
-
347
-    /**
348
-     * @return string
349
-     */
350
-    protected function _preview()
351
-    {
352
-        return $this->_send_message();
353
-    }
354
-
355
-
356
-    protected function _set_admin_settings_fields()
357
-    {
358
-    }
269
+		$this->_do_pdf($content);
270
+		exit(0);
271
+	}
272
+
273
+
274
+	/**
275
+	 * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates.  If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook.
276
+	 *
277
+	 * @since 4.5.0
278
+	 *
279
+	 * @return void
280
+	 */
281
+	protected function _deregister_wp_hooks()
282
+	{
283
+		remove_all_actions('wp_head');
284
+		remove_all_actions('wp_footer');
285
+		remove_all_actions('wp_print_footer_scripts');
286
+		remove_all_actions('wp_enqueue_scripts');
287
+		global $wp_scripts, $wp_styles;
288
+		$wp_scripts = $wp_styles = array();
289
+
290
+		// just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
291
+		add_action('wp_head', 'wp_enqueue_scripts');
292
+		add_action('wp_footer', 'wp_print_footer_scripts');
293
+		add_action('wp_print_footer_scripts', '_wp_footer_scripts');
294
+	}
295
+
296
+
297
+	/**
298
+	 * Overwrite parent _get_main_template for pdf purposes.
299
+	 *
300
+	 * @since  4.5.0
301
+	 *
302
+	 * @param bool $preview
303
+	 * @return string
304
+	 */
305
+	protected function _get_main_template($preview = false)
306
+	{
307
+		$wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main');
308
+		// add message type to template_args
309
+		$this->_template_args['message_type'] = $this->_incoming_message_type;
310
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
311
+	}
312
+
313
+
314
+	/**
315
+	 * This takes care of loading the dompdf library and generating the actual pdf
316
+	 *
317
+	 * @param string $content This is the generated html content being converted into a pdf.
318
+	 *
319
+	 * @return void
320
+	 */
321
+	protected function _do_pdf($content = '')
322
+	{
323
+		$invoice_name = $this->_subject;
324
+
325
+		// only load dompdf if nobody else has yet...
326
+		if (! class_exists('Dompdf\Dompdf')) {
327
+			require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
328
+			Dompdf\Autoloader::register();
329
+		}
330
+		$options = new Dompdf\Options();
331
+		$options->set('isRemoteEnabled', true);
332
+		$options->set('isJavascriptEnabled', false);
333
+		if (defined('DOMPDF_FONT_DIR')) {
334
+			$options->setFontDir(DOMPDF_FONT_DIR);
335
+			$options->setFontCache(DOMPDF_FONT_DIR);
336
+		}
337
+		$dompdf = new Dompdf\Dompdf($options);
338
+		// Remove all spaces between HTML tags
339
+		$content = preg_replace('/>\s+</', '><', $content);
340
+		$dompdf->loadHtml($content);
341
+		$dompdf->render();
342
+		// forcing the browser to open a download dialog.
343
+		$dompdf->stream($invoice_name . ".pdf", array('Attachment' => true));
344
+	}
345
+
346
+
347
+	/**
348
+	 * @return string
349
+	 */
350
+	protected function _preview()
351
+	{
352
+		return $this->_send_message();
353
+	}
354
+
355
+
356
+	protected function _set_admin_settings_fields()
357
+	{
358
+	}
359 359
 }
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/Invoice.class.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
             7 => "union.css",
84 84
         );
85 85
         // Get the CSS file
86
-        if (isset($themes[ $theme_requested ])) {
87
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
86
+        if (isset($themes[$theme_requested])) {
87
+            $template_args['invoice_css'] = $themes[$theme_requested];
88 88
         } else {
89 89
             $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
90 90
                 'legacy_invoice_css',
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
             );
94 94
         }
95 95
 
96
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
97
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
96
+        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) {
97
+            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/';
98 98
         } else {
99
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
99
+            $template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/';
100 100
         }
101 101
         $primary_attendee = $this->transaction->primary_registration()->attendee();
102 102
 
103 103
         $template_args['organization'] = $EE->CFG->organization->get_pretty('name');
104 104
         $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty(
105 105
             'address_1'
106
-        ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2');
106
+        ) : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2');
107 107
         $template_args['city'] = $EE->CFG->organization->get_pretty('city');
108 108
         $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID(
109 109
             $EE->CFG->organization->STA_ID
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         if ($template_args['amount_pd'] != $template_args['total_cost']) {
150 150
             // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
151 151
             $tax_items = $this->transaction->tax_items();
152
-            if (! empty($tax_items)) {
152
+            if ( ! empty($tax_items)) {
153 153
                 foreach ($tax_items as $tax) {
154 154
                     $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
155 155
                 }
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
                 $line_items_for_this_event = EEM_Line_Item::instance()->get_all(
184 184
                     array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()))
185 185
                 );
186
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
186
+                $ticket_line_items_per_event[$event_id] = $line_items_for_this_event;
187 187
                 foreach ($line_items_for_this_event as $line_item_id => $line_item) {
188 188
                     $ticket = $line_item->ticket();
189 189
                     $registrations_for_this_ticket = EEM_Registration::instance()->get_all(
190 190
                         array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()))
191 191
                     );
192
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
192
+                    $registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket;
193 193
                 }
194 194
                 $venues_for_events = array_merge($venues_for_events, $event->venues());
195 195
             }
@@ -219,21 +219,21 @@  discard block
 block discarded – undo
219 219
         // Get the HTML as an object
220 220
         $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
221 221
         $template_header = EEH_Template::locate_template(
222
-            $templates_relative_path . 'invoice_header.template.php',
222
+            $templates_relative_path.'invoice_header.template.php',
223 223
             $template_args,
224 224
             true,
225 225
             true
226 226
         );
227 227
         if (isset($_GET['receipt'])) {
228 228
             $template_body = EEH_Template::locate_template(
229
-                $templates_relative_path . 'receipt_body.template.php',
229
+                $templates_relative_path.'receipt_body.template.php',
230 230
                 $template_args,
231 231
                 true,
232 232
                 true
233 233
             );
234 234
         } else {
235 235
             $template_body = EEH_Template::locate_template(
236
-                $templates_relative_path . 'invoice_body.template.php',
236
+                $templates_relative_path.'invoice_body.template.php',
237 237
                 $template_args,
238 238
                 true,
239 239
                 true
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 
244 244
         $template_footer = EEH_Template::locate_template(
245
-            $templates_relative_path . 'invoice_footer.template.php',
245
+            $templates_relative_path.'invoice_footer.template.php',
246 246
             $template_args,
247 247
             true,
248 248
             true
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
         $content .= $this->espresso_replace_invoice_shortcodes($template_footer);
258 258
 
259 259
         // Check if debugging or mobile is set
260
-        if (! empty($_REQUEST['html'])) {
260
+        if ( ! empty($_REQUEST['html'])) {
261 261
             echo $content;
262 262
             exit(0);
263 263
         }
264
-        $invoice_name = $template_args['organization'] . ' ' . __(
264
+        $invoice_name = $template_args['organization'].' '.__(
265 265
             'Invoice #',
266 266
             'event_espresso'
267
-        ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
267
+        ).$template_args['registration_code'].__(' for ', 'event_espresso').$template_args['name'];
268 268
         $invoice_name = str_replace(' ', '_', $invoice_name);
269 269
         // Create the PDF
270 270
         if (array_key_exists('html', $_GET)) {
271 271
             echo $content;
272 272
         } else {
273 273
             // only load dompdf if nobody else has yet...
274
-            if (! class_exists('Dompdf\Dompdf')) {
275
-                require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
274
+            if ( ! class_exists('Dompdf\Dompdf')) {
275
+                require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php');
276 276
                 Dompdf\Autoloader::register();
277 277
             }
278 278
             $options = new Dompdf\Options();
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             $dompdf = new Dompdf\Dompdf($options);
282 282
             $dompdf->loadHtml($content);
283 283
             $dompdf->render();
284
-            $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download));
284
+            $dompdf->stream($invoice_name.".pdf", array('Attachment' => $download));
285 285
         }
286 286
         exit(0);
287 287
     }
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
             true,
320 320
             $EE->CFG->organization->logo_url
321 321
         );
322
-        if (! empty($invoice_logo_url)) {
322
+        if ( ! empty($invoice_logo_url)) {
323 323
             $image_size = getimagesize($invoice_logo_url);
324
-            $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
324
+            $invoice_logo_image = '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> ';
325 325
         } else {
326 326
             $invoice_logo_image = '';
327 327
         }
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
             $this->registration->reg_code(),
355 355
             $this->transaction->ID(),
356 356
             $primary_attendee->full_name(),
357
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
358
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
357
+            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
358
+                : EE_GATEWAYS_URL.'Invoice/lib/templates/',
359 359
             $this->registration->invoice_url(),
360 360
             // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
361 361
             $invoice_logo_image,
362 362
             empty($EE->CFG->organization->address_2)
363 363
                 ? $EE->CFG->organization->get_pretty('address_1')
364
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
364
+                : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty(
365 365
                     'address_2'
366 366
                 ),
367 367
             $EE->CFG->organization->get_pretty('city'),
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
         $find = array(' ');
399 399
         $replace = array('-');
400 400
         $row_id = strtolower(str_replace($find, $replace, $text));
401
-        $html .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
402
-        $html .= '<td class="item_r">' . $text . '</td>';
403
-        $html .= '<td class="item_r">' . $total_cost . '</td>';
401
+        $html .= '<tr id="'.$row_id.'-tr"><td colspan="4">&nbsp;</td>';
402
+        $html .= '<td class="item_r">'.$text.'</td>';
403
+        $html .= '<td class="item_r">'.$total_cost.'</td>';
404 404
         $html .= '</tr>';
405 405
         return $html;
406 406
     }
Please login to merge, or discard this patch.
Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -9,403 +9,403 @@
 block discarded – undo
9 9
 class Invoice
10 10
 {
11 11
 
12
-    /**
13
-     *
14
-     * @var EE_Registration
15
-     */
16
-    private $registration;
17
-    /**
18
-     *
19
-     * @var EE_Transaction
20
-     */
21
-    private $transaction;
22
-    /**
23
-     *
24
-     * @var EE_Payment_Method
25
-     */
26
-    private $invoice_payment_method;
27
-    private $EE;
12
+	/**
13
+	 *
14
+	 * @var EE_Registration
15
+	 */
16
+	private $registration;
17
+	/**
18
+	 *
19
+	 * @var EE_Transaction
20
+	 */
21
+	private $transaction;
22
+	/**
23
+	 *
24
+	 * @var EE_Payment_Method
25
+	 */
26
+	private $invoice_payment_method;
27
+	private $EE;
28 28
 
29 29
 
30
-    /**
31
-     * Invoice constructor.
32
-     *
33
-     * @deprecated 4.9.13
34
-     * @param int $url_link
35
-     */
36
-    public function __construct($url_link = 0)
37
-    {
38
-        EE_Error::doing_it_wrong(
39
-            __CLASS__,
40
-            esc_html__(
41
-                'This class has been deprecated and replaced by the new Messages library.',
42
-                'event_espresso'
43
-            ),
44
-            '4.9.12',
45
-            '5.0.0'
46
-        );
47
-        if ($this->registration = EE_Registry::instance()->load_model(
48
-            'Registration'
49
-        )->get_registration_for_reg_url_link($url_link)) {
50
-            $this->transaction = $this->registration->transaction();
51
-            // get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
52
-            $payment_settings = EE_Config::instance()->gateway->payment_settings;
53
-            $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
54
-        } else {
55
-            EE_Error::add_error(
56
-                __(
57
-                    'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
58
-                    'event_espresso'
59
-                ),
60
-                __FILE__,
61
-                __FUNCTION__,
62
-                __LINE__
63
-            );
64
-        }
65
-    }
30
+	/**
31
+	 * Invoice constructor.
32
+	 *
33
+	 * @deprecated 4.9.13
34
+	 * @param int $url_link
35
+	 */
36
+	public function __construct($url_link = 0)
37
+	{
38
+		EE_Error::doing_it_wrong(
39
+			__CLASS__,
40
+			esc_html__(
41
+				'This class has been deprecated and replaced by the new Messages library.',
42
+				'event_espresso'
43
+			),
44
+			'4.9.12',
45
+			'5.0.0'
46
+		);
47
+		if ($this->registration = EE_Registry::instance()->load_model(
48
+			'Registration'
49
+		)->get_registration_for_reg_url_link($url_link)) {
50
+			$this->transaction = $this->registration->transaction();
51
+			// get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
52
+			$payment_settings = EE_Config::instance()->gateway->payment_settings;
53
+			$this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
54
+		} else {
55
+			EE_Error::add_error(
56
+				__(
57
+					'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
58
+					'event_espresso'
59
+				),
60
+				__FILE__,
61
+				__FUNCTION__,
62
+				__LINE__
63
+			);
64
+		}
65
+	}
66 66
 
67
-    public function send_invoice($download = false)
68
-    {
69
-        $template_args = array();
70
-        $EE = EE_Registry::instance();
67
+	public function send_invoice($download = false)
68
+	{
69
+		$template_args = array();
70
+		$EE = EE_Registry::instance();
71 71
 
72
-        // allow the request to override the default theme defined in the invoice settings
73
-        $theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint(
74
-            $_REQUEST['theme']
75
-        ) : null;
76
-        $themes = array(
77
-            1 => "simple.css",
78
-            2 => "bauhaus.css",
79
-            3 => "ejs.css",
80
-            4 => "horizon.css",
81
-            5 => "lola.css",
82
-            6 => "tranquility.css",
83
-            7 => "union.css",
84
-        );
85
-        // Get the CSS file
86
-        if (isset($themes[ $theme_requested ])) {
87
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
88
-        } else {
89
-            $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
90
-                'legacy_invoice_css',
91
-                true,
92
-                'simple.css'
93
-            );
94
-        }
72
+		// allow the request to override the default theme defined in the invoice settings
73
+		$theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint(
74
+			$_REQUEST['theme']
75
+		) : null;
76
+		$themes = array(
77
+			1 => "simple.css",
78
+			2 => "bauhaus.css",
79
+			3 => "ejs.css",
80
+			4 => "horizon.css",
81
+			5 => "lola.css",
82
+			6 => "tranquility.css",
83
+			7 => "union.css",
84
+		);
85
+		// Get the CSS file
86
+		if (isset($themes[ $theme_requested ])) {
87
+			$template_args['invoice_css'] = $themes[ $theme_requested ];
88
+		} else {
89
+			$template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
90
+				'legacy_invoice_css',
91
+				true,
92
+				'simple.css'
93
+			);
94
+		}
95 95
 
96
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
97
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
98
-        } else {
99
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
100
-        }
101
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
96
+		if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
97
+			$template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
98
+		} else {
99
+			$template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
100
+		}
101
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
102 102
 
103
-        $template_args['organization'] = $EE->CFG->organization->get_pretty('name');
104
-        $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty(
105
-            'address_1'
106
-        ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2');
107
-        $template_args['city'] = $EE->CFG->organization->get_pretty('city');
108
-        $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID(
109
-            $EE->CFG->organization->STA_ID
110
-        );
111
-        $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
112
-            $EE->CFG->organization->CNT_ISO
113
-        );
114
-        $template_args['zip'] = $EE->CFG->organization->get_pretty('zip');
115
-        $template_args['email'] = $EE->CFG->organization->get_pretty('email');
103
+		$template_args['organization'] = $EE->CFG->organization->get_pretty('name');
104
+		$template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty(
105
+			'address_1'
106
+		) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2');
107
+		$template_args['city'] = $EE->CFG->organization->get_pretty('city');
108
+		$template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID(
109
+			$EE->CFG->organization->STA_ID
110
+		);
111
+		$template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
112
+			$EE->CFG->organization->CNT_ISO
113
+		);
114
+		$template_args['zip'] = $EE->CFG->organization->get_pretty('zip');
115
+		$template_args['email'] = $EE->CFG->organization->get_pretty('email');
116 116
 
117
-        $template_args['registration_code'] = $this->registration->reg_code();
118
-        $template_args['registration_date'] = $this->registration->date();
119
-        $template_args['name'] = $primary_attendee->full_name();
120
-        $template_args['attendee_address'] = $primary_attendee->address();
121
-        $template_args['attendee_address2'] = $primary_attendee->address2();
122
-        $template_args['attendee_city'] = $primary_attendee->city();
123
-        $attendee_state = $primary_attendee->state_obj();
124
-        if ($attendee_state) {
125
-            $attendee_state_name = $attendee_state->name();
126
-        } else {
127
-            $attendee_state_name = '';
128
-        }
129
-        $template_args['attendee_state'] = $attendee_state_name;
130
-        $template_args['attendee_zip'] = $primary_attendee->zip();
117
+		$template_args['registration_code'] = $this->registration->reg_code();
118
+		$template_args['registration_date'] = $this->registration->date();
119
+		$template_args['name'] = $primary_attendee->full_name();
120
+		$template_args['attendee_address'] = $primary_attendee->address();
121
+		$template_args['attendee_address2'] = $primary_attendee->address2();
122
+		$template_args['attendee_city'] = $primary_attendee->city();
123
+		$attendee_state = $primary_attendee->state_obj();
124
+		if ($attendee_state) {
125
+			$attendee_state_name = $attendee_state->name();
126
+		} else {
127
+			$attendee_state_name = '';
128
+		}
129
+		$template_args['attendee_state'] = $attendee_state_name;
130
+		$template_args['attendee_zip'] = $primary_attendee->zip();
131 131
 
132
-        $template_args['ship_name'] = $template_args['name'];
133
-        $template_args['ship_address'] = $template_args['attendee_address'];
134
-        $template_args['ship_city'] = $template_args['attendee_city'];
135
-        $template_args['ship_state'] = $template_args['attendee_state'];
136
-        $template_args['ship_zip'] = $template_args['attendee_zip'];
132
+		$template_args['ship_name'] = $template_args['name'];
133
+		$template_args['ship_address'] = $template_args['attendee_address'];
134
+		$template_args['ship_city'] = $template_args['attendee_city'];
135
+		$template_args['ship_state'] = $template_args['attendee_state'];
136
+		$template_args['ship_zip'] = $template_args['attendee_zip'];
137 137
 
138
-        $template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', '');
139
-        $template_args['transaction'] = $this->transaction;
140
-        $template_args['amount_pd'] = $this->transaction->paid();
141
-        $template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid();
142
-        $template_args['payments'] = $this->transaction->approved_payments();
143
-        $template_args['net_total'] = '';
144
-        $template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url();
145
-        $template_args['retry_payment_url'] = $this->registration->payment_overview_url();
146
-        $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
147
-            $this->transaction->total_line_item()
148
-        );
149
-        if ($template_args['amount_pd'] != $template_args['total_cost']) {
150
-            // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
151
-            $tax_items = $this->transaction->tax_items();
152
-            if (! empty($tax_items)) {
153
-                foreach ($tax_items as $tax) {
154
-                    $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
155
-                }
156
-            }
138
+		$template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', '');
139
+		$template_args['transaction'] = $this->transaction;
140
+		$template_args['amount_pd'] = $this->transaction->paid();
141
+		$template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid();
142
+		$template_args['payments'] = $this->transaction->approved_payments();
143
+		$template_args['net_total'] = '';
144
+		$template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url();
145
+		$template_args['retry_payment_url'] = $this->registration->payment_overview_url();
146
+		$template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
147
+			$this->transaction->total_line_item()
148
+		);
149
+		if ($template_args['amount_pd'] != $template_args['total_cost']) {
150
+			// $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
151
+			$tax_items = $this->transaction->tax_items();
152
+			if (! empty($tax_items)) {
153
+				foreach ($tax_items as $tax) {
154
+					$template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
155
+				}
156
+			}
157 157
 
158
-            $difference = $template_args['amount_pd'] - $template_args['total_cost'];
159
-            if ($difference < 0) {
160
-                $text = __('Discount', 'event_espresso');
161
-            } else {
162
-                $text = __('Extra', 'event_espresso');
163
-            }
164
-            $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
165
-        }
158
+			$difference = $template_args['amount_pd'] - $template_args['total_cost'];
159
+			if ($difference < 0) {
160
+				$text = __('Discount', 'event_espresso');
161
+			} else {
162
+				$text = __('Extra', 'event_espresso');
163
+			}
164
+			$template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
165
+		}
166 166
 
167
-        $template_args['currency_symbol'] = $EE->CFG->currency->sign;
168
-        $template_args['template_payment_instructions'] = wpautop(
169
-            stripslashes_deep(
170
-                html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
171
-            )
172
-        );
173
-        $template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true);
174
-        if (isset($_GET['receipt'])) {
175
-            // receipt-specific stuff
176
-            $events_for_txn = EEM_Event::instance()->get_all(
177
-                array(array('Registration.TXN_ID' => $this->transaction->ID()))
178
-            );
179
-            $ticket_line_items_per_event = array();
180
-            $registrations_per_line_item = array();
181
-            $venues_for_events = array();
182
-            foreach ($events_for_txn as $event_id => $event) {
183
-                $line_items_for_this_event = EEM_Line_Item::instance()->get_all(
184
-                    array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()))
185
-                );
186
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
187
-                foreach ($line_items_for_this_event as $line_item_id => $line_item) {
188
-                    $ticket = $line_item->ticket();
189
-                    $registrations_for_this_ticket = EEM_Registration::instance()->get_all(
190
-                        array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()))
191
-                    );
192
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
193
-                }
194
-                $venues_for_events = array_merge($venues_for_events, $event->venues());
195
-            }
196
-            $tax_total_line_item = EEM_Line_Item::instance()->get_one(
197
-                array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total))
198
-            );
199
-            $questions_to_skip = array(
200
-                EEM_Attendee::system_question_fname,
201
-                EEM_Attendee::system_question_lname,
202
-                EEM_Attendee::system_question_email,
203
-            );
167
+		$template_args['currency_symbol'] = $EE->CFG->currency->sign;
168
+		$template_args['template_payment_instructions'] = wpautop(
169
+			stripslashes_deep(
170
+				html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
171
+			)
172
+		);
173
+		$template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true);
174
+		if (isset($_GET['receipt'])) {
175
+			// receipt-specific stuff
176
+			$events_for_txn = EEM_Event::instance()->get_all(
177
+				array(array('Registration.TXN_ID' => $this->transaction->ID()))
178
+			);
179
+			$ticket_line_items_per_event = array();
180
+			$registrations_per_line_item = array();
181
+			$venues_for_events = array();
182
+			foreach ($events_for_txn as $event_id => $event) {
183
+				$line_items_for_this_event = EEM_Line_Item::instance()->get_all(
184
+					array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()))
185
+				);
186
+				$ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
187
+				foreach ($line_items_for_this_event as $line_item_id => $line_item) {
188
+					$ticket = $line_item->ticket();
189
+					$registrations_for_this_ticket = EEM_Registration::instance()->get_all(
190
+						array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()))
191
+					);
192
+					$registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
193
+				}
194
+				$venues_for_events = array_merge($venues_for_events, $event->venues());
195
+			}
196
+			$tax_total_line_item = EEM_Line_Item::instance()->get_one(
197
+				array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total))
198
+			);
199
+			$questions_to_skip = array(
200
+				EEM_Attendee::system_question_fname,
201
+				EEM_Attendee::system_question_lname,
202
+				EEM_Attendee::system_question_email,
203
+			);
204 204
 
205 205
 
206
-            $template_args['events_for_txn'] = $events_for_txn;
207
-            $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
208
-            $template_args['registrations_per_line_item'] = $registrations_per_line_item;
209
-            $template_args['venues_for_events'] = $venues_for_events;
210
-            $template_args['tax_total_line_item'] = $tax_total_line_item;
211
-            $template_args['questions_to_skip'] = $questions_to_skip;
212
-            // d($template_args);
213
-            $template_args['download_link'] = $this->registration->receipt_url('download');
214
-        } else {
215
-            // it's just an invoice we're accessing
216
-            $template_args['download_link'] = $this->registration->invoice_url('download');
217
-        }
206
+			$template_args['events_for_txn'] = $events_for_txn;
207
+			$template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
208
+			$template_args['registrations_per_line_item'] = $registrations_per_line_item;
209
+			$template_args['venues_for_events'] = $venues_for_events;
210
+			$template_args['tax_total_line_item'] = $tax_total_line_item;
211
+			$template_args['questions_to_skip'] = $questions_to_skip;
212
+			// d($template_args);
213
+			$template_args['download_link'] = $this->registration->receipt_url('download');
214
+		} else {
215
+			// it's just an invoice we're accessing
216
+			$template_args['download_link'] = $this->registration->invoice_url('download');
217
+		}
218 218
 
219
-        // Get the HTML as an object
220
-        $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
221
-        $template_header = EEH_Template::locate_template(
222
-            $templates_relative_path . 'invoice_header.template.php',
223
-            $template_args,
224
-            true,
225
-            true
226
-        );
227
-        if (isset($_GET['receipt'])) {
228
-            $template_body = EEH_Template::locate_template(
229
-                $templates_relative_path . 'receipt_body.template.php',
230
-                $template_args,
231
-                true,
232
-                true
233
-            );
234
-        } else {
235
-            $template_body = EEH_Template::locate_template(
236
-                $templates_relative_path . 'invoice_body.template.php',
237
-                $template_args,
238
-                true,
239
-                true
240
-            );
241
-        }
219
+		// Get the HTML as an object
220
+		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
221
+		$template_header = EEH_Template::locate_template(
222
+			$templates_relative_path . 'invoice_header.template.php',
223
+			$template_args,
224
+			true,
225
+			true
226
+		);
227
+		if (isset($_GET['receipt'])) {
228
+			$template_body = EEH_Template::locate_template(
229
+				$templates_relative_path . 'receipt_body.template.php',
230
+				$template_args,
231
+				true,
232
+				true
233
+			);
234
+		} else {
235
+			$template_body = EEH_Template::locate_template(
236
+				$templates_relative_path . 'invoice_body.template.php',
237
+				$template_args,
238
+				true,
239
+				true
240
+			);
241
+		}
242 242
 
243 243
 
244
-        $template_footer = EEH_Template::locate_template(
245
-            $templates_relative_path . 'invoice_footer.template.php',
246
-            $template_args,
247
-            true,
248
-            true
249
-        );
244
+		$template_footer = EEH_Template::locate_template(
245
+			$templates_relative_path . 'invoice_footer.template.php',
246
+			$template_args,
247
+			true,
248
+			true
249
+		);
250 250
 
251
-        $copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1;
251
+		$copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1;
252 252
 
253
-        $content = $this->espresso_replace_invoice_shortcodes($template_header);
254
-        for ($x = 1; $x <= $copies; $x++) {
255
-            $content .= $this->espresso_replace_invoice_shortcodes($template_body);
256
-        }
257
-        $content .= $this->espresso_replace_invoice_shortcodes($template_footer);
253
+		$content = $this->espresso_replace_invoice_shortcodes($template_header);
254
+		for ($x = 1; $x <= $copies; $x++) {
255
+			$content .= $this->espresso_replace_invoice_shortcodes($template_body);
256
+		}
257
+		$content .= $this->espresso_replace_invoice_shortcodes($template_footer);
258 258
 
259
-        // Check if debugging or mobile is set
260
-        if (! empty($_REQUEST['html'])) {
261
-            echo $content;
262
-            exit(0);
263
-        }
264
-        $invoice_name = $template_args['organization'] . ' ' . __(
265
-            'Invoice #',
266
-            'event_espresso'
267
-        ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
268
-        $invoice_name = str_replace(' ', '_', $invoice_name);
269
-        // Create the PDF
270
-        if (array_key_exists('html', $_GET)) {
271
-            echo $content;
272
-        } else {
273
-            // only load dompdf if nobody else has yet...
274
-            if (! class_exists('Dompdf\Dompdf')) {
275
-                require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
276
-                Dompdf\Autoloader::register();
277
-            }
278
-            $options = new Dompdf\Options();
279
-            $options->set('isRemoteEnabled', true);
280
-            $options->set('isJavascriptEnabled', false);
281
-            if (defined('DOMPDF_FONT_DIR')) {
282
-                $options->setFontDir(DOMPDF_FONT_DIR);
283
-                $options->setFontCache(DOMPDF_FONT_DIR);
284
-            }
285
-            $dompdf = new Dompdf\Dompdf($options);
286
-            $dompdf->loadHtml($content);
287
-            $dompdf->render();
288
-            $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download));
289
-        }
290
-        exit(0);
291
-    }
259
+		// Check if debugging or mobile is set
260
+		if (! empty($_REQUEST['html'])) {
261
+			echo $content;
262
+			exit(0);
263
+		}
264
+		$invoice_name = $template_args['organization'] . ' ' . __(
265
+			'Invoice #',
266
+			'event_espresso'
267
+		) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
268
+		$invoice_name = str_replace(' ', '_', $invoice_name);
269
+		// Create the PDF
270
+		if (array_key_exists('html', $_GET)) {
271
+			echo $content;
272
+		} else {
273
+			// only load dompdf if nobody else has yet...
274
+			if (! class_exists('Dompdf\Dompdf')) {
275
+				require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
276
+				Dompdf\Autoloader::register();
277
+			}
278
+			$options = new Dompdf\Options();
279
+			$options->set('isRemoteEnabled', true);
280
+			$options->set('isJavascriptEnabled', false);
281
+			if (defined('DOMPDF_FONT_DIR')) {
282
+				$options->setFontDir(DOMPDF_FONT_DIR);
283
+				$options->setFontCache(DOMPDF_FONT_DIR);
284
+			}
285
+			$dompdf = new Dompdf\Dompdf($options);
286
+			$dompdf->loadHtml($content);
287
+			$dompdf->render();
288
+			$dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download));
289
+		}
290
+		exit(0);
291
+	}
292 292
 
293
-    /**
294
-     * Checks if this line item, or any of its children, actually has a description.
295
-     * If none do, then the template can decide to not show any description column
296
-     *
297
-     * @param EE_Line_Item $line_item
298
-     * @return boolean
299
-     */
300
-    public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
301
-    {
302
-        if ($line_item->desc()) {
303
-            return true;
304
-        } else {
305
-            foreach ($line_item->children() as $child_line_item) {
306
-                if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
307
-                    return true;
308
-                }
309
-            }
310
-            // well, if I and my children don't have descriptions, I guess not
311
-            return false;
312
-        }
313
-    }
293
+	/**
294
+	 * Checks if this line item, or any of its children, actually has a description.
295
+	 * If none do, then the template can decide to not show any description column
296
+	 *
297
+	 * @param EE_Line_Item $line_item
298
+	 * @return boolean
299
+	 */
300
+	public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
301
+	{
302
+		if ($line_item->desc()) {
303
+			return true;
304
+		} else {
305
+			foreach ($line_item->children() as $child_line_item) {
306
+				if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
307
+					return true;
308
+				}
309
+			}
310
+			// well, if I and my children don't have descriptions, I guess not
311
+			return false;
312
+		}
313
+	}
314 314
 
315 315
 // Perform the shortcode replacement
316
-    public function espresso_replace_invoice_shortcodes($content)
317
-    {
316
+	public function espresso_replace_invoice_shortcodes($content)
317
+	{
318 318
 
319
-        $EE = EE_Registry::instance();
320
-        // Create the logo
321
-        $invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
322
-            'pdf_logo_image',
323
-            true,
324
-            $EE->CFG->organization->logo_url
325
-        );
326
-        if (! empty($invoice_logo_url)) {
327
-            $image_size = getimagesize($invoice_logo_url);
328
-            $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
329
-        } else {
330
-            $invoice_logo_image = '';
331
-        }
332
-        $SearchValues = array(
333
-            "[organization]",
334
-            "[registration_code]",
335
-            "[transaction_id]",
336
-            "[name]",
337
-            "[base_url]",
338
-            "[download_link]",
339
-            "[invoice_logo_image]",
340
-            "[street]",
341
-            "[city]",
342
-            "[state]",
343
-            "[zip]",
344
-            "[email]",
345
-            "[vat]",
346
-            "[registration_date]",
347
-            "[instructions]",
348
-        );
349
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
350
-        $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
351
-        if ($org_state) {
352
-            $org_state_name = $org_state->name();
353
-        } else {
354
-            $org_state_name = '';
355
-        }
356
-        $ReplaceValues = array(
357
-            $EE->CFG->organization->get_pretty('name'),
358
-            $this->registration->reg_code(),
359
-            $this->transaction->ID(),
360
-            $primary_attendee->full_name(),
361
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
362
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
363
-            $this->registration->invoice_url(),
364
-            // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
365
-            $invoice_logo_image,
366
-            empty($EE->CFG->organization->address_2)
367
-                ? $EE->CFG->organization->get_pretty('address_1')
368
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
369
-                    'address_2'
370
-                ),
371
-            $EE->CFG->organization->get_pretty('city'),
372
-            $org_state_name,
373
-            $EE->CFG->organization->get_pretty('zip'),
374
-            $EE->CFG->organization->get_pretty('email'),
375
-            $EE->CFG->organization->vat,
376
-            $this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
377
-            $this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
378
-        );
319
+		$EE = EE_Registry::instance();
320
+		// Create the logo
321
+		$invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
322
+			'pdf_logo_image',
323
+			true,
324
+			$EE->CFG->organization->logo_url
325
+		);
326
+		if (! empty($invoice_logo_url)) {
327
+			$image_size = getimagesize($invoice_logo_url);
328
+			$invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
329
+		} else {
330
+			$invoice_logo_image = '';
331
+		}
332
+		$SearchValues = array(
333
+			"[organization]",
334
+			"[registration_code]",
335
+			"[transaction_id]",
336
+			"[name]",
337
+			"[base_url]",
338
+			"[download_link]",
339
+			"[invoice_logo_image]",
340
+			"[street]",
341
+			"[city]",
342
+			"[state]",
343
+			"[zip]",
344
+			"[email]",
345
+			"[vat]",
346
+			"[registration_date]",
347
+			"[instructions]",
348
+		);
349
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
350
+		$org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
351
+		if ($org_state) {
352
+			$org_state_name = $org_state->name();
353
+		} else {
354
+			$org_state_name = '';
355
+		}
356
+		$ReplaceValues = array(
357
+			$EE->CFG->organization->get_pretty('name'),
358
+			$this->registration->reg_code(),
359
+			$this->transaction->ID(),
360
+			$primary_attendee->full_name(),
361
+			(is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
362
+				: EE_GATEWAYS_URL . 'Invoice/lib/templates/',
363
+			$this->registration->invoice_url(),
364
+			// home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
365
+			$invoice_logo_image,
366
+			empty($EE->CFG->organization->address_2)
367
+				? $EE->CFG->organization->get_pretty('address_1')
368
+				: $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
369
+					'address_2'
370
+				),
371
+			$EE->CFG->organization->get_pretty('city'),
372
+			$org_state_name,
373
+			$EE->CFG->organization->get_pretty('zip'),
374
+			$EE->CFG->organization->get_pretty('email'),
375
+			$EE->CFG->organization->vat,
376
+			$this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
377
+			$this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
378
+		);
379 379
 
380
-        return str_replace($SearchValues, $ReplaceValues, $content);
381
-    }
380
+		return str_replace($SearchValues, $ReplaceValues, $content);
381
+	}
382 382
 
383
-    public function espressoLoadData($items)
384
-    {
385
-        $lines = $items;
386
-        $data = array();
387
-        foreach ($lines as $line) {
388
-            $data[] = explode(';', chop($line));
389
-        }
383
+	public function espressoLoadData($items)
384
+	{
385
+		$lines = $items;
386
+		$data = array();
387
+		foreach ($lines as $line) {
388
+			$data[] = explode(';', chop($line));
389
+		}
390 390
 
391
-        return $data;
392
-    }
391
+		return $data;
392
+	}
393 393
 
394 394
 
395
-    public function espressoInvoiceTotals($text, $total_cost)
396
-    {
395
+	public function espressoInvoiceTotals($text, $total_cost)
396
+	{
397 397
 
398
-        $html = '';
399
-        if ($total_cost < 0) {
400
-            $total_cost = (-1) * $total_cost;
401
-        }
402
-        $find = array(' ');
403
-        $replace = array('-');
404
-        $row_id = strtolower(str_replace($find, $replace, $text));
405
-        $html .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
406
-        $html .= '<td class="item_r">' . $text . '</td>';
407
-        $html .= '<td class="item_r">' . $total_cost . '</td>';
408
-        $html .= '</tr>';
409
-        return $html;
410
-    }
398
+		$html = '';
399
+		if ($total_cost < 0) {
400
+			$total_cost = (-1) * $total_cost;
401
+		}
402
+		$find = array(' ');
403
+		$replace = array('-');
404
+		$row_id = strtolower(str_replace($find, $replace, $text));
405
+		$html .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
406
+		$html .= '<td class="item_r">' . $text . '</td>';
407
+		$html .= '<td class="item_r">' . $total_cost . '</td>';
408
+		$html .= '</tr>';
409
+		return $html;
410
+	}
411 411
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Question_Form_Input.class.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      *
376 376
      * @access public
377 377
      * @param \EE_Question_Option $QSO EE_Question_Option
378
-     * @return boolean
378
+     * @return boolean|null
379 379
      */
380 380
     public function add_temp_option(EE_Question_Option $QSO)
381 381
     {
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
      *
389 389
      * @access public
390 390
      * @param    string $property
391
-     * @param    mixed  $value
392
-     * @return mixed
391
+     * @param    boolean  $value
392
+     * @return boolean|null
393 393
      */
394 394
     public function set($property = null, $value = null)
395 395
     {
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
      *    get_meta
438 438
      *
439 439
      * @access public
440
-     * @param mixed $key
440
+     * @param string $key
441 441
      * @return mixed
442 442
      */
443 443
     public function get_meta($key = false)
Please login to merge, or discard this patch.
Indentation   +431 added lines, -431 removed lines patch added patch discarded remove patch
@@ -13,435 +13,435 @@
 block discarded – undo
13 13
 class EE_Question_Form_Input
14 14
 {
15 15
 
16
-    /**
17
-     *    EE_Question object
18
-     *
19
-     * @access private
20
-     * @var object
21
-     */
22
-    private $_QST = null;
23
-
24
-    /**
25
-     *    EE_Answer object
26
-     *
27
-     * @access private
28
-     * @var object
29
-     */
30
-    private $_ANS = null;
31
-
32
-    /**
33
-     *    $_QST_meta
34
-     * @access private
35
-     * @var array
36
-     */
37
-    private $_QST_meta = array();
38
-
39
-    /**
40
-     *    $QST_input_name
41
-     * @access private
42
-     * @var string
43
-     */
44
-    private $QST_input_name = '';
45
-
46
-    /**
47
-     *    $QST_input_id
48
-     * @access private
49
-     * @var string
50
-     */
51
-    private $QST_input_id = '';
52
-
53
-    /**
54
-     *    $QST_input_class
55
-     * @access private
56
-     * @var string
57
-     */
58
-    private $QST_input_class = '';
59
-
60
-    /**
61
-     * @var bool $QST_disabled
62
-     */
63
-    private $QST_disabled = false;
64
-
65
-
66
-    /**
67
-     * constructor for questions
68
-     *
69
-     * @param \EE_Question $QST EE_Question object
70
-     * @param \EE_Answer   $ANS EE_Answer object
71
-     * @param array        $q_meta
72
-     * @access public
73
-     * @return \EE_Question_Form_Input
74
-     */
75
-    public function __construct(EE_Question $QST = null, EE_Answer $ANS = null, $q_meta = array())
76
-    {
77
-        if (empty($QST) || empty($ANS)) {
78
-            EE_Error::add_error(
79
-                __('An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso'),
80
-                __FILE__,
81
-                __FUNCTION__,
82
-                __LINE__
83
-            );
84
-            return null;
85
-        }
86
-        $this->_QST = $QST;
87
-        $this->_ANS = $ANS;
88
-        $this->set_question_form_input_meta($q_meta);
89
-        $this->set_question_form_input_init();
90
-    }
91
-
92
-
93
-    /**
94
-     * sets meta data for the question form input
95
-     *
96
-     * @access public
97
-     * @param array $q_meta
98
-     * @return void
99
-     */
100
-    public function set_question_form_input_meta($q_meta = array())
101
-    {
102
-        $default_q_meta = array(
103
-            'att_nmbr'       => 1,
104
-            'ticket_id'      => '',
105
-            'date'           => '',
106
-            'time'           => '',
107
-            'input_name'     => '',
108
-            'input_id'       => '',
109
-            'input_class'    => '',
110
-            'input_prefix'   => 'qstn',
111
-            'append_qstn_id' => true,
112
-            'htmlentities'   => true,
113
-            'allow_null'     => false,
114
-        );
115
-        $this->_QST_meta = array_merge($default_q_meta, $q_meta);
116
-    }
117
-
118
-
119
-    /**
120
-     * set_question_form_input_init
121
-     *
122
-     * @access public
123
-     * @return void
124
-     */
125
-    public function set_question_form_input_init()
126
-    {
127
-        $qstn_id = $this->_QST->system_ID() ? $this->_QST->system_ID() : $this->_QST->ID();
128
-        $this->_set_input_name($qstn_id);
129
-        $this->_set_input_id($qstn_id);
130
-        $this->_set_input_class($qstn_id);
131
-        $this->set_question_form_input_answer($qstn_id);
132
-    }
133
-
134
-
135
-    /**
136
-     * set_input_name
137
-     *
138
-     * @access private
139
-     * @param $qstn_id
140
-     * @return void
141
-     */
142
-    private function _set_input_name($qstn_id)
143
-    {
144
-        if (! empty($qstn_id)) {
145
-            $ANS_ID = $this->get('ANS_ID');
146
-            $qstn_id = ! empty($ANS_ID) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']';
147
-        }
148
-        $this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id)
149
-            ? $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'] . $qstn_id
150
-            : $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'];
151
-    }
152
-
153
-
154
-    /**
155
-     * get property values for question form input
156
-     *
157
-     * @access public
158
-     * @param    string $property
159
-     * @return mixed
160
-     */
161
-    public function get($property = null)
162
-    {
163
-        if (! empty($property)) {
164
-            if (EEM_Question::instance()->has_field($property)) {
165
-                return $this->_QST->get($property);
166
-            } elseif (EEM_Answer::instance()->has_field($property)) {
167
-                return $this->_ANS->get($property);
168
-            } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) {
169
-                return $this->{$property};
170
-            }
171
-        }
172
-        return null;
173
-    }
174
-
175
-
176
-    /**
177
-     *    _question_form_input_property_exists
178
-     *
179
-     * @access private
180
-     * @param    string $classname
181
-     * @param    string $property
182
-     * @return boolean
183
-     */
184
-    private function _question_form_input_property_exists($classname, $property)
185
-    {
186
-        // first try regular property exists method which works as expected in PHP 5.3+
187
-        $prop = EEH_Class_Tools::has_property($classname, $property);
188
-        if (! $prop) {
189
-            // use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction
190
-            $reflector = new ReflectionClass($classname);
191
-            $prop = $reflector->hasProperty($property);
192
-        }
193
-        return $prop;
194
-    }
195
-
196
-
197
-    /**
198
-     * set_input_id
199
-     *
200
-     * @access private
201
-     * @param $qstn_id
202
-     * @return void
203
-     */
204
-    private function _set_input_id($qstn_id)
205
-    {
206
-        $input_id = isset($this->_QST_meta['input_id']) && ! empty($this->_QST_meta['input_id'])
207
-            ? $this->_QST_meta['input_id']
208
-            : sanitize_key(strip_tags($this->_QST->get('QST_display_text')));
209
-        $this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id)
210
-            ? $input_id . '-' . $qstn_id
211
-            : $input_id;
212
-    }
213
-
214
-
215
-    /**
216
-     * set_input_class
217
-     *
218
-     * @access private
219
-     * @return void
220
-     */
221
-    private function _set_input_class()
222
-    {
223
-        $this->QST_input_class = isset($this->_QST_meta['input_class']) ? $this->_QST_meta['input_class'] : '';
224
-    }
225
-
226
-
227
-    /**
228
-     * set_question_form_input_answer
229
-     *
230
-     * @access public
231
-     * @param mixed    int | string    $qstn_id
232
-     * @return void
233
-     */
234
-    public function set_question_form_input_answer($qstn_id)
235
-    {
236
-        // check for answer in $_REQUEST in case we are reprocessing a form after an error
237
-        if (isset($this->_QST_meta['EVT_ID'])
238
-            && isset($this->_QST_meta['att_nmbr'])
239
-            && isset($this->_QST_meta['date'])
240
-            && isset($this->_QST_meta['time'])
241
-            && isset($this->_QST_meta['price_id'])
242
-        ) {
243
-            if (isset($_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ])
244
-            ) {
245
-                $answer = $_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ];
246
-                $this->_ANS->set('ANS_value', $answer);
247
-            }
248
-        }
249
-    }
250
-
251
-
252
-    /**
253
-     *        generate_question_form_inputs_for_object
254
-     *
255
-     * @access    protected
256
-     * @param bool|object $object $object
257
-     * @param    array    $input_types
258
-     * @return        array
259
-     */
260
-    public static function generate_question_form_inputs_for_object($object = false, $input_types = array())
261
-    {
262
-        if (! is_object($object)) {
263
-            return false;
264
-        }
265
-        $inputs = array();
266
-        $fields = $object->get_model()->field_settings(false);
267
-        // $pk = $object->ID(); <<< NO!
268
-        // EEH_Debug_Tools::printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
269
-        // EEH_Debug_Tools::printr( $fields, '$fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
270
-        // EEH_Debug_Tools::printr( $input_types, '$input_types  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
271
-        foreach ($fields as $field_ID => $field) {
272
-            if ($field instanceof EE_Model_Field_Base) {
273
-                // echo '<h4>$field_ID : ' . $field_ID . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
274
-                // EEH_Debug_Tools::printr( $field, '$field  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
275
-                if (isset($input_types[ $field_ID ])) {
276
-                    // get saved value for field
277
-                    $value = $object->get($field_ID);
278
-                    // echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
279
-                    // if no saved value, then use default
280
-                    $value = $value !== null ? $value : $field->get_default_value();
281
-                    // if ( $field_ID == 'CNT_active' )
282
-                    // echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
283
-                    // determine question type
284
-                    $type = isset($input_types[ $field_ID ]) ? $input_types[ $field_ID ]['type'] : 'TEXT';
285
-                    // input name
286
-                    $input_name = isset($input_types[ $field_ID ]) && isset($input_types[ $field_ID ]['input_name'])
287
-                        ? $input_types[ $field_ID ]['input_name'] . '[' . $field_ID . ']'
288
-                        : $field_ID;
289
-                    // css class for input
290
-                    $class = isset($input_types[ $field_ID ]['class']) && ! empty($input_types[ $field_ID ]['class'])
291
-                        ? ' ' . $input_types[ $field_ID ]['class']
292
-                        : '';
293
-                    // whether to apply htmlentities to answer
294
-                    $htmlentities = isset($input_types[ $field_ID ]['htmlentities'])
295
-                        ? $input_types[ $field_ID ]['htmlentities']
296
-                        : true;
297
-                    // whether to apply htmlentities to answer
298
-                    $label_b4 = isset($input_types[ $field_ID ]['label_b4'])
299
-                        ? $input_types[ $field_ID ]['label_b4']
300
-                        : false;
301
-                    // whether to apply htmlentities to answer
302
-                    $use_desc_4_label = isset($input_types[ $field_ID ]['use_desc_4_label'])
303
-                        ? $input_types[ $field_ID ]['use_desc_4_label']
304
-                        : false;
305
-                    // whether input is disabled
306
-                    $disabled = isset($input_types[ $field_ID ]['disabled'])
307
-                        ? $input_types[ $field_ID ]['disabled']
308
-                        : false;
309
-
310
-                    // create EE_Question_Form_Input object
311
-                    $QFI = new EE_Question_Form_Input(
312
-                        EE_Question::new_instance(
313
-                            array(
314
-                                'QST_ID'           => 0,
315
-                                'QST_display_text' => $field->get_nicename(),
316
-                                'QST_type'         => $type,
317
-                            )
318
-                        ),
319
-                        EE_Answer::new_instance(
320
-                            array(
321
-                                'ANS_ID'    => 0,
322
-                                'QST_ID'    => 0,
323
-                                'REG_ID'    => 0,
324
-                                'ANS_value' => $value,
325
-                            )
326
-                        ),
327
-                        array(
328
-                            'input_id'         => $field_ID . '-' . $object->ID(),
329
-                            'input_name'       => $input_name,
330
-                            'input_class'      => $field_ID . $class,
331
-                            'input_prefix'     => '',
332
-                            'append_qstn_id'   => false,
333
-                            'htmlentities'     => $htmlentities,
334
-                            'label_b4'         => $label_b4,
335
-                            'use_desc_4_label' => $use_desc_4_label,
336
-                        )
337
-                    );
338
-                    // does question type have options ?
339
-                    if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX'))
340
-                        && isset($input_types[ $field_ID ])
341
-                        && isset($input_types[ $field_ID ]['options'])
342
-                    ) {
343
-                        foreach ($input_types[ $field_ID ]['options'] as $option) {
344
-                            $option = stripslashes_deep($option);
345
-                            $option_id = ! empty($option['id']) ? $option['id'] : 0;
346
-                            $QSO = EE_Question_Option::new_instance(
347
-                                array(
348
-                                    'QSO_value'   => (string) $option_id,
349
-                                    'QSO_desc'    => $option['text'],
350
-                                    'QSO_deleted' => false,
351
-                                )
352
-                            );
353
-                            // all QST (and ANS) properties can be accessed indirectly thru QFI
354
-                            $QFI->add_temp_option($QSO);
355
-                        }
356
-                    }
357
-                    // we don't want ppl manually changing primary keys cuz that would just lead to total craziness man
358
-                    if ($disabled || $field_ID == $object->get_model()->primary_key_name()) {
359
-                        $QFI->set('QST_disabled', true);
360
-                    }
361
-                    // EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
362
-                    $inputs[ $field_ID ] = $QFI;
363
-                    // if ( $field_ID == 'CNT_active' ) {
364
-                    // EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
365
-                    // }
366
-                }
367
-            }
368
-        }
369
-        return $inputs;
370
-    }
371
-
372
-
373
-    /**
374
-     *    add_temp_option
375
-     *
376
-     * @access public
377
-     * @param \EE_Question_Option $QSO EE_Question_Option
378
-     * @return boolean
379
-     */
380
-    public function add_temp_option(EE_Question_Option $QSO)
381
-    {
382
-        $this->_QST->add_temp_option($QSO);
383
-    }
384
-
385
-
386
-    /**
387
-     * set property values for question form input
388
-     *
389
-     * @access public
390
-     * @param    string $property
391
-     * @param    mixed  $value
392
-     * @return mixed
393
-     */
394
-    public function set($property = null, $value = null)
395
-    {
396
-        if (! empty($property)) {
397
-            if (EEM_Question::instance()->has_field($property)) {
398
-                $this->_QST->set($property, $value);
399
-            } elseif (EEM_Answer::instance()->has_field($property)) {
400
-                $this->_ANS->set($property, $value);
401
-            } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) {
402
-                // echo "<hr>$property is a prop of QFI";
403
-                $this->{$property} = $value;
404
-                return true;
405
-            }
406
-        }
407
-        return null;
408
-    }
409
-
410
-
411
-    /**
412
-     *    _question_form_input_property_exists
413
-     *
414
-     * @access public
415
-     * @param boolean      $notDeletedOptionsOnly            1
416
-     *                                                       whether to return ALL options, or only the ones which have
417
-     *                                                       not yet been deleted
418
-     * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question,
419
-     *                                                       we want to usually only show non-deleted options AND the
420
-     *                                                       value that was selected for the answer, whether it was
421
-     *                                                       trashed or not.
422
-     * @return EE_Question_Option
423
-     */
424
-    public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null)
425
-    {
426
-        $temp_options = $this->_QST->temp_options();
427
-        return ! empty($temp_options)
428
-            ? $temp_options
429
-            : $this->_QST->options(
430
-                $notDeletedOptionsOnly,
431
-                $selected_value_to_always_include
432
-            );
433
-    }
434
-
435
-
436
-    /**
437
-     *    get_meta
438
-     *
439
-     * @access public
440
-     * @param mixed $key
441
-     * @return mixed
442
-     */
443
-    public function get_meta($key = false)
444
-    {
445
-        return $key && isset($this->_QST_meta[ $key ]) ? $this->_QST_meta[ $key ] : false;
446
-    }
16
+	/**
17
+	 *    EE_Question object
18
+	 *
19
+	 * @access private
20
+	 * @var object
21
+	 */
22
+	private $_QST = null;
23
+
24
+	/**
25
+	 *    EE_Answer object
26
+	 *
27
+	 * @access private
28
+	 * @var object
29
+	 */
30
+	private $_ANS = null;
31
+
32
+	/**
33
+	 *    $_QST_meta
34
+	 * @access private
35
+	 * @var array
36
+	 */
37
+	private $_QST_meta = array();
38
+
39
+	/**
40
+	 *    $QST_input_name
41
+	 * @access private
42
+	 * @var string
43
+	 */
44
+	private $QST_input_name = '';
45
+
46
+	/**
47
+	 *    $QST_input_id
48
+	 * @access private
49
+	 * @var string
50
+	 */
51
+	private $QST_input_id = '';
52
+
53
+	/**
54
+	 *    $QST_input_class
55
+	 * @access private
56
+	 * @var string
57
+	 */
58
+	private $QST_input_class = '';
59
+
60
+	/**
61
+	 * @var bool $QST_disabled
62
+	 */
63
+	private $QST_disabled = false;
64
+
65
+
66
+	/**
67
+	 * constructor for questions
68
+	 *
69
+	 * @param \EE_Question $QST EE_Question object
70
+	 * @param \EE_Answer   $ANS EE_Answer object
71
+	 * @param array        $q_meta
72
+	 * @access public
73
+	 * @return \EE_Question_Form_Input
74
+	 */
75
+	public function __construct(EE_Question $QST = null, EE_Answer $ANS = null, $q_meta = array())
76
+	{
77
+		if (empty($QST) || empty($ANS)) {
78
+			EE_Error::add_error(
79
+				__('An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso'),
80
+				__FILE__,
81
+				__FUNCTION__,
82
+				__LINE__
83
+			);
84
+			return null;
85
+		}
86
+		$this->_QST = $QST;
87
+		$this->_ANS = $ANS;
88
+		$this->set_question_form_input_meta($q_meta);
89
+		$this->set_question_form_input_init();
90
+	}
91
+
92
+
93
+	/**
94
+	 * sets meta data for the question form input
95
+	 *
96
+	 * @access public
97
+	 * @param array $q_meta
98
+	 * @return void
99
+	 */
100
+	public function set_question_form_input_meta($q_meta = array())
101
+	{
102
+		$default_q_meta = array(
103
+			'att_nmbr'       => 1,
104
+			'ticket_id'      => '',
105
+			'date'           => '',
106
+			'time'           => '',
107
+			'input_name'     => '',
108
+			'input_id'       => '',
109
+			'input_class'    => '',
110
+			'input_prefix'   => 'qstn',
111
+			'append_qstn_id' => true,
112
+			'htmlentities'   => true,
113
+			'allow_null'     => false,
114
+		);
115
+		$this->_QST_meta = array_merge($default_q_meta, $q_meta);
116
+	}
117
+
118
+
119
+	/**
120
+	 * set_question_form_input_init
121
+	 *
122
+	 * @access public
123
+	 * @return void
124
+	 */
125
+	public function set_question_form_input_init()
126
+	{
127
+		$qstn_id = $this->_QST->system_ID() ? $this->_QST->system_ID() : $this->_QST->ID();
128
+		$this->_set_input_name($qstn_id);
129
+		$this->_set_input_id($qstn_id);
130
+		$this->_set_input_class($qstn_id);
131
+		$this->set_question_form_input_answer($qstn_id);
132
+	}
133
+
134
+
135
+	/**
136
+	 * set_input_name
137
+	 *
138
+	 * @access private
139
+	 * @param $qstn_id
140
+	 * @return void
141
+	 */
142
+	private function _set_input_name($qstn_id)
143
+	{
144
+		if (! empty($qstn_id)) {
145
+			$ANS_ID = $this->get('ANS_ID');
146
+			$qstn_id = ! empty($ANS_ID) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']';
147
+		}
148
+		$this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id)
149
+			? $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'] . $qstn_id
150
+			: $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'];
151
+	}
152
+
153
+
154
+	/**
155
+	 * get property values for question form input
156
+	 *
157
+	 * @access public
158
+	 * @param    string $property
159
+	 * @return mixed
160
+	 */
161
+	public function get($property = null)
162
+	{
163
+		if (! empty($property)) {
164
+			if (EEM_Question::instance()->has_field($property)) {
165
+				return $this->_QST->get($property);
166
+			} elseif (EEM_Answer::instance()->has_field($property)) {
167
+				return $this->_ANS->get($property);
168
+			} elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) {
169
+				return $this->{$property};
170
+			}
171
+		}
172
+		return null;
173
+	}
174
+
175
+
176
+	/**
177
+	 *    _question_form_input_property_exists
178
+	 *
179
+	 * @access private
180
+	 * @param    string $classname
181
+	 * @param    string $property
182
+	 * @return boolean
183
+	 */
184
+	private function _question_form_input_property_exists($classname, $property)
185
+	{
186
+		// first try regular property exists method which works as expected in PHP 5.3+
187
+		$prop = EEH_Class_Tools::has_property($classname, $property);
188
+		if (! $prop) {
189
+			// use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction
190
+			$reflector = new ReflectionClass($classname);
191
+			$prop = $reflector->hasProperty($property);
192
+		}
193
+		return $prop;
194
+	}
195
+
196
+
197
+	/**
198
+	 * set_input_id
199
+	 *
200
+	 * @access private
201
+	 * @param $qstn_id
202
+	 * @return void
203
+	 */
204
+	private function _set_input_id($qstn_id)
205
+	{
206
+		$input_id = isset($this->_QST_meta['input_id']) && ! empty($this->_QST_meta['input_id'])
207
+			? $this->_QST_meta['input_id']
208
+			: sanitize_key(strip_tags($this->_QST->get('QST_display_text')));
209
+		$this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id)
210
+			? $input_id . '-' . $qstn_id
211
+			: $input_id;
212
+	}
213
+
214
+
215
+	/**
216
+	 * set_input_class
217
+	 *
218
+	 * @access private
219
+	 * @return void
220
+	 */
221
+	private function _set_input_class()
222
+	{
223
+		$this->QST_input_class = isset($this->_QST_meta['input_class']) ? $this->_QST_meta['input_class'] : '';
224
+	}
225
+
226
+
227
+	/**
228
+	 * set_question_form_input_answer
229
+	 *
230
+	 * @access public
231
+	 * @param mixed    int | string    $qstn_id
232
+	 * @return void
233
+	 */
234
+	public function set_question_form_input_answer($qstn_id)
235
+	{
236
+		// check for answer in $_REQUEST in case we are reprocessing a form after an error
237
+		if (isset($this->_QST_meta['EVT_ID'])
238
+			&& isset($this->_QST_meta['att_nmbr'])
239
+			&& isset($this->_QST_meta['date'])
240
+			&& isset($this->_QST_meta['time'])
241
+			&& isset($this->_QST_meta['price_id'])
242
+		) {
243
+			if (isset($_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ])
244
+			) {
245
+				$answer = $_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ];
246
+				$this->_ANS->set('ANS_value', $answer);
247
+			}
248
+		}
249
+	}
250
+
251
+
252
+	/**
253
+	 *        generate_question_form_inputs_for_object
254
+	 *
255
+	 * @access    protected
256
+	 * @param bool|object $object $object
257
+	 * @param    array    $input_types
258
+	 * @return        array
259
+	 */
260
+	public static function generate_question_form_inputs_for_object($object = false, $input_types = array())
261
+	{
262
+		if (! is_object($object)) {
263
+			return false;
264
+		}
265
+		$inputs = array();
266
+		$fields = $object->get_model()->field_settings(false);
267
+		// $pk = $object->ID(); <<< NO!
268
+		// EEH_Debug_Tools::printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
269
+		// EEH_Debug_Tools::printr( $fields, '$fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
270
+		// EEH_Debug_Tools::printr( $input_types, '$input_types  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
271
+		foreach ($fields as $field_ID => $field) {
272
+			if ($field instanceof EE_Model_Field_Base) {
273
+				// echo '<h4>$field_ID : ' . $field_ID . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
274
+				// EEH_Debug_Tools::printr( $field, '$field  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
275
+				if (isset($input_types[ $field_ID ])) {
276
+					// get saved value for field
277
+					$value = $object->get($field_ID);
278
+					// echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
279
+					// if no saved value, then use default
280
+					$value = $value !== null ? $value : $field->get_default_value();
281
+					// if ( $field_ID == 'CNT_active' )
282
+					// echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
283
+					// determine question type
284
+					$type = isset($input_types[ $field_ID ]) ? $input_types[ $field_ID ]['type'] : 'TEXT';
285
+					// input name
286
+					$input_name = isset($input_types[ $field_ID ]) && isset($input_types[ $field_ID ]['input_name'])
287
+						? $input_types[ $field_ID ]['input_name'] . '[' . $field_ID . ']'
288
+						: $field_ID;
289
+					// css class for input
290
+					$class = isset($input_types[ $field_ID ]['class']) && ! empty($input_types[ $field_ID ]['class'])
291
+						? ' ' . $input_types[ $field_ID ]['class']
292
+						: '';
293
+					// whether to apply htmlentities to answer
294
+					$htmlentities = isset($input_types[ $field_ID ]['htmlentities'])
295
+						? $input_types[ $field_ID ]['htmlentities']
296
+						: true;
297
+					// whether to apply htmlentities to answer
298
+					$label_b4 = isset($input_types[ $field_ID ]['label_b4'])
299
+						? $input_types[ $field_ID ]['label_b4']
300
+						: false;
301
+					// whether to apply htmlentities to answer
302
+					$use_desc_4_label = isset($input_types[ $field_ID ]['use_desc_4_label'])
303
+						? $input_types[ $field_ID ]['use_desc_4_label']
304
+						: false;
305
+					// whether input is disabled
306
+					$disabled = isset($input_types[ $field_ID ]['disabled'])
307
+						? $input_types[ $field_ID ]['disabled']
308
+						: false;
309
+
310
+					// create EE_Question_Form_Input object
311
+					$QFI = new EE_Question_Form_Input(
312
+						EE_Question::new_instance(
313
+							array(
314
+								'QST_ID'           => 0,
315
+								'QST_display_text' => $field->get_nicename(),
316
+								'QST_type'         => $type,
317
+							)
318
+						),
319
+						EE_Answer::new_instance(
320
+							array(
321
+								'ANS_ID'    => 0,
322
+								'QST_ID'    => 0,
323
+								'REG_ID'    => 0,
324
+								'ANS_value' => $value,
325
+							)
326
+						),
327
+						array(
328
+							'input_id'         => $field_ID . '-' . $object->ID(),
329
+							'input_name'       => $input_name,
330
+							'input_class'      => $field_ID . $class,
331
+							'input_prefix'     => '',
332
+							'append_qstn_id'   => false,
333
+							'htmlentities'     => $htmlentities,
334
+							'label_b4'         => $label_b4,
335
+							'use_desc_4_label' => $use_desc_4_label,
336
+						)
337
+					);
338
+					// does question type have options ?
339
+					if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX'))
340
+						&& isset($input_types[ $field_ID ])
341
+						&& isset($input_types[ $field_ID ]['options'])
342
+					) {
343
+						foreach ($input_types[ $field_ID ]['options'] as $option) {
344
+							$option = stripslashes_deep($option);
345
+							$option_id = ! empty($option['id']) ? $option['id'] : 0;
346
+							$QSO = EE_Question_Option::new_instance(
347
+								array(
348
+									'QSO_value'   => (string) $option_id,
349
+									'QSO_desc'    => $option['text'],
350
+									'QSO_deleted' => false,
351
+								)
352
+							);
353
+							// all QST (and ANS) properties can be accessed indirectly thru QFI
354
+							$QFI->add_temp_option($QSO);
355
+						}
356
+					}
357
+					// we don't want ppl manually changing primary keys cuz that would just lead to total craziness man
358
+					if ($disabled || $field_ID == $object->get_model()->primary_key_name()) {
359
+						$QFI->set('QST_disabled', true);
360
+					}
361
+					// EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
362
+					$inputs[ $field_ID ] = $QFI;
363
+					// if ( $field_ID == 'CNT_active' ) {
364
+					// EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
365
+					// }
366
+				}
367
+			}
368
+		}
369
+		return $inputs;
370
+	}
371
+
372
+
373
+	/**
374
+	 *    add_temp_option
375
+	 *
376
+	 * @access public
377
+	 * @param \EE_Question_Option $QSO EE_Question_Option
378
+	 * @return boolean
379
+	 */
380
+	public function add_temp_option(EE_Question_Option $QSO)
381
+	{
382
+		$this->_QST->add_temp_option($QSO);
383
+	}
384
+
385
+
386
+	/**
387
+	 * set property values for question form input
388
+	 *
389
+	 * @access public
390
+	 * @param    string $property
391
+	 * @param    mixed  $value
392
+	 * @return mixed
393
+	 */
394
+	public function set($property = null, $value = null)
395
+	{
396
+		if (! empty($property)) {
397
+			if (EEM_Question::instance()->has_field($property)) {
398
+				$this->_QST->set($property, $value);
399
+			} elseif (EEM_Answer::instance()->has_field($property)) {
400
+				$this->_ANS->set($property, $value);
401
+			} elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) {
402
+				// echo "<hr>$property is a prop of QFI";
403
+				$this->{$property} = $value;
404
+				return true;
405
+			}
406
+		}
407
+		return null;
408
+	}
409
+
410
+
411
+	/**
412
+	 *    _question_form_input_property_exists
413
+	 *
414
+	 * @access public
415
+	 * @param boolean      $notDeletedOptionsOnly            1
416
+	 *                                                       whether to return ALL options, or only the ones which have
417
+	 *                                                       not yet been deleted
418
+	 * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question,
419
+	 *                                                       we want to usually only show non-deleted options AND the
420
+	 *                                                       value that was selected for the answer, whether it was
421
+	 *                                                       trashed or not.
422
+	 * @return EE_Question_Option
423
+	 */
424
+	public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null)
425
+	{
426
+		$temp_options = $this->_QST->temp_options();
427
+		return ! empty($temp_options)
428
+			? $temp_options
429
+			: $this->_QST->options(
430
+				$notDeletedOptionsOnly,
431
+				$selected_value_to_always_include
432
+			);
433
+	}
434
+
435
+
436
+	/**
437
+	 *    get_meta
438
+	 *
439
+	 * @access public
440
+	 * @param mixed $key
441
+	 * @return mixed
442
+	 */
443
+	public function get_meta($key = false)
444
+	{
445
+		return $key && isset($this->_QST_meta[ $key ]) ? $this->_QST_meta[ $key ] : false;
446
+	}
447 447
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
      */
142 142
     private function _set_input_name($qstn_id)
143 143
     {
144
-        if (! empty($qstn_id)) {
144
+        if ( ! empty($qstn_id)) {
145 145
             $ANS_ID = $this->get('ANS_ID');
146
-            $qstn_id = ! empty($ANS_ID) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']';
146
+            $qstn_id = ! empty($ANS_ID) ? '['.$qstn_id.']['.$ANS_ID.']' : '['.$qstn_id.']';
147 147
         }
148 148
         $this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id)
149
-            ? $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'] . $qstn_id
150
-            : $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'];
149
+            ? $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name'].$qstn_id
150
+            : $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name'];
151 151
     }
152 152
 
153 153
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     public function get($property = null)
162 162
     {
163
-        if (! empty($property)) {
163
+        if ( ! empty($property)) {
164 164
             if (EEM_Question::instance()->has_field($property)) {
165 165
                 return $this->_QST->get($property);
166 166
             } elseif (EEM_Answer::instance()->has_field($property)) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     {
186 186
         // first try regular property exists method which works as expected in PHP 5.3+
187 187
         $prop = EEH_Class_Tools::has_property($classname, $property);
188
-        if (! $prop) {
188
+        if ( ! $prop) {
189 189
             // use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction
190 190
             $reflector = new ReflectionClass($classname);
191 191
             $prop = $reflector->hasProperty($property);
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             ? $this->_QST_meta['input_id']
208 208
             : sanitize_key(strip_tags($this->_QST->get('QST_display_text')));
209 209
         $this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id)
210
-            ? $input_id . '-' . $qstn_id
210
+            ? $input_id.'-'.$qstn_id
211 211
             : $input_id;
212 212
     }
213 213
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
             && isset($this->_QST_meta['time'])
241 241
             && isset($this->_QST_meta['price_id'])
242 242
         ) {
243
-            if (isset($_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ])
243
+            if (isset($_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id])
244 244
             ) {
245
-                $answer = $_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ];
245
+                $answer = $_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id];
246 246
                 $this->_ANS->set('ANS_value', $answer);
247 247
             }
248 248
         }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public static function generate_question_form_inputs_for_object($object = false, $input_types = array())
261 261
     {
262
-        if (! is_object($object)) {
262
+        if ( ! is_object($object)) {
263 263
             return false;
264 264
         }
265 265
         $inputs = array();
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             if ($field instanceof EE_Model_Field_Base) {
273 273
                 // echo '<h4>$field_ID : ' . $field_ID . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
274 274
                 // EEH_Debug_Tools::printr( $field, '$field  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
275
-                if (isset($input_types[ $field_ID ])) {
275
+                if (isset($input_types[$field_ID])) {
276 276
                     // get saved value for field
277 277
                     $value = $object->get($field_ID);
278 278
                     // echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
@@ -281,30 +281,30 @@  discard block
 block discarded – undo
281 281
                     // if ( $field_ID == 'CNT_active' )
282 282
                     // echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
283 283
                     // determine question type
284
-                    $type = isset($input_types[ $field_ID ]) ? $input_types[ $field_ID ]['type'] : 'TEXT';
284
+                    $type = isset($input_types[$field_ID]) ? $input_types[$field_ID]['type'] : 'TEXT';
285 285
                     // input name
286
-                    $input_name = isset($input_types[ $field_ID ]) && isset($input_types[ $field_ID ]['input_name'])
287
-                        ? $input_types[ $field_ID ]['input_name'] . '[' . $field_ID . ']'
286
+                    $input_name = isset($input_types[$field_ID]) && isset($input_types[$field_ID]['input_name'])
287
+                        ? $input_types[$field_ID]['input_name'].'['.$field_ID.']'
288 288
                         : $field_ID;
289 289
                     // css class for input
290
-                    $class = isset($input_types[ $field_ID ]['class']) && ! empty($input_types[ $field_ID ]['class'])
291
-                        ? ' ' . $input_types[ $field_ID ]['class']
290
+                    $class = isset($input_types[$field_ID]['class']) && ! empty($input_types[$field_ID]['class'])
291
+                        ? ' '.$input_types[$field_ID]['class']
292 292
                         : '';
293 293
                     // whether to apply htmlentities to answer
294
-                    $htmlentities = isset($input_types[ $field_ID ]['htmlentities'])
295
-                        ? $input_types[ $field_ID ]['htmlentities']
294
+                    $htmlentities = isset($input_types[$field_ID]['htmlentities'])
295
+                        ? $input_types[$field_ID]['htmlentities']
296 296
                         : true;
297 297
                     // whether to apply htmlentities to answer
298
-                    $label_b4 = isset($input_types[ $field_ID ]['label_b4'])
299
-                        ? $input_types[ $field_ID ]['label_b4']
298
+                    $label_b4 = isset($input_types[$field_ID]['label_b4'])
299
+                        ? $input_types[$field_ID]['label_b4']
300 300
                         : false;
301 301
                     // whether to apply htmlentities to answer
302
-                    $use_desc_4_label = isset($input_types[ $field_ID ]['use_desc_4_label'])
303
-                        ? $input_types[ $field_ID ]['use_desc_4_label']
302
+                    $use_desc_4_label = isset($input_types[$field_ID]['use_desc_4_label'])
303
+                        ? $input_types[$field_ID]['use_desc_4_label']
304 304
                         : false;
305 305
                     // whether input is disabled
306
-                    $disabled = isset($input_types[ $field_ID ]['disabled'])
307
-                        ? $input_types[ $field_ID ]['disabled']
306
+                    $disabled = isset($input_types[$field_ID]['disabled'])
307
+                        ? $input_types[$field_ID]['disabled']
308 308
                         : false;
309 309
 
310 310
                     // create EE_Question_Form_Input object
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
                             )
326 326
                         ),
327 327
                         array(
328
-                            'input_id'         => $field_ID . '-' . $object->ID(),
328
+                            'input_id'         => $field_ID.'-'.$object->ID(),
329 329
                             'input_name'       => $input_name,
330
-                            'input_class'      => $field_ID . $class,
330
+                            'input_class'      => $field_ID.$class,
331 331
                             'input_prefix'     => '',
332 332
                             'append_qstn_id'   => false,
333 333
                             'htmlentities'     => $htmlentities,
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
                     );
338 338
                     // does question type have options ?
339 339
                     if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX'))
340
-                        && isset($input_types[ $field_ID ])
341
-                        && isset($input_types[ $field_ID ]['options'])
340
+                        && isset($input_types[$field_ID])
341
+                        && isset($input_types[$field_ID]['options'])
342 342
                     ) {
343
-                        foreach ($input_types[ $field_ID ]['options'] as $option) {
343
+                        foreach ($input_types[$field_ID]['options'] as $option) {
344 344
                             $option = stripslashes_deep($option);
345 345
                             $option_id = ! empty($option['id']) ? $option['id'] : 0;
346 346
                             $QSO = EE_Question_Option::new_instance(
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
                         $QFI->set('QST_disabled', true);
360 360
                     }
361 361
                     // EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
362
-                    $inputs[ $field_ID ] = $QFI;
362
+                    $inputs[$field_ID] = $QFI;
363 363
                     // if ( $field_ID == 'CNT_active' ) {
364 364
                     // EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
365 365
                     // }
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
      */
394 394
     public function set($property = null, $value = null)
395 395
     {
396
-        if (! empty($property)) {
396
+        if ( ! empty($property)) {
397 397
             if (EEM_Question::instance()->has_field($property)) {
398 398
                 $this->_QST->set($property, $value);
399 399
             } elseif (EEM_Answer::instance()->has_field($property)) {
@@ -442,6 +442,6 @@  discard block
 block discarded – undo
442 442
      */
443 443
     public function get_meta($key = false)
444 444
     {
445
-        return $key && isset($this->_QST_meta[ $key ]) ? $this->_QST_meta[ $key ] : false;
445
+        return $key && isset($this->_QST_meta[$key]) ? $this->_QST_meta[$key] : false;
446 446
     }
447 447
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/OrganizationSettings.php 1 patch
Indentation   +481 added lines, -481 removed lines patch added patch discarded remove patch
@@ -40,506 +40,506 @@
 block discarded – undo
40 40
 class OrganizationSettings extends FormHandler
41 41
 {
42 42
 
43
-    /**
44
-     * @var EE_Organization_Config
45
-     */
46
-    protected $organization_config;
43
+	/**
44
+	 * @var EE_Organization_Config
45
+	 */
46
+	protected $organization_config;
47 47
 
48
-    /**
49
-     * @var EE_Core_Config
50
-     */
51
-    protected $core_config;
48
+	/**
49
+	 * @var EE_Core_Config
50
+	 */
51
+	protected $core_config;
52 52
 
53 53
 
54
-    /**
55
-     * @var EE_Network_Core_Config
56
-     */
57
-    protected $network_core_config;
54
+	/**
55
+	 * @var EE_Network_Core_Config
56
+	 */
57
+	protected $network_core_config;
58 58
 
59
-    /**
60
-     * Form constructor.
61
-     *
62
-     * @param EE_Registry             $registry
63
-     * @param EE_Organization_Config  $organization_config
64
-     * @param EE_Core_Config          $core_config
65
-     * @param EE_Network_Core_Config $network_core_config
66
-     * @throws InvalidArgumentException
67
-     * @throws InvalidDataTypeException
68
-     * @throws DomainException
69
-     */
70
-    public function __construct(
71
-        EE_Registry $registry,
72
-        EE_Organization_Config $organization_config,
73
-        EE_Core_Config $core_config,
74
-        EE_Network_Core_Config $network_core_config
75
-    ) {
76
-        $this->organization_config = $organization_config;
77
-        $this->core_config = $core_config;
78
-        $this->network_core_config = $network_core_config;
79
-        parent::__construct(
80
-            esc_html__('Your Organization Settings', 'event_espresso'),
81
-            esc_html__('Your Organization Settings', 'event_espresso'),
82
-            'organization_settings',
83
-            '',
84
-            FormHandler::DO_NOT_SETUP_FORM,
85
-            $registry
86
-        );
87
-    }
59
+	/**
60
+	 * Form constructor.
61
+	 *
62
+	 * @param EE_Registry             $registry
63
+	 * @param EE_Organization_Config  $organization_config
64
+	 * @param EE_Core_Config          $core_config
65
+	 * @param EE_Network_Core_Config $network_core_config
66
+	 * @throws InvalidArgumentException
67
+	 * @throws InvalidDataTypeException
68
+	 * @throws DomainException
69
+	 */
70
+	public function __construct(
71
+		EE_Registry $registry,
72
+		EE_Organization_Config $organization_config,
73
+		EE_Core_Config $core_config,
74
+		EE_Network_Core_Config $network_core_config
75
+	) {
76
+		$this->organization_config = $organization_config;
77
+		$this->core_config = $core_config;
78
+		$this->network_core_config = $network_core_config;
79
+		parent::__construct(
80
+			esc_html__('Your Organization Settings', 'event_espresso'),
81
+			esc_html__('Your Organization Settings', 'event_espresso'),
82
+			'organization_settings',
83
+			'',
84
+			FormHandler::DO_NOT_SETUP_FORM,
85
+			$registry
86
+		);
87
+	}
88 88
 
89 89
 
90 90
 
91
-    /**
92
-     * creates and returns the actual form
93
-     *
94
-     * @return EE_Form_Section_Proper
95
-     * @throws EE_Error
96
-     */
97
-    public function generate()
98
-    {
99
-        $form = new EE_Form_Section_Proper(
100
-            array(
101
-                'name'            => 'organization_settings',
102
-                'html_id'         => 'organization_settings',
103
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
104
-                'subsections'     => array(
105
-                    'contact_information_hdr'        => new EE_Form_Section_HTML(
106
-                        EEH_HTML::h2(
107
-                            esc_html__('Contact Information', 'event_espresso')
108
-                            . ' '
109
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
110
-                            '',
111
-                            'contact-information-hdr'
112
-                        )
113
-                    ),
114
-                    'organization_name'      => new EE_Text_Input(
115
-                        array(
116
-                            'html_name' => 'organization_name',
117
-                            'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
118
-                            'html_help_text'  => esc_html__(
119
-                                'Displayed on all emails and invoices.',
120
-                                'event_espresso'
121
-                            ),
122
-                            'default'         => $this->organization_config->get_pretty('name'),
123
-                            'required'        => false,
124
-                        )
125
-                    ),
126
-                    'organization_address_1'      => new EE_Text_Input(
127
-                        array(
128
-                            'html_name' => 'organization_address_1',
129
-                            'html_label_text' => esc_html__('Street Address', 'event_espresso'),
130
-                            'default'         => $this->organization_config->get_pretty('address_1'),
131
-                            'required'        => false,
132
-                        )
133
-                    ),
134
-                    'organization_address_2'      => new EE_Text_Input(
135
-                        array(
136
-                            'html_name' => 'organization_address_2',
137
-                            'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
138
-                            'default'         => $this->organization_config->get_pretty('address_2'),
139
-                            'required'        => false,
140
-                        )
141
-                    ),
142
-                    'organization_city'      => new EE_Text_Input(
143
-                        array(
144
-                            'html_name' => 'organization_city',
145
-                            'html_label_text' => esc_html__('City', 'event_espresso'),
146
-                            'default'         => $this->organization_config->get_pretty('city'),
147
-                            'required'        => false,
148
-                        )
149
-                    ),
150
-                    'organization_state'      => new EE_State_Select_Input(
151
-                        null,
152
-                        array(
153
-                            'html_name' => 'organization_state',
154
-                            'html_label_text' => esc_html__('State/Province', 'event_espresso'),
155
-                            'default'         => $this->organization_config->STA_ID,
156
-                            'required'        => false,
157
-                        )
158
-                    ),
159
-                    'organization_country'      => new EE_Country_Select_Input(
160
-                        null,
161
-                        array(
162
-                            'html_name' => 'organization_country',
163
-                            'html_label_text' => esc_html__('Country', 'event_espresso'),
164
-                            'default'         => $this->organization_config->CNT_ISO,
165
-                            'required'        => false,
166
-                            'html_help_text' => sprintf(
167
-                                esc_html__(
168
-                                    '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
169
-                                    'event_espresso'
170
-                                ),
171
-                                '<span class="reminder-spn">',
172
-                                '</span>'
173
-                            ),
174
-                        )
175
-                    ),
176
-                    'organization_zip'      => new EE_Text_Input(
177
-                        array(
178
-                            'html_name' => 'organization_zip',
179
-                            'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
180
-                            'default'         => $this->organization_config->get_pretty('zip'),
181
-                            'required'        => false,
182
-                        )
183
-                    ),
184
-                    'organization_email'      => new EE_Text_Input(
185
-                        array(
186
-                            'html_name' => 'organization_email',
187
-                            'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
188
-                            'html_help_text'  => sprintf(
189
-                                esc_html__(
190
-                                    'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
191
-                                    'event_espresso'
192
-                                ),
193
-                                '<code>[CO_FORMATTED_EMAIL]</code>',
194
-                                '<code>[CO_EMAIL]</code>'
195
-                            ),
196
-                            'default'         => $this->organization_config->get_pretty('email'),
197
-                            'required'        => false,
198
-                        )
199
-                    ),
200
-                    'organization_phone'      => new EE_Text_Input(
201
-                        array(
202
-                            'html_name' => 'organization_phone',
203
-                            'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
204
-                            'html_help_text'  => esc_html__(
205
-                                'The phone number for your organization.',
206
-                                'event_espresso'
207
-                            ),
208
-                            'default'         => $this->organization_config->get_pretty('phone'),
209
-                            'required'        => false,
210
-                        )
211
-                    ),
212
-                    'organization_vat'      => new EE_Text_Input(
213
-                        array(
214
-                            'html_name' => 'organization_vat',
215
-                            'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
216
-                            'html_help_text'  => esc_html__(
217
-                                'The VAT/Tax Number may be displayed on invoices and receipts.',
218
-                                'event_espresso'
219
-                            ),
220
-                            'default'         => $this->organization_config->get_pretty('vat'),
221
-                            'required'        => false,
222
-                        )
223
-                    ),
224
-                    'company_logo_hdr'        => new EE_Form_Section_HTML(
225
-                        EEH_HTML::h2(
226
-                            esc_html__('Company Logo', 'event_espresso')
227
-                            . ' '
228
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
229
-                            '',
230
-                            'company-logo-hdr'
231
-                        )
232
-                    ),
233
-                    'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
234
-                        array(
235
-                            'html_name' => 'organization_logo_url',
236
-                            'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
237
-                            'html_help_text'  => esc_html__(
238
-                                'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
239
-                                'event_espresso'
240
-                            ),
241
-                            'default'         => $this->organization_config->get_pretty('logo_url'),
242
-                            'required'        => false,
243
-                        )
244
-                    ),
245
-                    'social_links_hdr'        => new EE_Form_Section_HTML(
246
-                        EEH_HTML::h2(
247
-                            esc_html__('Social Links', 'event_espresso')
248
-                            . ' '
249
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
250
-                            . EEH_HTML::br()
251
-                            . EEH_HTML::p(
252
-                                esc_html__(
253
-                                    'Enter any links to social accounts for your organization here',
254
-                                    'event_espresso'
255
-                                ),
256
-                                '',
257
-                                'description'
258
-                            ),
259
-                            '',
260
-                            'social-links-hdr'
261
-                        )
262
-                    ),
263
-                    'organization_facebook'      => new EE_Text_Input(
264
-                        array(
265
-                            'html_name' => 'organization_facebook',
266
-                            'html_label_text' => esc_html__('Facebook', 'event_espresso'),
267
-                            'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
268
-                            'default'         => $this->organization_config->get_pretty('facebook'),
269
-                            'required'        => false,
270
-                        )
271
-                    ),
272
-                    'organization_twitter'      => new EE_Text_Input(
273
-                        array(
274
-                            'html_name' => 'organization_twitter',
275
-                            'html_label_text' => esc_html__('Twitter', 'event_espresso'),
276
-                            'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
277
-                            'default'         => $this->organization_config->get_pretty('twitter'),
278
-                            'required'        => false,
279
-                        )
280
-                    ),
281
-                    'organization_linkedin'      => new EE_Text_Input(
282
-                        array(
283
-                            'html_name' => 'organization_linkedin',
284
-                            'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
285
-                            'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
286
-                            'default'         => $this->organization_config->get_pretty('linkedin'),
287
-                            'required'        => false,
288
-                        )
289
-                    ),
290
-                    'organization_pinterest'      => new EE_Text_Input(
291
-                        array(
292
-                            'html_name' => 'organization_pinterest',
293
-                            'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
294
-                            'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
295
-                            'default'         => $this->organization_config->get_pretty('pinterest'),
296
-                            'required'        => false,
297
-                        )
298
-                    ),
299
-                    'organization_google'      => new EE_Text_Input(
300
-                        array(
301
-                            'html_name' => 'organization_google',
302
-                            'html_label_text' => esc_html__('Google+', 'event_espresso'),
303
-                            'other_html_attributes' => ' placeholder="google.com/+profilename"',
304
-                            'default'         => $this->organization_config->get_pretty('google'),
305
-                            'required'        => false,
306
-                        )
307
-                    ),
308
-                    'organization_instagram'      => new EE_Text_Input(
309
-                        array(
310
-                            'html_name' => 'organization_instagram',
311
-                            'html_label_text' => esc_html__('Instagram', 'event_espresso'),
312
-                            'other_html_attributes' => ' placeholder="instagram.com/handle"',
313
-                            'default'         => $this->organization_config->get_pretty('instagram'),
314
-                            'required'        => false,
315
-                        )
316
-                    ),
317
-                ),
318
-            )
319
-        );
320
-        if (is_main_site()) {
321
-            $form->add_subsections(
322
-                array(
323
-                    'site_license_key_hdr' => new EE_Form_Section_HTML(
324
-                        EEH_HTML::h2(
325
-                            esc_html__('Your Event Espresso License Key', 'event_espresso')
326
-                            . ' '
327
-                            . EEH_HTML::span(
328
-                                EEH_Template::get_help_tab_link('site_license_key_info'),
329
-                                'help_tour_activation'
330
-                            ),
331
-                            '',
332
-                            'site-license-key-hdr'
333
-                        )
334
-                    ),
335
-                    'site_license_key' => $this->getSiteLicenseKeyField()
336
-                )
337
-            );
338
-            $form->add_subsections(
339
-                array(
340
-                    'uxip_optin_hdr' => new EE_Form_Section_HTML(
341
-                        $this->uxipOptinText()
342
-                    ),
343
-                    'ueip_optin' => new EE_Checkbox_Multi_Input(
344
-                        array(
345
-                            true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
346
-                        ),
347
-                        array(
348
-                            'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
349
-                            'html_label_text' => esc_html__(
350
-                                'UXIP Opt In?',
351
-                                'event_espresso'
352
-                            ),
353
-                            'default'         => isset($this->core_config->ee_ueip_optin)
354
-                                ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
355
-                                : false,
356
-                            'required'        => false,
357
-                        )
358
-                    ),
359
-                ),
360
-                'organization_instagram',
361
-                false
362
-            );
363
-        }
364
-        return $form;
365
-    }
91
+	/**
92
+	 * creates and returns the actual form
93
+	 *
94
+	 * @return EE_Form_Section_Proper
95
+	 * @throws EE_Error
96
+	 */
97
+	public function generate()
98
+	{
99
+		$form = new EE_Form_Section_Proper(
100
+			array(
101
+				'name'            => 'organization_settings',
102
+				'html_id'         => 'organization_settings',
103
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
104
+				'subsections'     => array(
105
+					'contact_information_hdr'        => new EE_Form_Section_HTML(
106
+						EEH_HTML::h2(
107
+							esc_html__('Contact Information', 'event_espresso')
108
+							. ' '
109
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
110
+							'',
111
+							'contact-information-hdr'
112
+						)
113
+					),
114
+					'organization_name'      => new EE_Text_Input(
115
+						array(
116
+							'html_name' => 'organization_name',
117
+							'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
118
+							'html_help_text'  => esc_html__(
119
+								'Displayed on all emails and invoices.',
120
+								'event_espresso'
121
+							),
122
+							'default'         => $this->organization_config->get_pretty('name'),
123
+							'required'        => false,
124
+						)
125
+					),
126
+					'organization_address_1'      => new EE_Text_Input(
127
+						array(
128
+							'html_name' => 'organization_address_1',
129
+							'html_label_text' => esc_html__('Street Address', 'event_espresso'),
130
+							'default'         => $this->organization_config->get_pretty('address_1'),
131
+							'required'        => false,
132
+						)
133
+					),
134
+					'organization_address_2'      => new EE_Text_Input(
135
+						array(
136
+							'html_name' => 'organization_address_2',
137
+							'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
138
+							'default'         => $this->organization_config->get_pretty('address_2'),
139
+							'required'        => false,
140
+						)
141
+					),
142
+					'organization_city'      => new EE_Text_Input(
143
+						array(
144
+							'html_name' => 'organization_city',
145
+							'html_label_text' => esc_html__('City', 'event_espresso'),
146
+							'default'         => $this->organization_config->get_pretty('city'),
147
+							'required'        => false,
148
+						)
149
+					),
150
+					'organization_state'      => new EE_State_Select_Input(
151
+						null,
152
+						array(
153
+							'html_name' => 'organization_state',
154
+							'html_label_text' => esc_html__('State/Province', 'event_espresso'),
155
+							'default'         => $this->organization_config->STA_ID,
156
+							'required'        => false,
157
+						)
158
+					),
159
+					'organization_country'      => new EE_Country_Select_Input(
160
+						null,
161
+						array(
162
+							'html_name' => 'organization_country',
163
+							'html_label_text' => esc_html__('Country', 'event_espresso'),
164
+							'default'         => $this->organization_config->CNT_ISO,
165
+							'required'        => false,
166
+							'html_help_text' => sprintf(
167
+								esc_html__(
168
+									'%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
169
+									'event_espresso'
170
+								),
171
+								'<span class="reminder-spn">',
172
+								'</span>'
173
+							),
174
+						)
175
+					),
176
+					'organization_zip'      => new EE_Text_Input(
177
+						array(
178
+							'html_name' => 'organization_zip',
179
+							'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
180
+							'default'         => $this->organization_config->get_pretty('zip'),
181
+							'required'        => false,
182
+						)
183
+					),
184
+					'organization_email'      => new EE_Text_Input(
185
+						array(
186
+							'html_name' => 'organization_email',
187
+							'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
188
+							'html_help_text'  => sprintf(
189
+								esc_html__(
190
+									'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
191
+									'event_espresso'
192
+								),
193
+								'<code>[CO_FORMATTED_EMAIL]</code>',
194
+								'<code>[CO_EMAIL]</code>'
195
+							),
196
+							'default'         => $this->organization_config->get_pretty('email'),
197
+							'required'        => false,
198
+						)
199
+					),
200
+					'organization_phone'      => new EE_Text_Input(
201
+						array(
202
+							'html_name' => 'organization_phone',
203
+							'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
204
+							'html_help_text'  => esc_html__(
205
+								'The phone number for your organization.',
206
+								'event_espresso'
207
+							),
208
+							'default'         => $this->organization_config->get_pretty('phone'),
209
+							'required'        => false,
210
+						)
211
+					),
212
+					'organization_vat'      => new EE_Text_Input(
213
+						array(
214
+							'html_name' => 'organization_vat',
215
+							'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
216
+							'html_help_text'  => esc_html__(
217
+								'The VAT/Tax Number may be displayed on invoices and receipts.',
218
+								'event_espresso'
219
+							),
220
+							'default'         => $this->organization_config->get_pretty('vat'),
221
+							'required'        => false,
222
+						)
223
+					),
224
+					'company_logo_hdr'        => new EE_Form_Section_HTML(
225
+						EEH_HTML::h2(
226
+							esc_html__('Company Logo', 'event_espresso')
227
+							. ' '
228
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
229
+							'',
230
+							'company-logo-hdr'
231
+						)
232
+					),
233
+					'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
234
+						array(
235
+							'html_name' => 'organization_logo_url',
236
+							'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
237
+							'html_help_text'  => esc_html__(
238
+								'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
239
+								'event_espresso'
240
+							),
241
+							'default'         => $this->organization_config->get_pretty('logo_url'),
242
+							'required'        => false,
243
+						)
244
+					),
245
+					'social_links_hdr'        => new EE_Form_Section_HTML(
246
+						EEH_HTML::h2(
247
+							esc_html__('Social Links', 'event_espresso')
248
+							. ' '
249
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
250
+							. EEH_HTML::br()
251
+							. EEH_HTML::p(
252
+								esc_html__(
253
+									'Enter any links to social accounts for your organization here',
254
+									'event_espresso'
255
+								),
256
+								'',
257
+								'description'
258
+							),
259
+							'',
260
+							'social-links-hdr'
261
+						)
262
+					),
263
+					'organization_facebook'      => new EE_Text_Input(
264
+						array(
265
+							'html_name' => 'organization_facebook',
266
+							'html_label_text' => esc_html__('Facebook', 'event_espresso'),
267
+							'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
268
+							'default'         => $this->organization_config->get_pretty('facebook'),
269
+							'required'        => false,
270
+						)
271
+					),
272
+					'organization_twitter'      => new EE_Text_Input(
273
+						array(
274
+							'html_name' => 'organization_twitter',
275
+							'html_label_text' => esc_html__('Twitter', 'event_espresso'),
276
+							'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
277
+							'default'         => $this->organization_config->get_pretty('twitter'),
278
+							'required'        => false,
279
+						)
280
+					),
281
+					'organization_linkedin'      => new EE_Text_Input(
282
+						array(
283
+							'html_name' => 'organization_linkedin',
284
+							'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
285
+							'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
286
+							'default'         => $this->organization_config->get_pretty('linkedin'),
287
+							'required'        => false,
288
+						)
289
+					),
290
+					'organization_pinterest'      => new EE_Text_Input(
291
+						array(
292
+							'html_name' => 'organization_pinterest',
293
+							'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
294
+							'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
295
+							'default'         => $this->organization_config->get_pretty('pinterest'),
296
+							'required'        => false,
297
+						)
298
+					),
299
+					'organization_google'      => new EE_Text_Input(
300
+						array(
301
+							'html_name' => 'organization_google',
302
+							'html_label_text' => esc_html__('Google+', 'event_espresso'),
303
+							'other_html_attributes' => ' placeholder="google.com/+profilename"',
304
+							'default'         => $this->organization_config->get_pretty('google'),
305
+							'required'        => false,
306
+						)
307
+					),
308
+					'organization_instagram'      => new EE_Text_Input(
309
+						array(
310
+							'html_name' => 'organization_instagram',
311
+							'html_label_text' => esc_html__('Instagram', 'event_espresso'),
312
+							'other_html_attributes' => ' placeholder="instagram.com/handle"',
313
+							'default'         => $this->organization_config->get_pretty('instagram'),
314
+							'required'        => false,
315
+						)
316
+					),
317
+				),
318
+			)
319
+		);
320
+		if (is_main_site()) {
321
+			$form->add_subsections(
322
+				array(
323
+					'site_license_key_hdr' => new EE_Form_Section_HTML(
324
+						EEH_HTML::h2(
325
+							esc_html__('Your Event Espresso License Key', 'event_espresso')
326
+							. ' '
327
+							. EEH_HTML::span(
328
+								EEH_Template::get_help_tab_link('site_license_key_info'),
329
+								'help_tour_activation'
330
+							),
331
+							'',
332
+							'site-license-key-hdr'
333
+						)
334
+					),
335
+					'site_license_key' => $this->getSiteLicenseKeyField()
336
+				)
337
+			);
338
+			$form->add_subsections(
339
+				array(
340
+					'uxip_optin_hdr' => new EE_Form_Section_HTML(
341
+						$this->uxipOptinText()
342
+					),
343
+					'ueip_optin' => new EE_Checkbox_Multi_Input(
344
+						array(
345
+							true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
346
+						),
347
+						array(
348
+							'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
349
+							'html_label_text' => esc_html__(
350
+								'UXIP Opt In?',
351
+								'event_espresso'
352
+							),
353
+							'default'         => isset($this->core_config->ee_ueip_optin)
354
+								? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
355
+								: false,
356
+							'required'        => false,
357
+						)
358
+					),
359
+				),
360
+				'organization_instagram',
361
+				false
362
+			);
363
+		}
364
+		return $form;
365
+	}
366 366
 
367 367
 
368
-    /**
369
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
370
-     * returns a string of HTML that can be directly echoed in a template
371
-     *
372
-     * @return string
373
-     * @throws EE_Error
374
-     * @throws InvalidArgumentException
375
-     * @throws InvalidDataTypeException
376
-     * @throws InvalidInterfaceException
377
-     * @throws LogicException
378
-     */
379
-    public function display()
380
-    {
381
-        $this->form()->enqueue_js();
382
-        return parent::display();
383
-    }
368
+	/**
369
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
370
+	 * returns a string of HTML that can be directly echoed in a template
371
+	 *
372
+	 * @return string
373
+	 * @throws EE_Error
374
+	 * @throws InvalidArgumentException
375
+	 * @throws InvalidDataTypeException
376
+	 * @throws InvalidInterfaceException
377
+	 * @throws LogicException
378
+	 */
379
+	public function display()
380
+	{
381
+		$this->form()->enqueue_js();
382
+		return parent::display();
383
+	}
384 384
 
385 385
 
386
-    /**
387
-     * handles processing the form submission
388
-     * returns true or false depending on whether the form was processed successfully or not
389
-     *
390
-     * @param array $form_data
391
-     * @return bool
392
-     * @throws InvalidFormSubmissionException
393
-     * @throws EE_Error
394
-     * @throws LogicException
395
-     * @throws InvalidArgumentException
396
-     * @throws InvalidDataTypeException
397
-     */
398
-    public function process($form_data = array())
399
-    {
400
-        // process form
401
-        $valid_data = (array) parent::process($form_data);
402
-        if (empty($valid_data)) {
403
-            return false;
404
-        }
386
+	/**
387
+	 * handles processing the form submission
388
+	 * returns true or false depending on whether the form was processed successfully or not
389
+	 *
390
+	 * @param array $form_data
391
+	 * @return bool
392
+	 * @throws InvalidFormSubmissionException
393
+	 * @throws EE_Error
394
+	 * @throws LogicException
395
+	 * @throws InvalidArgumentException
396
+	 * @throws InvalidDataTypeException
397
+	 */
398
+	public function process($form_data = array())
399
+	{
400
+		// process form
401
+		$valid_data = (array) parent::process($form_data);
402
+		if (empty($valid_data)) {
403
+			return false;
404
+		}
405 405
 
406
-        if (is_main_site()) {
407
-            $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
408
-                ? sanitize_text_field($form_data['ee_site_license_key'])
409
-                : $this->network_core_config->site_license_key;
410
-        }
411
-        $this->organization_config->name = isset($form_data['organization_name'])
412
-            ? sanitize_text_field($form_data['organization_name'])
413
-            : $this->organization_config->name;
414
-        $this->organization_config->address_1 = isset($form_data['organization_address_1'])
415
-            ? sanitize_text_field($form_data['organization_address_1'])
416
-            : $this->organization_config->address_1;
417
-        $this->organization_config->address_2 = isset($form_data['organization_address_2'])
418
-            ? sanitize_text_field($form_data['organization_address_2'])
419
-            : $this->organization_config->address_2;
420
-        $this->organization_config->city = isset($form_data['organization_city'])
421
-            ? sanitize_text_field($form_data['organization_city'])
422
-            : $this->organization_config->city;
423
-        $this->organization_config->STA_ID = isset($form_data['organization_state'])
424
-            ? absint($form_data['organization_state'])
425
-            : $this->organization_config->STA_ID;
426
-        $this->organization_config->CNT_ISO = isset($form_data['organization_country'])
427
-            ? sanitize_text_field($form_data['organization_country'])
428
-            : $this->organization_config->CNT_ISO;
429
-        $this->organization_config->zip = isset($form_data['organization_zip'])
430
-            ? sanitize_text_field($form_data['organization_zip'])
431
-            : $this->organization_config->zip;
432
-        $this->organization_config->email = isset($form_data['organization_email'])
433
-            ? sanitize_email($form_data['organization_email'])
434
-            : $this->organization_config->email;
435
-        $this->organization_config->vat = isset($form_data['organization_vat'])
436
-            ? sanitize_text_field($form_data['organization_vat'])
437
-            : $this->organization_config->vat;
438
-        $this->organization_config->phone = isset($form_data['organization_phone'])
439
-            ? sanitize_text_field($form_data['organization_phone'])
440
-            : $this->organization_config->phone;
441
-        $this->organization_config->logo_url = isset($form_data['organization_logo_url'])
442
-            ? esc_url_raw($form_data['organization_logo_url'])
443
-            : $this->organization_config->logo_url;
444
-        $this->organization_config->facebook = isset($form_data['organization_facebook'])
445
-            ? esc_url_raw($form_data['organization_facebook'])
446
-            : $this->organization_config->facebook;
447
-        $this->organization_config->twitter = isset($form_data['organization_twitter'])
448
-            ? esc_url_raw($form_data['organization_twitter'])
449
-            : $this->organization_config->twitter;
450
-        $this->organization_config->linkedin = isset($form_data['organization_linkedin'])
451
-            ? esc_url_raw($form_data['organization_linkedin'])
452
-            : $this->organization_config->linkedin;
453
-        $this->organization_config->pinterest = isset($form_data['organization_pinterest'])
454
-            ? esc_url_raw($form_data['organization_pinterest'])
455
-            : $this->organization_config->pinterest;
456
-        $this->organization_config->google = isset($form_data['organization_google'])
457
-            ? esc_url_raw($form_data['organization_google'])
458
-            : $this->organization_config->google;
459
-        $this->organization_config->instagram = isset($form_data['organization_instagram'])
460
-            ? esc_url_raw($form_data['organization_instagram'])
461
-            : $this->organization_config->instagram;
462
-        $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
463
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
464
-            : false;
465
-        $this->core_config->ee_ueip_has_notified = true;
406
+		if (is_main_site()) {
407
+			$this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
408
+				? sanitize_text_field($form_data['ee_site_license_key'])
409
+				: $this->network_core_config->site_license_key;
410
+		}
411
+		$this->organization_config->name = isset($form_data['organization_name'])
412
+			? sanitize_text_field($form_data['organization_name'])
413
+			: $this->organization_config->name;
414
+		$this->organization_config->address_1 = isset($form_data['organization_address_1'])
415
+			? sanitize_text_field($form_data['organization_address_1'])
416
+			: $this->organization_config->address_1;
417
+		$this->organization_config->address_2 = isset($form_data['organization_address_2'])
418
+			? sanitize_text_field($form_data['organization_address_2'])
419
+			: $this->organization_config->address_2;
420
+		$this->organization_config->city = isset($form_data['organization_city'])
421
+			? sanitize_text_field($form_data['organization_city'])
422
+			: $this->organization_config->city;
423
+		$this->organization_config->STA_ID = isset($form_data['organization_state'])
424
+			? absint($form_data['organization_state'])
425
+			: $this->organization_config->STA_ID;
426
+		$this->organization_config->CNT_ISO = isset($form_data['organization_country'])
427
+			? sanitize_text_field($form_data['organization_country'])
428
+			: $this->organization_config->CNT_ISO;
429
+		$this->organization_config->zip = isset($form_data['organization_zip'])
430
+			? sanitize_text_field($form_data['organization_zip'])
431
+			: $this->organization_config->zip;
432
+		$this->organization_config->email = isset($form_data['organization_email'])
433
+			? sanitize_email($form_data['organization_email'])
434
+			: $this->organization_config->email;
435
+		$this->organization_config->vat = isset($form_data['organization_vat'])
436
+			? sanitize_text_field($form_data['organization_vat'])
437
+			: $this->organization_config->vat;
438
+		$this->organization_config->phone = isset($form_data['organization_phone'])
439
+			? sanitize_text_field($form_data['organization_phone'])
440
+			: $this->organization_config->phone;
441
+		$this->organization_config->logo_url = isset($form_data['organization_logo_url'])
442
+			? esc_url_raw($form_data['organization_logo_url'])
443
+			: $this->organization_config->logo_url;
444
+		$this->organization_config->facebook = isset($form_data['organization_facebook'])
445
+			? esc_url_raw($form_data['organization_facebook'])
446
+			: $this->organization_config->facebook;
447
+		$this->organization_config->twitter = isset($form_data['organization_twitter'])
448
+			? esc_url_raw($form_data['organization_twitter'])
449
+			: $this->organization_config->twitter;
450
+		$this->organization_config->linkedin = isset($form_data['organization_linkedin'])
451
+			? esc_url_raw($form_data['organization_linkedin'])
452
+			: $this->organization_config->linkedin;
453
+		$this->organization_config->pinterest = isset($form_data['organization_pinterest'])
454
+			? esc_url_raw($form_data['organization_pinterest'])
455
+			: $this->organization_config->pinterest;
456
+		$this->organization_config->google = isset($form_data['organization_google'])
457
+			? esc_url_raw($form_data['organization_google'])
458
+			: $this->organization_config->google;
459
+		$this->organization_config->instagram = isset($form_data['organization_instagram'])
460
+			? esc_url_raw($form_data['organization_instagram'])
461
+			: $this->organization_config->instagram;
462
+		$this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
463
+			? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
464
+			: false;
465
+		$this->core_config->ee_ueip_has_notified = true;
466 466
 
467
-        $this->registry->CFG->currency = new EE_Currency_Config(
468
-            $this->organization_config->CNT_ISO
469
-        );
470
-        return true;
471
-    }
467
+		$this->registry->CFG->currency = new EE_Currency_Config(
468
+			$this->organization_config->CNT_ISO
469
+		);
470
+		return true;
471
+	}
472 472
 
473 473
 
474
-    /**
475
-     * @return string
476
-     */
477
-    private function uxipOptinText()
478
-    {
479
-        ob_start();
480
-        Stats::optinText(false);
481
-        return ob_get_clean();
482
-    }
474
+	/**
475
+	 * @return string
476
+	 */
477
+	private function uxipOptinText()
478
+	{
479
+		ob_start();
480
+		Stats::optinText(false);
481
+		return ob_get_clean();
482
+	}
483 483
 
484 484
 
485
-    /**
486
-     * Return whether the site license key has been verified or not.
487
-     * @return bool
488
-     */
489
-    private function licenseKeyVerified()
490
-    {
491
-        if (empty($this->network_core_config->site_license_key)) {
492
-            return false;
493
-        }
494
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
495
-        $verify_fail = get_option($ver_option_key, false);
496
-        return $verify_fail === false
497
-                  || (! empty($this->network_core_config->site_license_key)
498
-                        && $verify_fail === false
499
-                  );
500
-    }
485
+	/**
486
+	 * Return whether the site license key has been verified or not.
487
+	 * @return bool
488
+	 */
489
+	private function licenseKeyVerified()
490
+	{
491
+		if (empty($this->network_core_config->site_license_key)) {
492
+			return false;
493
+		}
494
+		$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
495
+		$verify_fail = get_option($ver_option_key, false);
496
+		return $verify_fail === false
497
+				  || (! empty($this->network_core_config->site_license_key)
498
+						&& $verify_fail === false
499
+				  );
500
+	}
501 501
 
502 502
 
503
-    /**
504
-     * @return EE_Text_Input
505
-     */
506
-    private function getSiteLicenseKeyField()
507
-    {
508
-        $text_input = new EE_Text_Input(
509
-            array(
510
-                'html_name' => 'ee_site_license_key',
511
-                'html_id' => 'site_license_key',
512
-                'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
513
-                /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
514
-                'html_help_text'  => sprintf(
515
-                    esc_html__(
516
-                        'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
517
-                        'event_espresso'
518
-                    ),
519
-                    '<strong>',
520
-                    '</strong>'
521
-                ),
522
-                /** phpcs:enable */
523
-                'default'         => isset($this->network_core_config->site_license_key)
524
-                    ? $this->network_core_config->site_license_key
525
-                    : '',
526
-                'required'        => false,
527
-                'form_html_filter' => new VsprintfFilter(
528
-                    '%2$s %1$s',
529
-                    array($this->getValidationIndicator())
530
-                )
531
-            )
532
-        );
533
-        return $text_input;
534
-    }
503
+	/**
504
+	 * @return EE_Text_Input
505
+	 */
506
+	private function getSiteLicenseKeyField()
507
+	{
508
+		$text_input = new EE_Text_Input(
509
+			array(
510
+				'html_name' => 'ee_site_license_key',
511
+				'html_id' => 'site_license_key',
512
+				'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
513
+				/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
514
+				'html_help_text'  => sprintf(
515
+					esc_html__(
516
+						'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
517
+						'event_espresso'
518
+					),
519
+					'<strong>',
520
+					'</strong>'
521
+				),
522
+				/** phpcs:enable */
523
+				'default'         => isset($this->network_core_config->site_license_key)
524
+					? $this->network_core_config->site_license_key
525
+					: '',
526
+				'required'        => false,
527
+				'form_html_filter' => new VsprintfFilter(
528
+					'%2$s %1$s',
529
+					array($this->getValidationIndicator())
530
+				)
531
+			)
532
+		);
533
+		return $text_input;
534
+	}
535 535
 
536 536
 
537
-    /**
538
-     * @return string
539
-     */
540
-    private function getValidationIndicator()
541
-    {
542
-        $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
543
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
544
-    }
537
+	/**
538
+	 * @return string
539
+	 */
540
+	private function getValidationIndicator()
541
+	{
542
+		$verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
543
+		return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
544
+	}
545 545
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 2 patches
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
         wp_enqueue_script('thickbox');
290 290
         wp_register_script(
291 291
             'organization_settings',
292
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
293 293
             array('jquery', 'media-upload', 'thickbox'),
294 294
             EVENT_ESPRESSO_VERSION,
295 295
             true
296 296
         );
297
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
297
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
298 298
         wp_enqueue_script('organization_settings');
299 299
         wp_enqueue_style('organization-css');
300 300
         $confirm_image_delete = array(
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
         // scripts
316 316
         wp_register_script(
317 317
             'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
318
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
319 319
             array('ee_admin_js'),
320 320
             EVENT_ESPRESSO_VERSION,
321 321
             true
322 322
         );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
323
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
324 324
         wp_enqueue_script('gen_settings_countries');
325 325
         wp_enqueue_style('organization-css');
326 326
     }
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
371 371
         $this->_set_publish_post_box_vars(null, false, false, null, false);
372 372
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
373
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
374 374
             $this->_template_args,
375 375
             true
376 376
         );
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
     {
535 535
         try {
536 536
             $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
537
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
537
+            $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
538 538
             EE_Registry::instance()->CFG->admin = apply_filters(
539 539
                 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
540 540
                 EE_Registry::instance()->CFG->admin
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         $this->_set_add_edit_form_tags('update_country_settings');
613 613
         $this->_set_publish_post_box_vars(null, false, false, null, false);
614 614
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
615
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
615
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
616 616
             $this->_template_args,
617 617
             true
618 618
         );
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
         $CNT_ISO = isset($this->_req_data['country'])
638 638
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
639 639
             : $CNT_ISO;
640
-        if (! $CNT_ISO) {
640
+        if ( ! $CNT_ISO) {
641 641
             return '';
642 642
         }
643 643
 
@@ -656,59 +656,59 @@  discard block
 block discarded – undo
656 656
         $country_input_types = array(
657 657
             'CNT_active'      => array(
658 658
                 'type'             => 'RADIO_BTN',
659
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
659
+                'input_name'       => 'cntry['.$CNT_ISO.']',
660 660
                 'class'            => '',
661 661
                 'options'          => $this->_yes_no_values,
662 662
                 'use_desc_4_label' => true,
663 663
             ),
664 664
             'CNT_ISO'         => array(
665 665
                 'type'       => 'TEXT',
666
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
666
+                'input_name' => 'cntry['.$CNT_ISO.']',
667 667
                 'class'      => 'small-text',
668 668
             ),
669 669
             'CNT_ISO3'        => array(
670 670
                 'type'       => 'TEXT',
671
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
671
+                'input_name' => 'cntry['.$CNT_ISO.']',
672 672
                 'class'      => 'small-text',
673 673
             ),
674 674
             'RGN_ID'          => array(
675 675
                 'type'       => 'TEXT',
676
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
676
+                'input_name' => 'cntry['.$CNT_ISO.']',
677 677
                 'class'      => 'small-text',
678 678
             ),
679 679
             'CNT_name'        => array(
680 680
                 'type'       => 'TEXT',
681
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
681
+                'input_name' => 'cntry['.$CNT_ISO.']',
682 682
                 'class'      => 'regular-text',
683 683
             ),
684 684
             'CNT_cur_code'    => array(
685 685
                 'type'       => 'TEXT',
686
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
686
+                'input_name' => 'cntry['.$CNT_ISO.']',
687 687
                 'class'      => 'small-text',
688 688
                 'disabled'   => $CNT_cur_disabled
689 689
             ),
690 690
             'CNT_cur_single'  => array(
691 691
                 'type'       => 'TEXT',
692
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
692
+                'input_name' => 'cntry['.$CNT_ISO.']',
693 693
                 'class'      => 'medium-text',
694 694
                 'disabled' => $CNT_cur_disabled
695 695
             ),
696 696
             'CNT_cur_plural'  => array(
697 697
                 'type'       => 'TEXT',
698
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
698
+                'input_name' => 'cntry['.$CNT_ISO.']',
699 699
                 'class'      => 'medium-text',
700 700
                 'disabled' => $CNT_cur_disabled
701 701
             ),
702 702
             'CNT_cur_sign'    => array(
703 703
                 'type'         => 'TEXT',
704
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
704
+                'input_name'   => 'cntry['.$CNT_ISO.']',
705 705
                 'class'        => 'small-text',
706 706
                 'htmlentities' => false,
707 707
                 'disabled' => $CNT_cur_disabled
708 708
             ),
709 709
             'CNT_cur_sign_b4' => array(
710 710
                 'type'             => 'RADIO_BTN',
711
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
711
+                'input_name'       => 'cntry['.$CNT_ISO.']',
712 712
                 'class'            => '',
713 713
                 'options'          => $this->_yes_no_values,
714 714
                 'use_desc_4_label' => true,
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
             ),
717 717
             'CNT_cur_dec_plc' => array(
718 718
                 'type'       => 'RADIO_BTN',
719
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
719
+                'input_name' => 'cntry['.$CNT_ISO.']',
720 720
                 'class'      => '',
721 721
                 'options'    => array(
722 722
                     array('id' => 0, 'text' => ''),
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
             ),
729 729
             'CNT_cur_dec_mrk' => array(
730 730
                 'type'             => 'RADIO_BTN',
731
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
731
+                'input_name'       => 'cntry['.$CNT_ISO.']',
732 732
                 'class'            => '',
733 733
                 'options'          => array(
734 734
                     array(
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
             ),
743 743
             'CNT_cur_thsnds'  => array(
744 744
                 'type'             => 'RADIO_BTN',
745
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
745
+                'input_name'       => 'cntry['.$CNT_ISO.']',
746 746
                 'class'            => '',
747 747
                 'options'          => array(
748 748
                     array(
@@ -756,12 +756,12 @@  discard block
 block discarded – undo
756 756
             ),
757 757
             'CNT_tel_code'    => array(
758 758
                 'type'       => 'TEXT',
759
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
759
+                'input_name' => 'cntry['.$CNT_ISO.']',
760 760
                 'class'      => 'small-text',
761 761
             ),
762 762
             'CNT_is_EU'       => array(
763 763
                 'type'             => 'RADIO_BTN',
764
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
764
+                'input_name'       => 'cntry['.$CNT_ISO.']',
765 765
                 'class'            => '',
766 766
                 'options'          => $this->_yes_no_values,
767 767
                 'use_desc_4_label' => true,
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
             $country_input_types
773 773
         );
774 774
         $country_details_settings = EEH_Template::display_template(
775
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
775
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
776 776
             $this->_template_args,
777 777
             true
778 778
         );
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 
807 807
         $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
808 808
 
809
-        if (! $CNT_ISO) {
809
+        if ( ! $CNT_ISO) {
810 810
             return '';
811 811
         }
812 812
         // for ajax
@@ -823,22 +823,22 @@  discard block
 block discarded – undo
823 823
                     $state_input_types = array(
824 824
                         'STA_abbrev' => array(
825 825
                             'type'       => 'TEXT',
826
-                            'input_name' => 'states[' . $STA_ID . ']',
826
+                            'input_name' => 'states['.$STA_ID.']',
827 827
                             'class'      => 'mid-text',
828 828
                         ),
829 829
                         'STA_name'   => array(
830 830
                             'type'       => 'TEXT',
831
-                            'input_name' => 'states[' . $STA_ID . ']',
831
+                            'input_name' => 'states['.$STA_ID.']',
832 832
                             'class'      => 'regular-text',
833 833
                         ),
834 834
                         'STA_active' => array(
835 835
                             'type'             => 'RADIO_BTN',
836
-                            'input_name'       => 'states[' . $STA_ID . ']',
836
+                            'input_name'       => 'states['.$STA_ID.']',
837 837
                             'options'          => $this->_yes_no_values,
838 838
                             'use_desc_4_label' => true,
839 839
                         ),
840 840
                     );
841
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
841
+                    $this->_template_args['states'][$STA_ID]['inputs'] =
842 842
                         EE_Question_Form_Input::generate_question_form_inputs_for_object(
843 843
                             $state,
844 844
                             $state_input_types
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
                         'CNT_ISO'    => $CNT_ISO,
850 850
                         'STA_abbrev' => $state->abbrev(),
851 851
                     );
852
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
852
+                    $this->_template_args['states'][$STA_ID]['delete_state_url'] =
853 853
                         EE_Admin_Page::add_query_args_and_nonce(
854 854
                             $query_args,
855 855
                             GEN_SET_ADMIN_URL
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
         );
867 867
 
868 868
         $state_details_settings = EEH_Template::display_template(
869
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
869
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
870 870
             $this->_template_args,
871 871
             true
872 872
         );
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
         $CNT_ISO = isset($this->_req_data['CNT_ISO'])
903 903
             ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
904 904
             : false;
905
-        if (! $CNT_ISO) {
905
+        if ( ! $CNT_ISO) {
906 906
             EE_Error::add_error(
907 907
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
908 908
                 __FILE__,
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
915 915
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
916 916
             : false;
917
-        if (! $STA_abbrev) {
917
+        if ( ! $STA_abbrev) {
918 918
             EE_Error::add_error(
919 919
                 __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
920 920
                 __FILE__,
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
         $STA_name = isset($this->_req_data['STA_name'])
927 927
             ? sanitize_text_field($this->_req_data['STA_name'])
928 928
             : false;
929
-        if (! $STA_name) {
929
+        if ( ! $STA_name) {
930 930
             EE_Error::add_error(
931 931
                 __('No State name or an invalid State name was received.', 'event_espresso'),
932 932
                 __FILE__,
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
977 977
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
978 978
             : false;
979
-        if (! $STA_ID) {
979
+        if ( ! $STA_ID) {
980 980
             EE_Error::add_error(
981 981
                 __('No State ID or an invalid State ID was received.', 'event_espresso'),
982 982
                 __FILE__,
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
         $CNT_ISO = isset($this->_req_data['country'])
1026 1026
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
1027 1027
             : false;
1028
-        if (! $CNT_ISO) {
1028
+        if ( ! $CNT_ISO) {
1029 1029
             EE_Error::add_error(
1030 1030
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1031 1031
                 __FILE__,
@@ -1036,47 +1036,47 @@  discard block
 block discarded – undo
1036 1036
             return;
1037 1037
         }
1038 1038
         $cols_n_values = array();
1039
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1040
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1039
+        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])
1040
+            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']))
1041 1041
             : false;
1042
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1043
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1042
+        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1043
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1044 1044
             : null;
1045
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1046
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1045
+        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1046
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1047 1047
             : null;
1048
-        $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1049
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']))
1048
+        $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])
1049
+            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']))
1050 1050
             : 'USD';
1051
-        $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1052
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1051
+        $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1052
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1053 1053
             : 'dollar';
1054
-        $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1055
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1054
+        $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1055
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1056 1056
             : 'dollars';
1057
-        $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1058
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1057
+        $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1058
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1059 1059
             : '$';
1060
-        $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1061
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1060
+        $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1061
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1062 1062
             : true;
1063
-        $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1064
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1063
+        $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1064
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1065 1065
             : 2;
1066
-        $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1067
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1066
+        $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1067
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1068 1068
             : '.';
1069
-        $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1070
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1069
+        $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1070
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1071 1071
             : ',';
1072
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1073
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1072
+        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1073
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1074 1074
             : null;
1075
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1076
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1075
+        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1076
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1077 1077
             : false;
1078
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1079
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1078
+        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1079
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1080 1080
             : false;
1081 1081
         // allow filtering of country data
1082 1082
         $cols_n_values = apply_filters(
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
         return '
1154 1154
 			<tr>
1155 1155
 				<th>
1156
-					' . $label . '
1156
+					' . $label.'
1157 1157
 				</th>';
1158 1158
     }
1159 1159
 
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
     {
1170 1170
         return '
1171 1171
 				<td class="general-settings-country-input-td">
1172
-					' . $input . '
1172
+					' . $input.'
1173 1173
 				</td>
1174 1174
 			</tr>';
1175 1175
     }
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
     {
1201 1201
         return '
1202 1202
 				<td class="general-settings-country-state-input-td">
1203
-					' . $input . '
1203
+					' . $input.'
1204 1204
 				</td>';
1205 1205
     }
1206 1206
 
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
                  . __('Edit', 'event_espresso')
1227 1227
                  . '</a>';
1228 1228
         $links .= ' &nbsp;|&nbsp; ';
1229
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1229
+        $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>';
1230 1230
 
1231 1231
         return $links;
1232 1232
     }
@@ -1259,9 +1259,9 @@  discard block
 block discarded – undo
1259 1259
             $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1260 1260
         }
1261 1261
 
1262
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1262
+        return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'
1263 1263
                . $pg_status
1264
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1264
+               . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
1265 1265
     }
1266 1266
 
1267 1267
 
Please login to merge, or discard this patch.
Indentation   +1308 added lines, -1308 removed lines patch added patch discarded remove patch
@@ -21,1323 +21,1323 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * _question_group
26
-     * holds the specific question group object for the question group details screen
27
-     *
28
-     * @var object
29
-     */
30
-    protected $_question_group;
31
-
32
-
33
-    /**
34
-     * Initialize basic properties.
35
-     */
36
-    protected function _init_page_props()
37
-    {
38
-        $this->page_slug = GEN_SET_PG_SLUG;
39
-        $this->page_label = GEN_SET_LABEL;
40
-        $this->_admin_base_url = GEN_SET_ADMIN_URL;
41
-        $this->_admin_base_path = GEN_SET_ADMIN;
42
-    }
43
-
44
-
45
-    /**
46
-     * Set ajax hooks
47
-     */
48
-    protected function _ajax_hooks()
49
-    {
50
-        add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
51
-        add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
52
-        add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
53
-        add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
54
-    }
55
-
56
-
57
-    /**
58
-     * More page properties initialization.
59
-     */
60
-    protected function _define_page_props()
61
-    {
62
-        $this->_admin_page_title = GEN_SET_LABEL;
63
-        $this->_labels = array(
64
-            'publishbox' => __('Update Settings', 'event_espresso'),
65
-        );
66
-    }
67
-
68
-
69
-    /**
70
-     * Set page routes property.
71
-     */
72
-    protected function _set_page_routes()
73
-    {
74
-        $this->_page_routes = array(
75
-
76
-            'critical_pages'                => array(
77
-                'func'       => '_espresso_page_settings',
78
-                'capability' => 'manage_options',
79
-            ),
80
-            'update_espresso_page_settings' => array(
81
-                'func'       => '_update_espresso_page_settings',
82
-                'capability' => 'manage_options',
83
-                'noheader'   => true,
84
-            ),
85
-            'default'                       => array(
86
-                'func'       => '_your_organization_settings',
87
-                'capability' => 'manage_options',
88
-            ),
89
-
90
-            'update_your_organization_settings' => array(
91
-                'func'       => '_update_your_organization_settings',
92
-                'capability' => 'manage_options',
93
-                'noheader'   => true,
94
-            ),
95
-
96
-            'admin_option_settings' => array(
97
-                'func'       => '_admin_option_settings',
98
-                'capability' => 'manage_options',
99
-            ),
100
-
101
-            'update_admin_option_settings' => array(
102
-                'func'       => '_update_admin_option_settings',
103
-                'capability' => 'manage_options',
104
-                'noheader'   => true,
105
-            ),
106
-
107
-            'country_settings' => array(
108
-                'func'       => '_country_settings',
109
-                'capability' => 'manage_options',
110
-            ),
111
-
112
-            'update_country_settings' => array(
113
-                'func'       => '_update_country_settings',
114
-                'capability' => 'manage_options',
115
-                'noheader'   => true,
116
-            ),
117
-
118
-            'display_country_settings' => array(
119
-                'func'       => 'display_country_settings',
120
-                'capability' => 'manage_options',
121
-                'noheader'   => true,
122
-            ),
123
-
124
-            'add_new_state' => array(
125
-                'func'       => 'add_new_state',
126
-                'capability' => 'manage_options',
127
-                'noheader'   => true,
128
-            ),
129
-
130
-            'delete_state' => array(
131
-                'func'       => 'delete_state',
132
-                'capability' => 'manage_options',
133
-                'noheader'   => true,
134
-            ),
135
-            'privacy_settings' => array(
136
-                'func' => 'privacySettings',
137
-                'capability' => 'manage_options',
138
-            ),
139
-            'update_privacy_settings' => array(
140
-                'func' => 'updatePrivacySettings',
141
-                'capability' => 'manage_options',
142
-                'noheader' => true,
143
-                'headers_sent_route' => 'privacy_settings'
144
-            )
145
-        );
146
-    }
147
-
148
-
149
-    /**
150
-     * Set page configuration property
151
-     */
152
-    protected function _set_page_config()
153
-    {
154
-        $this->_page_config = array(
155
-            'critical_pages'        => array(
156
-                'nav'           => array(
157
-                    'label' => __('Critical Pages', 'event_espresso'),
158
-                    'order' => 50,
159
-                ),
160
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
161
-                'help_tabs'     => array(
162
-                    'general_settings_critical_pages_help_tab' => array(
163
-                        'title'    => __('Critical Pages', 'event_espresso'),
164
-                        'filename' => 'general_settings_critical_pages',
165
-                    ),
166
-                ),
167
-                'help_tour'     => array('Critical_Pages_Help_Tour'),
168
-                'require_nonce' => false,
169
-            ),
170
-            'default'               => array(
171
-                'nav'           => array(
172
-                    'label' => __('Your Organization', 'event_espresso'),
173
-                    'order' => 20,
174
-                ),
175
-                'help_tabs'     => array(
176
-                    'general_settings_your_organization_help_tab' => array(
177
-                        'title'    => __('Your Organization', 'event_espresso'),
178
-                        'filename' => 'general_settings_your_organization',
179
-                    ),
180
-                ),
181
-                'help_tour'     => array('Your_Organization_Help_Tour'),
182
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
183
-                'require_nonce' => false,
184
-            ),
185
-            'admin_option_settings' => array(
186
-                'nav'           => array(
187
-                    'label' => __('Admin Options', 'event_espresso'),
188
-                    'order' => 60,
189
-                ),
190
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
191
-                'help_tabs'     => array(
192
-                    'general_settings_admin_options_help_tab' => array(
193
-                        'title'    => __('Admin Options', 'event_espresso'),
194
-                        'filename' => 'general_settings_admin_options',
195
-                    ),
196
-                ),
197
-                'help_tour'     => array('Admin_Options_Help_Tour'),
198
-                'require_nonce' => false,
199
-            ),
200
-            'country_settings'      => array(
201
-                'nav'           => array(
202
-                    'label' => __('Countries', 'event_espresso'),
203
-                    'order' => 70,
204
-                ),
205
-                'help_tabs'     => array(
206
-                    'general_settings_countries_help_tab' => array(
207
-                        'title'    => __('Countries', 'event_espresso'),
208
-                        'filename' => 'general_settings_countries',
209
-                    ),
210
-                ),
211
-                'help_tour'     => array('Countries_Help_Tour'),
212
-                'require_nonce' => false,
213
-            ),
214
-            'privacy_settings' => array(
215
-                'nav' => array(
216
-                    'label' => esc_html__('Privacy', 'event_espresso'),
217
-                    'order' => 80
218
-                ),
219
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
220
-                'require_nonce' => false
221
-            )
222
-        );
223
-    }
224
-
225
-
226
-    protected function _add_screen_options()
227
-    {
228
-    }
229
-
230
-    protected function _add_feature_pointers()
231
-    {
232
-    }
233
-
234
-
235
-    /**
236
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
237
-     */
238
-    public function load_scripts_styles()
239
-    {
240
-        // styles
241
-        wp_enqueue_style('espresso-ui-theme');
242
-        // scripts
243
-        wp_enqueue_script('ee_admin_js');
244
-    }
245
-
246
-
247
-    /**
248
-     * Execute logic running on `admin_init`
249
-     */
250
-    public function admin_init()
251
-    {
252
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
253
-            'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
254
-            'event_espresso'
255
-        );
256
-        EE_Registry::$i18n_js_strings['error_occurred'] = __(
257
-            'An error occurred! Please refresh the page and try again.',
258
-            'event_espresso'
259
-        );
260
-        EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
261
-            'Are you sure you want to delete this State / Province?',
262
-            'event_espresso'
263
-        );
264
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
265
-        EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
266
-            'admin-ajax.php?page=espresso_general_settings',
267
-            $protocol
268
-        );
269
-    }
270
-
271
-    public function admin_notices()
272
-    {
273
-    }
274
-
275
-    public function admin_footer_scripts()
276
-    {
277
-    }
278
-
279
-
280
-    /**
281
-     * Enqueue scripts and styles for the default route.
282
-     */
283
-    public function load_scripts_styles_default()
284
-    {
285
-        // styles
286
-        wp_enqueue_style('thickbox');
287
-        // scripts
288
-        wp_enqueue_script('media-upload');
289
-        wp_enqueue_script('thickbox');
290
-        wp_register_script(
291
-            'organization_settings',
292
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
293
-            array('jquery', 'media-upload', 'thickbox'),
294
-            EVENT_ESPRESSO_VERSION,
295
-            true
296
-        );
297
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
298
-        wp_enqueue_script('organization_settings');
299
-        wp_enqueue_style('organization-css');
300
-        $confirm_image_delete = array(
301
-            'text' => __(
302
-                'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
-                'event_espresso'
304
-            ),
305
-        );
306
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
-    }
308
-
309
-
310
-    /**
311
-     * Enqueue scripts and styles for the country settings route.
312
-     */
313
-    public function load_scripts_styles_country_settings()
314
-    {
315
-        // scripts
316
-        wp_register_script(
317
-            'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
-            array('ee_admin_js'),
320
-            EVENT_ESPRESSO_VERSION,
321
-            true
322
-        );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
324
-        wp_enqueue_script('gen_settings_countries');
325
-        wp_enqueue_style('organization-css');
326
-    }
327
-
328
-
329
-    /*************        Espresso Pages        *************/
330
-    /**
331
-     * _espresso_page_settings
332
-     *
333
-     * @throws \EE_Error
334
-     * @throws DomainException
335
-     * @throws DomainException
336
-     * @throws InvalidDataTypeException
337
-     * @throws InvalidArgumentException
338
-     */
339
-    protected function _espresso_page_settings()
340
-    {
341
-        // Check to make sure all of the main pages are setup properly,
342
-        // if not create the default pages and display an admin notice
343
-        EEH_Activation::verify_default_pages_exist();
344
-        $this->_transient_garbage_collection();
345
-        $this->_template_args['values'] = $this->_yes_no_values;
346
-        $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
347
-            ? EE_Registry::instance()->CFG->core->reg_page_id
348
-            : null;
349
-        $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
350
-            ? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
351
-            : false;
352
-        $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
353
-            ? EE_Registry::instance()->CFG->core->txn_page_id
354
-            : null;
355
-        $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
356
-            ? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
357
-            : false;
358
-        $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
359
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
360
-            : null;
361
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
362
-            ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
363
-            : false;
364
-        $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
365
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
366
-            : null;
367
-        $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
368
-            ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
369
-            : false;
370
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
371
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
372
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
373
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
374
-            $this->_template_args,
375
-            true
376
-        );
377
-        $this->display_admin_page_with_sidebar();
378
-    }
379
-
380
-
381
-    /**
382
-     * Handler for updating espresso page settings.
383
-     *
384
-     * @throws EE_Error
385
-     */
386
-    protected function _update_espresso_page_settings()
387
-    {
388
-        // capture incoming request data && set page IDs
389
-        EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
390
-            ? absint($this->_req_data['reg_page_id'])
391
-            : EE_Registry::instance()->CFG->core->reg_page_id;
392
-        EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
393
-            ? absint($this->_req_data['txn_page_id'])
394
-            : EE_Registry::instance()->CFG->core->txn_page_id;
395
-        EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
396
-            ? absint($this->_req_data['thank_you_page_id'])
397
-            : EE_Registry::instance()->CFG->core->thank_you_page_id;
398
-        EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
399
-            ? absint($this->_req_data['cancel_page_id'])
400
-            : EE_Registry::instance()->CFG->core->cancel_page_id;
401
-
402
-        EE_Registry::instance()->CFG->core = apply_filters(
403
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
404
-            EE_Registry::instance()->CFG->core,
405
-            $this->_req_data
406
-        );
407
-        $what = __('Critical Pages & Shortcodes', 'event_espresso');
408
-        $this->_redirect_after_action(
409
-            $this->_update_espresso_configuration(
410
-                $what,
411
-                EE_Registry::instance()->CFG->core,
412
-                __FILE__,
413
-                __FUNCTION__,
414
-                __LINE__
415
-            ),
416
-            $what,
417
-            '',
418
-            array(
419
-                'action' => 'critical_pages',
420
-            ),
421
-            true
422
-        );
423
-    }
424
-
425
-
426
-    /*************        Your Organization        *************/
427
-
428
-
429
-    /**
430
-     * @throws DomainException
431
-     * @throws EE_Error
432
-     * @throws InvalidArgumentException
433
-     * @throws InvalidDataTypeException
434
-     * @throws InvalidInterfaceException
435
-     */
436
-    protected function _your_organization_settings()
437
-    {
438
-        $this->_template_args['admin_page_content'] = '';
439
-        try {
440
-            $organization_settings_form = new OrganizationSettings(
441
-                EE_Registry::instance(),
442
-                EE_Registry::instance()->CFG->organization,
443
-                EE_Registry::instance()->CFG->core,
444
-                EE_Registry::instance()->NET_CFG->core
445
-            );
446
-            $this->_template_args['admin_page_content'] = $organization_settings_form->display();
447
-        } catch (Exception $e) {
448
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
449
-        }
450
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
451
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
452
-        $this->display_admin_page_with_sidebar();
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     * Handler for updating organization settings.
459
-     *
460
-     * @throws EE_Error
461
-     */
462
-    protected function _update_your_organization_settings()
463
-    {
464
-        try {
465
-            $organization_settings_form = new OrganizationSettings(
466
-                EE_Registry::instance(),
467
-                EE_Registry::instance()->CFG->organization,
468
-                EE_Registry::instance()->CFG->core,
469
-                EE_Registry::instance()->NET_CFG->core
470
-            );
471
-            $success = $organization_settings_form->process($this->_req_data);
472
-            EE_Registry::instance()->CFG = apply_filters(
473
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
474
-                EE_Registry::instance()->CFG
475
-            );
476
-        } catch (Exception $e) {
477
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
478
-            $success = false;
479
-        }
480
-
481
-        if ($success) {
482
-            $success = $this->_update_espresso_configuration(
483
-                esc_html__('Your Organization Settings', 'event_espresso'),
484
-                EE_Registry::instance()->CFG,
485
-                __FILE__,
486
-                __FUNCTION__,
487
-                __LINE__
488
-            );
489
-        }
490
-
491
-        $this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
492
-    }
493
-
494
-
495
-
496
-    /*************        Admin Options        *************/
497
-
498
-
499
-    /**
500
-     * _admin_option_settings
501
-     *
502
-     * @throws \EE_Error
503
-     * @throws \LogicException
504
-     */
505
-    protected function _admin_option_settings()
506
-    {
507
-        $this->_template_args['admin_page_content'] = '';
508
-        try {
509
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
510
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
511
-            $this->_template_args['values'] = $this->_yes_no_values;
512
-            // also need to account for the do_action that was in the old template
513
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
514
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
515
-        } catch (Exception $e) {
516
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
517
-        }
518
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
519
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
520
-        $this->display_admin_page_with_sidebar();
521
-    }
522
-
523
-
524
-    /**
525
-     * _update_admin_option_settings
526
-     *
527
-     * @throws \EE_Error
528
-     * @throws InvalidDataTypeException
529
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
530
-     * @throws \InvalidArgumentException
531
-     * @throws \LogicException
532
-     */
533
-    protected function _update_admin_option_settings()
534
-    {
535
-        try {
536
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
537
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
538
-            EE_Registry::instance()->CFG->admin = apply_filters(
539
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
540
-                EE_Registry::instance()->CFG->admin
541
-            );
542
-        } catch (Exception $e) {
543
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
544
-        }
545
-        $this->_redirect_after_action(
546
-            apply_filters(
547
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
548
-                $this->_update_espresso_configuration(
549
-                    'Admin Options',
550
-                    EE_Registry::instance()->CFG->admin,
551
-                    __FILE__,
552
-                    __FUNCTION__,
553
-                    __LINE__
554
-                )
555
-            ),
556
-            'Admin Options',
557
-            'updated',
558
-            array('action' => 'admin_option_settings')
559
-        );
560
-    }
561
-
562
-
563
-    /*************        Countries        *************/
564
-
565
-
566
-    /**
567
-     * Output Country Settings view.
568
-     *
569
-     * @throws DomainException
570
-     * @throws EE_Error
571
-     */
572
-    protected function _country_settings()
573
-    {
574
-        $CNT_ISO_for_site = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
575
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
576
-            : 'US';
577
-        $CNT_ISO = isset($this->_req_data['country'])
578
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
579
-            : $CNT_ISO_for_site;
580
-
581
-        // load field generator helper
582
-
583
-        $this->_template_args['values'] = $this->_yes_no_values;
584
-
585
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
586
-            EE_Question::new_instance(
587
-                array(
588
-                    'QST_ID'           => 0,
589
-                    'QST_display_text' => __('Select Country', 'event_espresso'),
590
-                    'QST_system'       => 'admin-country',
591
-                )
592
-            ),
593
-            EE_Answer::new_instance(
594
-                array(
595
-                    'ANS_ID'    => 0,
596
-                    'ANS_value' => $CNT_ISO,
597
-                )
598
-            ),
599
-            array(
600
-                'input_id'       => 'country',
601
-                'input_name'     => 'country',
602
-                'input_prefix'   => '',
603
-                'append_qstn_id' => false,
604
-            )
605
-        );
606
-
607
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
608
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
609
-        $this->_template_args['country_details_settings'] = $this->display_country_settings();
610
-        $this->_template_args['country_states_settings'] = $this->display_country_states();
611
-        $this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site)
612
-                                                                            ->name();
613
-
614
-        $this->_set_add_edit_form_tags('update_country_settings');
615
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
616
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
617
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
618
-            $this->_template_args,
619
-            true
620
-        );
621
-        $this->display_admin_page_with_no_sidebar();
622
-    }
623
-
624
-
625
-    /**
626
-     *        display_country_settings
627
-     *
628
-     * @access    public
629
-     * @param    string $CNT_ISO
630
-     * @return mixed string | array
631
-     * @throws DomainException
632
-     */
633
-    public function display_country_settings($CNT_ISO = '')
634
-    {
635
-        $CNT_ISO_for_site = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
636
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
637
-            : 'US';
638
-
639
-        $CNT_ISO = isset($this->_req_data['country'])
640
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
641
-            : $CNT_ISO;
642
-        if (! $CNT_ISO) {
643
-            return '';
644
-        }
645
-
646
-        // for ajax
647
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
648
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
649
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
650
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
651
-        /** @var EE_Country $country */
652
-        $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
653
-
654
-        $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
655
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
656
-
657
-        $country_input_types = array(
658
-            'CNT_active'      => array(
659
-                'type'             => 'RADIO_BTN',
660
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
661
-                'class'            => '',
662
-                'options'          => $this->_yes_no_values,
663
-                'use_desc_4_label' => true,
664
-            ),
665
-            'CNT_ISO'         => array(
666
-                'type'       => 'TEXT',
667
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
668
-                'class'      => 'small-text',
669
-            ),
670
-            'CNT_ISO3'        => array(
671
-                'type'       => 'TEXT',
672
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
673
-                'class'      => 'small-text',
674
-            ),
675
-            'RGN_ID'          => array(
676
-                'type'       => 'TEXT',
677
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
678
-                'class'      => 'small-text',
679
-            ),
680
-            'CNT_name'        => array(
681
-                'type'       => 'TEXT',
682
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
683
-                'class'      => 'regular-text',
684
-            ),
685
-            'CNT_cur_code'    => array(
686
-                'type'       => 'TEXT',
687
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
688
-                'class'      => 'small-text',
689
-                'disabled'   => $CNT_cur_disabled
690
-            ),
691
-            'CNT_cur_single'  => array(
692
-                'type'       => 'TEXT',
693
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
694
-                'class'      => 'medium-text',
695
-                'disabled' => $CNT_cur_disabled
696
-            ),
697
-            'CNT_cur_plural'  => array(
698
-                'type'       => 'TEXT',
699
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
700
-                'class'      => 'medium-text',
701
-                'disabled' => $CNT_cur_disabled
702
-            ),
703
-            'CNT_cur_sign'    => array(
704
-                'type'         => 'TEXT',
705
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
706
-                'class'        => 'small-text',
707
-                'htmlentities' => false,
708
-                'disabled' => $CNT_cur_disabled
709
-            ),
710
-            'CNT_cur_sign_b4' => array(
711
-                'type'             => 'RADIO_BTN',
712
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
713
-                'class'            => '',
714
-                'options'          => $this->_yes_no_values,
715
-                'use_desc_4_label' => true,
716
-                'disabled' => $CNT_cur_disabled
717
-            ),
718
-            'CNT_cur_dec_plc' => array(
719
-                'type'       => 'RADIO_BTN',
720
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
721
-                'class'      => '',
722
-                'options'    => array(
723
-                    array('id' => 0, 'text' => ''),
724
-                    array('id' => 1, 'text' => ''),
725
-                    array('id' => 2, 'text' => ''),
726
-                    array('id' => 3, 'text' => ''),
727
-                ),
728
-                'disabled' => $CNT_cur_disabled
729
-            ),
730
-            'CNT_cur_dec_mrk' => array(
731
-                'type'             => 'RADIO_BTN',
732
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
733
-                'class'            => '',
734
-                'options'          => array(
735
-                    array(
736
-                        'id'   => ',',
737
-                        'text' => __(', (comma)', 'event_espresso'),
738
-                    ),
739
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
740
-                ),
741
-                'use_desc_4_label' => true,
742
-                'disabled' => $CNT_cur_disabled
743
-            ),
744
-            'CNT_cur_thsnds'  => array(
745
-                'type'             => 'RADIO_BTN',
746
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
747
-                'class'            => '',
748
-                'options'          => array(
749
-                    array(
750
-                        'id'   => ',',
751
-                        'text' => __(', (comma)', 'event_espresso'),
752
-                    ),
753
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
754
-                ),
755
-                'use_desc_4_label' => true,
756
-                'disabled' => $CNT_cur_disabled
757
-            ),
758
-            'CNT_tel_code'    => array(
759
-                'type'       => 'TEXT',
760
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
761
-                'class'      => 'small-text',
762
-            ),
763
-            'CNT_is_EU'       => array(
764
-                'type'             => 'RADIO_BTN',
765
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
766
-                'class'            => '',
767
-                'options'          => $this->_yes_no_values,
768
-                'use_desc_4_label' => true,
769
-            ),
770
-        );
771
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
772
-            $country,
773
-            $country_input_types
774
-        );
775
-        $country_details_settings = EEH_Template::display_template(
776
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
777
-            $this->_template_args,
778
-            true
779
-        );
780
-
781
-        if (defined('DOING_AJAX')) {
782
-            $notices = EE_Error::get_notices(false, false, false);
783
-            echo wp_json_encode(
784
-                array(
785
-                    'return_data' => $country_details_settings,
786
-                    'success'     => $notices['success'],
787
-                    'errors'      => $notices['errors'],
788
-                )
789
-            );
790
-            die();
791
-        } else {
792
-            return $country_details_settings;
793
-        }
794
-    }
795
-
796
-
797
-    /**
798
-     *        display_country_states
799
-     *
800
-     * @access    public
801
-     * @param    string $CNT_ISO
802
-     * @return string
803
-     * @throws DomainException
804
-     */
805
-    public function display_country_states($CNT_ISO = '')
806
-    {
807
-
808
-        $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
809
-
810
-        if (! $CNT_ISO) {
811
-            return '';
812
-        }
813
-        // for ajax
814
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
815
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
816
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
817
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
818
-        $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
819
-
820
-        if ($states) {
821
-            foreach ($states as $STA_ID => $state) {
822
-                if ($state instanceof EE_State) {
823
-                    // STA_abbrev    STA_name    STA_active
824
-                    $state_input_types = array(
825
-                        'STA_abbrev' => array(
826
-                            'type'       => 'TEXT',
827
-                            'input_name' => 'states[' . $STA_ID . ']',
828
-                            'class'      => 'mid-text',
829
-                        ),
830
-                        'STA_name'   => array(
831
-                            'type'       => 'TEXT',
832
-                            'input_name' => 'states[' . $STA_ID . ']',
833
-                            'class'      => 'regular-text',
834
-                        ),
835
-                        'STA_active' => array(
836
-                            'type'             => 'RADIO_BTN',
837
-                            'input_name'       => 'states[' . $STA_ID . ']',
838
-                            'options'          => $this->_yes_no_values,
839
-                            'use_desc_4_label' => true,
840
-                        ),
841
-                    );
842
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
843
-                        EE_Question_Form_Input::generate_question_form_inputs_for_object(
844
-                            $state,
845
-                            $state_input_types
846
-                        );
847
-                    $query_args = array(
848
-                        'action'     => 'delete_state',
849
-                        'STA_ID'     => $STA_ID,
850
-                        'CNT_ISO'    => $CNT_ISO,
851
-                        'STA_abbrev' => $state->abbrev(),
852
-                    );
853
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
854
-                        EE_Admin_Page::add_query_args_and_nonce(
855
-                            $query_args,
856
-                            GEN_SET_ADMIN_URL
857
-                        );
858
-                }
859
-            }
860
-        } else {
861
-            $this->_template_args['states'] = false;
862
-        }
863
-
864
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
865
-            array('action' => 'add_new_state'),
866
-            GEN_SET_ADMIN_URL
867
-        );
868
-
869
-        $state_details_settings = EEH_Template::display_template(
870
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
871
-            $this->_template_args,
872
-            true
873
-        );
874
-
875
-        if (defined('DOING_AJAX')) {
876
-            $notices = EE_Error::get_notices(false, false, false);
877
-            echo wp_json_encode(
878
-                array(
879
-                    'return_data' => $state_details_settings,
880
-                    'success'     => $notices['success'],
881
-                    'errors'      => $notices['errors'],
882
-                )
883
-            );
884
-            die();
885
-        } else {
886
-            return $state_details_settings;
887
-        }
888
-    }
889
-
890
-
891
-    /**
892
-     *        add_new_state
893
-     *
894
-     * @access    public
895
-     * @return void
896
-     * @throws EE_Error
897
-     */
898
-    public function add_new_state()
899
-    {
900
-
901
-        $success = true;
902
-
903
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
904
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
905
-            : false;
906
-        if (! $CNT_ISO) {
907
-            EE_Error::add_error(
908
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
909
-                __FILE__,
910
-                __FUNCTION__,
911
-                __LINE__
912
-            );
913
-            $success = false;
914
-        }
915
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
916
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
917
-            : false;
918
-        if (! $STA_abbrev) {
919
-            EE_Error::add_error(
920
-                __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
921
-                __FILE__,
922
-                __FUNCTION__,
923
-                __LINE__
924
-            );
925
-            $success = false;
926
-        }
927
-        $STA_name = isset($this->_req_data['STA_name'])
928
-            ? sanitize_text_field($this->_req_data['STA_name'])
929
-            : false;
930
-        if (! $STA_name) {
931
-            EE_Error::add_error(
932
-                __('No State name or an invalid State name was received.', 'event_espresso'),
933
-                __FILE__,
934
-                __FUNCTION__,
935
-                __LINE__
936
-            );
937
-            $success = false;
938
-        }
939
-
940
-        if ($success) {
941
-            $cols_n_values = array(
942
-                'CNT_ISO'    => $CNT_ISO,
943
-                'STA_abbrev' => $STA_abbrev,
944
-                'STA_name'   => $STA_name,
945
-                'STA_active' => true,
946
-            );
947
-            $success = EEM_State::instance()->insert($cols_n_values);
948
-            EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
949
-        }
950
-
951
-        if (defined('DOING_AJAX')) {
952
-            $notices = EE_Error::get_notices(false, false, false);
953
-            echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
954
-            die();
955
-        } else {
956
-            $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
957
-        }
958
-    }
959
-
960
-
961
-    /**
962
-     *        delete_state
963
-     *
964
-     * @access    public
965
-     * @return        boolean
966
-     * @throws EE_Error
967
-     * @throws EE_Error
968
-     */
969
-    public function delete_state()
970
-    {
971
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
972
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
973
-            : false;
974
-        $STA_ID = isset($this->_req_data['STA_ID'])
975
-            ? sanitize_text_field($this->_req_data['STA_ID'])
976
-            : false;
977
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
978
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
979
-            : false;
980
-        if (! $STA_ID) {
981
-            EE_Error::add_error(
982
-                __('No State ID or an invalid State ID was received.', 'event_espresso'),
983
-                __FILE__,
984
-                __FUNCTION__,
985
-                __LINE__
986
-            );
987
-            return false;
988
-        }
989
-
990
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
991
-        if ($success !== false) {
992
-            do_action(
993
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
994
-                $CNT_ISO,
995
-                $STA_ID,
996
-                array('STA_abbrev' => $STA_abbrev)
997
-            );
998
-            EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
999
-        }
1000
-        if (defined('DOING_AJAX')) {
1001
-            $notices = EE_Error::get_notices(false, false);
1002
-            $notices['return_data'] = true;
1003
-            echo wp_json_encode($notices);
1004
-            die();
1005
-        } else {
1006
-            $this->_redirect_after_action(
1007
-                $success,
1008
-                'State',
1009
-                'deleted',
1010
-                array('action' => 'country_settings')
1011
-            );
1012
-        }
1013
-    }
1014
-
1015
-
1016
-    /**
1017
-     *        _update_country_settings
1018
-     *
1019
-     * @access    protected
1020
-     * @return void
1021
-     * @throws EE_Error
1022
-     */
1023
-    protected function _update_country_settings()
1024
-    {
1025
-        // grab the country ISO code
1026
-        $CNT_ISO = isset($this->_req_data['country'])
1027
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
1028
-            : false;
1029
-        if (! $CNT_ISO) {
1030
-            EE_Error::add_error(
1031
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1032
-                __FILE__,
1033
-                __FUNCTION__,
1034
-                __LINE__
1035
-            );
1036
-
1037
-            return;
1038
-        }
1039
-        $cols_n_values = array();
1040
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1041
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1042
-            : false;
1043
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1044
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1045
-            : null;
1046
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1047
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1048
-            : null;
1049
-        $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1050
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']))
1051
-            : 'USD';
1052
-        $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1053
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1054
-            : 'dollar';
1055
-        $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1056
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1057
-            : 'dollars';
1058
-        $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1059
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1060
-            : '$';
1061
-        $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1062
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1063
-            : true;
1064
-        $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1065
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1066
-            : 2;
1067
-        $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1068
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1069
-            : '.';
1070
-        $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1071
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1072
-            : ',';
1073
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1074
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1075
-            : null;
1076
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1077
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1078
-            : false;
1079
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1080
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1081
-            : false;
1082
-        // allow filtering of country data
1083
-        $cols_n_values = apply_filters(
1084
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1085
-            $cols_n_values
1086
-        );
1087
-
1088
-        // where values
1089
-        $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1090
-        // run the update
1091
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1092
-
1093
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1094
-            // allow filtering of states data
1095
-            $states = apply_filters(
1096
-                'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1097
-                $this->_req_data['states']
1098
-            );
1099
-
1100
-            // loop thru state data ( looks like : states[75][STA_name] )
1101
-            foreach ($states as $STA_ID => $state) {
1102
-                $cols_n_values = array(
1103
-                    'CNT_ISO'    => $CNT_ISO,
1104
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1105
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1106
-                    'STA_active' => (bool) absint($state['STA_active']),
1107
-                );
1108
-                // where values
1109
-                $where_cols_n_values = array(array('STA_ID' => $STA_ID));
1110
-                // run the update
1111
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1112
-                if ($success !== false) {
1113
-                    do_action(
1114
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1115
-                        $CNT_ISO,
1116
-                        $STA_ID,
1117
-                        $cols_n_values
1118
-                    );
1119
-                }
1120
-            }
1121
-        }
1122
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1123
-        if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1124
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1125
-        ) {
1126
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1127
-            EE_Registry::instance()->CFG->update_espresso_config();
1128
-        }
1129
-
1130
-        if ($success !== false) {
1131
-            EE_Error::add_success(
1132
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1133
-            );
1134
-        }
1135
-        $this->_redirect_after_action(
1136
-            $success,
1137
-            '',
1138
-            '',
1139
-            array('action' => 'country_settings', 'country' => $CNT_ISO),
1140
-            true
1141
-        );
1142
-    }
1143
-
1144
-
1145
-    /**
1146
-     *        form_form_field_label_wrap
1147
-     *
1148
-     * @access        public
1149
-     * @param        string $label
1150
-     * @return        string
1151
-     */
1152
-    public function country_form_field_label_wrap($label, $required_text)
1153
-    {
1154
-        return '
24
+	/**
25
+	 * _question_group
26
+	 * holds the specific question group object for the question group details screen
27
+	 *
28
+	 * @var object
29
+	 */
30
+	protected $_question_group;
31
+
32
+
33
+	/**
34
+	 * Initialize basic properties.
35
+	 */
36
+	protected function _init_page_props()
37
+	{
38
+		$this->page_slug = GEN_SET_PG_SLUG;
39
+		$this->page_label = GEN_SET_LABEL;
40
+		$this->_admin_base_url = GEN_SET_ADMIN_URL;
41
+		$this->_admin_base_path = GEN_SET_ADMIN;
42
+	}
43
+
44
+
45
+	/**
46
+	 * Set ajax hooks
47
+	 */
48
+	protected function _ajax_hooks()
49
+	{
50
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
51
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
52
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
53
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
54
+	}
55
+
56
+
57
+	/**
58
+	 * More page properties initialization.
59
+	 */
60
+	protected function _define_page_props()
61
+	{
62
+		$this->_admin_page_title = GEN_SET_LABEL;
63
+		$this->_labels = array(
64
+			'publishbox' => __('Update Settings', 'event_espresso'),
65
+		);
66
+	}
67
+
68
+
69
+	/**
70
+	 * Set page routes property.
71
+	 */
72
+	protected function _set_page_routes()
73
+	{
74
+		$this->_page_routes = array(
75
+
76
+			'critical_pages'                => array(
77
+				'func'       => '_espresso_page_settings',
78
+				'capability' => 'manage_options',
79
+			),
80
+			'update_espresso_page_settings' => array(
81
+				'func'       => '_update_espresso_page_settings',
82
+				'capability' => 'manage_options',
83
+				'noheader'   => true,
84
+			),
85
+			'default'                       => array(
86
+				'func'       => '_your_organization_settings',
87
+				'capability' => 'manage_options',
88
+			),
89
+
90
+			'update_your_organization_settings' => array(
91
+				'func'       => '_update_your_organization_settings',
92
+				'capability' => 'manage_options',
93
+				'noheader'   => true,
94
+			),
95
+
96
+			'admin_option_settings' => array(
97
+				'func'       => '_admin_option_settings',
98
+				'capability' => 'manage_options',
99
+			),
100
+
101
+			'update_admin_option_settings' => array(
102
+				'func'       => '_update_admin_option_settings',
103
+				'capability' => 'manage_options',
104
+				'noheader'   => true,
105
+			),
106
+
107
+			'country_settings' => array(
108
+				'func'       => '_country_settings',
109
+				'capability' => 'manage_options',
110
+			),
111
+
112
+			'update_country_settings' => array(
113
+				'func'       => '_update_country_settings',
114
+				'capability' => 'manage_options',
115
+				'noheader'   => true,
116
+			),
117
+
118
+			'display_country_settings' => array(
119
+				'func'       => 'display_country_settings',
120
+				'capability' => 'manage_options',
121
+				'noheader'   => true,
122
+			),
123
+
124
+			'add_new_state' => array(
125
+				'func'       => 'add_new_state',
126
+				'capability' => 'manage_options',
127
+				'noheader'   => true,
128
+			),
129
+
130
+			'delete_state' => array(
131
+				'func'       => 'delete_state',
132
+				'capability' => 'manage_options',
133
+				'noheader'   => true,
134
+			),
135
+			'privacy_settings' => array(
136
+				'func' => 'privacySettings',
137
+				'capability' => 'manage_options',
138
+			),
139
+			'update_privacy_settings' => array(
140
+				'func' => 'updatePrivacySettings',
141
+				'capability' => 'manage_options',
142
+				'noheader' => true,
143
+				'headers_sent_route' => 'privacy_settings'
144
+			)
145
+		);
146
+	}
147
+
148
+
149
+	/**
150
+	 * Set page configuration property
151
+	 */
152
+	protected function _set_page_config()
153
+	{
154
+		$this->_page_config = array(
155
+			'critical_pages'        => array(
156
+				'nav'           => array(
157
+					'label' => __('Critical Pages', 'event_espresso'),
158
+					'order' => 50,
159
+				),
160
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
161
+				'help_tabs'     => array(
162
+					'general_settings_critical_pages_help_tab' => array(
163
+						'title'    => __('Critical Pages', 'event_espresso'),
164
+						'filename' => 'general_settings_critical_pages',
165
+					),
166
+				),
167
+				'help_tour'     => array('Critical_Pages_Help_Tour'),
168
+				'require_nonce' => false,
169
+			),
170
+			'default'               => array(
171
+				'nav'           => array(
172
+					'label' => __('Your Organization', 'event_espresso'),
173
+					'order' => 20,
174
+				),
175
+				'help_tabs'     => array(
176
+					'general_settings_your_organization_help_tab' => array(
177
+						'title'    => __('Your Organization', 'event_espresso'),
178
+						'filename' => 'general_settings_your_organization',
179
+					),
180
+				),
181
+				'help_tour'     => array('Your_Organization_Help_Tour'),
182
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
183
+				'require_nonce' => false,
184
+			),
185
+			'admin_option_settings' => array(
186
+				'nav'           => array(
187
+					'label' => __('Admin Options', 'event_espresso'),
188
+					'order' => 60,
189
+				),
190
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
191
+				'help_tabs'     => array(
192
+					'general_settings_admin_options_help_tab' => array(
193
+						'title'    => __('Admin Options', 'event_espresso'),
194
+						'filename' => 'general_settings_admin_options',
195
+					),
196
+				),
197
+				'help_tour'     => array('Admin_Options_Help_Tour'),
198
+				'require_nonce' => false,
199
+			),
200
+			'country_settings'      => array(
201
+				'nav'           => array(
202
+					'label' => __('Countries', 'event_espresso'),
203
+					'order' => 70,
204
+				),
205
+				'help_tabs'     => array(
206
+					'general_settings_countries_help_tab' => array(
207
+						'title'    => __('Countries', 'event_espresso'),
208
+						'filename' => 'general_settings_countries',
209
+					),
210
+				),
211
+				'help_tour'     => array('Countries_Help_Tour'),
212
+				'require_nonce' => false,
213
+			),
214
+			'privacy_settings' => array(
215
+				'nav' => array(
216
+					'label' => esc_html__('Privacy', 'event_espresso'),
217
+					'order' => 80
218
+				),
219
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
220
+				'require_nonce' => false
221
+			)
222
+		);
223
+	}
224
+
225
+
226
+	protected function _add_screen_options()
227
+	{
228
+	}
229
+
230
+	protected function _add_feature_pointers()
231
+	{
232
+	}
233
+
234
+
235
+	/**
236
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
237
+	 */
238
+	public function load_scripts_styles()
239
+	{
240
+		// styles
241
+		wp_enqueue_style('espresso-ui-theme');
242
+		// scripts
243
+		wp_enqueue_script('ee_admin_js');
244
+	}
245
+
246
+
247
+	/**
248
+	 * Execute logic running on `admin_init`
249
+	 */
250
+	public function admin_init()
251
+	{
252
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
253
+			'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
254
+			'event_espresso'
255
+		);
256
+		EE_Registry::$i18n_js_strings['error_occurred'] = __(
257
+			'An error occurred! Please refresh the page and try again.',
258
+			'event_espresso'
259
+		);
260
+		EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
261
+			'Are you sure you want to delete this State / Province?',
262
+			'event_espresso'
263
+		);
264
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
265
+		EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
266
+			'admin-ajax.php?page=espresso_general_settings',
267
+			$protocol
268
+		);
269
+	}
270
+
271
+	public function admin_notices()
272
+	{
273
+	}
274
+
275
+	public function admin_footer_scripts()
276
+	{
277
+	}
278
+
279
+
280
+	/**
281
+	 * Enqueue scripts and styles for the default route.
282
+	 */
283
+	public function load_scripts_styles_default()
284
+	{
285
+		// styles
286
+		wp_enqueue_style('thickbox');
287
+		// scripts
288
+		wp_enqueue_script('media-upload');
289
+		wp_enqueue_script('thickbox');
290
+		wp_register_script(
291
+			'organization_settings',
292
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
293
+			array('jquery', 'media-upload', 'thickbox'),
294
+			EVENT_ESPRESSO_VERSION,
295
+			true
296
+		);
297
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
298
+		wp_enqueue_script('organization_settings');
299
+		wp_enqueue_style('organization-css');
300
+		$confirm_image_delete = array(
301
+			'text' => __(
302
+				'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
+				'event_espresso'
304
+			),
305
+		);
306
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
+	}
308
+
309
+
310
+	/**
311
+	 * Enqueue scripts and styles for the country settings route.
312
+	 */
313
+	public function load_scripts_styles_country_settings()
314
+	{
315
+		// scripts
316
+		wp_register_script(
317
+			'gen_settings_countries',
318
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
+			array('ee_admin_js'),
320
+			EVENT_ESPRESSO_VERSION,
321
+			true
322
+		);
323
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
324
+		wp_enqueue_script('gen_settings_countries');
325
+		wp_enqueue_style('organization-css');
326
+	}
327
+
328
+
329
+	/*************        Espresso Pages        *************/
330
+	/**
331
+	 * _espresso_page_settings
332
+	 *
333
+	 * @throws \EE_Error
334
+	 * @throws DomainException
335
+	 * @throws DomainException
336
+	 * @throws InvalidDataTypeException
337
+	 * @throws InvalidArgumentException
338
+	 */
339
+	protected function _espresso_page_settings()
340
+	{
341
+		// Check to make sure all of the main pages are setup properly,
342
+		// if not create the default pages and display an admin notice
343
+		EEH_Activation::verify_default_pages_exist();
344
+		$this->_transient_garbage_collection();
345
+		$this->_template_args['values'] = $this->_yes_no_values;
346
+		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
347
+			? EE_Registry::instance()->CFG->core->reg_page_id
348
+			: null;
349
+		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
350
+			? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
351
+			: false;
352
+		$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
353
+			? EE_Registry::instance()->CFG->core->txn_page_id
354
+			: null;
355
+		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
356
+			? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
357
+			: false;
358
+		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
359
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
360
+			: null;
361
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
362
+			? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
363
+			: false;
364
+		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
365
+			? EE_Registry::instance()->CFG->core->cancel_page_id
366
+			: null;
367
+		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
368
+			? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
369
+			: false;
370
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
371
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
372
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
373
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
374
+			$this->_template_args,
375
+			true
376
+		);
377
+		$this->display_admin_page_with_sidebar();
378
+	}
379
+
380
+
381
+	/**
382
+	 * Handler for updating espresso page settings.
383
+	 *
384
+	 * @throws EE_Error
385
+	 */
386
+	protected function _update_espresso_page_settings()
387
+	{
388
+		// capture incoming request data && set page IDs
389
+		EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
390
+			? absint($this->_req_data['reg_page_id'])
391
+			: EE_Registry::instance()->CFG->core->reg_page_id;
392
+		EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
393
+			? absint($this->_req_data['txn_page_id'])
394
+			: EE_Registry::instance()->CFG->core->txn_page_id;
395
+		EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
396
+			? absint($this->_req_data['thank_you_page_id'])
397
+			: EE_Registry::instance()->CFG->core->thank_you_page_id;
398
+		EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
399
+			? absint($this->_req_data['cancel_page_id'])
400
+			: EE_Registry::instance()->CFG->core->cancel_page_id;
401
+
402
+		EE_Registry::instance()->CFG->core = apply_filters(
403
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
404
+			EE_Registry::instance()->CFG->core,
405
+			$this->_req_data
406
+		);
407
+		$what = __('Critical Pages & Shortcodes', 'event_espresso');
408
+		$this->_redirect_after_action(
409
+			$this->_update_espresso_configuration(
410
+				$what,
411
+				EE_Registry::instance()->CFG->core,
412
+				__FILE__,
413
+				__FUNCTION__,
414
+				__LINE__
415
+			),
416
+			$what,
417
+			'',
418
+			array(
419
+				'action' => 'critical_pages',
420
+			),
421
+			true
422
+		);
423
+	}
424
+
425
+
426
+	/*************        Your Organization        *************/
427
+
428
+
429
+	/**
430
+	 * @throws DomainException
431
+	 * @throws EE_Error
432
+	 * @throws InvalidArgumentException
433
+	 * @throws InvalidDataTypeException
434
+	 * @throws InvalidInterfaceException
435
+	 */
436
+	protected function _your_organization_settings()
437
+	{
438
+		$this->_template_args['admin_page_content'] = '';
439
+		try {
440
+			$organization_settings_form = new OrganizationSettings(
441
+				EE_Registry::instance(),
442
+				EE_Registry::instance()->CFG->organization,
443
+				EE_Registry::instance()->CFG->core,
444
+				EE_Registry::instance()->NET_CFG->core
445
+			);
446
+			$this->_template_args['admin_page_content'] = $organization_settings_form->display();
447
+		} catch (Exception $e) {
448
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
449
+		}
450
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
451
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
452
+		$this->display_admin_page_with_sidebar();
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 * Handler for updating organization settings.
459
+	 *
460
+	 * @throws EE_Error
461
+	 */
462
+	protected function _update_your_organization_settings()
463
+	{
464
+		try {
465
+			$organization_settings_form = new OrganizationSettings(
466
+				EE_Registry::instance(),
467
+				EE_Registry::instance()->CFG->organization,
468
+				EE_Registry::instance()->CFG->core,
469
+				EE_Registry::instance()->NET_CFG->core
470
+			);
471
+			$success = $organization_settings_form->process($this->_req_data);
472
+			EE_Registry::instance()->CFG = apply_filters(
473
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
474
+				EE_Registry::instance()->CFG
475
+			);
476
+		} catch (Exception $e) {
477
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
478
+			$success = false;
479
+		}
480
+
481
+		if ($success) {
482
+			$success = $this->_update_espresso_configuration(
483
+				esc_html__('Your Organization Settings', 'event_espresso'),
484
+				EE_Registry::instance()->CFG,
485
+				__FILE__,
486
+				__FUNCTION__,
487
+				__LINE__
488
+			);
489
+		}
490
+
491
+		$this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
492
+	}
493
+
494
+
495
+
496
+	/*************        Admin Options        *************/
497
+
498
+
499
+	/**
500
+	 * _admin_option_settings
501
+	 *
502
+	 * @throws \EE_Error
503
+	 * @throws \LogicException
504
+	 */
505
+	protected function _admin_option_settings()
506
+	{
507
+		$this->_template_args['admin_page_content'] = '';
508
+		try {
509
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
510
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
511
+			$this->_template_args['values'] = $this->_yes_no_values;
512
+			// also need to account for the do_action that was in the old template
513
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
514
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
515
+		} catch (Exception $e) {
516
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
517
+		}
518
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
519
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
520
+		$this->display_admin_page_with_sidebar();
521
+	}
522
+
523
+
524
+	/**
525
+	 * _update_admin_option_settings
526
+	 *
527
+	 * @throws \EE_Error
528
+	 * @throws InvalidDataTypeException
529
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
530
+	 * @throws \InvalidArgumentException
531
+	 * @throws \LogicException
532
+	 */
533
+	protected function _update_admin_option_settings()
534
+	{
535
+		try {
536
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
537
+			$admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
538
+			EE_Registry::instance()->CFG->admin = apply_filters(
539
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
540
+				EE_Registry::instance()->CFG->admin
541
+			);
542
+		} catch (Exception $e) {
543
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
544
+		}
545
+		$this->_redirect_after_action(
546
+			apply_filters(
547
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
548
+				$this->_update_espresso_configuration(
549
+					'Admin Options',
550
+					EE_Registry::instance()->CFG->admin,
551
+					__FILE__,
552
+					__FUNCTION__,
553
+					__LINE__
554
+				)
555
+			),
556
+			'Admin Options',
557
+			'updated',
558
+			array('action' => 'admin_option_settings')
559
+		);
560
+	}
561
+
562
+
563
+	/*************        Countries        *************/
564
+
565
+
566
+	/**
567
+	 * Output Country Settings view.
568
+	 *
569
+	 * @throws DomainException
570
+	 * @throws EE_Error
571
+	 */
572
+	protected function _country_settings()
573
+	{
574
+		$CNT_ISO_for_site = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
575
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
576
+			: 'US';
577
+		$CNT_ISO = isset($this->_req_data['country'])
578
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
579
+			: $CNT_ISO_for_site;
580
+
581
+		// load field generator helper
582
+
583
+		$this->_template_args['values'] = $this->_yes_no_values;
584
+
585
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
586
+			EE_Question::new_instance(
587
+				array(
588
+					'QST_ID'           => 0,
589
+					'QST_display_text' => __('Select Country', 'event_espresso'),
590
+					'QST_system'       => 'admin-country',
591
+				)
592
+			),
593
+			EE_Answer::new_instance(
594
+				array(
595
+					'ANS_ID'    => 0,
596
+					'ANS_value' => $CNT_ISO,
597
+				)
598
+			),
599
+			array(
600
+				'input_id'       => 'country',
601
+				'input_name'     => 'country',
602
+				'input_prefix'   => '',
603
+				'append_qstn_id' => false,
604
+			)
605
+		);
606
+
607
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
608
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
609
+		$this->_template_args['country_details_settings'] = $this->display_country_settings();
610
+		$this->_template_args['country_states_settings'] = $this->display_country_states();
611
+		$this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site)
612
+																			->name();
613
+
614
+		$this->_set_add_edit_form_tags('update_country_settings');
615
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
616
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
617
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
618
+			$this->_template_args,
619
+			true
620
+		);
621
+		$this->display_admin_page_with_no_sidebar();
622
+	}
623
+
624
+
625
+	/**
626
+	 *        display_country_settings
627
+	 *
628
+	 * @access    public
629
+	 * @param    string $CNT_ISO
630
+	 * @return mixed string | array
631
+	 * @throws DomainException
632
+	 */
633
+	public function display_country_settings($CNT_ISO = '')
634
+	{
635
+		$CNT_ISO_for_site = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
636
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
637
+			: 'US';
638
+
639
+		$CNT_ISO = isset($this->_req_data['country'])
640
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
641
+			: $CNT_ISO;
642
+		if (! $CNT_ISO) {
643
+			return '';
644
+		}
645
+
646
+		// for ajax
647
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
648
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
649
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
650
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
651
+		/** @var EE_Country $country */
652
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
653
+
654
+		$CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
655
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
656
+
657
+		$country_input_types = array(
658
+			'CNT_active'      => array(
659
+				'type'             => 'RADIO_BTN',
660
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
661
+				'class'            => '',
662
+				'options'          => $this->_yes_no_values,
663
+				'use_desc_4_label' => true,
664
+			),
665
+			'CNT_ISO'         => array(
666
+				'type'       => 'TEXT',
667
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
668
+				'class'      => 'small-text',
669
+			),
670
+			'CNT_ISO3'        => array(
671
+				'type'       => 'TEXT',
672
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
673
+				'class'      => 'small-text',
674
+			),
675
+			'RGN_ID'          => array(
676
+				'type'       => 'TEXT',
677
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
678
+				'class'      => 'small-text',
679
+			),
680
+			'CNT_name'        => array(
681
+				'type'       => 'TEXT',
682
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
683
+				'class'      => 'regular-text',
684
+			),
685
+			'CNT_cur_code'    => array(
686
+				'type'       => 'TEXT',
687
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
688
+				'class'      => 'small-text',
689
+				'disabled'   => $CNT_cur_disabled
690
+			),
691
+			'CNT_cur_single'  => array(
692
+				'type'       => 'TEXT',
693
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
694
+				'class'      => 'medium-text',
695
+				'disabled' => $CNT_cur_disabled
696
+			),
697
+			'CNT_cur_plural'  => array(
698
+				'type'       => 'TEXT',
699
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
700
+				'class'      => 'medium-text',
701
+				'disabled' => $CNT_cur_disabled
702
+			),
703
+			'CNT_cur_sign'    => array(
704
+				'type'         => 'TEXT',
705
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
706
+				'class'        => 'small-text',
707
+				'htmlentities' => false,
708
+				'disabled' => $CNT_cur_disabled
709
+			),
710
+			'CNT_cur_sign_b4' => array(
711
+				'type'             => 'RADIO_BTN',
712
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
713
+				'class'            => '',
714
+				'options'          => $this->_yes_no_values,
715
+				'use_desc_4_label' => true,
716
+				'disabled' => $CNT_cur_disabled
717
+			),
718
+			'CNT_cur_dec_plc' => array(
719
+				'type'       => 'RADIO_BTN',
720
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
721
+				'class'      => '',
722
+				'options'    => array(
723
+					array('id' => 0, 'text' => ''),
724
+					array('id' => 1, 'text' => ''),
725
+					array('id' => 2, 'text' => ''),
726
+					array('id' => 3, 'text' => ''),
727
+				),
728
+				'disabled' => $CNT_cur_disabled
729
+			),
730
+			'CNT_cur_dec_mrk' => array(
731
+				'type'             => 'RADIO_BTN',
732
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
733
+				'class'            => '',
734
+				'options'          => array(
735
+					array(
736
+						'id'   => ',',
737
+						'text' => __(', (comma)', 'event_espresso'),
738
+					),
739
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
740
+				),
741
+				'use_desc_4_label' => true,
742
+				'disabled' => $CNT_cur_disabled
743
+			),
744
+			'CNT_cur_thsnds'  => array(
745
+				'type'             => 'RADIO_BTN',
746
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
747
+				'class'            => '',
748
+				'options'          => array(
749
+					array(
750
+						'id'   => ',',
751
+						'text' => __(', (comma)', 'event_espresso'),
752
+					),
753
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
754
+				),
755
+				'use_desc_4_label' => true,
756
+				'disabled' => $CNT_cur_disabled
757
+			),
758
+			'CNT_tel_code'    => array(
759
+				'type'       => 'TEXT',
760
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
761
+				'class'      => 'small-text',
762
+			),
763
+			'CNT_is_EU'       => array(
764
+				'type'             => 'RADIO_BTN',
765
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
766
+				'class'            => '',
767
+				'options'          => $this->_yes_no_values,
768
+				'use_desc_4_label' => true,
769
+			),
770
+		);
771
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
772
+			$country,
773
+			$country_input_types
774
+		);
775
+		$country_details_settings = EEH_Template::display_template(
776
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
777
+			$this->_template_args,
778
+			true
779
+		);
780
+
781
+		if (defined('DOING_AJAX')) {
782
+			$notices = EE_Error::get_notices(false, false, false);
783
+			echo wp_json_encode(
784
+				array(
785
+					'return_data' => $country_details_settings,
786
+					'success'     => $notices['success'],
787
+					'errors'      => $notices['errors'],
788
+				)
789
+			);
790
+			die();
791
+		} else {
792
+			return $country_details_settings;
793
+		}
794
+	}
795
+
796
+
797
+	/**
798
+	 *        display_country_states
799
+	 *
800
+	 * @access    public
801
+	 * @param    string $CNT_ISO
802
+	 * @return string
803
+	 * @throws DomainException
804
+	 */
805
+	public function display_country_states($CNT_ISO = '')
806
+	{
807
+
808
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
809
+
810
+		if (! $CNT_ISO) {
811
+			return '';
812
+		}
813
+		// for ajax
814
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
815
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
816
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
817
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
818
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
819
+
820
+		if ($states) {
821
+			foreach ($states as $STA_ID => $state) {
822
+				if ($state instanceof EE_State) {
823
+					// STA_abbrev    STA_name    STA_active
824
+					$state_input_types = array(
825
+						'STA_abbrev' => array(
826
+							'type'       => 'TEXT',
827
+							'input_name' => 'states[' . $STA_ID . ']',
828
+							'class'      => 'mid-text',
829
+						),
830
+						'STA_name'   => array(
831
+							'type'       => 'TEXT',
832
+							'input_name' => 'states[' . $STA_ID . ']',
833
+							'class'      => 'regular-text',
834
+						),
835
+						'STA_active' => array(
836
+							'type'             => 'RADIO_BTN',
837
+							'input_name'       => 'states[' . $STA_ID . ']',
838
+							'options'          => $this->_yes_no_values,
839
+							'use_desc_4_label' => true,
840
+						),
841
+					);
842
+					$this->_template_args['states'][ $STA_ID ]['inputs'] =
843
+						EE_Question_Form_Input::generate_question_form_inputs_for_object(
844
+							$state,
845
+							$state_input_types
846
+						);
847
+					$query_args = array(
848
+						'action'     => 'delete_state',
849
+						'STA_ID'     => $STA_ID,
850
+						'CNT_ISO'    => $CNT_ISO,
851
+						'STA_abbrev' => $state->abbrev(),
852
+					);
853
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
854
+						EE_Admin_Page::add_query_args_and_nonce(
855
+							$query_args,
856
+							GEN_SET_ADMIN_URL
857
+						);
858
+				}
859
+			}
860
+		} else {
861
+			$this->_template_args['states'] = false;
862
+		}
863
+
864
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
865
+			array('action' => 'add_new_state'),
866
+			GEN_SET_ADMIN_URL
867
+		);
868
+
869
+		$state_details_settings = EEH_Template::display_template(
870
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
871
+			$this->_template_args,
872
+			true
873
+		);
874
+
875
+		if (defined('DOING_AJAX')) {
876
+			$notices = EE_Error::get_notices(false, false, false);
877
+			echo wp_json_encode(
878
+				array(
879
+					'return_data' => $state_details_settings,
880
+					'success'     => $notices['success'],
881
+					'errors'      => $notices['errors'],
882
+				)
883
+			);
884
+			die();
885
+		} else {
886
+			return $state_details_settings;
887
+		}
888
+	}
889
+
890
+
891
+	/**
892
+	 *        add_new_state
893
+	 *
894
+	 * @access    public
895
+	 * @return void
896
+	 * @throws EE_Error
897
+	 */
898
+	public function add_new_state()
899
+	{
900
+
901
+		$success = true;
902
+
903
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
904
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
905
+			: false;
906
+		if (! $CNT_ISO) {
907
+			EE_Error::add_error(
908
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
909
+				__FILE__,
910
+				__FUNCTION__,
911
+				__LINE__
912
+			);
913
+			$success = false;
914
+		}
915
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
916
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
917
+			: false;
918
+		if (! $STA_abbrev) {
919
+			EE_Error::add_error(
920
+				__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
921
+				__FILE__,
922
+				__FUNCTION__,
923
+				__LINE__
924
+			);
925
+			$success = false;
926
+		}
927
+		$STA_name = isset($this->_req_data['STA_name'])
928
+			? sanitize_text_field($this->_req_data['STA_name'])
929
+			: false;
930
+		if (! $STA_name) {
931
+			EE_Error::add_error(
932
+				__('No State name or an invalid State name was received.', 'event_espresso'),
933
+				__FILE__,
934
+				__FUNCTION__,
935
+				__LINE__
936
+			);
937
+			$success = false;
938
+		}
939
+
940
+		if ($success) {
941
+			$cols_n_values = array(
942
+				'CNT_ISO'    => $CNT_ISO,
943
+				'STA_abbrev' => $STA_abbrev,
944
+				'STA_name'   => $STA_name,
945
+				'STA_active' => true,
946
+			);
947
+			$success = EEM_State::instance()->insert($cols_n_values);
948
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
949
+		}
950
+
951
+		if (defined('DOING_AJAX')) {
952
+			$notices = EE_Error::get_notices(false, false, false);
953
+			echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
954
+			die();
955
+		} else {
956
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
957
+		}
958
+	}
959
+
960
+
961
+	/**
962
+	 *        delete_state
963
+	 *
964
+	 * @access    public
965
+	 * @return        boolean
966
+	 * @throws EE_Error
967
+	 * @throws EE_Error
968
+	 */
969
+	public function delete_state()
970
+	{
971
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
972
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
973
+			: false;
974
+		$STA_ID = isset($this->_req_data['STA_ID'])
975
+			? sanitize_text_field($this->_req_data['STA_ID'])
976
+			: false;
977
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
978
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
979
+			: false;
980
+		if (! $STA_ID) {
981
+			EE_Error::add_error(
982
+				__('No State ID or an invalid State ID was received.', 'event_espresso'),
983
+				__FILE__,
984
+				__FUNCTION__,
985
+				__LINE__
986
+			);
987
+			return false;
988
+		}
989
+
990
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
991
+		if ($success !== false) {
992
+			do_action(
993
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
994
+				$CNT_ISO,
995
+				$STA_ID,
996
+				array('STA_abbrev' => $STA_abbrev)
997
+			);
998
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
999
+		}
1000
+		if (defined('DOING_AJAX')) {
1001
+			$notices = EE_Error::get_notices(false, false);
1002
+			$notices['return_data'] = true;
1003
+			echo wp_json_encode($notices);
1004
+			die();
1005
+		} else {
1006
+			$this->_redirect_after_action(
1007
+				$success,
1008
+				'State',
1009
+				'deleted',
1010
+				array('action' => 'country_settings')
1011
+			);
1012
+		}
1013
+	}
1014
+
1015
+
1016
+	/**
1017
+	 *        _update_country_settings
1018
+	 *
1019
+	 * @access    protected
1020
+	 * @return void
1021
+	 * @throws EE_Error
1022
+	 */
1023
+	protected function _update_country_settings()
1024
+	{
1025
+		// grab the country ISO code
1026
+		$CNT_ISO = isset($this->_req_data['country'])
1027
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
1028
+			: false;
1029
+		if (! $CNT_ISO) {
1030
+			EE_Error::add_error(
1031
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1032
+				__FILE__,
1033
+				__FUNCTION__,
1034
+				__LINE__
1035
+			);
1036
+
1037
+			return;
1038
+		}
1039
+		$cols_n_values = array();
1040
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1041
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1042
+			: false;
1043
+		$cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1044
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1045
+			: null;
1046
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1047
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1048
+			: null;
1049
+		$cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1050
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']))
1051
+			: 'USD';
1052
+		$cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1053
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1054
+			: 'dollar';
1055
+		$cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1056
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1057
+			: 'dollars';
1058
+		$cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1059
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1060
+			: '$';
1061
+		$cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1062
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1063
+			: true;
1064
+		$cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1065
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1066
+			: 2;
1067
+		$cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1068
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1069
+			: '.';
1070
+		$cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1071
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1072
+			: ',';
1073
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1074
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1075
+			: null;
1076
+		$cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1077
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1078
+			: false;
1079
+		$cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1080
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1081
+			: false;
1082
+		// allow filtering of country data
1083
+		$cols_n_values = apply_filters(
1084
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1085
+			$cols_n_values
1086
+		);
1087
+
1088
+		// where values
1089
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1090
+		// run the update
1091
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1092
+
1093
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1094
+			// allow filtering of states data
1095
+			$states = apply_filters(
1096
+				'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1097
+				$this->_req_data['states']
1098
+			);
1099
+
1100
+			// loop thru state data ( looks like : states[75][STA_name] )
1101
+			foreach ($states as $STA_ID => $state) {
1102
+				$cols_n_values = array(
1103
+					'CNT_ISO'    => $CNT_ISO,
1104
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1105
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1106
+					'STA_active' => (bool) absint($state['STA_active']),
1107
+				);
1108
+				// where values
1109
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
1110
+				// run the update
1111
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1112
+				if ($success !== false) {
1113
+					do_action(
1114
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1115
+						$CNT_ISO,
1116
+						$STA_ID,
1117
+						$cols_n_values
1118
+					);
1119
+				}
1120
+			}
1121
+		}
1122
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1123
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1124
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1125
+		) {
1126
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1127
+			EE_Registry::instance()->CFG->update_espresso_config();
1128
+		}
1129
+
1130
+		if ($success !== false) {
1131
+			EE_Error::add_success(
1132
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1133
+			);
1134
+		}
1135
+		$this->_redirect_after_action(
1136
+			$success,
1137
+			'',
1138
+			'',
1139
+			array('action' => 'country_settings', 'country' => $CNT_ISO),
1140
+			true
1141
+		);
1142
+	}
1143
+
1144
+
1145
+	/**
1146
+	 *        form_form_field_label_wrap
1147
+	 *
1148
+	 * @access        public
1149
+	 * @param        string $label
1150
+	 * @return        string
1151
+	 */
1152
+	public function country_form_field_label_wrap($label, $required_text)
1153
+	{
1154
+		return '
1155 1155
 			<tr>
1156 1156
 				<th>
1157 1157
 					' . $label . '
1158 1158
 				</th>';
1159
-    }
1160
-
1161
-
1162
-    /**
1163
-     *        form_form_field_input__wrap
1164
-     *
1165
-     * @access        public
1166
-     * @param        string $label
1167
-     * @return        string
1168
-     */
1169
-    public function country_form_field_input__wrap($input, $label)
1170
-    {
1171
-        return '
1159
+	}
1160
+
1161
+
1162
+	/**
1163
+	 *        form_form_field_input__wrap
1164
+	 *
1165
+	 * @access        public
1166
+	 * @param        string $label
1167
+	 * @return        string
1168
+	 */
1169
+	public function country_form_field_input__wrap($input, $label)
1170
+	{
1171
+		return '
1172 1172
 				<td class="general-settings-country-input-td">
1173 1173
 					' . $input . '
1174 1174
 				</td>
1175 1175
 			</tr>';
1176
-    }
1177
-
1178
-
1179
-    /**
1180
-     *        form_form_field_label_wrap
1181
-     *
1182
-     * @access        public
1183
-     * @param        string $label
1184
-     * @param        string $required_text
1185
-     * @return        string
1186
-     */
1187
-    public function state_form_field_label_wrap($label, $required_text)
1188
-    {
1189
-        return $required_text;
1190
-    }
1191
-
1192
-
1193
-    /**
1194
-     *        form_form_field_input__wrap
1195
-     *
1196
-     * @access        public
1197
-     * @param        string $label
1198
-     * @return        string
1199
-     */
1200
-    public function state_form_field_input__wrap($input, $label)
1201
-    {
1202
-        return '
1176
+	}
1177
+
1178
+
1179
+	/**
1180
+	 *        form_form_field_label_wrap
1181
+	 *
1182
+	 * @access        public
1183
+	 * @param        string $label
1184
+	 * @param        string $required_text
1185
+	 * @return        string
1186
+	 */
1187
+	public function state_form_field_label_wrap($label, $required_text)
1188
+	{
1189
+		return $required_text;
1190
+	}
1191
+
1192
+
1193
+	/**
1194
+	 *        form_form_field_input__wrap
1195
+	 *
1196
+	 * @access        public
1197
+	 * @param        string $label
1198
+	 * @return        string
1199
+	 */
1200
+	public function state_form_field_input__wrap($input, $label)
1201
+	{
1202
+		return '
1203 1203
 				<td class="general-settings-country-state-input-td">
1204 1204
 					' . $input . '
1205 1205
 				</td>';
1206
-    }
1207
-
1208
-
1209
-    /***********/
1210
-
1211
-
1212
-    /**
1213
-     * displays edit and view links for critical EE pages
1214
-     *
1215
-     * @access public
1216
-     * @param int $ee_page_id
1217
-     * @return string
1218
-     */
1219
-    public static function edit_view_links($ee_page_id)
1220
-    {
1221
-        $links = '<a href="'
1222
-                 . add_query_arg(
1223
-                     array('post' => $ee_page_id, 'action' => 'edit'),
1224
-                     admin_url('post.php')
1225
-                 )
1226
-                 . '" >'
1227
-                 . __('Edit', 'event_espresso')
1228
-                 . '</a>';
1229
-        $links .= ' &nbsp;|&nbsp; ';
1230
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1231
-
1232
-        return $links;
1233
-    }
1234
-
1235
-
1236
-    /**
1237
-     * displays page and shortcode status for critical EE pages
1238
-     *
1239
-     * @param WP page object $ee_page
1240
-     * @return string
1241
-     */
1242
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1243
-    {
1244
-
1245
-        // page status
1246
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1247
-            $pg_colour = 'green';
1248
-            $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1249
-        } else {
1250
-            $pg_colour = 'red';
1251
-            $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1252
-        }
1253
-
1254
-        // shortcode status
1255
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1256
-            $sc_colour = 'green';
1257
-            $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1258
-        } else {
1259
-            $sc_colour = 'red';
1260
-            $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1261
-        }
1262
-
1263
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1264
-               . $pg_status
1265
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1266
-    }
1267
-
1268
-
1269
-    /**
1270
-     * generates a dropdown of all parent pages - copied from WP core
1271
-     *
1272
-     * @param int $default
1273
-     * @param int $parent
1274
-     * @param int $level
1275
-     */
1276
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1277
-    {
1278
-        global $wpdb;
1279
-        $items = $wpdb->get_results(
1280
-            $wpdb->prepare(
1281
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1282
-                $parent
1283
-            )
1284
-        );
1285
-
1286
-        if ($items) {
1287
-            foreach ($items as $item) {
1288
-                $pad = str_repeat('&nbsp;', $level * 3);
1289
-                if ($item->ID == $default) {
1290
-                    $current = ' selected="selected"';
1291
-                } else {
1292
-                    $current = '';
1293
-                }
1294
-
1295
-                echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1296
-                     . esc_html($item->post_title)
1297
-                     . "</option>";
1298
-                parent_dropdown($default, $item->ID, $level + 1);
1299
-            }
1300
-        }
1301
-    }
1302
-
1303
-
1304
-    /**
1305
-     * Loads the scripts for the privacy settings form
1306
-     */
1307
-    public function load_scripts_styles_privacy_settings()
1308
-    {
1309
-        $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1310
-        $form_handler->enqueueStylesAndScripts();
1311
-    }
1312
-
1313
-
1314
-    /**
1315
-     * display the privacy settings form
1316
-     */
1317
-    public function privacySettings()
1318
-    {
1319
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1320
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1321
-        $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1322
-        $this->_template_args['admin_page_content'] = $form_handler->display();
1323
-        $this->display_admin_page_with_sidebar();
1324
-    }
1325
-
1326
-
1327
-    /**
1328
-     * Update the privacy settings from form data
1329
-     *
1330
-     * @throws EE_Error
1331
-     */
1332
-    public function updatePrivacySettings()
1333
-    {
1334
-        $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1335
-        $success = $form_handler->process($this->get_request_data());
1336
-        $this->_redirect_after_action(
1337
-            $success,
1338
-            esc_html__('Registration Form Options', 'event_espresso'),
1339
-            'updated',
1340
-            array('action' => 'privacy_settings')
1341
-        );
1342
-    }
1206
+	}
1207
+
1208
+
1209
+	/***********/
1210
+
1211
+
1212
+	/**
1213
+	 * displays edit and view links for critical EE pages
1214
+	 *
1215
+	 * @access public
1216
+	 * @param int $ee_page_id
1217
+	 * @return string
1218
+	 */
1219
+	public static function edit_view_links($ee_page_id)
1220
+	{
1221
+		$links = '<a href="'
1222
+				 . add_query_arg(
1223
+					 array('post' => $ee_page_id, 'action' => 'edit'),
1224
+					 admin_url('post.php')
1225
+				 )
1226
+				 . '" >'
1227
+				 . __('Edit', 'event_espresso')
1228
+				 . '</a>';
1229
+		$links .= ' &nbsp;|&nbsp; ';
1230
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1231
+
1232
+		return $links;
1233
+	}
1234
+
1235
+
1236
+	/**
1237
+	 * displays page and shortcode status for critical EE pages
1238
+	 *
1239
+	 * @param WP page object $ee_page
1240
+	 * @return string
1241
+	 */
1242
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1243
+	{
1244
+
1245
+		// page status
1246
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1247
+			$pg_colour = 'green';
1248
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1249
+		} else {
1250
+			$pg_colour = 'red';
1251
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1252
+		}
1253
+
1254
+		// shortcode status
1255
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1256
+			$sc_colour = 'green';
1257
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1258
+		} else {
1259
+			$sc_colour = 'red';
1260
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1261
+		}
1262
+
1263
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1264
+			   . $pg_status
1265
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1266
+	}
1267
+
1268
+
1269
+	/**
1270
+	 * generates a dropdown of all parent pages - copied from WP core
1271
+	 *
1272
+	 * @param int $default
1273
+	 * @param int $parent
1274
+	 * @param int $level
1275
+	 */
1276
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1277
+	{
1278
+		global $wpdb;
1279
+		$items = $wpdb->get_results(
1280
+			$wpdb->prepare(
1281
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1282
+				$parent
1283
+			)
1284
+		);
1285
+
1286
+		if ($items) {
1287
+			foreach ($items as $item) {
1288
+				$pad = str_repeat('&nbsp;', $level * 3);
1289
+				if ($item->ID == $default) {
1290
+					$current = ' selected="selected"';
1291
+				} else {
1292
+					$current = '';
1293
+				}
1294
+
1295
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1296
+					 . esc_html($item->post_title)
1297
+					 . "</option>";
1298
+				parent_dropdown($default, $item->ID, $level + 1);
1299
+			}
1300
+		}
1301
+	}
1302
+
1303
+
1304
+	/**
1305
+	 * Loads the scripts for the privacy settings form
1306
+	 */
1307
+	public function load_scripts_styles_privacy_settings()
1308
+	{
1309
+		$form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1310
+		$form_handler->enqueueStylesAndScripts();
1311
+	}
1312
+
1313
+
1314
+	/**
1315
+	 * display the privacy settings form
1316
+	 */
1317
+	public function privacySettings()
1318
+	{
1319
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1320
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1321
+		$form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1322
+		$this->_template_args['admin_page_content'] = $form_handler->display();
1323
+		$this->display_admin_page_with_sidebar();
1324
+	}
1325
+
1326
+
1327
+	/**
1328
+	 * Update the privacy settings from form data
1329
+	 *
1330
+	 * @throws EE_Error
1331
+	 */
1332
+	public function updatePrivacySettings()
1333
+	{
1334
+		$form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1335
+		$success = $form_handler->process($this->get_request_data());
1336
+		$this->_redirect_after_action(
1337
+			$success,
1338
+			esc_html__('Registration Form Options', 'event_espresso'),
1339
+			'updated',
1340
+			array('action' => 'privacy_settings')
1341
+		);
1342
+	}
1343 1343
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/templates/countries_settings.template.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 
11 11
     <h2 class="ee-admin-settings-hdr">
12 12
         <?php _e(
13
-            'Countries and States/Provinces',
14
-            'event_espresso'
15
-        ); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2>
13
+			'Countries and States/Provinces',
14
+			'event_espresso'
15
+		); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2>
16 16
     <table class="form-table">
17 17
         <tbody>
18 18
         <?php echo EEH_Form_Fields::generate_form_input($countries); ?>
@@ -21,38 +21,38 @@  discard block
 block discarded – undo
21 21
     <br/>
22 22
     <p>
23 23
         <?php
24
-        esc_html_e(
25
-            'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.',
26
-            'event_espresso'
27
-        );
28
-        ?>
24
+		esc_html_e(
25
+			'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.',
26
+			'event_espresso'
27
+		);
28
+		?>
29 29
     </p>
30 30
     <p id="country-currency-setting-disabled-pg" style="display: none;">
31 31
         <span class="reminder-spn">
32 32
             <?php printf(
33
-                esc_html__(
34
-                    'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.',
35
-                    'event_espresso'
36
-                ),
37
-                $CNT_name_for_site
38
-            ); ?>
33
+				esc_html__(
34
+					'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.',
35
+					'event_espresso'
36
+				),
37
+				$CNT_name_for_site
38
+			); ?>
39 39
         </span>
40 40
     </p>
41 41
     <div id="country-details-settings-dv">
42 42
         <h2 class="ee-admin-settings-hdr">
43 43
             <?php _e(
44
-                'Country Details',
45
-                'event_espresso'
46
-            ); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2>
44
+				'Country Details',
45
+				'event_espresso'
46
+			); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2>
47 47
         <div id="country-details-dv"><?php echo $country_details_settings; ?></div>
48 48
     </div>
49 49
 
50 50
     <div id="country-states-settings-dv">
51 51
         <h2 class="ee-admin-settings-hdr">
52 52
             <?php _e(
53
-                'States/Provinces',
54
-                'event_espresso'
55
-            ); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2>
53
+				'States/Provinces',
54
+				'event_espresso'
55
+			); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2>
56 56
         <div id="country-states-dv"><?php echo $country_states_settings; ?></div>
57 57
     </div>
58 58
 
Please login to merge, or discard this patch.
general_settings/templates/country_details_settings.template.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
8 8
 <table id="general-setting-country-details-tbl" class="form-table">
9 9
     <tbody>
10 10
     <?php
11
-    foreach ($inputs as $ID => $input) {
12
-        echo EEH_Form_Fields::generate_form_input($input);
13
-    }
14
-    ?>
11
+	foreach ($inputs as $ID => $input) {
12
+		echo EEH_Form_Fields::generate_form_input($input);
13
+	}
14
+	?>
15 15
     <tr>
16 16
         <th></th>
17 17
         <td>
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlerBaseClasses/JobHandlerFile.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function __construct(\EEHI_File $file_helper = null)
36 36
     {
37
-        if (! $file_helper) {
37
+        if ( ! $file_helper) {
38 38
             $this->_file_helper = new EEH_File();
39 39
         }
40 40
     }
@@ -55,23 +55,23 @@  discard block
 block discarded – undo
55 55
         try {
56 56
             $base_folder = $this->get_base_folder();
57 57
             $success = $this->_file_helper->ensure_folder_exists_and_is_writable(
58
-                $base_folder . JobHandlerFile::temp_folder_name
58
+                $base_folder.JobHandlerFile::temp_folder_name
59 59
             );
60 60
             if ($success) {
61 61
                 $success = $this->_file_helper->ensure_folder_exists_and_is_writable(
62
-                    $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id
62
+                    $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id
63 63
                 );
64 64
             }
65 65
             if ($success) {
66
-                $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename;
66
+                $filepath = $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id.DS.$filename;
67 67
                 $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath);
68 68
             }
69 69
             // let's add the .htaccess file so safari will open the file properly
70 70
             if ($success) {
71 71
                 $extension = EEH_File::get_file_extension($filepath);
72 72
                 EEH_File::write_to_file(
73
-                    $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess',
74
-                    'AddType ' . $filetype . ' ' . $extension,
73
+                    $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id.DS.'.htaccess',
74
+                    'AddType '.$filetype.' '.$extension,
75 75
                     '.htaccess'
76 76
                 );
77 77
             }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
                 )
95 95
             );
96 96
             // those methods normally fail with an exception, but if not, let's do it
97
-            if (! $success) {
97
+            if ( ! $success) {
98 98
                 throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso'));
99 99
             }
100 100
         } catch (\EE_Error $e) {
Please login to merge, or discard this patch.
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -17,135 +17,135 @@
 block discarded – undo
17 17
  */
18 18
 abstract class JobHandlerFile extends JobHandler
19 19
 {
20
-    // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
21
-    const temp_folder_name = 'batch_temp_folder';
20
+	// phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
21
+	const temp_folder_name = 'batch_temp_folder';
22 22
 
23
-    // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
24
-    /**
25
-     * @var \EEHI_File
26
-     */
27
-    protected $_file_helper = null;
23
+	// phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
24
+	/**
25
+	 * @var \EEHI_File
26
+	 */
27
+	protected $_file_helper = null;
28 28
 
29 29
 
30
-    /**
31
-     * JobHandlerFile constructor.
32
-     *
33
-     * @param \EEHI_File|null $file_helper
34
-     */
35
-    public function __construct(\EEHI_File $file_helper = null)
36
-    {
37
-        if (! $file_helper) {
38
-            $this->_file_helper = new EEH_File();
39
-        }
40
-    }
30
+	/**
31
+	 * JobHandlerFile constructor.
32
+	 *
33
+	 * @param \EEHI_File|null $file_helper
34
+	 */
35
+	public function __construct(\EEHI_File $file_helper = null)
36
+	{
37
+		if (! $file_helper) {
38
+			$this->_file_helper = new EEH_File();
39
+		}
40
+	}
41 41
 
42
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
43
-    /**
44
-     * Creates a file
45
-     *
46
-     * @param string $job_id
47
-     * @param string $filename
48
-     * @param string $filetype
49
-     * @param string $bom initial content to place in the file.
50
-     * @return string
51
-     * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException
52
-     */
53
-    public function create_file_from_job_with_name(
54
-        $job_id,
55
-        $filename,
56
-        $filetype = 'application/ms-excel',
57
-        $bom = "\xEF\xBB\xBF"
58
-    ) {
59
-        $filepath = '';
60
-        try {
61
-            $base_folder = $this->get_base_folder();
62
-            $success = $this->_file_helper->ensure_folder_exists_and_is_writable(
63
-                $base_folder . JobHandlerFile::temp_folder_name
64
-            );
65
-            if ($success) {
66
-                $success = $this->_file_helper->ensure_folder_exists_and_is_writable(
67
-                    $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id
68
-                );
69
-            }
70
-            if ($success) {
71
-                $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename;
72
-                $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath);
73
-            }
74
-            // let's add the .htaccess file so safari will open the file properly
75
-            if ($success) {
76
-                $extension = EEH_File::get_file_extension($filepath);
77
-                EEH_File::write_to_file(
78
-                    $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess',
79
-                    'AddType ' . $filetype . ' ' . $extension,
80
-                    '.htaccess'
81
-                );
82
-            }
83
-            /**
84
-             * Filters what initial content will be added to the file.
85
-             * @param string $return_value. By default it's whatever was pased into
86
-             *                              JobHandlerFile::create_file_from_job_with_name()
87
-             * @param string $filename
88
-             * @param string $filetype default 'application/ms-excel'
89
-             * @param string $filepath
90
-             */
91
-            EEH_File::write_to_file(
92
-                $filepath,
93
-                apply_filters(
94
-                    'FHEE__EE_CSV__begin_sending_csv__start_writing',
95
-                    $bom,
96
-                    $filename,
97
-                    $filetype,
98
-                    $filepath
99
-                )
100
-            );
101
-            // those methods normally fail with an exception, but if not, let's do it
102
-            if (! $success) {
103
-                throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso'));
104
-            }
105
-        } catch (\EE_Error $e) {
106
-            throw new BatchRequestException(
107
-                sprintf(
108
-                    // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment
109
-                    __('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'),
110
-                    $job_id,
111
-                    $e->getMessage()
112
-                ),
113
-                500,
114
-                $e
115
-            );
116
-        }
117
-        return $filepath;
118
-    }
42
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
43
+	/**
44
+	 * Creates a file
45
+	 *
46
+	 * @param string $job_id
47
+	 * @param string $filename
48
+	 * @param string $filetype
49
+	 * @param string $bom initial content to place in the file.
50
+	 * @return string
51
+	 * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException
52
+	 */
53
+	public function create_file_from_job_with_name(
54
+		$job_id,
55
+		$filename,
56
+		$filetype = 'application/ms-excel',
57
+		$bom = "\xEF\xBB\xBF"
58
+	) {
59
+		$filepath = '';
60
+		try {
61
+			$base_folder = $this->get_base_folder();
62
+			$success = $this->_file_helper->ensure_folder_exists_and_is_writable(
63
+				$base_folder . JobHandlerFile::temp_folder_name
64
+			);
65
+			if ($success) {
66
+				$success = $this->_file_helper->ensure_folder_exists_and_is_writable(
67
+					$base_folder . JobHandlerFile::temp_folder_name . DS . $job_id
68
+				);
69
+			}
70
+			if ($success) {
71
+				$filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename;
72
+				$success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath);
73
+			}
74
+			// let's add the .htaccess file so safari will open the file properly
75
+			if ($success) {
76
+				$extension = EEH_File::get_file_extension($filepath);
77
+				EEH_File::write_to_file(
78
+					$base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess',
79
+					'AddType ' . $filetype . ' ' . $extension,
80
+					'.htaccess'
81
+				);
82
+			}
83
+			/**
84
+			 * Filters what initial content will be added to the file.
85
+			 * @param string $return_value. By default it's whatever was pased into
86
+			 *                              JobHandlerFile::create_file_from_job_with_name()
87
+			 * @param string $filename
88
+			 * @param string $filetype default 'application/ms-excel'
89
+			 * @param string $filepath
90
+			 */
91
+			EEH_File::write_to_file(
92
+				$filepath,
93
+				apply_filters(
94
+					'FHEE__EE_CSV__begin_sending_csv__start_writing',
95
+					$bom,
96
+					$filename,
97
+					$filetype,
98
+					$filepath
99
+				)
100
+			);
101
+			// those methods normally fail with an exception, but if not, let's do it
102
+			if (! $success) {
103
+				throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso'));
104
+			}
105
+		} catch (\EE_Error $e) {
106
+			throw new BatchRequestException(
107
+				sprintf(
108
+					// phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment
109
+					__('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'),
110
+					$job_id,
111
+					$e->getMessage()
112
+				),
113
+				500,
114
+				$e
115
+			);
116
+		}
117
+		return $filepath;
118
+	}
119 119
 
120
-    /**
121
-     * Gets the URL to download the file
122
-     *
123
-     * @param string $filepath
124
-     * @return string url to file
125
-     */
126
-    public function get_url_to_file($filepath)
127
-    {
128
-        return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath);
129
-    }
120
+	/**
121
+	 * Gets the URL to download the file
122
+	 *
123
+	 * @param string $filepath
124
+	 * @return string url to file
125
+	 */
126
+	public function get_url_to_file($filepath)
127
+	{
128
+		return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath);
129
+	}
130 130
 
131
-    /**
132
-     * Gets the folder which will contain the "batch_temp_folder"
133
-     *
134
-     * @return string
135
-     */
136
-    public function get_base_folder()
137
-    {
138
-        return apply_filters(
139
-            'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder',
140
-            EVENT_ESPRESSO_UPLOAD_DIR
141
-        );
142
-    }
131
+	/**
132
+	 * Gets the folder which will contain the "batch_temp_folder"
133
+	 *
134
+	 * @return string
135
+	 */
136
+	public function get_base_folder()
137
+	{
138
+		return apply_filters(
139
+			'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder',
140
+			EVENT_ESPRESSO_UPLOAD_DIR
141
+		);
142
+	}
143 143
 
144
-    public function get_base_url()
145
-    {
146
-        return apply_filters(
147
-            'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url',
148
-            EVENT_ESPRESSO_UPLOAD_URL
149
-        );
150
-    }
144
+	public function get_base_url()
145
+	{
146
+		return apply_filters(
147
+			'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url',
148
+			EVENT_ESPRESSO_UPLOAD_URL
149
+		);
150
+	}
151 151
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.69.rc.008');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.69.rc.008');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.