Completed
Branch FET-10416-autoload-b4-bootstra... (61e003)
by
unknown
148:03 queued 136:16
created
caffeinated/modules/event_single_caff/EED_Event_Single_Caff.module.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -118,40 +118,40 @@
 block discarded – undo
118 118
 	 * @return EE_Template_Config
119 119
 	 */
120 120
 	public static function update_template_settings(EE_Template_Config $CFG, $REQ ) {
121
-	    if(! $CFG->EED_Event_Single instanceof EE_Event_Single_Config){
122
-            $CFG->EED_Event_Single = new EE_Event_Single_Config();
123
-        }
124
-        $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
125
-            ? $CFG->EED_Event_Single->display_order_event
126
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
121
+		if(! $CFG->EED_Event_Single instanceof EE_Event_Single_Config){
122
+			$CFG->EED_Event_Single = new EE_Event_Single_Config();
123
+		}
124
+		$display_order_event = $CFG->EED_Event_Single->display_order_event !== null
125
+			? $CFG->EED_Event_Single->display_order_event
126
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
127 127
 		$display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null
128
-            ? $CFG->EED_Event_Single->display_order_datetimes
129
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
130
-        $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
131
-            ? $CFG->EED_Event_Single->display_order_tickets
132
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
128
+			? $CFG->EED_Event_Single->display_order_datetimes
129
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
130
+		$display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
131
+			? $CFG->EED_Event_Single->display_order_tickets
132
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
133 133
 		$display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null
134
-            ? $CFG->EED_Event_Single->display_order_venue
135
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
134
+			? $CFG->EED_Event_Single->display_order_venue
135
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
136 136
 		$CFG->EED_Event_Single = new EE_Event_Single_Config();
137 137
 		$CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] )
138
-            && $REQ['display_status_banner_single'];
138
+			&& $REQ['display_status_banner_single'];
139 139
 		$CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue'];
140 140
 		$CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
141
-            ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
142
-            : 0;
141
+			? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
142
+			: 0;
143 143
 		$CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
144
-            ? $display_order_event
145
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
144
+			? $display_order_event
145
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
146 146
 		$CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order
147
-            ? $display_order_datetimes
148
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
147
+			? $display_order_datetimes
148
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
149 149
 		$CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order
150
-            ? $display_order_tickets
151
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
150
+			? $display_order_tickets
151
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
152 152
 		$CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
153
-            ? $display_order_venue
154
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
153
+			? $display_order_venue
154
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
155 155
 		do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ );
156 156
 		return $CFG;
157 157
 	}
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @return EED_Event_Single_Caff
30 30
 	 */
31 31
 	public static function instance() {
32
-		return parent::get_instance( __CLASS__ );
32
+		return parent::get_instance(__CLASS__);
33 33
 	}
34 34
 
35 35
 
@@ -50,34 +50,34 @@  discard block
 block discarded – undo
50 50
 	 *  @return 	void
51 51
 	 */
52 52
 	public static function set_hooks_admin() {
53
-		define( 'EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS );
54
-		define( 'EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
53
+		define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS);
54
+		define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
55 55
 		add_action(
56 56
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings',
57
-			array( 'EED_Event_Single_Caff', 'load_scripts_styles' ),
57
+			array('EED_Event_Single_Caff', 'load_scripts_styles'),
58 58
 			10
59 59
 		);
60
-		add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Event_Single_Caff', 'template_settings_form' ), 10 );
61
-		add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Event_Single_Caff', 'update_template_settings' ), 10, 2 );
60
+		add_action('AHEE__template_settings__template__before_settings_form', array('EED_Event_Single_Caff', 'template_settings_form'), 10);
61
+		add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Event_Single_Caff', 'update_template_settings'), 10, 2);
62 62
 		// AJAX
63
-		add_action( 'wp_ajax_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) );
64
-		add_action( 'wp_ajax_nopriv_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) );
63
+		add_action('wp_ajax_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order'));
64
+		add_action('wp_ajax_nopriv_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order'));
65 65
 
66 66
 	}
67 67
 
68 68
 
69 69
 
70 70
 	public static function load_scripts_styles() {
71
-		add_action( 'admin_enqueue_scripts', array( 'EED_Event_Single_Caff', 'enqueue_scripts_styles' ), 10 );
71
+		add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10);
72 72
 	}
73 73
 
74 74
 
75 75
 
76 76
 	public static function enqueue_scripts_styles() {
77
-		wp_register_style( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION );
78
-		wp_enqueue_style( 'eed-event-single-sortable' );
79
-		wp_register_script( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', array( 'jquery-ui-sortable' ), EVENT_ESPRESSO_VERSION, true );
80
-		wp_enqueue_script( 'eed-event-single-sortable' );
77
+		wp_register_style('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION);
78
+		wp_enqueue_style('eed-event-single-sortable');
79
+		wp_register_script('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
80
+		wp_enqueue_script('eed-event-single-sortable');
81 81
 	}
82 82
 
83 83
 
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public static function template_settings_form() {
93 93
 		$config = EE_Registry::instance()->CFG->template_settings;
94
-		$config = isset( $config->EED_Event_Single ) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config();
95
-		$config->use_sortable_display_order = isset( $config->use_sortable_display_order ) ? $config->use_sortable_display_order : false;
96
-		$config = apply_filters( 'FHEE__EED_Event_Single__template_settings_form__event_list_config', $config );
94
+		$config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config();
95
+		$config->use_sortable_display_order = isset($config->use_sortable_display_order) ? $config->use_sortable_display_order : false;
96
+		$config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config);
97 97
 
98 98
 		$event_single_order_array = array();
99
-		$event_single_order_array[ $config->display_order_tickets ] = 'tickets';
100
-		$event_single_order_array[ $config->display_order_datetimes ] = 'datetimes';
101
-		$event_single_order_array[ $config->display_order_event ] = 'event';
102
-		$event_single_order_array[ $config->display_order_venue ] = 'venue';
99
+		$event_single_order_array[$config->display_order_tickets] = 'tickets';
100
+		$event_single_order_array[$config->display_order_datetimes] = 'datetimes';
101
+		$event_single_order_array[$config->display_order_event] = 'event';
102
+		$event_single_order_array[$config->display_order_venue] = 'venue';
103 103
 		// get template parts
104
-		$template_parts = EED_Event_Single::instance()->initialize_template_parts( $config );
104
+		$template_parts = EED_Event_Single::instance()->initialize_template_parts($config);
105 105
 		// convert to array so that we can add more properties
106
-		$config = get_object_vars( $config );
107
-		$config[ 'event_single_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-single-sortable-js', '', 'single-sortable-li single-sortable-js' );
108
-		EEH_Template::display_template( EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', $config );
106
+		$config = get_object_vars($config);
107
+		$config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-single-sortable-js', '', 'single-sortable-li single-sortable-js');
108
+		EEH_Template::display_template(EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php', $config);
109 109
 	}
110 110
 
111 111
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 * @param array $REQ
118 118
 	 * @return EE_Template_Config
119 119
 	 */
120
-	public static function update_template_settings(EE_Template_Config $CFG, $REQ ) {
121
-	    if(! $CFG->EED_Event_Single instanceof EE_Event_Single_Config){
120
+	public static function update_template_settings(EE_Template_Config $CFG, $REQ) {
121
+	    if ( ! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) {
122 122
             $CFG->EED_Event_Single = new EE_Event_Single_Config();
123 123
         }
124 124
         $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
             ? $CFG->EED_Event_Single->display_order_venue
135 135
             : EED_Event_Single::EVENT_VENUES_PRIORITY;
136 136
 		$CFG->EED_Event_Single = new EE_Event_Single_Config();
137
-		$CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] )
137
+		$CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single'])
138 138
             && $REQ['display_status_banner_single'];
139
-		$CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue'];
140
-		$CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
141
-            ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
139
+		$CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue'];
140
+		$CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order'])
141
+            ? absint($REQ['EED_Events_Single_use_sortable_display_order'])
142 142
             : 0;
143 143
 		$CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
144 144
             ? $display_order_event
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		$CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
153 153
             ? $display_order_venue
154 154
             : EED_Event_Single::EVENT_VENUES_PRIORITY;
155
-		do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ );
155
+		do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ);
156 156
 		return $CFG;
157 157
 	}
158 158
 
@@ -166,23 +166,23 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public static function update_event_single_order() {
168 168
 		$config_saved = false;
169
-		$template_parts = sanitize_text_field( $_POST[ 'elements' ] );
170
-		if ( ! empty( $template_parts ) ) {
171
-			$template_parts = explode( ',', trim( $template_parts, ',' ) );
172
-			foreach ( $template_parts as $key => $template_part ) {
169
+		$template_parts = sanitize_text_field($_POST['elements']);
170
+		if ( ! empty($template_parts)) {
171
+			$template_parts = explode(',', trim($template_parts, ','));
172
+			foreach ($template_parts as $key => $template_part) {
173 173
 				$template_part = "display_order_$template_part";
174
-				$priority = ( $key * 10 ) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
174
+				$priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
175 175
 				EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority;
176
-				do_action( "AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority );
176
+				do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority);
177 177
 			}
178
-			$config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false );
178
+			$config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
179 179
 		}
180
-		if ( $config_saved ) {
181
-			EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) );
180
+		if ($config_saved) {
181
+			EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso'));
182 182
 		} else {
183
-			EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
183
+			EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
184 184
 		}
185
-		echo wp_json_encode( EE_Error::get_notices( false ));
185
+		echo wp_json_encode(EE_Error::get_notices(false));
186 186
 		exit();
187 187
 	}
188 188
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @param WP $WP
196 196
 	 * @return    void
197 197
 	 */
198
-	public function run( $WP ) {
198
+	public function run($WP) {
199 199
 	}
200 200
 
201 201
 
Please login to merge, or discard this patch.
acceptance_tests/Helpers/CountrySettingsAdmin.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\Codeception\helpers;
3 3
 
4
-use Page\CoreAdmin;
5 4
 use Page\CountrySettingsAdmin as CountrySettings;
6 5
 
7 6
 trait CountrySettingsAdmin
Please login to merge, or discard this patch.
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -6,59 +6,59 @@
 block discarded – undo
6 6
 
7 7
 trait CountrySettingsAdmin
8 8
 {
9
-    /**
10
-     * Instructs the actor to browse to the country settings page.
11
-     * Assumes the actor is already logged in.
12
-     * @param string $additional_params
13
-     */
14
-    public function amOnCountrySettingsAdminPage($additional_params = '')
15
-    {
16
-        $this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
-    }
9
+	/**
10
+	 * Instructs the actor to browse to the country settings page.
11
+	 * Assumes the actor is already logged in.
12
+	 * @param string $additional_params
13
+	 */
14
+	public function amOnCountrySettingsAdminPage($additional_params = '')
15
+	{
16
+		$this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * Instructs the actor to select the given decimal places radio option.
22
-     * Assumes the actor is already on the country settings page.
23
-     * @param string $decimal_places
24
-     * @param string $country_code
25
-     */
26
-    public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
-    {
28
-        $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
-    }
20
+	/**
21
+	 * Instructs the actor to select the given decimal places radio option.
22
+	 * Assumes the actor is already on the country settings page.
23
+	 * @param string $decimal_places
24
+	 * @param string $country_code
25
+	 */
26
+	public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
+	{
28
+		$this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Instructs the actor to select the given decimal mark radio option.
34
-     * Assumes the actor is already on the country settings page.
35
-     * @param string $decimal_mark
36
-     */
37
-    public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
-    {
39
-        $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
-    }
32
+	/**
33
+	 * Instructs the actor to select the given decimal mark radio option.
34
+	 * Assumes the actor is already on the country settings page.
35
+	 * @param string $decimal_mark
36
+	 */
37
+	public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
+	{
39
+		$this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Instructs the actor to select the given thousands separator radio option.
45
-     * Assumes the actor is already on the country settings page.
46
-     * @param string $thousands_seperator
47
-     */
48
-    public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
-    {
50
-        $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
-    }
43
+	/**
44
+	 * Instructs the actor to select the given thousands separator radio option.
45
+	 * Assumes the actor is already on the country settings page.
46
+	 * @param string $thousands_seperator
47
+	 */
48
+	public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
+	{
50
+		$this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * Clicks the country settings submit button.
56
-     * Assumes the actor is on the country settings admin page.
57
-     */
58
-    public function saveCountrySettings()
59
-    {
60
-        $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
-        //no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
-        $this->actor()->wait(5);
63
-    }
54
+	/**
55
+	 * Clicks the country settings submit button.
56
+	 * Assumes the actor is on the country settings admin page.
57
+	 */
58
+	public function saveCountrySettings()
59
+	{
60
+		$this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
+		//no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
+		$this->actor()->wait(5);
63
+	}
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/EventsAdmin.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -14,118 +14,118 @@
 block discarded – undo
14 14
 trait EventsAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * @param string $additional_params
19
-     */
20
-    public function amOnDefaultEventsListTablePage($additional_params = '')
21
-    {
22
-        $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
-    }
24
-
25
-
26
-    /**
27
-     * Triggers the publishing of the Event.
28
-     */
29
-    public function publishEvent()
30
-    {
31
-        $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
-    }
33
-
34
-
35
-    /**
36
-     * Triggers saving the Event.
37
-     */
38
-    public function saveEvent()
39
-    {
40
-        $this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
41
-    }
42
-
43
-
44
-    /**
45
-     * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
46
-     * First this will search using the given title and then attempt to edit from the results of the search.
47
-     *
48
-     * Assumes actor is already logged in.
49
-     * @param $event_title
50
-     */
51
-    public function amEditingTheEventWithTitle($event_title)
52
-    {
53
-        $this->amOnDefaultEventsListTablePage();
54
-        $this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
55
-        $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
56
-        $this->actor()->waitForText('Displaying search results for');
57
-        $this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title));
58
-    }
59
-
60
-
61
-    /**
62
-     * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
63
-     * link for the event in the event list table.
64
-     * Assumes the actor is already logged in and on the Event list table page.
65
-     *
66
-     * @param string $event_title
67
-     */
68
-    public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
69
-    {
70
-        $this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
71
-        $this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
72
-    }
73
-
74
-
75
-    /**
76
-     * This performs the click action on the gear icon that triggers the advanced settings view state.
77
-     * Assumes the actor is already logged in and editing an event.
78
-     *
79
-     * @param int $row_number  What ticket row to toggle open/close.
80
-     */
81
-    public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
82
-    {
83
-        $this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
84
-    }
85
-
86
-
87
-    /**
88
-     * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
89
-     * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
90
-     * ticket is "open".
91
-     *
92
-     * @param int $row_number  What ticket row to toggle the checkbox for.
93
-     */
94
-    public function toggleTicketIsTaxableForTicketRow($row_number = 1)
95
-    {
96
-        $this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
97
-    }
98
-
99
-
100
-    /**
101
-     * Use to change the default registration status for the event.
102
-     * Assumes the view is already on the event editor.
103
-     * @param $registration_status
104
-     */
105
-    public function changeDefaultRegistrationStatusTo($registration_status)
106
-    {
107
-        $this->actor()->selectOption(
108
-            EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
109
-            $registration_status
110
-        );
111
-    }
112
-
113
-
114
-    /**
115
-     * Use this from the context of the event editor to select the given custom template for a given message type and
116
-     * messenger.
117
-     *
118
-     * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
119
-     * @param string $messenger_slug      The slug for the messenger (eg 'email')
120
-     * @param string $custom_template_label The visible label in the select input for the custom template you want
121
-     *                                      selected.
122
-     */
123
-    public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
124
-    {
125
-        $this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
126
-        $this->actor()->selectOption(
127
-            EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
128
-            $custom_template_label
129
-        );
130
-    }
17
+	/**
18
+	 * @param string $additional_params
19
+	 */
20
+	public function amOnDefaultEventsListTablePage($additional_params = '')
21
+	{
22
+		$this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
+	}
24
+
25
+
26
+	/**
27
+	 * Triggers the publishing of the Event.
28
+	 */
29
+	public function publishEvent()
30
+	{
31
+		$this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
+	}
33
+
34
+
35
+	/**
36
+	 * Triggers saving the Event.
37
+	 */
38
+	public function saveEvent()
39
+	{
40
+		$this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
41
+	}
42
+
43
+
44
+	/**
45
+	 * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
46
+	 * First this will search using the given title and then attempt to edit from the results of the search.
47
+	 *
48
+	 * Assumes actor is already logged in.
49
+	 * @param $event_title
50
+	 */
51
+	public function amEditingTheEventWithTitle($event_title)
52
+	{
53
+		$this->amOnDefaultEventsListTablePage();
54
+		$this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
55
+		$this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
56
+		$this->actor()->waitForText('Displaying search results for');
57
+		$this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title));
58
+	}
59
+
60
+
61
+	/**
62
+	 * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
63
+	 * link for the event in the event list table.
64
+	 * Assumes the actor is already logged in and on the Event list table page.
65
+	 *
66
+	 * @param string $event_title
67
+	 */
68
+	public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
69
+	{
70
+		$this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
71
+		$this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
72
+	}
73
+
74
+
75
+	/**
76
+	 * This performs the click action on the gear icon that triggers the advanced settings view state.
77
+	 * Assumes the actor is already logged in and editing an event.
78
+	 *
79
+	 * @param int $row_number  What ticket row to toggle open/close.
80
+	 */
81
+	public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
82
+	{
83
+		$this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
84
+	}
85
+
86
+
87
+	/**
88
+	 * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
89
+	 * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
90
+	 * ticket is "open".
91
+	 *
92
+	 * @param int $row_number  What ticket row to toggle the checkbox for.
93
+	 */
94
+	public function toggleTicketIsTaxableForTicketRow($row_number = 1)
95
+	{
96
+		$this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
97
+	}
98
+
99
+
100
+	/**
101
+	 * Use to change the default registration status for the event.
102
+	 * Assumes the view is already on the event editor.
103
+	 * @param $registration_status
104
+	 */
105
+	public function changeDefaultRegistrationStatusTo($registration_status)
106
+	{
107
+		$this->actor()->selectOption(
108
+			EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
109
+			$registration_status
110
+		);
111
+	}
112
+
113
+
114
+	/**
115
+	 * Use this from the context of the event editor to select the given custom template for a given message type and
116
+	 * messenger.
117
+	 *
118
+	 * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
119
+	 * @param string $messenger_slug      The slug for the messenger (eg 'email')
120
+	 * @param string $custom_template_label The visible label in the select input for the custom template you want
121
+	 *                                      selected.
122
+	 */
123
+	public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
124
+	{
125
+		$this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
126
+		$this->actor()->selectOption(
127
+			EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
128
+			$custom_template_label
129
+		);
130
+	}
131 131
 }
132 132
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/EventsAdmin.php 1 patch
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -14,231 +14,231 @@
 block discarded – undo
14 14
 class EventsAdmin extends CoreAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * Selector for the Add new Event button in the admin.
19
-     * @var string
20
-     */
21
-    const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
-
23
-
24
-    /**
25
-     * Selector for the Event Title field in the event editor
26
-     * @var string
27
-     */
28
-    const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
-
30
-    /**
31
-     * Selector for the publish submit button in the event editor.
32
-     * @var string
33
-     */
34
-    const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
-
36
-
37
-    /**
38
-     * Selector for the save button in the event editor
39
-     */
40
-    const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post";
41
-
42
-
43
-    /**
44
-     * @var string
45
-     */
46
-    const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status';
17
+	/**
18
+	 * Selector for the Add new Event button in the admin.
19
+	 * @var string
20
+	 */
21
+	const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
+
23
+
24
+	/**
25
+	 * Selector for the Event Title field in the event editor
26
+	 * @var string
27
+	 */
28
+	const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
+
30
+	/**
31
+	 * Selector for the publish submit button in the event editor.
32
+	 * @var string
33
+	 */
34
+	const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
+
36
+
37
+	/**
38
+	 * Selector for the save button in the event editor
39
+	 */
40
+	const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post";
41
+
42
+
43
+	/**
44
+	 * @var string
45
+	 */
46
+	const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status';
47 47
 
48
-    /**
49
-     * Selector for the view link after publishing an event.
50
-     * @var string
51
-     */
52
-    const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a";
48
+	/**
49
+	 * Selector for the view link after publishing an event.
50
+	 * @var string
51
+	 */
52
+	const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a";
53 53
 
54 54
 
55
-    /**
56
-     * Selector for the ID of the event in the event editor
57
-     * @var string
58
-     */
59
-    const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
55
+	/**
56
+	 * Selector for the ID of the event in the event editor
57
+	 * @var string
58
+	 */
59
+	const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
60 60
 
61 61
 
62
-    /**
63
-     * Selector for the search input on the event list table page.
64
-     * @var string
65
-     */
66
-    const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
67
-
68
-
69
-
70
-
71
-    /**
72
-     * @param string $additional_params
73
-     * @return string
74
-     */
75
-    public static function defaultEventsListTableUrl($additional_params = '')
76
-    {
77
-        return self::adminUrl('espresso_events', 'default', $additional_params);
78
-    }
79
-
80
-
81
-    /**
82
-     * The selector for the DTTname field for the given row in the event editor.
83
-     * @param int $row_number
84
-     * @return string
85
-     */
86
-    public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
87
-    {
88
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
89
-    }
90
-
91
-
92
-    /**
93
-     * The selector for the DTT_EVT_start field for the given row in the event editor.d
94
-     * @param int $row_number
95
-     * @return string
96
-     */
97
-    public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
98
-    {
99
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
100
-    }
101
-
102
-
103
-    /**
104
-     * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
105
-     *
106
-     * @param string $field_name
107
-     * @param int    $row_number
108
-     * @return string
109
-     */
110
-    public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
111
-    {
112
-        return "//input[@id='event-datetime-$field_name-$row_number']";
113
-    }
114
-
115
-
116
-    /**
117
-     * The selector for the TKT_name field for the given display row in the event editor.
118
-     * @param int $row_number
119
-     * @return string
120
-     */
121
-    public static function eventEditorTicketNameFieldSelector($row_number = 1)
122
-    {
123
-        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
124
-    }
125
-
126
-
127
-    public static function eventEditorTicketPriceFieldSelector($row_number = 1)
128
-    {
129
-        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number);
130
-    }
131
-
132
-
133
-    public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1)
134
-    {
135
-        return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]";
136
-    }
137
-
138
-
139
-    public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1)
140
-    {
141
-        return "//span[@id='price-total-amount-$row_number']";
142
-    }
143
-
144
-
145
-    public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1)
146
-    {
147
-        return "//span[@id='price-total-amount-$row_number']";
148
-    }
149
-
150
-
151
-    public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1)
152
-    {
153
-        return "//input[@id='edit-ticket-TKT_taxable-$row_number']";
154
-    }
155
-
156
-
157
-    /**
158
-     * This returns the xpath locater for the Tax amount display container within the advanced settings view for the
159
-     * given ticket (row) and the given tax id (PRC_ID).
160
-     *
161
-     * @param int $tax_id     The PRC_ID for the tax you want the locater for.  Note, this defaults to the default tax
162
-     *                        setup on a fresh install.
163
-     * @param int $row_number What row representing the ticket you want the locator for.
164
-     * @return string
165
-     */
166
-    public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1)
167
-    {
168
-        return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']";
169
-    }
170
-
171
-
172
-    /**
173
-     * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
174
-     * @param     $field_name
175
-     * @param int $row_number
176
-     * @return string
177
-     */
178
-    public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
179
-    {
180
-        return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]";
181
-    }
182
-
183
-
184
-    /**
185
-     * Returns the selector for the event title edit link in the events list table for the given Event Title.
186
-     * @param string $event_title
187
-     * @return string
188
-     */
189
-    public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
190
-    {
191
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
192
-    }
193
-
194
-
195
-    /**
196
-     * Locator for for the ID column in the event list table for a given event title.
197
-     * @param string $event_title
198
-     * @return string
199
-     */
200
-    public static function eventListTableEventIdSelectorForTitle($event_title)
201
-    {
202
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
203
-               . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
204
-    }
205
-
206
-
207
-    /**
208
-     * Locator for the view link in the row of an event list table for the given event title.
209
-     * @param string $event_title
210
-     * @return string
211
-     */
212
-    public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
213
-    {
214
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
215
-               . "//ancestor::td//span[@class='view']/a";
216
-    }
217
-
218
-
219
-    /**
220
-     * Locator for the messenger tab in the Notifications metabox in the event editor.
221
-     * @param string $messenger_slug  The slug for the messenger (it's reference slug).
222
-     * @return string
223
-     */
224
-    public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)
225
-    {
226
-        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
227
-               . "//a[@rel='ee-tab-$messenger_slug']";
228
-    }
229
-
230
-
231
-    /**
232
-     * Locator for the select input within the notifications metabox.
233
-     * Note, this assumes the tab content for the related messenger is already visible.
234
-     * @param string $message_type_label The message type label (visible string in the table) you want the selector for.
235
-     * @return string
236
-     */
237
-    public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label)
238
-    {
239
-        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
240
-               . "//table[@class='messages-custom-template-switcher']"
241
-               . "//tr/td[contains(.,'Registration Approved')]"
242
-               . "//ancestor::tr//select[contains(@class,'message-template-selector')]";
243
-    }
62
+	/**
63
+	 * Selector for the search input on the event list table page.
64
+	 * @var string
65
+	 */
66
+	const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
67
+
68
+
69
+
70
+
71
+	/**
72
+	 * @param string $additional_params
73
+	 * @return string
74
+	 */
75
+	public static function defaultEventsListTableUrl($additional_params = '')
76
+	{
77
+		return self::adminUrl('espresso_events', 'default', $additional_params);
78
+	}
79
+
80
+
81
+	/**
82
+	 * The selector for the DTTname field for the given row in the event editor.
83
+	 * @param int $row_number
84
+	 * @return string
85
+	 */
86
+	public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
87
+	{
88
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
89
+	}
90
+
91
+
92
+	/**
93
+	 * The selector for the DTT_EVT_start field for the given row in the event editor.d
94
+	 * @param int $row_number
95
+	 * @return string
96
+	 */
97
+	public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
98
+	{
99
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
100
+	}
101
+
102
+
103
+	/**
104
+	 * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
105
+	 *
106
+	 * @param string $field_name
107
+	 * @param int    $row_number
108
+	 * @return string
109
+	 */
110
+	public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
111
+	{
112
+		return "//input[@id='event-datetime-$field_name-$row_number']";
113
+	}
114
+
115
+
116
+	/**
117
+	 * The selector for the TKT_name field for the given display row in the event editor.
118
+	 * @param int $row_number
119
+	 * @return string
120
+	 */
121
+	public static function eventEditorTicketNameFieldSelector($row_number = 1)
122
+	{
123
+		return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
124
+	}
125
+
126
+
127
+	public static function eventEditorTicketPriceFieldSelector($row_number = 1)
128
+	{
129
+		return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number);
130
+	}
131
+
132
+
133
+	public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1)
134
+	{
135
+		return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]";
136
+	}
137
+
138
+
139
+	public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1)
140
+	{
141
+		return "//span[@id='price-total-amount-$row_number']";
142
+	}
143
+
144
+
145
+	public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1)
146
+	{
147
+		return "//span[@id='price-total-amount-$row_number']";
148
+	}
149
+
150
+
151
+	public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1)
152
+	{
153
+		return "//input[@id='edit-ticket-TKT_taxable-$row_number']";
154
+	}
155
+
156
+
157
+	/**
158
+	 * This returns the xpath locater for the Tax amount display container within the advanced settings view for the
159
+	 * given ticket (row) and the given tax id (PRC_ID).
160
+	 *
161
+	 * @param int $tax_id     The PRC_ID for the tax you want the locater for.  Note, this defaults to the default tax
162
+	 *                        setup on a fresh install.
163
+	 * @param int $row_number What row representing the ticket you want the locator for.
164
+	 * @return string
165
+	 */
166
+	public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1)
167
+	{
168
+		return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']";
169
+	}
170
+
171
+
172
+	/**
173
+	 * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
174
+	 * @param     $field_name
175
+	 * @param int $row_number
176
+	 * @return string
177
+	 */
178
+	public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
179
+	{
180
+		return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]";
181
+	}
182
+
183
+
184
+	/**
185
+	 * Returns the selector for the event title edit link in the events list table for the given Event Title.
186
+	 * @param string $event_title
187
+	 * @return string
188
+	 */
189
+	public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
190
+	{
191
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
192
+	}
193
+
194
+
195
+	/**
196
+	 * Locator for for the ID column in the event list table for a given event title.
197
+	 * @param string $event_title
198
+	 * @return string
199
+	 */
200
+	public static function eventListTableEventIdSelectorForTitle($event_title)
201
+	{
202
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
203
+			   . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
204
+	}
205
+
206
+
207
+	/**
208
+	 * Locator for the view link in the row of an event list table for the given event title.
209
+	 * @param string $event_title
210
+	 * @return string
211
+	 */
212
+	public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
213
+	{
214
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
215
+			   . "//ancestor::td//span[@class='view']/a";
216
+	}
217
+
218
+
219
+	/**
220
+	 * Locator for the messenger tab in the Notifications metabox in the event editor.
221
+	 * @param string $messenger_slug  The slug for the messenger (it's reference slug).
222
+	 * @return string
223
+	 */
224
+	public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)
225
+	{
226
+		return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
227
+			   . "//a[@rel='ee-tab-$messenger_slug']";
228
+	}
229
+
230
+
231
+	/**
232
+	 * Locator for the select input within the notifications metabox.
233
+	 * Note, this assumes the tab content for the related messenger is already visible.
234
+	 * @param string $message_type_label The message type label (visible string in the table) you want the selector for.
235
+	 * @return string
236
+	 */
237
+	public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label)
238
+	{
239
+		return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
240
+			   . "//table[@class='messages-custom-template-switcher']"
241
+			   . "//tr/td[contains(.,'Registration Approved')]"
242
+			   . "//ancestor::tr//select[contains(@class,'message-template-selector')]";
243
+	}
244 244
 }
Please login to merge, or discard this patch.
acceptance_tests/Page/CountrySettingsAdmin.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,51 +14,51 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2';
17
+	const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2';
18 18
 
19 19
 
20 20
 
21
-    /**
22
-     * Return the url for the country settings admin page.
23
-     * @param string $additional_params
24
-     * @return string
25
-     */
26
-    public static function url($additional_params = '')
27
-    {
28
-        return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params);
29
-    }
21
+	/**
22
+	 * Return the url for the country settings admin page.
23
+	 * @param string $additional_params
24
+	 * @return string
25
+	 */
26
+	public static function url($additional_params = '')
27
+	{
28
+		return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Return the decimal places (precision) radio field locator for selection.
34
-     * @param int    $decimal_place_value
35
-     * @param string $country_code
36
-     * @return string
37
-     */
38
-    public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US')
39
-    {
40
-        return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']";
41
-    }
32
+	/**
33
+	 * Return the decimal places (precision) radio field locator for selection.
34
+	 * @param int    $decimal_place_value
35
+	 * @param string $country_code
36
+	 * @return string
37
+	 */
38
+	public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US')
39
+	{
40
+		return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']";
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * Return the currency decimal mark field locator for selection.
46
-     * @param string $decimal_mark
47
-     * @return string
48
-     */
49
-    public static function currencyDecimalMarkRadioField($decimal_mark = '.')
50
-    {
51
-        return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']";
52
-    }
44
+	/**
45
+	 * Return the currency decimal mark field locator for selection.
46
+	 * @param string $decimal_mark
47
+	 * @return string
48
+	 */
49
+	public static function currencyDecimalMarkRadioField($decimal_mark = '.')
50
+	{
51
+		return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']";
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Return the currency thousands separator field locator for selection.
57
-     * @param string $thousands_separator
58
-     * @return string
59
-     */
60
-    public static function currencyThousandsSeparatorField($thousands_separator = ',')
61
-    {
62
-        return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']";
63
-    }
55
+	/**
56
+	 * Return the currency thousands separator field locator for selection.
57
+	 * @param string $thousands_separator
58
+	 * @return string
59
+	 */
60
+	public static function currencyThousandsSeparatorField($thousands_separator = ',')
61
+	{
62
+		return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']";
63
+	}
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
      * Returns template for the additional datetime.
340 340
      * @param $template
341 341
      * @param $template_args
342
-     * @return mixed
342
+     * @return string
343 343
      * @throws DomainException
344 344
      */
345 345
     public function add_additional_datetime_button($template, $template_args)
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      * Returns the template for cloning a datetime.
357 357
      * @param $template
358 358
      * @param $template_args
359
-     * @return mixed
359
+     * @return string
360 360
      * @throws DomainException
361 361
      */
362 362
     public function add_datetime_clone_button($template, $template_args)
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      * Returns the template for datetime timezones.
374 374
      * @param $template
375 375
      * @param $template_args
376
-     * @return mixed
376
+     * @return string
377 377
      * @throws DomainException
378 378
      */
379 379
     public function datetime_timezones_template($template, $template_args)
Please login to merge, or discard this patch.
Indentation   +1235 added lines, -1235 removed lines patch added patch discarded remove patch
@@ -14,1239 +14,1239 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /**
18
-     * Extend_Events_Admin_Page constructor.
19
-     *
20
-     * @param bool $routing
21
-     */
22
-    public function __construct($routing = true)
23
-    {
24
-        parent::__construct($routing);
25
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
26
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
27
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
28
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
29
-        }
30
-    }
31
-
32
-
33
-    /**
34
-     * Sets routes.
35
-     */
36
-    protected function _extend_page_config()
37
-    {
38
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
39
-        //is there a evt_id in the request?
40
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
41
-            ? $this->_req_data['EVT_ID']
42
-            : 0;
43
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
44
-        //tkt_id?
45
-        $tkt_id             = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
46
-            ? $this->_req_data['TKT_ID']
47
-            : 0;
48
-        $new_page_routes    = array(
49
-            'duplicate_event'          => array(
50
-                'func'       => '_duplicate_event',
51
-                'capability' => 'ee_edit_event',
52
-                'obj_id'     => $evt_id,
53
-                'noheader'   => true,
54
-            ),
55
-            'ticket_list_table'        => array(
56
-                'func'       => '_tickets_overview_list_table',
57
-                'capability' => 'ee_read_default_tickets',
58
-            ),
59
-            'trash_ticket'             => array(
60
-                'func'       => '_trash_or_restore_ticket',
61
-                'capability' => 'ee_delete_default_ticket',
62
-                'obj_id'     => $tkt_id,
63
-                'noheader'   => true,
64
-                'args'       => array('trash' => true),
65
-            ),
66
-            'trash_tickets'            => array(
67
-                'func'       => '_trash_or_restore_ticket',
68
-                'capability' => 'ee_delete_default_tickets',
69
-                'noheader'   => true,
70
-                'args'       => array('trash' => true),
71
-            ),
72
-            'restore_ticket'           => array(
73
-                'func'       => '_trash_or_restore_ticket',
74
-                'capability' => 'ee_delete_default_ticket',
75
-                'obj_id'     => $tkt_id,
76
-                'noheader'   => true,
77
-            ),
78
-            'restore_tickets'          => array(
79
-                'func'       => '_trash_or_restore_ticket',
80
-                'capability' => 'ee_delete_default_tickets',
81
-                'noheader'   => true,
82
-            ),
83
-            'delete_ticket'            => array(
84
-                'func'       => '_delete_ticket',
85
-                'capability' => 'ee_delete_default_ticket',
86
-                'obj_id'     => $tkt_id,
87
-                'noheader'   => true,
88
-            ),
89
-            'delete_tickets'           => array(
90
-                'func'       => '_delete_ticket',
91
-                'capability' => 'ee_delete_default_tickets',
92
-                'noheader'   => true,
93
-            ),
94
-            'import_page'              => array(
95
-                'func'       => '_import_page',
96
-                'capability' => 'import',
97
-            ),
98
-            'import'                   => array(
99
-                'func'       => '_import_events',
100
-                'capability' => 'import',
101
-                'noheader'   => true,
102
-            ),
103
-            'import_events'            => array(
104
-                'func'       => '_import_events',
105
-                'capability' => 'import',
106
-                'noheader'   => true,
107
-            ),
108
-            'export_events'            => array(
109
-                'func'       => '_events_export',
110
-                'capability' => 'export',
111
-                'noheader'   => true,
112
-            ),
113
-            'export_categories'        => array(
114
-                'func'       => '_categories_export',
115
-                'capability' => 'export',
116
-                'noheader'   => true,
117
-            ),
118
-            'sample_export_file'       => array(
119
-                'func'       => '_sample_export_file',
120
-                'capability' => 'export',
121
-                'noheader'   => true,
122
-            ),
123
-            'update_template_settings' => array(
124
-                'func'       => '_update_template_settings',
125
-                'capability' => 'manage_options',
126
-                'noheader'   => true,
127
-            ),
128
-        );
129
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
130
-        //partial route/config override
131
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
132
-        $this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
133
-        $this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
134
-        $this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
135
-        $this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
136
-        $this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
137
-        //add tickets tab but only if there are more than one default ticket!
138
-        $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
139
-            array(array('TKT_is_default' => 1)),
140
-            'TKT_ID',
141
-            true
142
-        );
143
-        if ($tkt_count > 1) {
144
-            $new_page_config = array(
145
-                'ticket_list_table' => array(
146
-                    'nav'           => array(
147
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
148
-                        'order' => 60,
149
-                    ),
150
-                    'list_table'    => 'Tickets_List_Table',
151
-                    'require_nonce' => false,
152
-                ),
153
-            );
154
-        }
155
-        //template settings
156
-        $new_page_config['template_settings'] = array(
157
-            'nav'           => array(
158
-                'label' => esc_html__('Templates', 'event_espresso'),
159
-                'order' => 30,
160
-            ),
161
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
162
-            'help_tabs'     => array(
163
-                'general_settings_templates_help_tab' => array(
164
-                    'title'    => esc_html__('Templates', 'event_espresso'),
165
-                    'filename' => 'general_settings_templates',
166
-                ),
167
-            ),
168
-            'help_tour'     => array('Templates_Help_Tour'),
169
-            'require_nonce' => false,
170
-        );
171
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
172
-        //add filters and actions
173
-        //modifying _views
174
-        add_filter(
175
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
176
-            array($this, 'add_additional_datetime_button'),
177
-            10,
178
-            2
179
-        );
180
-        add_filter(
181
-            'FHEE_event_datetime_metabox_clone_button_template',
182
-            array($this, 'add_datetime_clone_button'),
183
-            10,
184
-            2
185
-        );
186
-        add_filter(
187
-            'FHEE_event_datetime_metabox_timezones_template',
188
-            array($this, 'datetime_timezones_template'),
189
-            10,
190
-            2
191
-        );
192
-        //filters for event list table
193
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
194
-        add_filter(
195
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
196
-            array($this, 'extra_list_table_actions'),
197
-            10,
198
-            2
199
-        );
200
-        //legend item
201
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
202
-        add_action('admin_init', array($this, 'admin_init'));
203
-        //heartbeat stuff
204
-        add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2);
205
-    }
206
-
207
-
208
-    /**
209
-     * admin_init
210
-     */
211
-    public function admin_init()
212
-    {
213
-        EE_Registry::$i18n_js_strings = array_merge(
214
-            EE_Registry::$i18n_js_strings,
215
-            array(
216
-                'image_confirm'          => esc_html__(
217
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
218
-                    'event_espresso'
219
-                ),
220
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
221
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
222
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
223
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
224
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
225
-            )
226
-        );
227
-    }
228
-
229
-
230
-    /**
231
-     * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle
232
-     * accordingly.
233
-     *
234
-     * @param array $response The existing heartbeat response array.
235
-     * @param array $data     The incoming data package.
236
-     * @return array  possibly appended response.
237
-     */
238
-    public function heartbeat_response($response, $data)
239
-    {
240
-        /**
241
-         * check whether count of tickets is approaching the potential
242
-         * limits for the server.
243
-         */
244
-        if (! empty($data['input_count'])) {
245
-            $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check(
246
-                $data['input_count']
247
-            );
248
-        }
249
-        return $response;
250
-    }
251
-
252
-
253
-    /**
254
-     * Add per page screen options to the default ticket list table view.
255
-     */
256
-    protected function _add_screen_options_ticket_list_table()
257
-    {
258
-        $this->_per_page_screen_option();
259
-    }
260
-
261
-
262
-    /**
263
-     * @param string $return
264
-     * @param int    $id
265
-     * @param string $new_title
266
-     * @param string $new_slug
267
-     * @return string
268
-     */
269
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
270
-    {
271
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
272
-        //make sure this is only when editing
273
-        if (! empty($id)) {
274
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
275
-                array('action' => 'duplicate_event', 'EVT_ID' => $id),
276
-                $this->_admin_base_url
277
-            );
278
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
279
-            $return .= '<a href="'
280
-                       . $href
281
-                       . '" title="'
282
-                       . $title
283
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
284
-                       . $title
285
-                       . '</button>';
286
-        }
287
-        return $return;
288
-    }
289
-
290
-
291
-    /**
292
-     * Set the list table views for the default ticket list table view.
293
-     */
294
-    public function _set_list_table_views_ticket_list_table()
295
-    {
296
-        $this->_views = array(
297
-            'all'     => array(
298
-                'slug'        => 'all',
299
-                'label'       => esc_html__('All', 'event_espresso'),
300
-                'count'       => 0,
301
-                'bulk_action' => array(
302
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
303
-                ),
304
-            ),
305
-            'trashed' => array(
306
-                'slug'        => 'trashed',
307
-                'label'       => esc_html__('Trash', 'event_espresso'),
308
-                'count'       => 0,
309
-                'bulk_action' => array(
310
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
311
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
312
-                ),
313
-            ),
314
-        );
315
-    }
316
-
317
-
318
-    /**
319
-     * Enqueue scripts and styles for the event editor.
320
-     */
321
-    public function load_scripts_styles_edit()
322
-    {
323
-        wp_register_script(
324
-            'ee-event-editor-heartbeat',
325
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
326
-            array('ee_admin_js', 'heartbeat'),
327
-            EVENT_ESPRESSO_VERSION,
328
-            true
329
-        );
330
-        wp_enqueue_script('ee-accounting');
331
-        //styles
332
-        wp_enqueue_style('espresso-ui-theme');
333
-        wp_enqueue_script('event_editor_js');
334
-        wp_enqueue_script('ee-event-editor-heartbeat');
335
-    }
336
-
337
-
338
-    /**
339
-     * Returns template for the additional datetime.
340
-     * @param $template
341
-     * @param $template_args
342
-     * @return mixed
343
-     * @throws DomainException
344
-     */
345
-    public function add_additional_datetime_button($template, $template_args)
346
-    {
347
-        return EEH_Template::display_template(
348
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
349
-            $template_args,
350
-            true
351
-        );
352
-    }
353
-
354
-
355
-    /**
356
-     * Returns the template for cloning a datetime.
357
-     * @param $template
358
-     * @param $template_args
359
-     * @return mixed
360
-     * @throws DomainException
361
-     */
362
-    public function add_datetime_clone_button($template, $template_args)
363
-    {
364
-        return EEH_Template::display_template(
365
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
366
-            $template_args,
367
-            true
368
-        );
369
-    }
370
-
371
-
372
-    /**
373
-     * Returns the template for datetime timezones.
374
-     * @param $template
375
-     * @param $template_args
376
-     * @return mixed
377
-     * @throws DomainException
378
-     */
379
-    public function datetime_timezones_template($template, $template_args)
380
-    {
381
-        return EEH_Template::display_template(
382
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
383
-            $template_args,
384
-            true
385
-        );
386
-    }
387
-
388
-
389
-    /**
390
-     * Sets the views for the default list table view.
391
-     */
392
-    protected function _set_list_table_views_default()
393
-    {
394
-        parent::_set_list_table_views_default();
395
-        $new_views    = array(
396
-            'today' => array(
397
-                'slug'        => 'today',
398
-                'label'       => esc_html__('Today', 'event_espresso'),
399
-                'count'       => $this->total_events_today(),
400
-                'bulk_action' => array(
401
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
402
-                ),
403
-            ),
404
-            'month' => array(
405
-                'slug'        => 'month',
406
-                'label'       => esc_html__('This Month', 'event_espresso'),
407
-                'count'       => $this->total_events_this_month(),
408
-                'bulk_action' => array(
409
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
410
-                ),
411
-            ),
412
-        );
413
-        $this->_views = array_merge($this->_views, $new_views);
414
-    }
415
-
416
-
417
-    /**
418
-     * Returns the extra action links for the default list table view.
419
-     * @param array     $action_links
420
-     * @param \EE_Event $event
421
-     * @return array
422
-     * @throws EE_Error
423
-     */
424
-    public function extra_list_table_actions(array $action_links, \EE_Event $event)
425
-    {
426
-        if (EE_Registry::instance()->CAP->current_user_can(
427
-            'ee_read_registrations',
428
-            'espresso_registrations_reports',
429
-            $event->ID()
430
-        )
431
-        ) {
432
-            $reports_query_args = array(
433
-                'action' => 'reports',
434
-                'EVT_ID' => $event->ID(),
435
-            );
436
-            $reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
437
-            $action_links[]     = '<a href="'
438
-                                  . $reports_link
439
-                                  . '" title="'
440
-                                  . esc_attr__('View Report', 'event_espresso')
441
-                                  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
442
-                                  . "\n\t";
443
-        }
444
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
445
-            EE_Registry::instance()->load_helper('MSG_Template');
446
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
447
-                'see_notifications_for',
448
-                null,
449
-                array('EVT_ID' => $event->ID())
450
-            );
451
-        }
452
-        return $action_links;
453
-    }
454
-
455
-
456
-    /**
457
-     * @param $items
458
-     * @return mixed
459
-     */
460
-    public function additional_legend_items($items)
461
-    {
462
-        if (EE_Registry::instance()->CAP->current_user_can(
463
-            'ee_read_registrations',
464
-            'espresso_registrations_reports'
465
-        )
466
-        ) {
467
-            $items['reports'] = array(
468
-                'class' => 'dashicons dashicons-chart-bar',
469
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
470
-            );
471
-        }
472
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
473
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
474
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
475
-                $items['view_related_messages'] = array(
476
-                    'class' => $related_for_icon['css_class'],
477
-                    'desc'  => $related_for_icon['label'],
478
-                );
479
-            }
480
-        }
481
-        return $items;
482
-    }
483
-
484
-
485
-    /**
486
-     * This is the callback method for the duplicate event route
487
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
488
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
489
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
490
-     * After duplication the redirect is to the new event edit page.
491
-     *
492
-     * @return void
493
-     * @access protected
494
-     * @throws EE_Error If EE_Event is not available with given ID
495
-     */
496
-    protected function _duplicate_event()
497
-    {
498
-        // first make sure the ID for the event is in the request.
499
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
500
-        if (! isset($this->_req_data['EVT_ID'])) {
501
-            EE_Error::add_error(
502
-                esc_html__(
503
-                    'In order to duplicate an event an Event ID is required.  None was given.',
504
-                    'event_espresso'
505
-                ),
506
-                __FILE__,
507
-                __FUNCTION__,
508
-                __LINE__
509
-            );
510
-            $this->_redirect_after_action(false, '', '', array(), true);
511
-            return;
512
-        }
513
-        //k we've got EVT_ID so let's use that to get the event we'll duplicate
514
-        $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
515
-        if (! $orig_event instanceof EE_Event) {
516
-            throw new EE_Error(
517
-                sprintf(
518
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
519
-                    $this->_req_data['EVT_ID']
520
-                )
521
-            );
522
-        }
523
-        //k now let's clone the $orig_event before getting relations
524
-        $new_event = clone $orig_event;
525
-        //original datetimes
526
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
527
-        //other original relations
528
-        $orig_ven = $orig_event->get_many_related('Venue');
529
-        //reset the ID and modify other details to make it clear this is a dupe
530
-        $new_event->set('EVT_ID', 0);
531
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
532
-        $new_event->set('EVT_name', $new_name);
533
-        $new_event->set(
534
-            'EVT_slug',
535
-            wp_unique_post_slug(
536
-                sanitize_title($orig_event->name()),
537
-                0,
538
-                'publish',
539
-                'espresso_events',
540
-                0
541
-            )
542
-        );
543
-        $new_event->set('status', 'draft');
544
-        //duplicate discussion settings
545
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
546
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
547
-        //save the new event
548
-        $new_event->save();
549
-        //venues
550
-        foreach ($orig_ven as $ven) {
551
-            $new_event->_add_relation_to($ven, 'Venue');
552
-        }
553
-        $new_event->save();
554
-        //now we need to get the question group relations and handle that
555
-        //first primary question groups
556
-        $orig_primary_qgs = $orig_event->get_many_related(
557
-            'Question_Group',
558
-            array(array('Event_Question_Group.EQG_primary' => 1))
559
-        );
560
-        if (! empty($orig_primary_qgs)) {
561
-            foreach ($orig_primary_qgs as $id => $obj) {
562
-                if ($obj instanceof EE_Question_Group) {
563
-                    $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
564
-                }
565
-            }
566
-        }
567
-        //next additional attendee question groups
568
-        $orig_additional_qgs = $orig_event->get_many_related(
569
-            'Question_Group',
570
-            array(array('Event_Question_Group.EQG_primary' => 0))
571
-        );
572
-        if (! empty($orig_additional_qgs)) {
573
-            foreach ($orig_additional_qgs as $id => $obj) {
574
-                if ($obj instanceof EE_Question_Group) {
575
-                    $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
576
-                }
577
-            }
578
-        }
579
-        //now save
580
-        $new_event->save();
581
-        //k now that we have the new event saved we can loop through the datetimes and start adding relations.
582
-        $cloned_tickets = array();
583
-        foreach ($orig_datetimes as $orig_dtt) {
584
-            if (! $orig_dtt instanceof EE_Datetime) {
585
-                continue;
586
-            }
587
-            $new_dtt   = clone $orig_dtt;
588
-            $orig_tkts = $orig_dtt->tickets();
589
-            //save new dtt then add to event
590
-            $new_dtt->set('DTT_ID', 0);
591
-            $new_dtt->set('DTT_sold', 0);
592
-            $new_dtt->set_reserved(0);
593
-            $new_dtt->save();
594
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
595
-            $new_event->save();
596
-            //now let's get the ticket relations setup.
597
-            foreach ((array)$orig_tkts as $orig_tkt) {
598
-                //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
599
-                if (! $orig_tkt instanceof EE_Ticket) {
600
-                    continue;
601
-                }
602
-                //is this ticket archived?  If it is then let's skip
603
-                if ($orig_tkt->get('TKT_deleted')) {
604
-                    continue;
605
-                }
606
-                // does this original ticket already exist in the clone_tickets cache?
607
-                //  If so we'll just use the new ticket from it.
608
-                if (isset($cloned_tickets[$orig_tkt->ID()])) {
609
-                    $new_tkt = $cloned_tickets[$orig_tkt->ID()];
610
-                } else {
611
-                    $new_tkt = clone $orig_tkt;
612
-                    //get relations on the $orig_tkt that we need to setup.
613
-                    $orig_prices = $orig_tkt->prices();
614
-                    $new_tkt->set('TKT_ID', 0);
615
-                    $new_tkt->set('TKT_sold', 0);
616
-                    $new_tkt->set('TKT_reserved', 0);
617
-                    $new_tkt->save(); //make sure new ticket has ID.
618
-                    //price relations on new ticket need to be setup.
619
-                    foreach ($orig_prices as $orig_price) {
620
-                        $new_price = clone $orig_price;
621
-                        $new_price->set('PRC_ID', 0);
622
-                        $new_price->save();
623
-                        $new_tkt->_add_relation_to($new_price, 'Price');
624
-                        $new_tkt->save();
625
-                    }
626
-                }
627
-                // k now we can add the new ticket as a relation to the new datetime
628
-                // and make sure its added to our cached $cloned_tickets array
629
-                // for use with later datetimes that have the same ticket.
630
-                $new_dtt->_add_relation_to($new_tkt, 'Ticket');
631
-                $new_dtt->save();
632
-                $cloned_tickets[$orig_tkt->ID()] = $new_tkt;
633
-            }
634
-        }
635
-        //clone taxonomy information
636
-        $taxonomies_to_clone_with = apply_filters(
637
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
638
-            array('espresso_event_categories', 'espresso_event_type', 'post_tag')
639
-        );
640
-        //get terms for original event (notice)
641
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
642
-        //loop through terms and add them to new event.
643
-        foreach ($orig_terms as $term) {
644
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
645
-        }
646
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
647
-        //now let's redirect to the edit page for this duplicated event if we have a new event id.
648
-        if ($new_event->ID()) {
649
-            $redirect_args = array(
650
-                'post'   => $new_event->ID(),
651
-                'action' => 'edit',
652
-            );
653
-            EE_Error::add_success(
654
-                esc_html__(
655
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
656
-                    'event_espresso'
657
-                )
658
-            );
659
-        } else {
660
-            $redirect_args = array(
661
-                'action' => 'default',
662
-            );
663
-            EE_Error::add_error(
664
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
665
-                __FILE__,
666
-                __FUNCTION__,
667
-                __LINE__
668
-            );
669
-        }
670
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
671
-    }
672
-
673
-
674
-    /**
675
-     * Generates output for the import page.
676
-     * @throws DomainException
677
-     */
678
-    protected function _import_page()
679
-    {
680
-        $title                                      = esc_html__('Import', 'event_espresso');
681
-        $intro                                      = esc_html__(
682
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
683
-            'event_espresso'
684
-        );
685
-        $form_url                                   = EVENTS_ADMIN_URL;
686
-        $action                                     = 'import_events';
687
-        $type                                       = 'csv';
688
-        $this->_template_args['form']               = EE_Import::instance()->upload_form(
689
-            $title, $intro, $form_url, $action, $type
690
-        );
691
-        $this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
692
-            array('action' => 'sample_export_file'),
693
-            $this->_admin_base_url
694
-        );
695
-        $content                                    = EEH_Template::display_template(
696
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
697
-            $this->_template_args,
698
-            true
699
-        );
700
-        $this->_template_args['admin_page_content'] = $content;
701
-        $this->display_admin_page_with_sidebar();
702
-    }
703
-
704
-
705
-    /**
706
-     * _import_events
707
-     * This handles displaying the screen and running imports for importing events.
708
-     *
709
-     * @return void
710
-     */
711
-    protected function _import_events()
712
-    {
713
-        require_once(EE_CLASSES . 'EE_Import.class.php');
714
-        $success = EE_Import::instance()->import();
715
-        $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
716
-    }
717
-
718
-
719
-    /**
720
-     * _events_export
721
-     * Will export all (or just the given event) to a Excel compatible file.
722
-     *
723
-     * @access protected
724
-     * @return void
725
-     */
726
-    protected function _events_export()
727
-    {
728
-        if (isset($this->_req_data['EVT_ID'])) {
729
-            $event_ids = $this->_req_data['EVT_ID'];
730
-        } elseif (isset($this->_req_data['EVT_IDs'])) {
731
-            $event_ids = $this->_req_data['EVT_IDs'];
732
-        } else {
733
-            $event_ids = null;
734
-        }
735
-        //todo: I don't like doing this but it'll do until we modify EE_Export Class.
736
-        $new_request_args = array(
737
-            'export' => 'report',
738
-            'action' => 'all_event_data',
739
-            'EVT_ID' => $event_ids,
740
-        );
741
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
742
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
743
-            require_once(EE_CLASSES . 'EE_Export.class.php');
744
-            $EE_Export = EE_Export::instance($this->_req_data);
745
-            $EE_Export->export();
746
-        }
747
-    }
748
-
749
-
750
-    /**
751
-     * handle category exports()
752
-     *
753
-     * @return void
754
-     */
755
-    protected function _categories_export()
756
-    {
757
-        //todo: I don't like doing this but it'll do until we modify EE_Export Class.
758
-        $new_request_args = array(
759
-            'export'       => 'report',
760
-            'action'       => 'categories',
761
-            'category_ids' => $this->_req_data['EVT_CAT_ID'],
762
-        );
763
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
764
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
765
-            require_once(EE_CLASSES . 'EE_Export.class.php');
766
-            $EE_Export = EE_Export::instance($this->_req_data);
767
-            $EE_Export->export();
768
-        }
769
-    }
770
-
771
-
772
-    /**
773
-     * Creates a sample CSV file for importing
774
-     */
775
-    protected function _sample_export_file()
776
-    {
777
-        //		require_once(EE_CLASSES . 'EE_Export.class.php');
778
-        EE_Export::instance()->export_sample();
779
-    }
780
-
781
-
782
-    /*************        Template Settings        *************/
783
-    /**
784
-     * Generates template settings page output
785
-     * @throws DomainException
786
-     * @throws EE_Error
787
-     */
788
-    protected function _template_settings()
789
-    {
790
-        $this->_template_args['values'] = $this->_yes_no_values;
791
-        /**
792
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
793
-         * from General_Settings_Admin_Page to here.
794
-         */
795
-        $this->_template_args = apply_filters(
796
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
797
-            $this->_template_args
798
-        );
799
-        $this->_set_add_edit_form_tags('update_template_settings');
800
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
801
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
802
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
803
-            $this->_template_args,
804
-            true
805
-        );
806
-        $this->display_admin_page_with_sidebar();
807
-    }
808
-
809
-
810
-    /**
811
-     * Handler for updating template settings.
812
-     */
813
-    protected function _update_template_settings()
814
-    {
815
-        /**
816
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
817
-         * from General_Settings_Admin_Page to here.
818
-         */
819
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
820
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
821
-            EE_Registry::instance()->CFG->template_settings,
822
-            $this->_req_data
823
-        );
824
-        //update custom post type slugs and detect if we need to flush rewrite rules
825
-        $old_slug                                          = EE_Registry::instance()->CFG->core->event_cpt_slug;
826
-        EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
827
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
828
-            : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']);
829
-        $what                                              = 'Template Settings';
830
-        $success                                           = $this->_update_espresso_configuration(
831
-            $what,
832
-            EE_Registry::instance()->CFG->template_settings,
833
-            __FILE__,
834
-            __FUNCTION__,
835
-            __LINE__
836
-        );
837
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
838
-            update_option('ee_flush_rewrite_rules', true);
839
-        }
840
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
841
-    }
842
-
843
-
844
-    /**
845
-     * _premium_event_editor_meta_boxes
846
-     * add all metaboxes related to the event_editor
847
-     *
848
-     * @access protected
849
-     * @return void
850
-     * @throws EE_Error
851
-     */
852
-    protected function _premium_event_editor_meta_boxes()
853
-    {
854
-        $this->verify_cpt_object();
855
-        add_meta_box(
856
-            'espresso_event_editor_event_options',
857
-            esc_html__('Event Registration Options', 'event_espresso'),
858
-            array($this, 'registration_options_meta_box'),
859
-            $this->page_slug,
860
-            'side',
861
-            'core'
862
-        );
863
-    }
864
-
865
-
866
-    /**
867
-     * override caf metabox
868
-     *
869
-     * @return void
870
-     * @throws DomainException
871
-     */
872
-    public function registration_options_meta_box()
873
-    {
874
-        $yes_no_values                                    = array(
875
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
876
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
877
-        );
878
-        $default_reg_status_values                        = EEM_Registration::reg_status_array(
879
-            array(
880
-                EEM_Registration::status_id_cancelled,
881
-                EEM_Registration::status_id_declined,
882
-                EEM_Registration::status_id_incomplete,
883
-                EEM_Registration::status_id_wait_list,
884
-            ),
885
-            true
886
-        );
887
-        $template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
888
-        $template_args['_event']                          = $this->_cpt_model_obj;
889
-        $template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
890
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
891
-            'default_reg_status',
892
-            $default_reg_status_values,
893
-            $this->_cpt_model_obj->default_registration_status()
894
-        );
895
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
896
-            'display_desc',
897
-            $yes_no_values,
898
-            $this->_cpt_model_obj->display_description()
899
-        );
900
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
901
-            'display_ticket_selector',
902
-            $yes_no_values,
903
-            $this->_cpt_model_obj->display_ticket_selector(),
904
-            '',
905
-            '',
906
-            false
907
-        );
908
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
909
-            'EVT_default_registration_status',
910
-            $default_reg_status_values,
911
-            $this->_cpt_model_obj->default_registration_status()
912
-        );
913
-        $template_args['additional_registration_options'] = apply_filters(
914
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
915
-            '',
916
-            $template_args,
917
-            $yes_no_values,
918
-            $default_reg_status_values
919
-        );
920
-        EEH_Template::display_template(
921
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
922
-            $template_args
923
-        );
924
-    }
925
-
926
-
927
-
928
-    /**
929
-     * wp_list_table_mods for caf
930
-     * ============================
931
-     */
932
-    /**
933
-     * hook into list table filters and provide filters for caffeinated list table
934
-     *
935
-     * @param  array $old_filters    any existing filters present
936
-     * @param  array $list_table_obj the list table object
937
-     * @return array                  new filters
938
-     */
939
-    public function list_table_filters($old_filters, $list_table_obj)
940
-    {
941
-        $filters = array();
942
-        //first month/year filters
943
-        $filters[] = $this->espresso_event_months_dropdown();
944
-        $status    = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
945
-        //active status dropdown
946
-        if ($status !== 'draft') {
947
-            $filters[] = $this->active_status_dropdown(
948
-                isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
949
-            );
950
-        }
951
-        //category filter
952
-        $filters[] = $this->category_dropdown();
953
-        return array_merge($old_filters, $filters);
954
-    }
955
-
956
-
957
-    /**
958
-     * espresso_event_months_dropdown
959
-     *
960
-     * @access public
961
-     * @return string                dropdown listing month/year selections for events.
962
-     */
963
-    public function espresso_event_months_dropdown()
964
-    {
965
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
966
-        // Note we need to include any other filters that are set!
967
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
968
-        //categories?
969
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
970
-            ? $this->_req_data['EVT_CAT']
971
-            : null;
972
-        //active status?
973
-        $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
974
-        $cur_date      = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
975
-        return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
976
-    }
977
-
978
-
979
-    /**
980
-     * returns a list of "active" statuses on the event
981
-     *
982
-     * @param  string $current_value whatever the current active status is
983
-     * @return string
984
-     */
985
-    public function active_status_dropdown($current_value = '')
986
-    {
987
-        $select_name = 'active_status';
988
-        $values      = array(
989
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
990
-            'active'   => esc_html__('Active', 'event_espresso'),
991
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
992
-            'expired'  => esc_html__('Expired', 'event_espresso'),
993
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
994
-        );
995
-        $id          = 'id="espresso-active-status-dropdown-filter"';
996
-        $class       = 'wide';
997
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class);
998
-    }
999
-
1000
-
1001
-    /**
1002
-     * output a dropdown of the categories for the category filter on the event admin list table
1003
-     *
1004
-     * @access  public
1005
-     * @return string html
1006
-     */
1007
-    public function category_dropdown()
1008
-    {
1009
-        $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1010
-        return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1011
-    }
1012
-
1013
-
1014
-    /**
1015
-     * get total number of events today
1016
-     *
1017
-     * @access public
1018
-     * @return int
1019
-     * @throws EE_Error
1020
-     */
1021
-    public function total_events_today()
1022
-    {
1023
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1024
-            'DTT_EVT_start',
1025
-            date('Y-m-d') . ' 00:00:00',
1026
-            'Y-m-d H:i:s',
1027
-            'UTC'
1028
-        );
1029
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1030
-            'DTT_EVT_start',
1031
-            date('Y-m-d') . ' 23:59:59',
1032
-            'Y-m-d H:i:s',
1033
-            'UTC'
1034
-        );
1035
-        $where = array(
1036
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1037
-        );
1038
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1039
-        return $count;
1040
-    }
1041
-
1042
-
1043
-    /**
1044
-     * get total number of events this month
1045
-     *
1046
-     * @access public
1047
-     * @return int
1048
-     * @throws EE_Error
1049
-     */
1050
-    public function total_events_this_month()
1051
-    {
1052
-        //Dates
1053
-        $this_year_r     = date('Y');
1054
-        $this_month_r    = date('m');
1055
-        $days_this_month = date('t');
1056
-        $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1057
-            'DTT_EVT_start',
1058
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1059
-            'Y-m-d H:i:s',
1060
-            'UTC'
1061
-        );
1062
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1063
-            'DTT_EVT_start',
1064
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1065
-            'Y-m-d H:i:s',
1066
-            'UTC'
1067
-        );
1068
-        $where           = array(
1069
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1070
-        );
1071
-        $count           = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1072
-        return $count;
1073
-    }
1074
-
1075
-
1076
-    /** DEFAULT TICKETS STUFF **/
1077
-
1078
-    /**
1079
-     * Output default tickets list table view.
1080
-     */
1081
-    public function _tickets_overview_list_table()
1082
-    {
1083
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1084
-        $this->display_admin_list_table_page_with_no_sidebar();
1085
-    }
1086
-
1087
-
1088
-    /**
1089
-     * @param int  $per_page
1090
-     * @param bool $count
1091
-     * @param bool $trashed
1092
-     * @return \EE_Soft_Delete_Base_Class[]|int
1093
-     */
1094
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1095
-    {
1096
-        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1097
-        $order   = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1098
-        switch ($orderby) {
1099
-            case 'TKT_name':
1100
-                $orderby = array('TKT_name' => $order);
1101
-                break;
1102
-            case 'TKT_price':
1103
-                $orderby = array('TKT_price' => $order);
1104
-                break;
1105
-            case 'TKT_uses':
1106
-                $orderby = array('TKT_uses' => $order);
1107
-                break;
1108
-            case 'TKT_min':
1109
-                $orderby = array('TKT_min' => $order);
1110
-                break;
1111
-            case 'TKT_max':
1112
-                $orderby = array('TKT_max' => $order);
1113
-                break;
1114
-            case 'TKT_qty':
1115
-                $orderby = array('TKT_qty' => $order);
1116
-                break;
1117
-        }
1118
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1119
-            ? $this->_req_data['paged']
1120
-            : 1;
1121
-        $per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1122
-            ? $this->_req_data['perpage']
1123
-            : $per_page;
1124
-        $_where       = array(
1125
-            'TKT_is_default' => 1,
1126
-            'TKT_deleted'    => $trashed,
1127
-        );
1128
-        $offset       = ($current_page - 1) * $per_page;
1129
-        $limit        = array($offset, $per_page);
1130
-        if (isset($this->_req_data['s'])) {
1131
-            $sstr         = '%' . $this->_req_data['s'] . '%';
1132
-            $_where['OR'] = array(
1133
-                'TKT_name'        => array('LIKE', $sstr),
1134
-                'TKT_description' => array('LIKE', $sstr),
1135
-            );
1136
-        }
1137
-        $query_params = array(
1138
-            $_where,
1139
-            'order_by' => $orderby,
1140
-            'limit'    => $limit,
1141
-            'group_by' => 'TKT_ID',
1142
-        );
1143
-        if ($count) {
1144
-            return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1145
-        } else {
1146
-            return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1147
-        }
1148
-    }
1149
-
1150
-
1151
-    /**
1152
-     * @param bool $trash
1153
-     * @throws EE_Error
1154
-     */
1155
-    protected function _trash_or_restore_ticket($trash = false)
1156
-    {
1157
-        $success = 1;
1158
-        $TKT     = EEM_Ticket::instance();
1159
-        //checkboxes?
1160
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1161
-            //if array has more than one element then success message should be plural
1162
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1163
-            //cycle thru the boxes
1164
-            while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1165
-                if ($trash) {
1166
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1167
-                        $success = 0;
1168
-                    }
1169
-                } else {
1170
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1171
-                        $success = 0;
1172
-                    }
1173
-                }
1174
-            }
1175
-        } else {
1176
-            //grab single id and trash
1177
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1178
-            if ($trash) {
1179
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1180
-                    $success = 0;
1181
-                }
1182
-            } else {
1183
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1184
-                    $success = 0;
1185
-                }
1186
-            }
1187
-        }
1188
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1189
-        $query_args  = array(
1190
-            'action' => 'ticket_list_table',
1191
-            'status' => $trash ? '' : 'trashed',
1192
-        );
1193
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1194
-    }
1195
-
1196
-
1197
-    /**
1198
-     * Handles trashing default ticket.
1199
-     */
1200
-    protected function _delete_ticket()
1201
-    {
1202
-        $success = 1;
1203
-        //checkboxes?
1204
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1205
-            //if array has more than one element then success message should be plural
1206
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1207
-            //cycle thru the boxes
1208
-            while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1209
-                //delete
1210
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1211
-                    $success = 0;
1212
-                }
1213
-            }
1214
-        } else {
1215
-            //grab single id and trash
1216
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1217
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1218
-                $success = 0;
1219
-            }
1220
-        }
1221
-        $action_desc = 'deleted';
1222
-        $query_args  = array(
1223
-            'action' => 'ticket_list_table',
1224
-            'status' => 'trashed',
1225
-        );
1226
-        //fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1227
-        if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1228
-            array(array('TKT_is_default' => 1)),
1229
-            'TKT_ID',
1230
-            true
1231
-        )
1232
-        ) {
1233
-            $query_args = array();
1234
-        }
1235
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1236
-    }
1237
-
1238
-
1239
-    /**
1240
-     * @param int $TKT_ID
1241
-     * @return bool|int
1242
-     * @throws EE_Error
1243
-     */
1244
-    protected function _delete_the_ticket($TKT_ID)
1245
-    {
1246
-        $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1247
-        $tkt->_remove_relations('Datetime');
1248
-        //delete all related prices first
1249
-        $tkt->delete_related_permanently('Price');
1250
-        return $tkt->delete_permanently();
1251
-    }
17
+	/**
18
+	 * Extend_Events_Admin_Page constructor.
19
+	 *
20
+	 * @param bool $routing
21
+	 */
22
+	public function __construct($routing = true)
23
+	{
24
+		parent::__construct($routing);
25
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
26
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
27
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
28
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
29
+		}
30
+	}
31
+
32
+
33
+	/**
34
+	 * Sets routes.
35
+	 */
36
+	protected function _extend_page_config()
37
+	{
38
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
39
+		//is there a evt_id in the request?
40
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
41
+			? $this->_req_data['EVT_ID']
42
+			: 0;
43
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
44
+		//tkt_id?
45
+		$tkt_id             = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
46
+			? $this->_req_data['TKT_ID']
47
+			: 0;
48
+		$new_page_routes    = array(
49
+			'duplicate_event'          => array(
50
+				'func'       => '_duplicate_event',
51
+				'capability' => 'ee_edit_event',
52
+				'obj_id'     => $evt_id,
53
+				'noheader'   => true,
54
+			),
55
+			'ticket_list_table'        => array(
56
+				'func'       => '_tickets_overview_list_table',
57
+				'capability' => 'ee_read_default_tickets',
58
+			),
59
+			'trash_ticket'             => array(
60
+				'func'       => '_trash_or_restore_ticket',
61
+				'capability' => 'ee_delete_default_ticket',
62
+				'obj_id'     => $tkt_id,
63
+				'noheader'   => true,
64
+				'args'       => array('trash' => true),
65
+			),
66
+			'trash_tickets'            => array(
67
+				'func'       => '_trash_or_restore_ticket',
68
+				'capability' => 'ee_delete_default_tickets',
69
+				'noheader'   => true,
70
+				'args'       => array('trash' => true),
71
+			),
72
+			'restore_ticket'           => array(
73
+				'func'       => '_trash_or_restore_ticket',
74
+				'capability' => 'ee_delete_default_ticket',
75
+				'obj_id'     => $tkt_id,
76
+				'noheader'   => true,
77
+			),
78
+			'restore_tickets'          => array(
79
+				'func'       => '_trash_or_restore_ticket',
80
+				'capability' => 'ee_delete_default_tickets',
81
+				'noheader'   => true,
82
+			),
83
+			'delete_ticket'            => array(
84
+				'func'       => '_delete_ticket',
85
+				'capability' => 'ee_delete_default_ticket',
86
+				'obj_id'     => $tkt_id,
87
+				'noheader'   => true,
88
+			),
89
+			'delete_tickets'           => array(
90
+				'func'       => '_delete_ticket',
91
+				'capability' => 'ee_delete_default_tickets',
92
+				'noheader'   => true,
93
+			),
94
+			'import_page'              => array(
95
+				'func'       => '_import_page',
96
+				'capability' => 'import',
97
+			),
98
+			'import'                   => array(
99
+				'func'       => '_import_events',
100
+				'capability' => 'import',
101
+				'noheader'   => true,
102
+			),
103
+			'import_events'            => array(
104
+				'func'       => '_import_events',
105
+				'capability' => 'import',
106
+				'noheader'   => true,
107
+			),
108
+			'export_events'            => array(
109
+				'func'       => '_events_export',
110
+				'capability' => 'export',
111
+				'noheader'   => true,
112
+			),
113
+			'export_categories'        => array(
114
+				'func'       => '_categories_export',
115
+				'capability' => 'export',
116
+				'noheader'   => true,
117
+			),
118
+			'sample_export_file'       => array(
119
+				'func'       => '_sample_export_file',
120
+				'capability' => 'export',
121
+				'noheader'   => true,
122
+			),
123
+			'update_template_settings' => array(
124
+				'func'       => '_update_template_settings',
125
+				'capability' => 'manage_options',
126
+				'noheader'   => true,
127
+			),
128
+		);
129
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
130
+		//partial route/config override
131
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
132
+		$this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
133
+		$this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
134
+		$this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
135
+		$this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
136
+		$this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
137
+		//add tickets tab but only if there are more than one default ticket!
138
+		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
139
+			array(array('TKT_is_default' => 1)),
140
+			'TKT_ID',
141
+			true
142
+		);
143
+		if ($tkt_count > 1) {
144
+			$new_page_config = array(
145
+				'ticket_list_table' => array(
146
+					'nav'           => array(
147
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
148
+						'order' => 60,
149
+					),
150
+					'list_table'    => 'Tickets_List_Table',
151
+					'require_nonce' => false,
152
+				),
153
+			);
154
+		}
155
+		//template settings
156
+		$new_page_config['template_settings'] = array(
157
+			'nav'           => array(
158
+				'label' => esc_html__('Templates', 'event_espresso'),
159
+				'order' => 30,
160
+			),
161
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
162
+			'help_tabs'     => array(
163
+				'general_settings_templates_help_tab' => array(
164
+					'title'    => esc_html__('Templates', 'event_espresso'),
165
+					'filename' => 'general_settings_templates',
166
+				),
167
+			),
168
+			'help_tour'     => array('Templates_Help_Tour'),
169
+			'require_nonce' => false,
170
+		);
171
+		$this->_page_config                   = array_merge($this->_page_config, $new_page_config);
172
+		//add filters and actions
173
+		//modifying _views
174
+		add_filter(
175
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
176
+			array($this, 'add_additional_datetime_button'),
177
+			10,
178
+			2
179
+		);
180
+		add_filter(
181
+			'FHEE_event_datetime_metabox_clone_button_template',
182
+			array($this, 'add_datetime_clone_button'),
183
+			10,
184
+			2
185
+		);
186
+		add_filter(
187
+			'FHEE_event_datetime_metabox_timezones_template',
188
+			array($this, 'datetime_timezones_template'),
189
+			10,
190
+			2
191
+		);
192
+		//filters for event list table
193
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
194
+		add_filter(
195
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
196
+			array($this, 'extra_list_table_actions'),
197
+			10,
198
+			2
199
+		);
200
+		//legend item
201
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
202
+		add_action('admin_init', array($this, 'admin_init'));
203
+		//heartbeat stuff
204
+		add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2);
205
+	}
206
+
207
+
208
+	/**
209
+	 * admin_init
210
+	 */
211
+	public function admin_init()
212
+	{
213
+		EE_Registry::$i18n_js_strings = array_merge(
214
+			EE_Registry::$i18n_js_strings,
215
+			array(
216
+				'image_confirm'          => esc_html__(
217
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
218
+					'event_espresso'
219
+				),
220
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
221
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
222
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
223
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
224
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
225
+			)
226
+		);
227
+	}
228
+
229
+
230
+	/**
231
+	 * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle
232
+	 * accordingly.
233
+	 *
234
+	 * @param array $response The existing heartbeat response array.
235
+	 * @param array $data     The incoming data package.
236
+	 * @return array  possibly appended response.
237
+	 */
238
+	public function heartbeat_response($response, $data)
239
+	{
240
+		/**
241
+		 * check whether count of tickets is approaching the potential
242
+		 * limits for the server.
243
+		 */
244
+		if (! empty($data['input_count'])) {
245
+			$response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check(
246
+				$data['input_count']
247
+			);
248
+		}
249
+		return $response;
250
+	}
251
+
252
+
253
+	/**
254
+	 * Add per page screen options to the default ticket list table view.
255
+	 */
256
+	protected function _add_screen_options_ticket_list_table()
257
+	{
258
+		$this->_per_page_screen_option();
259
+	}
260
+
261
+
262
+	/**
263
+	 * @param string $return
264
+	 * @param int    $id
265
+	 * @param string $new_title
266
+	 * @param string $new_slug
267
+	 * @return string
268
+	 */
269
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
270
+	{
271
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
272
+		//make sure this is only when editing
273
+		if (! empty($id)) {
274
+			$href   = EE_Admin_Page::add_query_args_and_nonce(
275
+				array('action' => 'duplicate_event', 'EVT_ID' => $id),
276
+				$this->_admin_base_url
277
+			);
278
+			$title  = esc_attr__('Duplicate Event', 'event_espresso');
279
+			$return .= '<a href="'
280
+					   . $href
281
+					   . '" title="'
282
+					   . $title
283
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
284
+					   . $title
285
+					   . '</button>';
286
+		}
287
+		return $return;
288
+	}
289
+
290
+
291
+	/**
292
+	 * Set the list table views for the default ticket list table view.
293
+	 */
294
+	public function _set_list_table_views_ticket_list_table()
295
+	{
296
+		$this->_views = array(
297
+			'all'     => array(
298
+				'slug'        => 'all',
299
+				'label'       => esc_html__('All', 'event_espresso'),
300
+				'count'       => 0,
301
+				'bulk_action' => array(
302
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
303
+				),
304
+			),
305
+			'trashed' => array(
306
+				'slug'        => 'trashed',
307
+				'label'       => esc_html__('Trash', 'event_espresso'),
308
+				'count'       => 0,
309
+				'bulk_action' => array(
310
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
311
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
312
+				),
313
+			),
314
+		);
315
+	}
316
+
317
+
318
+	/**
319
+	 * Enqueue scripts and styles for the event editor.
320
+	 */
321
+	public function load_scripts_styles_edit()
322
+	{
323
+		wp_register_script(
324
+			'ee-event-editor-heartbeat',
325
+			EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
326
+			array('ee_admin_js', 'heartbeat'),
327
+			EVENT_ESPRESSO_VERSION,
328
+			true
329
+		);
330
+		wp_enqueue_script('ee-accounting');
331
+		//styles
332
+		wp_enqueue_style('espresso-ui-theme');
333
+		wp_enqueue_script('event_editor_js');
334
+		wp_enqueue_script('ee-event-editor-heartbeat');
335
+	}
336
+
337
+
338
+	/**
339
+	 * Returns template for the additional datetime.
340
+	 * @param $template
341
+	 * @param $template_args
342
+	 * @return mixed
343
+	 * @throws DomainException
344
+	 */
345
+	public function add_additional_datetime_button($template, $template_args)
346
+	{
347
+		return EEH_Template::display_template(
348
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
349
+			$template_args,
350
+			true
351
+		);
352
+	}
353
+
354
+
355
+	/**
356
+	 * Returns the template for cloning a datetime.
357
+	 * @param $template
358
+	 * @param $template_args
359
+	 * @return mixed
360
+	 * @throws DomainException
361
+	 */
362
+	public function add_datetime_clone_button($template, $template_args)
363
+	{
364
+		return EEH_Template::display_template(
365
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
366
+			$template_args,
367
+			true
368
+		);
369
+	}
370
+
371
+
372
+	/**
373
+	 * Returns the template for datetime timezones.
374
+	 * @param $template
375
+	 * @param $template_args
376
+	 * @return mixed
377
+	 * @throws DomainException
378
+	 */
379
+	public function datetime_timezones_template($template, $template_args)
380
+	{
381
+		return EEH_Template::display_template(
382
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
383
+			$template_args,
384
+			true
385
+		);
386
+	}
387
+
388
+
389
+	/**
390
+	 * Sets the views for the default list table view.
391
+	 */
392
+	protected function _set_list_table_views_default()
393
+	{
394
+		parent::_set_list_table_views_default();
395
+		$new_views    = array(
396
+			'today' => array(
397
+				'slug'        => 'today',
398
+				'label'       => esc_html__('Today', 'event_espresso'),
399
+				'count'       => $this->total_events_today(),
400
+				'bulk_action' => array(
401
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
402
+				),
403
+			),
404
+			'month' => array(
405
+				'slug'        => 'month',
406
+				'label'       => esc_html__('This Month', 'event_espresso'),
407
+				'count'       => $this->total_events_this_month(),
408
+				'bulk_action' => array(
409
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
410
+				),
411
+			),
412
+		);
413
+		$this->_views = array_merge($this->_views, $new_views);
414
+	}
415
+
416
+
417
+	/**
418
+	 * Returns the extra action links for the default list table view.
419
+	 * @param array     $action_links
420
+	 * @param \EE_Event $event
421
+	 * @return array
422
+	 * @throws EE_Error
423
+	 */
424
+	public function extra_list_table_actions(array $action_links, \EE_Event $event)
425
+	{
426
+		if (EE_Registry::instance()->CAP->current_user_can(
427
+			'ee_read_registrations',
428
+			'espresso_registrations_reports',
429
+			$event->ID()
430
+		)
431
+		) {
432
+			$reports_query_args = array(
433
+				'action' => 'reports',
434
+				'EVT_ID' => $event->ID(),
435
+			);
436
+			$reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
437
+			$action_links[]     = '<a href="'
438
+								  . $reports_link
439
+								  . '" title="'
440
+								  . esc_attr__('View Report', 'event_espresso')
441
+								  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
442
+								  . "\n\t";
443
+		}
444
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
445
+			EE_Registry::instance()->load_helper('MSG_Template');
446
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
447
+				'see_notifications_for',
448
+				null,
449
+				array('EVT_ID' => $event->ID())
450
+			);
451
+		}
452
+		return $action_links;
453
+	}
454
+
455
+
456
+	/**
457
+	 * @param $items
458
+	 * @return mixed
459
+	 */
460
+	public function additional_legend_items($items)
461
+	{
462
+		if (EE_Registry::instance()->CAP->current_user_can(
463
+			'ee_read_registrations',
464
+			'espresso_registrations_reports'
465
+		)
466
+		) {
467
+			$items['reports'] = array(
468
+				'class' => 'dashicons dashicons-chart-bar',
469
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
470
+			);
471
+		}
472
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
473
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
474
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
475
+				$items['view_related_messages'] = array(
476
+					'class' => $related_for_icon['css_class'],
477
+					'desc'  => $related_for_icon['label'],
478
+				);
479
+			}
480
+		}
481
+		return $items;
482
+	}
483
+
484
+
485
+	/**
486
+	 * This is the callback method for the duplicate event route
487
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
488
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
489
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
490
+	 * After duplication the redirect is to the new event edit page.
491
+	 *
492
+	 * @return void
493
+	 * @access protected
494
+	 * @throws EE_Error If EE_Event is not available with given ID
495
+	 */
496
+	protected function _duplicate_event()
497
+	{
498
+		// first make sure the ID for the event is in the request.
499
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
500
+		if (! isset($this->_req_data['EVT_ID'])) {
501
+			EE_Error::add_error(
502
+				esc_html__(
503
+					'In order to duplicate an event an Event ID is required.  None was given.',
504
+					'event_espresso'
505
+				),
506
+				__FILE__,
507
+				__FUNCTION__,
508
+				__LINE__
509
+			);
510
+			$this->_redirect_after_action(false, '', '', array(), true);
511
+			return;
512
+		}
513
+		//k we've got EVT_ID so let's use that to get the event we'll duplicate
514
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
515
+		if (! $orig_event instanceof EE_Event) {
516
+			throw new EE_Error(
517
+				sprintf(
518
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
519
+					$this->_req_data['EVT_ID']
520
+				)
521
+			);
522
+		}
523
+		//k now let's clone the $orig_event before getting relations
524
+		$new_event = clone $orig_event;
525
+		//original datetimes
526
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
527
+		//other original relations
528
+		$orig_ven = $orig_event->get_many_related('Venue');
529
+		//reset the ID and modify other details to make it clear this is a dupe
530
+		$new_event->set('EVT_ID', 0);
531
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
532
+		$new_event->set('EVT_name', $new_name);
533
+		$new_event->set(
534
+			'EVT_slug',
535
+			wp_unique_post_slug(
536
+				sanitize_title($orig_event->name()),
537
+				0,
538
+				'publish',
539
+				'espresso_events',
540
+				0
541
+			)
542
+		);
543
+		$new_event->set('status', 'draft');
544
+		//duplicate discussion settings
545
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
546
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
547
+		//save the new event
548
+		$new_event->save();
549
+		//venues
550
+		foreach ($orig_ven as $ven) {
551
+			$new_event->_add_relation_to($ven, 'Venue');
552
+		}
553
+		$new_event->save();
554
+		//now we need to get the question group relations and handle that
555
+		//first primary question groups
556
+		$orig_primary_qgs = $orig_event->get_many_related(
557
+			'Question_Group',
558
+			array(array('Event_Question_Group.EQG_primary' => 1))
559
+		);
560
+		if (! empty($orig_primary_qgs)) {
561
+			foreach ($orig_primary_qgs as $id => $obj) {
562
+				if ($obj instanceof EE_Question_Group) {
563
+					$new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
564
+				}
565
+			}
566
+		}
567
+		//next additional attendee question groups
568
+		$orig_additional_qgs = $orig_event->get_many_related(
569
+			'Question_Group',
570
+			array(array('Event_Question_Group.EQG_primary' => 0))
571
+		);
572
+		if (! empty($orig_additional_qgs)) {
573
+			foreach ($orig_additional_qgs as $id => $obj) {
574
+				if ($obj instanceof EE_Question_Group) {
575
+					$new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
576
+				}
577
+			}
578
+		}
579
+		//now save
580
+		$new_event->save();
581
+		//k now that we have the new event saved we can loop through the datetimes and start adding relations.
582
+		$cloned_tickets = array();
583
+		foreach ($orig_datetimes as $orig_dtt) {
584
+			if (! $orig_dtt instanceof EE_Datetime) {
585
+				continue;
586
+			}
587
+			$new_dtt   = clone $orig_dtt;
588
+			$orig_tkts = $orig_dtt->tickets();
589
+			//save new dtt then add to event
590
+			$new_dtt->set('DTT_ID', 0);
591
+			$new_dtt->set('DTT_sold', 0);
592
+			$new_dtt->set_reserved(0);
593
+			$new_dtt->save();
594
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
595
+			$new_event->save();
596
+			//now let's get the ticket relations setup.
597
+			foreach ((array)$orig_tkts as $orig_tkt) {
598
+				//it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
599
+				if (! $orig_tkt instanceof EE_Ticket) {
600
+					continue;
601
+				}
602
+				//is this ticket archived?  If it is then let's skip
603
+				if ($orig_tkt->get('TKT_deleted')) {
604
+					continue;
605
+				}
606
+				// does this original ticket already exist in the clone_tickets cache?
607
+				//  If so we'll just use the new ticket from it.
608
+				if (isset($cloned_tickets[$orig_tkt->ID()])) {
609
+					$new_tkt = $cloned_tickets[$orig_tkt->ID()];
610
+				} else {
611
+					$new_tkt = clone $orig_tkt;
612
+					//get relations on the $orig_tkt that we need to setup.
613
+					$orig_prices = $orig_tkt->prices();
614
+					$new_tkt->set('TKT_ID', 0);
615
+					$new_tkt->set('TKT_sold', 0);
616
+					$new_tkt->set('TKT_reserved', 0);
617
+					$new_tkt->save(); //make sure new ticket has ID.
618
+					//price relations on new ticket need to be setup.
619
+					foreach ($orig_prices as $orig_price) {
620
+						$new_price = clone $orig_price;
621
+						$new_price->set('PRC_ID', 0);
622
+						$new_price->save();
623
+						$new_tkt->_add_relation_to($new_price, 'Price');
624
+						$new_tkt->save();
625
+					}
626
+				}
627
+				// k now we can add the new ticket as a relation to the new datetime
628
+				// and make sure its added to our cached $cloned_tickets array
629
+				// for use with later datetimes that have the same ticket.
630
+				$new_dtt->_add_relation_to($new_tkt, 'Ticket');
631
+				$new_dtt->save();
632
+				$cloned_tickets[$orig_tkt->ID()] = $new_tkt;
633
+			}
634
+		}
635
+		//clone taxonomy information
636
+		$taxonomies_to_clone_with = apply_filters(
637
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
638
+			array('espresso_event_categories', 'espresso_event_type', 'post_tag')
639
+		);
640
+		//get terms for original event (notice)
641
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
642
+		//loop through terms and add them to new event.
643
+		foreach ($orig_terms as $term) {
644
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
645
+		}
646
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
647
+		//now let's redirect to the edit page for this duplicated event if we have a new event id.
648
+		if ($new_event->ID()) {
649
+			$redirect_args = array(
650
+				'post'   => $new_event->ID(),
651
+				'action' => 'edit',
652
+			);
653
+			EE_Error::add_success(
654
+				esc_html__(
655
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
656
+					'event_espresso'
657
+				)
658
+			);
659
+		} else {
660
+			$redirect_args = array(
661
+				'action' => 'default',
662
+			);
663
+			EE_Error::add_error(
664
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
665
+				__FILE__,
666
+				__FUNCTION__,
667
+				__LINE__
668
+			);
669
+		}
670
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
671
+	}
672
+
673
+
674
+	/**
675
+	 * Generates output for the import page.
676
+	 * @throws DomainException
677
+	 */
678
+	protected function _import_page()
679
+	{
680
+		$title                                      = esc_html__('Import', 'event_espresso');
681
+		$intro                                      = esc_html__(
682
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
683
+			'event_espresso'
684
+		);
685
+		$form_url                                   = EVENTS_ADMIN_URL;
686
+		$action                                     = 'import_events';
687
+		$type                                       = 'csv';
688
+		$this->_template_args['form']               = EE_Import::instance()->upload_form(
689
+			$title, $intro, $form_url, $action, $type
690
+		);
691
+		$this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
692
+			array('action' => 'sample_export_file'),
693
+			$this->_admin_base_url
694
+		);
695
+		$content                                    = EEH_Template::display_template(
696
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
697
+			$this->_template_args,
698
+			true
699
+		);
700
+		$this->_template_args['admin_page_content'] = $content;
701
+		$this->display_admin_page_with_sidebar();
702
+	}
703
+
704
+
705
+	/**
706
+	 * _import_events
707
+	 * This handles displaying the screen and running imports for importing events.
708
+	 *
709
+	 * @return void
710
+	 */
711
+	protected function _import_events()
712
+	{
713
+		require_once(EE_CLASSES . 'EE_Import.class.php');
714
+		$success = EE_Import::instance()->import();
715
+		$this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
716
+	}
717
+
718
+
719
+	/**
720
+	 * _events_export
721
+	 * Will export all (or just the given event) to a Excel compatible file.
722
+	 *
723
+	 * @access protected
724
+	 * @return void
725
+	 */
726
+	protected function _events_export()
727
+	{
728
+		if (isset($this->_req_data['EVT_ID'])) {
729
+			$event_ids = $this->_req_data['EVT_ID'];
730
+		} elseif (isset($this->_req_data['EVT_IDs'])) {
731
+			$event_ids = $this->_req_data['EVT_IDs'];
732
+		} else {
733
+			$event_ids = null;
734
+		}
735
+		//todo: I don't like doing this but it'll do until we modify EE_Export Class.
736
+		$new_request_args = array(
737
+			'export' => 'report',
738
+			'action' => 'all_event_data',
739
+			'EVT_ID' => $event_ids,
740
+		);
741
+		$this->_req_data  = array_merge($this->_req_data, $new_request_args);
742
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
743
+			require_once(EE_CLASSES . 'EE_Export.class.php');
744
+			$EE_Export = EE_Export::instance($this->_req_data);
745
+			$EE_Export->export();
746
+		}
747
+	}
748
+
749
+
750
+	/**
751
+	 * handle category exports()
752
+	 *
753
+	 * @return void
754
+	 */
755
+	protected function _categories_export()
756
+	{
757
+		//todo: I don't like doing this but it'll do until we modify EE_Export Class.
758
+		$new_request_args = array(
759
+			'export'       => 'report',
760
+			'action'       => 'categories',
761
+			'category_ids' => $this->_req_data['EVT_CAT_ID'],
762
+		);
763
+		$this->_req_data  = array_merge($this->_req_data, $new_request_args);
764
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
765
+			require_once(EE_CLASSES . 'EE_Export.class.php');
766
+			$EE_Export = EE_Export::instance($this->_req_data);
767
+			$EE_Export->export();
768
+		}
769
+	}
770
+
771
+
772
+	/**
773
+	 * Creates a sample CSV file for importing
774
+	 */
775
+	protected function _sample_export_file()
776
+	{
777
+		//		require_once(EE_CLASSES . 'EE_Export.class.php');
778
+		EE_Export::instance()->export_sample();
779
+	}
780
+
781
+
782
+	/*************        Template Settings        *************/
783
+	/**
784
+	 * Generates template settings page output
785
+	 * @throws DomainException
786
+	 * @throws EE_Error
787
+	 */
788
+	protected function _template_settings()
789
+	{
790
+		$this->_template_args['values'] = $this->_yes_no_values;
791
+		/**
792
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
793
+		 * from General_Settings_Admin_Page to here.
794
+		 */
795
+		$this->_template_args = apply_filters(
796
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
797
+			$this->_template_args
798
+		);
799
+		$this->_set_add_edit_form_tags('update_template_settings');
800
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
801
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
802
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
803
+			$this->_template_args,
804
+			true
805
+		);
806
+		$this->display_admin_page_with_sidebar();
807
+	}
808
+
809
+
810
+	/**
811
+	 * Handler for updating template settings.
812
+	 */
813
+	protected function _update_template_settings()
814
+	{
815
+		/**
816
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
817
+		 * from General_Settings_Admin_Page to here.
818
+		 */
819
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
820
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
821
+			EE_Registry::instance()->CFG->template_settings,
822
+			$this->_req_data
823
+		);
824
+		//update custom post type slugs and detect if we need to flush rewrite rules
825
+		$old_slug                                          = EE_Registry::instance()->CFG->core->event_cpt_slug;
826
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
827
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
828
+			: sanitize_title_with_dashes($this->_req_data['event_cpt_slug']);
829
+		$what                                              = 'Template Settings';
830
+		$success                                           = $this->_update_espresso_configuration(
831
+			$what,
832
+			EE_Registry::instance()->CFG->template_settings,
833
+			__FILE__,
834
+			__FUNCTION__,
835
+			__LINE__
836
+		);
837
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
838
+			update_option('ee_flush_rewrite_rules', true);
839
+		}
840
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
841
+	}
842
+
843
+
844
+	/**
845
+	 * _premium_event_editor_meta_boxes
846
+	 * add all metaboxes related to the event_editor
847
+	 *
848
+	 * @access protected
849
+	 * @return void
850
+	 * @throws EE_Error
851
+	 */
852
+	protected function _premium_event_editor_meta_boxes()
853
+	{
854
+		$this->verify_cpt_object();
855
+		add_meta_box(
856
+			'espresso_event_editor_event_options',
857
+			esc_html__('Event Registration Options', 'event_espresso'),
858
+			array($this, 'registration_options_meta_box'),
859
+			$this->page_slug,
860
+			'side',
861
+			'core'
862
+		);
863
+	}
864
+
865
+
866
+	/**
867
+	 * override caf metabox
868
+	 *
869
+	 * @return void
870
+	 * @throws DomainException
871
+	 */
872
+	public function registration_options_meta_box()
873
+	{
874
+		$yes_no_values                                    = array(
875
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
876
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
877
+		);
878
+		$default_reg_status_values                        = EEM_Registration::reg_status_array(
879
+			array(
880
+				EEM_Registration::status_id_cancelled,
881
+				EEM_Registration::status_id_declined,
882
+				EEM_Registration::status_id_incomplete,
883
+				EEM_Registration::status_id_wait_list,
884
+			),
885
+			true
886
+		);
887
+		$template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
888
+		$template_args['_event']                          = $this->_cpt_model_obj;
889
+		$template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
890
+		$template_args['default_registration_status']     = EEH_Form_Fields::select_input(
891
+			'default_reg_status',
892
+			$default_reg_status_values,
893
+			$this->_cpt_model_obj->default_registration_status()
894
+		);
895
+		$template_args['display_description']             = EEH_Form_Fields::select_input(
896
+			'display_desc',
897
+			$yes_no_values,
898
+			$this->_cpt_model_obj->display_description()
899
+		);
900
+		$template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
901
+			'display_ticket_selector',
902
+			$yes_no_values,
903
+			$this->_cpt_model_obj->display_ticket_selector(),
904
+			'',
905
+			'',
906
+			false
907
+		);
908
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
909
+			'EVT_default_registration_status',
910
+			$default_reg_status_values,
911
+			$this->_cpt_model_obj->default_registration_status()
912
+		);
913
+		$template_args['additional_registration_options'] = apply_filters(
914
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
915
+			'',
916
+			$template_args,
917
+			$yes_no_values,
918
+			$default_reg_status_values
919
+		);
920
+		EEH_Template::display_template(
921
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
922
+			$template_args
923
+		);
924
+	}
925
+
926
+
927
+
928
+	/**
929
+	 * wp_list_table_mods for caf
930
+	 * ============================
931
+	 */
932
+	/**
933
+	 * hook into list table filters and provide filters for caffeinated list table
934
+	 *
935
+	 * @param  array $old_filters    any existing filters present
936
+	 * @param  array $list_table_obj the list table object
937
+	 * @return array                  new filters
938
+	 */
939
+	public function list_table_filters($old_filters, $list_table_obj)
940
+	{
941
+		$filters = array();
942
+		//first month/year filters
943
+		$filters[] = $this->espresso_event_months_dropdown();
944
+		$status    = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
945
+		//active status dropdown
946
+		if ($status !== 'draft') {
947
+			$filters[] = $this->active_status_dropdown(
948
+				isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
949
+			);
950
+		}
951
+		//category filter
952
+		$filters[] = $this->category_dropdown();
953
+		return array_merge($old_filters, $filters);
954
+	}
955
+
956
+
957
+	/**
958
+	 * espresso_event_months_dropdown
959
+	 *
960
+	 * @access public
961
+	 * @return string                dropdown listing month/year selections for events.
962
+	 */
963
+	public function espresso_event_months_dropdown()
964
+	{
965
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
966
+		// Note we need to include any other filters that are set!
967
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
968
+		//categories?
969
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
970
+			? $this->_req_data['EVT_CAT']
971
+			: null;
972
+		//active status?
973
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
974
+		$cur_date      = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
975
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
976
+	}
977
+
978
+
979
+	/**
980
+	 * returns a list of "active" statuses on the event
981
+	 *
982
+	 * @param  string $current_value whatever the current active status is
983
+	 * @return string
984
+	 */
985
+	public function active_status_dropdown($current_value = '')
986
+	{
987
+		$select_name = 'active_status';
988
+		$values      = array(
989
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
990
+			'active'   => esc_html__('Active', 'event_espresso'),
991
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
992
+			'expired'  => esc_html__('Expired', 'event_espresso'),
993
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
994
+		);
995
+		$id          = 'id="espresso-active-status-dropdown-filter"';
996
+		$class       = 'wide';
997
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class);
998
+	}
999
+
1000
+
1001
+	/**
1002
+	 * output a dropdown of the categories for the category filter on the event admin list table
1003
+	 *
1004
+	 * @access  public
1005
+	 * @return string html
1006
+	 */
1007
+	public function category_dropdown()
1008
+	{
1009
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1010
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1011
+	}
1012
+
1013
+
1014
+	/**
1015
+	 * get total number of events today
1016
+	 *
1017
+	 * @access public
1018
+	 * @return int
1019
+	 * @throws EE_Error
1020
+	 */
1021
+	public function total_events_today()
1022
+	{
1023
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1024
+			'DTT_EVT_start',
1025
+			date('Y-m-d') . ' 00:00:00',
1026
+			'Y-m-d H:i:s',
1027
+			'UTC'
1028
+		);
1029
+		$end   = EEM_Datetime::instance()->convert_datetime_for_query(
1030
+			'DTT_EVT_start',
1031
+			date('Y-m-d') . ' 23:59:59',
1032
+			'Y-m-d H:i:s',
1033
+			'UTC'
1034
+		);
1035
+		$where = array(
1036
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1037
+		);
1038
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1039
+		return $count;
1040
+	}
1041
+
1042
+
1043
+	/**
1044
+	 * get total number of events this month
1045
+	 *
1046
+	 * @access public
1047
+	 * @return int
1048
+	 * @throws EE_Error
1049
+	 */
1050
+	public function total_events_this_month()
1051
+	{
1052
+		//Dates
1053
+		$this_year_r     = date('Y');
1054
+		$this_month_r    = date('m');
1055
+		$days_this_month = date('t');
1056
+		$start           = EEM_Datetime::instance()->convert_datetime_for_query(
1057
+			'DTT_EVT_start',
1058
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1059
+			'Y-m-d H:i:s',
1060
+			'UTC'
1061
+		);
1062
+		$end             = EEM_Datetime::instance()->convert_datetime_for_query(
1063
+			'DTT_EVT_start',
1064
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1065
+			'Y-m-d H:i:s',
1066
+			'UTC'
1067
+		);
1068
+		$where           = array(
1069
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1070
+		);
1071
+		$count           = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1072
+		return $count;
1073
+	}
1074
+
1075
+
1076
+	/** DEFAULT TICKETS STUFF **/
1077
+
1078
+	/**
1079
+	 * Output default tickets list table view.
1080
+	 */
1081
+	public function _tickets_overview_list_table()
1082
+	{
1083
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1084
+		$this->display_admin_list_table_page_with_no_sidebar();
1085
+	}
1086
+
1087
+
1088
+	/**
1089
+	 * @param int  $per_page
1090
+	 * @param bool $count
1091
+	 * @param bool $trashed
1092
+	 * @return \EE_Soft_Delete_Base_Class[]|int
1093
+	 */
1094
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1095
+	{
1096
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1097
+		$order   = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1098
+		switch ($orderby) {
1099
+			case 'TKT_name':
1100
+				$orderby = array('TKT_name' => $order);
1101
+				break;
1102
+			case 'TKT_price':
1103
+				$orderby = array('TKT_price' => $order);
1104
+				break;
1105
+			case 'TKT_uses':
1106
+				$orderby = array('TKT_uses' => $order);
1107
+				break;
1108
+			case 'TKT_min':
1109
+				$orderby = array('TKT_min' => $order);
1110
+				break;
1111
+			case 'TKT_max':
1112
+				$orderby = array('TKT_max' => $order);
1113
+				break;
1114
+			case 'TKT_qty':
1115
+				$orderby = array('TKT_qty' => $order);
1116
+				break;
1117
+		}
1118
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1119
+			? $this->_req_data['paged']
1120
+			: 1;
1121
+		$per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1122
+			? $this->_req_data['perpage']
1123
+			: $per_page;
1124
+		$_where       = array(
1125
+			'TKT_is_default' => 1,
1126
+			'TKT_deleted'    => $trashed,
1127
+		);
1128
+		$offset       = ($current_page - 1) * $per_page;
1129
+		$limit        = array($offset, $per_page);
1130
+		if (isset($this->_req_data['s'])) {
1131
+			$sstr         = '%' . $this->_req_data['s'] . '%';
1132
+			$_where['OR'] = array(
1133
+				'TKT_name'        => array('LIKE', $sstr),
1134
+				'TKT_description' => array('LIKE', $sstr),
1135
+			);
1136
+		}
1137
+		$query_params = array(
1138
+			$_where,
1139
+			'order_by' => $orderby,
1140
+			'limit'    => $limit,
1141
+			'group_by' => 'TKT_ID',
1142
+		);
1143
+		if ($count) {
1144
+			return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1145
+		} else {
1146
+			return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1147
+		}
1148
+	}
1149
+
1150
+
1151
+	/**
1152
+	 * @param bool $trash
1153
+	 * @throws EE_Error
1154
+	 */
1155
+	protected function _trash_or_restore_ticket($trash = false)
1156
+	{
1157
+		$success = 1;
1158
+		$TKT     = EEM_Ticket::instance();
1159
+		//checkboxes?
1160
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1161
+			//if array has more than one element then success message should be plural
1162
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1163
+			//cycle thru the boxes
1164
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1165
+				if ($trash) {
1166
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1167
+						$success = 0;
1168
+					}
1169
+				} else {
1170
+					if (! $TKT->restore_by_ID($TKT_ID)) {
1171
+						$success = 0;
1172
+					}
1173
+				}
1174
+			}
1175
+		} else {
1176
+			//grab single id and trash
1177
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1178
+			if ($trash) {
1179
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1180
+					$success = 0;
1181
+				}
1182
+			} else {
1183
+				if (! $TKT->restore_by_ID($TKT_ID)) {
1184
+					$success = 0;
1185
+				}
1186
+			}
1187
+		}
1188
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1189
+		$query_args  = array(
1190
+			'action' => 'ticket_list_table',
1191
+			'status' => $trash ? '' : 'trashed',
1192
+		);
1193
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1194
+	}
1195
+
1196
+
1197
+	/**
1198
+	 * Handles trashing default ticket.
1199
+	 */
1200
+	protected function _delete_ticket()
1201
+	{
1202
+		$success = 1;
1203
+		//checkboxes?
1204
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1205
+			//if array has more than one element then success message should be plural
1206
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1207
+			//cycle thru the boxes
1208
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1209
+				//delete
1210
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1211
+					$success = 0;
1212
+				}
1213
+			}
1214
+		} else {
1215
+			//grab single id and trash
1216
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1217
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1218
+				$success = 0;
1219
+			}
1220
+		}
1221
+		$action_desc = 'deleted';
1222
+		$query_args  = array(
1223
+			'action' => 'ticket_list_table',
1224
+			'status' => 'trashed',
1225
+		);
1226
+		//fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1227
+		if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1228
+			array(array('TKT_is_default' => 1)),
1229
+			'TKT_ID',
1230
+			true
1231
+		)
1232
+		) {
1233
+			$query_args = array();
1234
+		}
1235
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1236
+	}
1237
+
1238
+
1239
+	/**
1240
+	 * @param int $TKT_ID
1241
+	 * @return bool|int
1242
+	 * @throws EE_Error
1243
+	 */
1244
+	protected function _delete_the_ticket($TKT_ID)
1245
+	{
1246
+		$tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1247
+		$tkt->_remove_relations('Datetime');
1248
+		//delete all related prices first
1249
+		$tkt->delete_related_permanently('Price');
1250
+		return $tkt->delete_permanently();
1251
+	}
1252 1252
 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
     public function __construct($routing = true)
23 23
     {
24 24
         parent::__construct($routing);
25
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
26
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
27
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
28
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
25
+        if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) {
26
+            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/');
27
+            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/');
28
+            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/');
29 29
         }
30 30
     }
31 31
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     protected function _extend_page_config()
37 37
     {
38
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
38
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events';
39 39
         //is there a evt_id in the request?
40 40
         $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
41 41
             ? $this->_req_data['EVT_ID']
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             'help_tour'     => array('Templates_Help_Tour'),
169 169
             'require_nonce' => false,
170 170
         );
171
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
171
+        $this->_page_config = array_merge($this->_page_config, $new_page_config);
172 172
         //add filters and actions
173 173
         //modifying _views
174 174
         add_filter(
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
          * check whether count of tickets is approaching the potential
242 242
          * limits for the server.
243 243
          */
244
-        if (! empty($data['input_count'])) {
244
+        if ( ! empty($data['input_count'])) {
245 245
             $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check(
246 246
                 $data['input_count']
247 247
             );
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
     {
271 271
         $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
272 272
         //make sure this is only when editing
273
-        if (! empty($id)) {
274
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
273
+        if ( ! empty($id)) {
274
+            $href = EE_Admin_Page::add_query_args_and_nonce(
275 275
                 array('action' => 'duplicate_event', 'EVT_ID' => $id),
276 276
                 $this->_admin_base_url
277 277
             );
278
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
278
+            $title = esc_attr__('Duplicate Event', 'event_espresso');
279 279
             $return .= '<a href="'
280 280
                        . $href
281 281
                        . '" title="'
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
     {
323 323
         wp_register_script(
324 324
             'ee-event-editor-heartbeat',
325
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
325
+            EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js',
326 326
             array('ee_admin_js', 'heartbeat'),
327 327
             EVENT_ESPRESSO_VERSION,
328 328
             true
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     public function add_additional_datetime_button($template, $template_args)
346 346
     {
347 347
         return EEH_Template::display_template(
348
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
348
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php',
349 349
             $template_args,
350 350
             true
351 351
         );
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     public function add_datetime_clone_button($template, $template_args)
363 363
     {
364 364
         return EEH_Template::display_template(
365
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
365
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php',
366 366
             $template_args,
367 367
             true
368 368
         );
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     public function datetime_timezones_template($template, $template_args)
380 380
     {
381 381
         return EEH_Template::display_template(
382
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
382
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php',
383 383
             $template_args,
384 384
             true
385 385
         );
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
     protected function _set_list_table_views_default()
393 393
     {
394 394
         parent::_set_list_table_views_default();
395
-        $new_views    = array(
395
+        $new_views = array(
396 396
             'today' => array(
397 397
                 'slug'        => 'today',
398 398
                 'label'       => esc_html__('Today', 'event_espresso'),
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     {
498 498
         // first make sure the ID for the event is in the request.
499 499
         //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
500
-        if (! isset($this->_req_data['EVT_ID'])) {
500
+        if ( ! isset($this->_req_data['EVT_ID'])) {
501 501
             EE_Error::add_error(
502 502
                 esc_html__(
503 503
                     'In order to duplicate an event an Event ID is required.  None was given.',
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         }
513 513
         //k we've got EVT_ID so let's use that to get the event we'll duplicate
514 514
         $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
515
-        if (! $orig_event instanceof EE_Event) {
515
+        if ( ! $orig_event instanceof EE_Event) {
516 516
             throw new EE_Error(
517 517
                 sprintf(
518 518
                     esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
         $orig_ven = $orig_event->get_many_related('Venue');
529 529
         //reset the ID and modify other details to make it clear this is a dupe
530 530
         $new_event->set('EVT_ID', 0);
531
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
531
+        $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso');
532 532
         $new_event->set('EVT_name', $new_name);
533 533
         $new_event->set(
534 534
             'EVT_slug',
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
             'Question_Group',
558 558
             array(array('Event_Question_Group.EQG_primary' => 1))
559 559
         );
560
-        if (! empty($orig_primary_qgs)) {
560
+        if ( ! empty($orig_primary_qgs)) {
561 561
             foreach ($orig_primary_qgs as $id => $obj) {
562 562
                 if ($obj instanceof EE_Question_Group) {
563 563
                     $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
             'Question_Group',
570 570
             array(array('Event_Question_Group.EQG_primary' => 0))
571 571
         );
572
-        if (! empty($orig_additional_qgs)) {
572
+        if ( ! empty($orig_additional_qgs)) {
573 573
             foreach ($orig_additional_qgs as $id => $obj) {
574 574
                 if ($obj instanceof EE_Question_Group) {
575 575
                     $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
         //k now that we have the new event saved we can loop through the datetimes and start adding relations.
582 582
         $cloned_tickets = array();
583 583
         foreach ($orig_datetimes as $orig_dtt) {
584
-            if (! $orig_dtt instanceof EE_Datetime) {
584
+            if ( ! $orig_dtt instanceof EE_Datetime) {
585 585
                 continue;
586 586
             }
587 587
             $new_dtt   = clone $orig_dtt;
@@ -594,9 +594,9 @@  discard block
 block discarded – undo
594 594
             $new_event->_add_relation_to($new_dtt, 'Datetime');
595 595
             $new_event->save();
596 596
             //now let's get the ticket relations setup.
597
-            foreach ((array)$orig_tkts as $orig_tkt) {
597
+            foreach ((array) $orig_tkts as $orig_tkt) {
598 598
                 //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
599
-                if (! $orig_tkt instanceof EE_Ticket) {
599
+                if ( ! $orig_tkt instanceof EE_Ticket) {
600 600
                     continue;
601 601
                 }
602 602
                 //is this ticket archived?  If it is then let's skip
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
             array('action' => 'sample_export_file'),
693 693
             $this->_admin_base_url
694 694
         );
695
-        $content                                    = EEH_Template::display_template(
696
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
695
+        $content = EEH_Template::display_template(
696
+            EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php',
697 697
             $this->_template_args,
698 698
             true
699 699
         );
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
      */
711 711
     protected function _import_events()
712 712
     {
713
-        require_once(EE_CLASSES . 'EE_Import.class.php');
713
+        require_once(EE_CLASSES.'EE_Import.class.php');
714 714
         $success = EE_Import::instance()->import();
715 715
         $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
716 716
     }
@@ -738,9 +738,9 @@  discard block
 block discarded – undo
738 738
             'action' => 'all_event_data',
739 739
             'EVT_ID' => $event_ids,
740 740
         );
741
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
742
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
743
-            require_once(EE_CLASSES . 'EE_Export.class.php');
741
+        $this->_req_data = array_merge($this->_req_data, $new_request_args);
742
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
743
+            require_once(EE_CLASSES.'EE_Export.class.php');
744 744
             $EE_Export = EE_Export::instance($this->_req_data);
745 745
             $EE_Export->export();
746 746
         }
@@ -760,9 +760,9 @@  discard block
 block discarded – undo
760 760
             'action'       => 'categories',
761 761
             'category_ids' => $this->_req_data['EVT_CAT_ID'],
762 762
         );
763
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
764
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
765
-            require_once(EE_CLASSES . 'EE_Export.class.php');
763
+        $this->_req_data = array_merge($this->_req_data, $new_request_args);
764
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
765
+            require_once(EE_CLASSES.'EE_Export.class.php');
766 766
             $EE_Export = EE_Export::instance($this->_req_data);
767 767
             $EE_Export->export();
768 768
         }
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
         $this->_set_add_edit_form_tags('update_template_settings');
800 800
         $this->_set_publish_post_box_vars(null, false, false, null, false);
801 801
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
802
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
802
+            EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php',
803 803
             $this->_template_args,
804 804
             true
805 805
         );
@@ -871,11 +871,11 @@  discard block
 block discarded – undo
871 871
      */
872 872
     public function registration_options_meta_box()
873 873
     {
874
-        $yes_no_values                                    = array(
874
+        $yes_no_values = array(
875 875
             array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
876 876
             array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
877 877
         );
878
-        $default_reg_status_values                        = EEM_Registration::reg_status_array(
878
+        $default_reg_status_values = EEM_Registration::reg_status_array(
879 879
             array(
880 880
                 EEM_Registration::status_id_cancelled,
881 881
                 EEM_Registration::status_id_declined,
@@ -892,12 +892,12 @@  discard block
 block discarded – undo
892 892
             $default_reg_status_values,
893 893
             $this->_cpt_model_obj->default_registration_status()
894 894
         );
895
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
895
+        $template_args['display_description'] = EEH_Form_Fields::select_input(
896 896
             'display_desc',
897 897
             $yes_no_values,
898 898
             $this->_cpt_model_obj->display_description()
899 899
         );
900
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
900
+        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
901 901
             'display_ticket_selector',
902 902
             $yes_no_values,
903 903
             $this->_cpt_model_obj->display_ticket_selector(),
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
             $default_reg_status_values
919 919
         );
920 920
         EEH_Template::display_template(
921
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
921
+            EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php',
922 922
             $template_args
923 923
         );
924 924
     }
@@ -1022,13 +1022,13 @@  discard block
 block discarded – undo
1022 1022
     {
1023 1023
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1024 1024
             'DTT_EVT_start',
1025
-            date('Y-m-d') . ' 00:00:00',
1025
+            date('Y-m-d').' 00:00:00',
1026 1026
             'Y-m-d H:i:s',
1027 1027
             'UTC'
1028 1028
         );
1029
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1029
+        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1030 1030
             'DTT_EVT_start',
1031
-            date('Y-m-d') . ' 23:59:59',
1031
+            date('Y-m-d').' 23:59:59',
1032 1032
             'Y-m-d H:i:s',
1033 1033
             'UTC'
1034 1034
         );
@@ -1055,13 +1055,13 @@  discard block
 block discarded – undo
1055 1055
         $days_this_month = date('t');
1056 1056
         $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1057 1057
             'DTT_EVT_start',
1058
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1058
+            $this_year_r.'-'.$this_month_r.'-01 00:00:00',
1059 1059
             'Y-m-d H:i:s',
1060 1060
             'UTC'
1061 1061
         );
1062
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1062
+        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1063 1063
             'DTT_EVT_start',
1064
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1064
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59',
1065 1065
             'Y-m-d H:i:s',
1066 1066
             'UTC'
1067 1067
         );
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
         $offset       = ($current_page - 1) * $per_page;
1129 1129
         $limit        = array($offset, $per_page);
1130 1130
         if (isset($this->_req_data['s'])) {
1131
-            $sstr         = '%' . $this->_req_data['s'] . '%';
1131
+            $sstr         = '%'.$this->_req_data['s'].'%';
1132 1132
             $_where['OR'] = array(
1133 1133
                 'TKT_name'        => array('LIKE', $sstr),
1134 1134
                 'TKT_description' => array('LIKE', $sstr),
@@ -1157,17 +1157,17 @@  discard block
 block discarded – undo
1157 1157
         $success = 1;
1158 1158
         $TKT     = EEM_Ticket::instance();
1159 1159
         //checkboxes?
1160
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1160
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1161 1161
             //if array has more than one element then success message should be plural
1162 1162
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1163 1163
             //cycle thru the boxes
1164 1164
             while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1165 1165
                 if ($trash) {
1166
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1166
+                    if ( ! $TKT->delete_by_ID($TKT_ID)) {
1167 1167
                         $success = 0;
1168 1168
                     }
1169 1169
                 } else {
1170
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1170
+                    if ( ! $TKT->restore_by_ID($TKT_ID)) {
1171 1171
                         $success = 0;
1172 1172
                     }
1173 1173
                 }
@@ -1176,11 +1176,11 @@  discard block
 block discarded – undo
1176 1176
             //grab single id and trash
1177 1177
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1178 1178
             if ($trash) {
1179
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1179
+                if ( ! $TKT->delete_by_ID($TKT_ID)) {
1180 1180
                     $success = 0;
1181 1181
                 }
1182 1182
             } else {
1183
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1183
+                if ( ! $TKT->restore_by_ID($TKT_ID)) {
1184 1184
                     $success = 0;
1185 1185
                 }
1186 1186
             }
@@ -1201,20 +1201,20 @@  discard block
 block discarded – undo
1201 1201
     {
1202 1202
         $success = 1;
1203 1203
         //checkboxes?
1204
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1204
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1205 1205
             //if array has more than one element then success message should be plural
1206 1206
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1207 1207
             //cycle thru the boxes
1208 1208
             while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1209 1209
                 //delete
1210
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1210
+                if ( ! $this->_delete_the_ticket($TKT_ID)) {
1211 1211
                     $success = 0;
1212 1212
                 }
1213 1213
             }
1214 1214
         } else {
1215 1215
             //grab single id and trash
1216 1216
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1217
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1217
+            if ( ! $this->_delete_the_ticket($TKT_ID)) {
1218 1218
                 $success = 0;
1219 1219
             }
1220 1220
         }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      *
749 749
      * @access    public
750 750
      * @param    string $CNT_ISO
751
-     * @return mixed string | array
751
+     * @return string|null string | array
752 752
      * @throws DomainException
753 753
      */
754 754
     public function display_country_settings($CNT_ISO = '')
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
      *        delete_state
1065 1065
      *
1066 1066
      * @access    public
1067
-     * @return        boolean
1067
+     * @return        false|null
1068 1068
      */
1069 1069
     public function delete_state()
1070 1070
     {
Please login to merge, or discard this patch.
Indentation   +1371 added lines, -1371 removed lines patch added patch discarded remove patch
@@ -17,1386 +17,1386 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * _question_group
22
-     * holds the specific question group object for the question group details screen
23
-     *
24
-     * @var object
25
-     */
26
-    protected $_question_group;
27
-
28
-
29
-    /**
30
-     * Initialize basic properties.
31
-     */
32
-    protected function _init_page_props()
33
-    {
34
-        $this->page_slug        = GEN_SET_PG_SLUG;
35
-        $this->page_label       = GEN_SET_LABEL;
36
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
-        $this->_admin_base_path = GEN_SET_ADMIN;
38
-    }
39
-
40
-
41
-    /**
42
-     * Set ajax hooks
43
-     */
44
-    protected function _ajax_hooks()
45
-    {
46
-        add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
47
-        add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
48
-        add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
49
-        add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
50
-    }
51
-
52
-
53
-    /**
54
-     * More page properties initialization.
55
-     */
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = GEN_SET_LABEL;
59
-        $this->_labels           = array(
60
-            'publishbox' => __('Update Settings', 'event_espresso'),
61
-        );
62
-    }
63
-
64
-
65
-    /**
66
-     * Set page routes property.
67
-     */
68
-    protected function _set_page_routes()
69
-    {
70
-        $this->_page_routes = array(
71
-
72
-            'critical_pages'                => array(
73
-                'func'       => '_espresso_page_settings',
74
-                'capability' => 'manage_options',
75
-            ),
76
-            'update_espresso_page_settings' => array(
77
-                'func'       => '_update_espresso_page_settings',
78
-                'capability' => 'manage_options',
79
-                'noheader'   => true,
80
-            ),
81
-            'default'                       => array(
82
-                'func'       => '_your_organization_settings',
83
-                'capability' => 'manage_options',
84
-            ),
85
-
86
-            'update_your_organization_settings' => array(
87
-                'func'       => '_update_your_organization_settings',
88
-                'capability' => 'manage_options',
89
-                'noheader'   => true,
90
-            ),
91
-
92
-            'admin_option_settings' => array(
93
-                'func'       => '_admin_option_settings',
94
-                'capability' => 'manage_options',
95
-            ),
96
-
97
-            'update_admin_option_settings' => array(
98
-                'func'       => '_update_admin_option_settings',
99
-                'capability' => 'manage_options',
100
-                'noheader'   => true,
101
-            ),
102
-
103
-            'country_settings' => array(
104
-                'func'       => '_country_settings',
105
-                'capability' => 'manage_options',
106
-            ),
107
-
108
-            'update_country_settings' => array(
109
-                'func'       => '_update_country_settings',
110
-                'capability' => 'manage_options',
111
-                'noheader'   => true,
112
-            ),
113
-
114
-            'display_country_settings' => array(
115
-                'func'       => 'display_country_settings',
116
-                'capability' => 'manage_options',
117
-                'noheader'   => true,
118
-            ),
119
-
120
-            'add_new_state' => array(
121
-                'func'       => 'add_new_state',
122
-                'capability' => 'manage_options',
123
-                'noheader'   => true,
124
-            ),
125
-
126
-            'delete_state' => array(
127
-                'func'       => 'delete_state',
128
-                'capability' => 'manage_options',
129
-                'noheader'   => true,
130
-            ),
131
-        );
132
-    }
133
-
134
-
135
-    /**
136
-     * Set page configuration property
137
-     */
138
-    protected function _set_page_config()
139
-    {
140
-        $this->_page_config = array(
141
-            'critical_pages'        => array(
142
-                'nav'           => array(
143
-                    'label' => __('Critical Pages', 'event_espresso'),
144
-                    'order' => 50,
145
-                ),
146
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
147
-                'help_tabs'     => array(
148
-                    'general_settings_critical_pages_help_tab' => array(
149
-                        'title'    => __('Critical Pages', 'event_espresso'),
150
-                        'filename' => 'general_settings_critical_pages',
151
-                    ),
152
-                ),
153
-                'help_tour'     => array('Critical_Pages_Help_Tour'),
154
-                'require_nonce' => false,
155
-            ),
156
-            'default'               => array(
157
-                'nav'           => array(
158
-                    'label' => __('Your Organization', 'event_espresso'),
159
-                    'order' => 20,
160
-                ),
161
-                'help_tabs'     => array(
162
-                    'general_settings_your_organization_help_tab' => array(
163
-                        'title'    => __('Your Organization', 'event_espresso'),
164
-                        'filename' => 'general_settings_your_organization',
165
-                    ),
166
-                ),
167
-                'help_tour'     => array('Your_Organization_Help_Tour'),
168
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
169
-                'require_nonce' => false,
170
-            ),
171
-            'admin_option_settings' => array(
172
-                'nav'           => array(
173
-                    'label' => __('Admin Options', 'event_espresso'),
174
-                    'order' => 60,
175
-                ),
176
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
177
-                'help_tabs'     => array(
178
-                    'general_settings_admin_options_help_tab' => array(
179
-                        'title'    => __('Admin Options', 'event_espresso'),
180
-                        'filename' => 'general_settings_admin_options',
181
-                    ),
182
-                ),
183
-                'help_tour'     => array('Admin_Options_Help_Tour'),
184
-                'require_nonce' => false,
185
-            ),
186
-            'country_settings'      => array(
187
-                'nav'           => array(
188
-                    'label' => __('Countries', 'event_espresso'),
189
-                    'order' => 70,
190
-                ),
191
-                'help_tabs'     => array(
192
-                    'general_settings_countries_help_tab' => array(
193
-                        'title'    => __('Countries', 'event_espresso'),
194
-                        'filename' => 'general_settings_countries',
195
-                    ),
196
-                ),
197
-                'help_tour'     => array('Countries_Help_Tour'),
198
-                'require_nonce' => false,
199
-            ),
200
-        );
201
-    }
202
-
203
-
204
-
205
-    protected function _add_screen_options()
206
-    {
207
-    }
208
-
209
-    protected function _add_feature_pointers()
210
-    {
211
-    }
212
-
213
-
214
-    /**
215
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
216
-     */
217
-    public function load_scripts_styles()
218
-    {
219
-        //styles
220
-        wp_enqueue_style('espresso-ui-theme');
221
-        //scripts
222
-        wp_enqueue_script('ee_admin_js');
223
-    }
224
-
225
-
226
-    /**
227
-     * Execute logic running on `admin_init`
228
-     */
229
-    public function admin_init()
230
-    {
231
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
232
-            '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.',
233
-            'event_espresso'
234
-        );
235
-        EE_Registry::$i18n_js_strings['error_occurred']          = __(
236
-            'An error occurred! Please refresh the page and try again.',
237
-            'event_espresso'
238
-        );
239
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = __(
240
-            'Are you sure you want to delete this State / Province?',
241
-            'event_espresso'
242
-        );
243
-        $protocol                                                = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
244
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
245
-            'admin-ajax.php?page=espresso_general_settings',
246
-            $protocol
247
-        );
248
-    }
249
-
250
-    public function admin_notices()
251
-    {
252
-    }
253
-
254
-    public function admin_footer_scripts()
255
-    {
256
-    }
257
-
258
-
259
-    /**
260
-     * Enqueue scripts and styles for the default route.
261
-     */
262
-    public function load_scripts_styles_default()
263
-    {
264
-        //styles
265
-        wp_enqueue_style('thickbox');
266
-        //scripts
267
-        wp_enqueue_script('media-upload');
268
-        wp_enqueue_script('thickbox');
269
-        wp_register_script(
270
-            'organization_settings',
271
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
272
-            array('jquery', 'media-upload', 'thickbox'),
273
-            EVENT_ESPRESSO_VERSION,
274
-            true
275
-        );
276
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
277
-        wp_enqueue_script('organization_settings');
278
-        wp_enqueue_style('organization-css');
279
-        $confirm_image_delete = array(
280
-            'text' => __(
281
-                'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
282
-                'event_espresso'
283
-            ),
284
-        );
285
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
286
-    }
287
-
288
-
289
-    /**
290
-     * Enqueue scripts and styles for the country settings route.
291
-     */
292
-    public function load_scripts_styles_country_settings()
293
-    {
294
-        //scripts
295
-        wp_register_script(
296
-            'gen_settings_countries',
297
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
298
-            array('ee_admin_js'),
299
-            EVENT_ESPRESSO_VERSION,
300
-            true
301
-        );
302
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
303
-        wp_enqueue_script('gen_settings_countries');
304
-        wp_enqueue_style('organization-css');
305
-    }
306
-
307
-
308
-    /*************        Espresso Pages        *************/
309
-    /**
310
-     * _espresso_page_settings
311
-     *
312
-     * @throws \EE_Error
313
-     */
314
-    protected function _espresso_page_settings()
315
-    {
316
-        // Check to make sure all of the main pages are setup properly,
317
-        // if not create the default pages and display an admin notice
318
-        EEH_Activation::verify_default_pages_exist();
319
-        $this->_transient_garbage_collection();
320
-        $this->_template_args['values']             = $this->_yes_no_values;
321
-        $this->_template_args['reg_page_id']        = isset(EE_Registry::instance()->CFG->core->reg_page_id)
322
-            ? EE_Registry::instance()->CFG->core->reg_page_id
323
-            : null;
324
-        $this->_template_args['reg_page_obj']       = isset(EE_Registry::instance()->CFG->core->reg_page_id)
325
-            ? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
326
-            : false;
327
-        $this->_template_args['txn_page_id']        = isset(EE_Registry::instance()->CFG->core->txn_page_id)
328
-            ? EE_Registry::instance()->CFG->core->txn_page_id
329
-            : null;
330
-        $this->_template_args['txn_page_obj']       = isset(EE_Registry::instance()->CFG->core->txn_page_id)
331
-            ? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
332
-            : false;
333
-        $this->_template_args['thank_you_page_id']  = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
334
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
335
-            : null;
336
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
337
-            ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
338
-            : false;
339
-        $this->_template_args['cancel_page_id']     = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
340
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
341
-            : null;
342
-        $this->_template_args['cancel_page_obj']    = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
343
-            ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
344
-            : false;
345
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
346
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
347
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
348
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
349
-            $this->_template_args,
350
-            true
351
-        );
352
-        $this->display_admin_page_with_sidebar();
353
-    }
354
-
355
-
356
-    /**
357
-     * Handler for updating espresso page settings.
358
-     */
359
-    protected function _update_espresso_page_settings()
360
-    {
361
-        // capture incoming request data && set page IDs
362
-        EE_Registry::instance()->CFG->core->reg_page_id       = isset($this->_req_data['reg_page_id'])
363
-            ? absint($this->_req_data['reg_page_id'])
364
-            : EE_Registry::instance()->CFG->core->reg_page_id;
365
-        EE_Registry::instance()->CFG->core->txn_page_id       = isset($this->_req_data['txn_page_id'])
366
-            ? absint($this->_req_data['txn_page_id'])
367
-            : EE_Registry::instance()->CFG->core->txn_page_id;
368
-        EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
369
-            ? absint($this->_req_data['thank_you_page_id'])
370
-            : EE_Registry::instance()->CFG->core->thank_you_page_id;
371
-        EE_Registry::instance()->CFG->core->cancel_page_id    = isset($this->_req_data['cancel_page_id'])
372
-            ? absint($this->_req_data['cancel_page_id'])
373
-            : EE_Registry::instance()->CFG->core->cancel_page_id;
374
-
375
-        EE_Registry::instance()->CFG->core = apply_filters(
376
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
377
-            EE_Registry::instance()->CFG->core,
378
-            $this->_req_data
379
-        );
380
-        $what                              = __('Critical Pages & Shortcodes', 'event_espresso');
381
-        $this->_redirect_after_action(
382
-            $this->_update_espresso_configuration(
383
-                $what,
384
-                EE_Registry::instance()->CFG->core,
385
-                __FILE__,
386
-                __FUNCTION__,
387
-                __LINE__
388
-            ),
389
-            $what,
390
-            '',
391
-            array(
392
-                'action' => 'critical_pages',
393
-            ),
394
-            true
395
-        );
396
-    }
397
-
398
-
399
-    /*************        Your Organization        *************/
400
-
401
-
402
-    /**
403
-     * Output for the Your Organization settings route.
404
-     * @throws DomainException
405
-     * @throws EE_Error
406
-     */
407
-    protected function _your_organization_settings()
408
-    {
409
-
410
-        $this->_template_args['site_license_key']       = isset(
411
-            EE_Registry::instance()->NET_CFG->core->site_license_key
412
-        )
413
-            ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key')
414
-            : '';
415
-        $this->_template_args['organization_name']      = isset(EE_Registry::instance()->CFG->organization->name)
416
-            ? EE_Registry::instance()->CFG->organization->get_pretty('name')
417
-            : '';
418
-        $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1)
419
-            ? EE_Registry::instance()->CFG->organization->get_pretty('address_1')
420
-            : '';
421
-        $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2)
422
-            ? EE_Registry::instance()->CFG->organization->get_pretty('address_2')
423
-            : '';
424
-        $this->_template_args['organization_city']      = isset(EE_Registry::instance()->CFG->organization->city)
425
-            ? EE_Registry::instance()->CFG->organization->get_pretty('city')
426
-            : '';
427
-        $this->_template_args['organization_zip']       = isset(EE_Registry::instance()->CFG->organization->zip)
428
-            ? EE_Registry::instance()->CFG->organization->get_pretty('zip')
429
-            : '';
430
-        $this->_template_args['organization_email']     = isset(EE_Registry::instance()->CFG->organization->email)
431
-            ? EE_Registry::instance()->CFG->organization->get_pretty('email')
432
-            : '';
433
-        $this->_template_args['organization_phone']     = isset(EE_Registry::instance()->CFG->organization->phone)
434
-            ? EE_Registry::instance()->CFG->organization->get_pretty('phone')
435
-            : '';
436
-        $this->_template_args['organization_vat']       = isset(EE_Registry::instance()->CFG->organization->vat)
437
-            ? EE_Registry::instance()->CFG->organization->get_pretty('vat')
438
-            : '';
439
-        $this->_template_args['currency_sign']          = isset(EE_Registry::instance()->CFG->currency->sign)
440
-            ? EE_Registry::instance()->CFG->currency->get_pretty('sign')
441
-            : '$';
442
-        $this->_template_args['organization_logo_url']  = isset(EE_Registry::instance()->CFG->organization->logo_url)
443
-            ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url')
444
-            : false;
445
-        $this->_template_args['organization_facebook']  = isset(EE_Registry::instance()->CFG->organization->facebook)
446
-            ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
447
-            : '';
448
-        $this->_template_args['organization_twitter']   = isset(EE_Registry::instance()->CFG->organization->twitter)
449
-            ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
450
-            : '';
451
-        $this->_template_args['organization_linkedin']  = isset(EE_Registry::instance()->CFG->organization->linkedin)
452
-            ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin')
453
-            : '';
454
-        $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest)
455
-            ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest')
456
-            : '';
457
-        $this->_template_args['organization_google']    = isset(EE_Registry::instance()->CFG->organization->google)
458
-            ? EE_Registry::instance()->CFG->organization->get_pretty('google')
459
-            : '';
460
-        $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram)
461
-            ? EE_Registry::instance()->CFG->organization->get_pretty('instagram')
462
-            : '';
463
-        //UXIP settings
464
-        $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin)
465
-            ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin')
466
-            : true;
467
-
468
-        $STA_ID                         = isset(EE_Registry::instance()->CFG->organization->STA_ID)
469
-            ? EE_Registry::instance()->CFG->organization->STA_ID
470
-            : 4;
471
-        $this->_template_args['states'] = new EE_Question_Form_Input(
472
-            EE_Question::new_instance(array(
473
-                'QST_ID'           => 0,
474
-                'QST_display_text' => __('State/Province', 'event_espresso'),
475
-                'QST_system'       => 'admin-state',
476
-            )),
477
-            EE_Answer::new_instance(array(
478
-                'ANS_ID'    => 0,
479
-                'ANS_value' => $STA_ID,
480
-            )),
481
-            array(
482
-                'input_id'       => 'organization_state',
483
-                'input_name'     => 'organization_state',
484
-                'input_prefix'   => '',
485
-                'append_qstn_id' => false,
486
-            )
487
-        );
488
-
489
-        $CNT_ISO                           = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
490
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
491
-            : 'US';
492
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
493
-            EE_Question::new_instance(array(
494
-                'QST_ID'           => 0,
495
-                'QST_display_text' => __('Country', 'event_espresso'),
496
-                'QST_system'       => 'admin-country',
497
-            )),
498
-            EE_Answer::new_instance(array(
499
-                'ANS_ID'    => 0,
500
-                'ANS_value' => $CNT_ISO,
501
-            )),
502
-            array(
503
-                'input_id'       => 'organization_country',
504
-                'input_name'     => 'organization_country',
505
-                'input_prefix'   => '',
506
-                'append_qstn_id' => false,
507
-            )
508
-        );
509
-
510
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
511
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
512
-
513
-        //PUE verification stuff
514
-        $ver_option_key                                    = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
515
-        $verify_fail                                       = get_option($ver_option_key);
516
-        $this->_template_args['site_license_key_verified'] = $verify_fail
517
-                                                             || ! empty($verify_fail)
518
-                                                             || (empty($this->_template_args['site_license_key'])
519
-                                                                 && empty($verify_fail)
520
-                                                             )
521
-            ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>'
522
-            : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
523
-
524
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
525
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
526
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
527
-            GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
528
-            $this->_template_args,
529
-            true
530
-        );
531
-
532
-        $this->display_admin_page_with_sidebar();
533
-    }
534
-
535
-
536
-    /**
537
-     * Handler for updating organziation settings.
538
-     */
539
-    protected function _update_your_organization_settings()
540
-    {
541
-        if (is_main_site()) {
542
-            EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key'])
543
-                ? sanitize_text_field($this->_req_data['site_license_key'])
544
-                : EE_Registry::instance()->NET_CFG->core->site_license_key;
545
-        }
546
-        EE_Registry::instance()->CFG->organization->name      = isset($this->_req_data['organization_name'])
547
-            ? sanitize_text_field($this->_req_data['organization_name'])
548
-            : EE_Registry::instance()->CFG->organization->name;
549
-        EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1'])
550
-            ? sanitize_text_field($this->_req_data['organization_address_1'])
551
-            : EE_Registry::instance()->CFG->organization->address_1;
552
-        EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2'])
553
-            ? sanitize_text_field($this->_req_data['organization_address_2'])
554
-            : EE_Registry::instance()->CFG->organization->address_2;
555
-        EE_Registry::instance()->CFG->organization->city      = isset($this->_req_data['organization_city'])
556
-            ? sanitize_text_field($this->_req_data['organization_city'])
557
-            : EE_Registry::instance()->CFG->organization->city;
558
-        EE_Registry::instance()->CFG->organization->STA_ID    = isset($this->_req_data['organization_state'])
559
-            ? absint($this->_req_data['organization_state'])
560
-            : EE_Registry::instance()->CFG->organization->STA_ID;
561
-        EE_Registry::instance()->CFG->organization->CNT_ISO   = isset($this->_req_data['organization_country'])
562
-            ? sanitize_text_field($this->_req_data['organization_country'])
563
-            : EE_Registry::instance()->CFG->organization->CNT_ISO;
564
-        EE_Registry::instance()->CFG->organization->zip       = isset($this->_req_data['organization_zip'])
565
-            ? sanitize_text_field($this->_req_data['organization_zip'])
566
-            : EE_Registry::instance()->CFG->organization->zip;
567
-        EE_Registry::instance()->CFG->organization->email     = isset($this->_req_data['organization_email'])
568
-            ? sanitize_email($this->_req_data['organization_email'])
569
-            : EE_Registry::instance()->CFG->organization->email;
570
-        EE_Registry::instance()->CFG->organization->vat       = isset($this->_req_data['organization_vat'])
571
-            ? sanitize_text_field($this->_req_data['organization_vat'])
572
-            : EE_Registry::instance()->CFG->organization->vat;
573
-        EE_Registry::instance()->CFG->organization->phone     = isset($this->_req_data['organization_phone'])
574
-            ? sanitize_text_field($this->_req_data['organization_phone'])
575
-            : EE_Registry::instance()->CFG->organization->phone;
576
-        EE_Registry::instance()->CFG->organization->logo_url  = isset($this->_req_data['organization_logo_url'])
577
-            ? esc_url_raw($this->_req_data['organization_logo_url'])
578
-            : EE_Registry::instance()->CFG->organization->logo_url;
579
-        EE_Registry::instance()->CFG->organization->facebook  = isset($this->_req_data['organization_facebook'])
580
-            ? esc_url_raw($this->_req_data['organization_facebook'])
581
-            : EE_Registry::instance()->CFG->organization->facebook;
582
-        EE_Registry::instance()->CFG->organization->twitter   = isset($this->_req_data['organization_twitter'])
583
-            ? esc_url_raw($this->_req_data['organization_twitter'])
584
-            : EE_Registry::instance()->CFG->organization->twitter;
585
-        EE_Registry::instance()->CFG->organization->linkedin  = isset($this->_req_data['organization_linkedin'])
586
-            ? esc_url_raw($this->_req_data['organization_linkedin'])
587
-            : EE_Registry::instance()->CFG->organization->linkedin;
588
-        EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest'])
589
-            ? esc_url_raw($this->_req_data['organization_pinterest'])
590
-            : EE_Registry::instance()->CFG->organization->pinterest;
591
-        EE_Registry::instance()->CFG->organization->google    = isset($this->_req_data['organization_google'])
592
-            ? esc_url_raw($this->_req_data['organization_google'])
593
-            : EE_Registry::instance()->CFG->organization->google;
594
-        EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram'])
595
-            ? esc_url_raw($this->_req_data['organization_instagram'])
596
-            : EE_Registry::instance()->CFG->organization->instagram;
597
-        EE_Registry::instance()->CFG->core->ee_ueip_optin     = isset($this->_req_data['ueip_optin'])
598
-                                                                && ! empty($this->_req_data['ueip_optin'])
599
-            ? $this->_req_data['ueip_optin']
600
-            : EE_Registry::instance()->CFG->core->ee_ueip_optin;
601
-
602
-        EE_Registry::instance()->CFG->currency = new EE_Currency_Config(
603
-            EE_Registry::instance()->CFG->organization->CNT_ISO
604
-        );
605
-
606
-        EE_Registry::instance()->CFG = apply_filters(
607
-            'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
608
-            EE_Registry::instance()->CFG
609
-        );
610
-
611
-        $what    = 'Your Organization Settings';
612
-        $success = $this->_update_espresso_configuration(
613
-            $what,
614
-            EE_Registry::instance()->CFG,
615
-            __FILE__,
616
-            __FUNCTION__,
617
-            __LINE__
618
-        );
619
-
620
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
621
-    }
622
-
623
-
624
-
625
-    /*************        Admin Options        *************/
626
-
627
-
628
-    /**
629
-     * _admin_option_settings
630
-     *
631
-     * @throws \EE_Error
632
-     * @throws \LogicException
633
-     */
634
-    protected function _admin_option_settings()
635
-    {
636
-        $this->_template_args['admin_page_content'] = '';
637
-        try {
638
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
639
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
640
-            $this->_template_args['values'] = $this->_yes_no_values;
641
-            // also need to account for the do_action that was in the old template
642
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
643
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
644
-        } catch (Exception $e) {
645
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
646
-        }
647
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
648
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
649
-        $this->display_admin_page_with_sidebar();
650
-    }
651
-
652
-
653
-    /**
654
-     * _update_admin_option_settings
655
-     *
656
-     * @throws \EE_Error
657
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
658
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
659
-     * @throws \InvalidArgumentException
660
-     * @throws \LogicException
661
-     */
662
-    protected function _update_admin_option_settings()
663
-    {
664
-        try {
665
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
666
-            $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
667
-            EE_Registry::instance()->CFG->admin = apply_filters(
668
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
669
-                EE_Registry::instance()->CFG->admin
670
-            );
671
-        } catch (Exception $e) {
672
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
673
-        }
674
-        $this->_redirect_after_action(
675
-            apply_filters(
676
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
677
-                $this->_update_espresso_configuration(
678
-                    'Admin Options',
679
-                    EE_Registry::instance()->CFG->admin,
680
-                    __FILE__, __FUNCTION__, __LINE__
681
-                )
682
-            ),
683
-            'Admin Options',
684
-            'updated',
685
-            array('action' => 'admin_option_settings')
686
-        );
687
-
688
-    }
689
-
690
-
691
-    /*************        Countries        *************/
692
-
693
-
694
-    /**
695
-     * Output Country Settings view.
696
-     * @throws DomainException
697
-     * @throws EE_Error
698
-     */
699
-    protected function _country_settings()
700
-    {
701
-        $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
702
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
703
-            : 'US';
704
-        $CNT_ISO = isset($this->_req_data['country'])
705
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
706
-            : $CNT_ISO;
707
-
708
-        //load field generator helper
709
-
710
-        $this->_template_args['values'] = $this->_yes_no_values;
711
-
712
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
713
-            EE_Question::new_instance(array(
714
-                'QST_ID'           => 0,
715
-                'QST_display_text' => __('Select Country', 'event_espresso'),
716
-                'QST_system'       => 'admin-country',
717
-            )),
718
-            EE_Answer::new_instance(array(
719
-                'ANS_ID'    => 0,
720
-                'ANS_value' => $CNT_ISO,
721
-            )),
722
-            array(
723
-                'input_id'       => 'country',
724
-                'input_name'     => 'country',
725
-                'input_prefix'   => '',
726
-                'append_qstn_id' => false,
727
-            )
728
-        );
729
-
730
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
731
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
732
-        $this->_template_args['country_details_settings'] = $this->display_country_settings();
733
-        $this->_template_args['country_states_settings']  = $this->display_country_states();
734
-
735
-        $this->_set_add_edit_form_tags('update_country_settings');
736
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
737
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
738
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
739
-            $this->_template_args,
740
-            true
741
-        );
742
-        $this->display_admin_page_with_no_sidebar();
743
-    }
744
-
745
-
746
-    /**
747
-     *        display_country_settings
748
-     *
749
-     * @access    public
750
-     * @param    string $CNT_ISO
751
-     * @return mixed string | array
752
-     * @throws DomainException
753
-     */
754
-    public function display_country_settings($CNT_ISO = '')
755
-    {
756
-
757
-        $CNT_ISO = isset($this->_req_data['country'])
758
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
759
-            : $CNT_ISO;
760
-        if (! $CNT_ISO) {
761
-            return '';
762
-        }
763
-
764
-        // for ajax
765
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
766
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
767
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
768
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
769
-        $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
770
-
771
-        $country_input_types            = array(
772
-            'CNT_active'      => array(
773
-                'type'             => 'RADIO_BTN',
774
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
775
-                'class'            => '',
776
-                'options'          => $this->_yes_no_values,
777
-                'use_desc_4_label' => true,
778
-            ),
779
-            'CNT_ISO'         => array(
780
-                'type'       => 'TEXT',
781
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
782
-                'class'      => 'small-text',
783
-            ),
784
-            'CNT_ISO3'        => array(
785
-                'type'       => 'TEXT',
786
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
787
-                'class'      => 'small-text',
788
-            ),
789
-            'RGN_ID'          => array(
790
-                'type'       => 'TEXT',
791
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
792
-                'class'      => 'small-text',
793
-            ),
794
-            'CNT_name'        => array(
795
-                'type'       => 'TEXT',
796
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
797
-                'class'      => 'regular-text',
798
-            ),
799
-            'CNT_cur_code'    => array(
800
-                'type'       => 'TEXT',
801
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
802
-                'class'      => 'small-text',
803
-            ),
804
-            'CNT_cur_single'  => array(
805
-                'type'       => 'TEXT',
806
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
807
-                'class'      => 'medium-text',
808
-            ),
809
-            'CNT_cur_plural'  => array(
810
-                'type'       => 'TEXT',
811
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
812
-                'class'      => 'medium-text',
813
-            ),
814
-            'CNT_cur_sign'    => array(
815
-                'type'         => 'TEXT',
816
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
817
-                'class'        => 'small-text',
818
-                'htmlentities' => false,
819
-            ),
820
-            'CNT_cur_sign_b4' => array(
821
-                'type'             => 'RADIO_BTN',
822
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
823
-                'class'            => '',
824
-                'options'          => $this->_yes_no_values,
825
-                'use_desc_4_label' => true,
826
-            ),
827
-            'CNT_cur_dec_plc' => array(
828
-                'type'       => 'RADIO_BTN',
829
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
830
-                'class'      => '',
831
-                'options'    => array(
832
-                    array('id' => 0, 'text' => ''),
833
-                    array('id' => 1, 'text' => ''),
834
-                    array('id' => 2, 'text' => ''),
835
-                    array('id' => 3, 'text' => ''),
836
-                ),
837
-            ),
838
-            'CNT_cur_dec_mrk' => array(
839
-                'type'             => 'RADIO_BTN',
840
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
841
-                'class'            => '',
842
-                'options'          => array(
843
-                    array(
844
-                        'id'   => ',',
845
-                        'text' => __(', (comma)', 'event_espresso'),
846
-                    ),
847
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
848
-                ),
849
-                'use_desc_4_label' => true,
850
-            ),
851
-            'CNT_cur_thsnds'  => array(
852
-                'type'             => 'RADIO_BTN',
853
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
854
-                'class'            => '',
855
-                'options'          => array(
856
-                    array(
857
-                        'id'   => ',',
858
-                        'text' => __(', (comma)', 'event_espresso'),
859
-                    ),
860
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
861
-                ),
862
-                'use_desc_4_label' => true,
863
-            ),
864
-            'CNT_tel_code'    => array(
865
-                'type'       => 'TEXT',
866
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
867
-                'class'      => 'small-text',
868
-            ),
869
-            'CNT_is_EU'       => array(
870
-                'type'             => 'RADIO_BTN',
871
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
872
-                'class'            => '',
873
-                'options'          => $this->_yes_no_values,
874
-                'use_desc_4_label' => true,
875
-            ),
876
-        );
877
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
878
-            $country,
879
-            $country_input_types
880
-        );
881
-        $country_details_settings       = EEH_Template::display_template(
882
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
883
-            $this->_template_args,
884
-            true
885
-        );
886
-
887
-        if (defined('DOING_AJAX')) {
888
-            $notices = EE_Error::get_notices(false, false, false);
889
-            echo wp_json_encode(array(
890
-                'return_data' => $country_details_settings,
891
-                'success'     => $notices['success'],
892
-                'errors'      => $notices['errors'],
893
-            ));
894
-            die();
895
-        } else {
896
-            return $country_details_settings;
897
-        }
898
-    }
899
-
900
-
901
-    /**
902
-     *        display_country_states
903
-     *
904
-     * @access    public
905
-     * @param    string $CNT_ISO
906
-     * @return string
907
-     * @throws DomainException
908
-     */
909
-    public function display_country_states($CNT_ISO = '')
910
-    {
911
-
912
-        $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
913
-
914
-        if (! $CNT_ISO) {
915
-            return '';
916
-        }
917
-        // for ajax
918
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
919
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
920
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
921
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
922
-        $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
923
-
924
-        if ($states) {
925
-            foreach ($states as $STA_ID => $state) {
926
-                if ($state instanceof EE_State) {
927
-                    //STA_abbrev 	STA_name 	STA_active
928
-                    $state_input_types                                           = array(
929
-                        'STA_abbrev' => array(
930
-                            'type'       => 'TEXT',
931
-                            'input_name' => 'states[' . $STA_ID . ']',
932
-                            'class'      => 'mid-text',
933
-                        ),
934
-                        'STA_name'   => array(
935
-                            'type'       => 'TEXT',
936
-                            'input_name' => 'states[' . $STA_ID . ']',
937
-                            'class'      => 'regular-text',
938
-                        ),
939
-                        'STA_active' => array(
940
-                            'type'             => 'RADIO_BTN',
941
-                            'input_name'       => 'states[' . $STA_ID . ']',
942
-                            'options'          => $this->_yes_no_values,
943
-                            'use_desc_4_label' => true,
944
-                        ),
945
-                    );
946
-                    $this->_template_args['states'][$STA_ID]['inputs'] =
947
-                        EE_Question_Form_Input::generate_question_form_inputs_for_object(
948
-                            $state,
949
-                            $state_input_types
950
-                        );
951
-                    $query_args                                                  = array(
952
-                        'action'     => 'delete_state',
953
-                        'STA_ID'     => $STA_ID,
954
-                        'CNT_ISO'    => $CNT_ISO,
955
-                        'STA_abbrev' => $state->abbrev(),
956
-                    );
957
-                    $this->_template_args['states'][$STA_ID]['delete_state_url'] =
958
-                        EE_Admin_Page::add_query_args_and_nonce(
959
-                            $query_args,
960
-                            GEN_SET_ADMIN_URL
961
-                        );
962
-                }
963
-            }
964
-        } else {
965
-            $this->_template_args['states'] = false;
966
-        }
967
-
968
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
969
-            array('action' => 'add_new_state'),
970
-            GEN_SET_ADMIN_URL
971
-        );
972
-
973
-        $state_details_settings = EEH_Template::display_template(
974
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
975
-            $this->_template_args,
976
-            true
977
-        );
978
-
979
-        if (defined('DOING_AJAX')) {
980
-            $notices = EE_Error::get_notices(false, false, false);
981
-            echo wp_json_encode(array(
982
-                'return_data' => $state_details_settings,
983
-                'success'     => $notices['success'],
984
-                'errors'      => $notices['errors'],
985
-            ));
986
-            die();
987
-        } else {
988
-            return $state_details_settings;
989
-        }
990
-    }
991
-
992
-
993
-    /**
994
-     *        add_new_state
995
-     *
996
-     * @access    public
997
-     * @return void
998
-     * @throws EE_Error
999
-     */
1000
-    public function add_new_state()
1001
-    {
1002
-
1003
-        $success = true;
1004
-
1005
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
1006
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1007
-            : false;
1008
-        if (! $CNT_ISO) {
1009
-            EE_Error::add_error(
1010
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1011
-                __FILE__,
1012
-                __FUNCTION__,
1013
-                __LINE__
1014
-            );
1015
-            $success = false;
1016
-        }
1017
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1018
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
1019
-            : false;
1020
-        if (! $STA_abbrev) {
1021
-            EE_Error::add_error(
1022
-                __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1023
-                __FILE__,
1024
-                __FUNCTION__,
1025
-                __LINE__
1026
-            );
1027
-            $success = false;
1028
-        }
1029
-        $STA_name = isset($this->_req_data['STA_name'])
1030
-            ? sanitize_text_field($this->_req_data['STA_name'])
1031
-            : false;
1032
-        if (! $STA_name) {
1033
-            EE_Error::add_error(
1034
-                __('No State name or an invalid State name was received.', 'event_espresso'),
1035
-                __FILE__,
1036
-                __FUNCTION__,
1037
-                __LINE__
1038
-            );
1039
-            $success = false;
1040
-        }
1041
-
1042
-        if ($success) {
1043
-            $cols_n_values = array(
1044
-                'CNT_ISO'    => $CNT_ISO,
1045
-                'STA_abbrev' => $STA_abbrev,
1046
-                'STA_name'   => $STA_name,
1047
-                'STA_active' => true,
1048
-            );
1049
-            $success       = EEM_State::instance()->insert($cols_n_values);
1050
-            EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1051
-        }
1052
-
1053
-        if (defined('DOING_AJAX')) {
1054
-            $notices = EE_Error::get_notices(false, false, false);
1055
-            echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
1056
-            die();
1057
-        } else {
1058
-            $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
1059
-        }
1060
-    }
1061
-
1062
-
1063
-    /**
1064
-     *        delete_state
1065
-     *
1066
-     * @access    public
1067
-     * @return        boolean
1068
-     */
1069
-    public function delete_state()
1070
-    {
1071
-        $CNT_ISO    = isset($this->_req_data['CNT_ISO'])
1072
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1073
-            : false;
1074
-        $STA_ID     = isset($this->_req_data['STA_ID'])
1075
-            ? sanitize_text_field($this->_req_data['STA_ID'])
1076
-            : false;
1077
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1078
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
1079
-            : false;
1080
-        if (! $STA_ID) {
1081
-            EE_Error::add_error(
1082
-                __('No State ID or an invalid State ID was received.', 'event_espresso'),
1083
-                __FILE__,
1084
-                __FUNCTION__,
1085
-                __LINE__
1086
-            );
1087
-            return false;
1088
-        }
1089
-
1090
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1091
-        if ($success !== false) {
1092
-            do_action(
1093
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1094
-                $CNT_ISO,
1095
-                $STA_ID,
1096
-                array('STA_abbrev' => $STA_abbrev)
1097
-            );
1098
-            EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1099
-        }
1100
-        if (defined('DOING_AJAX')) {
1101
-            $notices                = EE_Error::get_notices(false, false);
1102
-            $notices['return_data'] = true;
1103
-            echo wp_json_encode($notices);
1104
-            die();
1105
-        } else {
1106
-            $this->_redirect_after_action(
1107
-                $success,
1108
-                'State',
1109
-                'deleted',
1110
-                array('action' => 'country_settings')
1111
-            );
1112
-        }
1113
-    }
1114
-
1115
-
1116
-    /**
1117
-     *        _update_country_settings
1118
-     *
1119
-     * @access    protected
1120
-     * @return void
1121
-     * @throws EE_Error
1122
-     */
1123
-    protected function _update_country_settings()
1124
-    {
1125
-        // grab the country ISO code
1126
-        $CNT_ISO = isset($this->_req_data['country'])
1127
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
1128
-            : false;
1129
-        if (! $CNT_ISO) {
1130
-            EE_Error::add_error(
1131
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1132
-                __FILE__,
1133
-                __FUNCTION__,
1134
-                __LINE__
1135
-            );
1136
-
1137
-            return;
1138
-        }
1139
-        $cols_n_values                    = array();
1140
-        $cols_n_values['CNT_ISO3']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])
1141
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']))
1142
-            : false;
1143
-        $cols_n_values['RGN_ID']          = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1144
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1145
-            : null;
1146
-        $cols_n_values['CNT_name']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1147
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1148
-            : null;
1149
-        $cols_n_values['CNT_cur_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])
1150
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']))
1151
-            : 'USD';
1152
-        $cols_n_values['CNT_cur_single']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1153
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1154
-            : 'dollar';
1155
-        $cols_n_values['CNT_cur_plural']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1156
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1157
-            : 'dollars';
1158
-        $cols_n_values['CNT_cur_sign']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1159
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1160
-            : '$';
1161
-        $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1162
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1163
-            : true;
1164
-        $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1165
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1166
-            : 2;
1167
-        $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1168
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1169
-            : '.';
1170
-        $cols_n_values['CNT_cur_thsnds']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1171
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1172
-            : ',';
1173
-        $cols_n_values['CNT_tel_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1174
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1175
-            : null;
1176
-        $cols_n_values['CNT_is_EU']       = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1177
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1178
-            : false;
1179
-        $cols_n_values['CNT_active']      = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1180
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1181
-            : false;
1182
-        // allow filtering of country data
1183
-        $cols_n_values = apply_filters(
1184
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1185
-            $cols_n_values
1186
-        );
1187
-
1188
-        // where values
1189
-        $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1190
-        // run the update
1191
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1192
-
1193
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1194
-            // allow filtering of states data
1195
-            $states = apply_filters(
1196
-                'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1197
-                $this->_req_data['states']
1198
-            );
1199
-
1200
-            // loop thru state data ( looks like : states[75][STA_name] )
1201
-            foreach ($states as $STA_ID => $state) {
1202
-                $cols_n_values = array(
1203
-                    'CNT_ISO'    => $CNT_ISO,
1204
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1205
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1206
-                    'STA_active' => (bool)absint($state['STA_active']),
1207
-                );
1208
-                // where values
1209
-                $where_cols_n_values = array(array('STA_ID' => $STA_ID));
1210
-                // run the update
1211
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1212
-                if ($success !== false) {
1213
-                    do_action(
1214
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1215
-                        $CNT_ISO,
1216
-                        $STA_ID,
1217
-                        $cols_n_values
1218
-                    );
1219
-                }
1220
-            }
1221
-        }
1222
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1223
-        if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1224
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1225
-        ) {
1226
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1227
-            EE_Registry::instance()->CFG->update_espresso_config();
1228
-        }
1229
-
1230
-        if ($success !== false) {
1231
-            EE_Error::add_success(
1232
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1233
-            );
1234
-        }
1235
-        $this->_redirect_after_action(
1236
-            $success,
1237
-            '',
1238
-            '',
1239
-            array('action' => 'country_settings', 'country' => $CNT_ISO),
1240
-            true
1241
-        );
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     *        form_form_field_label_wrap
1247
-     *
1248
-     * @access        public
1249
-     * @param        string $label
1250
-     * @return        string
1251
-     */
1252
-    public function country_form_field_label_wrap($label, $required_text)
1253
-    {
1254
-        return '
20
+	/**
21
+	 * _question_group
22
+	 * holds the specific question group object for the question group details screen
23
+	 *
24
+	 * @var object
25
+	 */
26
+	protected $_question_group;
27
+
28
+
29
+	/**
30
+	 * Initialize basic properties.
31
+	 */
32
+	protected function _init_page_props()
33
+	{
34
+		$this->page_slug        = GEN_SET_PG_SLUG;
35
+		$this->page_label       = GEN_SET_LABEL;
36
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
+		$this->_admin_base_path = GEN_SET_ADMIN;
38
+	}
39
+
40
+
41
+	/**
42
+	 * Set ajax hooks
43
+	 */
44
+	protected function _ajax_hooks()
45
+	{
46
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
47
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
48
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
49
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
50
+	}
51
+
52
+
53
+	/**
54
+	 * More page properties initialization.
55
+	 */
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = GEN_SET_LABEL;
59
+		$this->_labels           = array(
60
+			'publishbox' => __('Update Settings', 'event_espresso'),
61
+		);
62
+	}
63
+
64
+
65
+	/**
66
+	 * Set page routes property.
67
+	 */
68
+	protected function _set_page_routes()
69
+	{
70
+		$this->_page_routes = array(
71
+
72
+			'critical_pages'                => array(
73
+				'func'       => '_espresso_page_settings',
74
+				'capability' => 'manage_options',
75
+			),
76
+			'update_espresso_page_settings' => array(
77
+				'func'       => '_update_espresso_page_settings',
78
+				'capability' => 'manage_options',
79
+				'noheader'   => true,
80
+			),
81
+			'default'                       => array(
82
+				'func'       => '_your_organization_settings',
83
+				'capability' => 'manage_options',
84
+			),
85
+
86
+			'update_your_organization_settings' => array(
87
+				'func'       => '_update_your_organization_settings',
88
+				'capability' => 'manage_options',
89
+				'noheader'   => true,
90
+			),
91
+
92
+			'admin_option_settings' => array(
93
+				'func'       => '_admin_option_settings',
94
+				'capability' => 'manage_options',
95
+			),
96
+
97
+			'update_admin_option_settings' => array(
98
+				'func'       => '_update_admin_option_settings',
99
+				'capability' => 'manage_options',
100
+				'noheader'   => true,
101
+			),
102
+
103
+			'country_settings' => array(
104
+				'func'       => '_country_settings',
105
+				'capability' => 'manage_options',
106
+			),
107
+
108
+			'update_country_settings' => array(
109
+				'func'       => '_update_country_settings',
110
+				'capability' => 'manage_options',
111
+				'noheader'   => true,
112
+			),
113
+
114
+			'display_country_settings' => array(
115
+				'func'       => 'display_country_settings',
116
+				'capability' => 'manage_options',
117
+				'noheader'   => true,
118
+			),
119
+
120
+			'add_new_state' => array(
121
+				'func'       => 'add_new_state',
122
+				'capability' => 'manage_options',
123
+				'noheader'   => true,
124
+			),
125
+
126
+			'delete_state' => array(
127
+				'func'       => 'delete_state',
128
+				'capability' => 'manage_options',
129
+				'noheader'   => true,
130
+			),
131
+		);
132
+	}
133
+
134
+
135
+	/**
136
+	 * Set page configuration property
137
+	 */
138
+	protected function _set_page_config()
139
+	{
140
+		$this->_page_config = array(
141
+			'critical_pages'        => array(
142
+				'nav'           => array(
143
+					'label' => __('Critical Pages', 'event_espresso'),
144
+					'order' => 50,
145
+				),
146
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
147
+				'help_tabs'     => array(
148
+					'general_settings_critical_pages_help_tab' => array(
149
+						'title'    => __('Critical Pages', 'event_espresso'),
150
+						'filename' => 'general_settings_critical_pages',
151
+					),
152
+				),
153
+				'help_tour'     => array('Critical_Pages_Help_Tour'),
154
+				'require_nonce' => false,
155
+			),
156
+			'default'               => array(
157
+				'nav'           => array(
158
+					'label' => __('Your Organization', 'event_espresso'),
159
+					'order' => 20,
160
+				),
161
+				'help_tabs'     => array(
162
+					'general_settings_your_organization_help_tab' => array(
163
+						'title'    => __('Your Organization', 'event_espresso'),
164
+						'filename' => 'general_settings_your_organization',
165
+					),
166
+				),
167
+				'help_tour'     => array('Your_Organization_Help_Tour'),
168
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
169
+				'require_nonce' => false,
170
+			),
171
+			'admin_option_settings' => array(
172
+				'nav'           => array(
173
+					'label' => __('Admin Options', 'event_espresso'),
174
+					'order' => 60,
175
+				),
176
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
177
+				'help_tabs'     => array(
178
+					'general_settings_admin_options_help_tab' => array(
179
+						'title'    => __('Admin Options', 'event_espresso'),
180
+						'filename' => 'general_settings_admin_options',
181
+					),
182
+				),
183
+				'help_tour'     => array('Admin_Options_Help_Tour'),
184
+				'require_nonce' => false,
185
+			),
186
+			'country_settings'      => array(
187
+				'nav'           => array(
188
+					'label' => __('Countries', 'event_espresso'),
189
+					'order' => 70,
190
+				),
191
+				'help_tabs'     => array(
192
+					'general_settings_countries_help_tab' => array(
193
+						'title'    => __('Countries', 'event_espresso'),
194
+						'filename' => 'general_settings_countries',
195
+					),
196
+				),
197
+				'help_tour'     => array('Countries_Help_Tour'),
198
+				'require_nonce' => false,
199
+			),
200
+		);
201
+	}
202
+
203
+
204
+
205
+	protected function _add_screen_options()
206
+	{
207
+	}
208
+
209
+	protected function _add_feature_pointers()
210
+	{
211
+	}
212
+
213
+
214
+	/**
215
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
216
+	 */
217
+	public function load_scripts_styles()
218
+	{
219
+		//styles
220
+		wp_enqueue_style('espresso-ui-theme');
221
+		//scripts
222
+		wp_enqueue_script('ee_admin_js');
223
+	}
224
+
225
+
226
+	/**
227
+	 * Execute logic running on `admin_init`
228
+	 */
229
+	public function admin_init()
230
+	{
231
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
232
+			'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.',
233
+			'event_espresso'
234
+		);
235
+		EE_Registry::$i18n_js_strings['error_occurred']          = __(
236
+			'An error occurred! Please refresh the page and try again.',
237
+			'event_espresso'
238
+		);
239
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = __(
240
+			'Are you sure you want to delete this State / Province?',
241
+			'event_espresso'
242
+		);
243
+		$protocol                                                = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
244
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
245
+			'admin-ajax.php?page=espresso_general_settings',
246
+			$protocol
247
+		);
248
+	}
249
+
250
+	public function admin_notices()
251
+	{
252
+	}
253
+
254
+	public function admin_footer_scripts()
255
+	{
256
+	}
257
+
258
+
259
+	/**
260
+	 * Enqueue scripts and styles for the default route.
261
+	 */
262
+	public function load_scripts_styles_default()
263
+	{
264
+		//styles
265
+		wp_enqueue_style('thickbox');
266
+		//scripts
267
+		wp_enqueue_script('media-upload');
268
+		wp_enqueue_script('thickbox');
269
+		wp_register_script(
270
+			'organization_settings',
271
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
272
+			array('jquery', 'media-upload', 'thickbox'),
273
+			EVENT_ESPRESSO_VERSION,
274
+			true
275
+		);
276
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
277
+		wp_enqueue_script('organization_settings');
278
+		wp_enqueue_style('organization-css');
279
+		$confirm_image_delete = array(
280
+			'text' => __(
281
+				'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
282
+				'event_espresso'
283
+			),
284
+		);
285
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
286
+	}
287
+
288
+
289
+	/**
290
+	 * Enqueue scripts and styles for the country settings route.
291
+	 */
292
+	public function load_scripts_styles_country_settings()
293
+	{
294
+		//scripts
295
+		wp_register_script(
296
+			'gen_settings_countries',
297
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
298
+			array('ee_admin_js'),
299
+			EVENT_ESPRESSO_VERSION,
300
+			true
301
+		);
302
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
303
+		wp_enqueue_script('gen_settings_countries');
304
+		wp_enqueue_style('organization-css');
305
+	}
306
+
307
+
308
+	/*************        Espresso Pages        *************/
309
+	/**
310
+	 * _espresso_page_settings
311
+	 *
312
+	 * @throws \EE_Error
313
+	 */
314
+	protected function _espresso_page_settings()
315
+	{
316
+		// Check to make sure all of the main pages are setup properly,
317
+		// if not create the default pages and display an admin notice
318
+		EEH_Activation::verify_default_pages_exist();
319
+		$this->_transient_garbage_collection();
320
+		$this->_template_args['values']             = $this->_yes_no_values;
321
+		$this->_template_args['reg_page_id']        = isset(EE_Registry::instance()->CFG->core->reg_page_id)
322
+			? EE_Registry::instance()->CFG->core->reg_page_id
323
+			: null;
324
+		$this->_template_args['reg_page_obj']       = isset(EE_Registry::instance()->CFG->core->reg_page_id)
325
+			? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
326
+			: false;
327
+		$this->_template_args['txn_page_id']        = isset(EE_Registry::instance()->CFG->core->txn_page_id)
328
+			? EE_Registry::instance()->CFG->core->txn_page_id
329
+			: null;
330
+		$this->_template_args['txn_page_obj']       = isset(EE_Registry::instance()->CFG->core->txn_page_id)
331
+			? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
332
+			: false;
333
+		$this->_template_args['thank_you_page_id']  = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
334
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
335
+			: null;
336
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
337
+			? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
338
+			: false;
339
+		$this->_template_args['cancel_page_id']     = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
340
+			? EE_Registry::instance()->CFG->core->cancel_page_id
341
+			: null;
342
+		$this->_template_args['cancel_page_obj']    = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
343
+			? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
344
+			: false;
345
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
346
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
347
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
348
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
349
+			$this->_template_args,
350
+			true
351
+		);
352
+		$this->display_admin_page_with_sidebar();
353
+	}
354
+
355
+
356
+	/**
357
+	 * Handler for updating espresso page settings.
358
+	 */
359
+	protected function _update_espresso_page_settings()
360
+	{
361
+		// capture incoming request data && set page IDs
362
+		EE_Registry::instance()->CFG->core->reg_page_id       = isset($this->_req_data['reg_page_id'])
363
+			? absint($this->_req_data['reg_page_id'])
364
+			: EE_Registry::instance()->CFG->core->reg_page_id;
365
+		EE_Registry::instance()->CFG->core->txn_page_id       = isset($this->_req_data['txn_page_id'])
366
+			? absint($this->_req_data['txn_page_id'])
367
+			: EE_Registry::instance()->CFG->core->txn_page_id;
368
+		EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
369
+			? absint($this->_req_data['thank_you_page_id'])
370
+			: EE_Registry::instance()->CFG->core->thank_you_page_id;
371
+		EE_Registry::instance()->CFG->core->cancel_page_id    = isset($this->_req_data['cancel_page_id'])
372
+			? absint($this->_req_data['cancel_page_id'])
373
+			: EE_Registry::instance()->CFG->core->cancel_page_id;
374
+
375
+		EE_Registry::instance()->CFG->core = apply_filters(
376
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
377
+			EE_Registry::instance()->CFG->core,
378
+			$this->_req_data
379
+		);
380
+		$what                              = __('Critical Pages & Shortcodes', 'event_espresso');
381
+		$this->_redirect_after_action(
382
+			$this->_update_espresso_configuration(
383
+				$what,
384
+				EE_Registry::instance()->CFG->core,
385
+				__FILE__,
386
+				__FUNCTION__,
387
+				__LINE__
388
+			),
389
+			$what,
390
+			'',
391
+			array(
392
+				'action' => 'critical_pages',
393
+			),
394
+			true
395
+		);
396
+	}
397
+
398
+
399
+	/*************        Your Organization        *************/
400
+
401
+
402
+	/**
403
+	 * Output for the Your Organization settings route.
404
+	 * @throws DomainException
405
+	 * @throws EE_Error
406
+	 */
407
+	protected function _your_organization_settings()
408
+	{
409
+
410
+		$this->_template_args['site_license_key']       = isset(
411
+			EE_Registry::instance()->NET_CFG->core->site_license_key
412
+		)
413
+			? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key')
414
+			: '';
415
+		$this->_template_args['organization_name']      = isset(EE_Registry::instance()->CFG->organization->name)
416
+			? EE_Registry::instance()->CFG->organization->get_pretty('name')
417
+			: '';
418
+		$this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1)
419
+			? EE_Registry::instance()->CFG->organization->get_pretty('address_1')
420
+			: '';
421
+		$this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2)
422
+			? EE_Registry::instance()->CFG->organization->get_pretty('address_2')
423
+			: '';
424
+		$this->_template_args['organization_city']      = isset(EE_Registry::instance()->CFG->organization->city)
425
+			? EE_Registry::instance()->CFG->organization->get_pretty('city')
426
+			: '';
427
+		$this->_template_args['organization_zip']       = isset(EE_Registry::instance()->CFG->organization->zip)
428
+			? EE_Registry::instance()->CFG->organization->get_pretty('zip')
429
+			: '';
430
+		$this->_template_args['organization_email']     = isset(EE_Registry::instance()->CFG->organization->email)
431
+			? EE_Registry::instance()->CFG->organization->get_pretty('email')
432
+			: '';
433
+		$this->_template_args['organization_phone']     = isset(EE_Registry::instance()->CFG->organization->phone)
434
+			? EE_Registry::instance()->CFG->organization->get_pretty('phone')
435
+			: '';
436
+		$this->_template_args['organization_vat']       = isset(EE_Registry::instance()->CFG->organization->vat)
437
+			? EE_Registry::instance()->CFG->organization->get_pretty('vat')
438
+			: '';
439
+		$this->_template_args['currency_sign']          = isset(EE_Registry::instance()->CFG->currency->sign)
440
+			? EE_Registry::instance()->CFG->currency->get_pretty('sign')
441
+			: '$';
442
+		$this->_template_args['organization_logo_url']  = isset(EE_Registry::instance()->CFG->organization->logo_url)
443
+			? EE_Registry::instance()->CFG->organization->get_pretty('logo_url')
444
+			: false;
445
+		$this->_template_args['organization_facebook']  = isset(EE_Registry::instance()->CFG->organization->facebook)
446
+			? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
447
+			: '';
448
+		$this->_template_args['organization_twitter']   = isset(EE_Registry::instance()->CFG->organization->twitter)
449
+			? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
450
+			: '';
451
+		$this->_template_args['organization_linkedin']  = isset(EE_Registry::instance()->CFG->organization->linkedin)
452
+			? EE_Registry::instance()->CFG->organization->get_pretty('linkedin')
453
+			: '';
454
+		$this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest)
455
+			? EE_Registry::instance()->CFG->organization->get_pretty('pinterest')
456
+			: '';
457
+		$this->_template_args['organization_google']    = isset(EE_Registry::instance()->CFG->organization->google)
458
+			? EE_Registry::instance()->CFG->organization->get_pretty('google')
459
+			: '';
460
+		$this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram)
461
+			? EE_Registry::instance()->CFG->organization->get_pretty('instagram')
462
+			: '';
463
+		//UXIP settings
464
+		$this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin)
465
+			? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin')
466
+			: true;
467
+
468
+		$STA_ID                         = isset(EE_Registry::instance()->CFG->organization->STA_ID)
469
+			? EE_Registry::instance()->CFG->organization->STA_ID
470
+			: 4;
471
+		$this->_template_args['states'] = new EE_Question_Form_Input(
472
+			EE_Question::new_instance(array(
473
+				'QST_ID'           => 0,
474
+				'QST_display_text' => __('State/Province', 'event_espresso'),
475
+				'QST_system'       => 'admin-state',
476
+			)),
477
+			EE_Answer::new_instance(array(
478
+				'ANS_ID'    => 0,
479
+				'ANS_value' => $STA_ID,
480
+			)),
481
+			array(
482
+				'input_id'       => 'organization_state',
483
+				'input_name'     => 'organization_state',
484
+				'input_prefix'   => '',
485
+				'append_qstn_id' => false,
486
+			)
487
+		);
488
+
489
+		$CNT_ISO                           = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
490
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
491
+			: 'US';
492
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
493
+			EE_Question::new_instance(array(
494
+				'QST_ID'           => 0,
495
+				'QST_display_text' => __('Country', 'event_espresso'),
496
+				'QST_system'       => 'admin-country',
497
+			)),
498
+			EE_Answer::new_instance(array(
499
+				'ANS_ID'    => 0,
500
+				'ANS_value' => $CNT_ISO,
501
+			)),
502
+			array(
503
+				'input_id'       => 'organization_country',
504
+				'input_name'     => 'organization_country',
505
+				'input_prefix'   => '',
506
+				'append_qstn_id' => false,
507
+			)
508
+		);
509
+
510
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
511
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
512
+
513
+		//PUE verification stuff
514
+		$ver_option_key                                    = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
515
+		$verify_fail                                       = get_option($ver_option_key);
516
+		$this->_template_args['site_license_key_verified'] = $verify_fail
517
+															 || ! empty($verify_fail)
518
+															 || (empty($this->_template_args['site_license_key'])
519
+																 && empty($verify_fail)
520
+															 )
521
+			? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>'
522
+			: '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
523
+
524
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
525
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
526
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
527
+			GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
528
+			$this->_template_args,
529
+			true
530
+		);
531
+
532
+		$this->display_admin_page_with_sidebar();
533
+	}
534
+
535
+
536
+	/**
537
+	 * Handler for updating organziation settings.
538
+	 */
539
+	protected function _update_your_organization_settings()
540
+	{
541
+		if (is_main_site()) {
542
+			EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key'])
543
+				? sanitize_text_field($this->_req_data['site_license_key'])
544
+				: EE_Registry::instance()->NET_CFG->core->site_license_key;
545
+		}
546
+		EE_Registry::instance()->CFG->organization->name      = isset($this->_req_data['organization_name'])
547
+			? sanitize_text_field($this->_req_data['organization_name'])
548
+			: EE_Registry::instance()->CFG->organization->name;
549
+		EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1'])
550
+			? sanitize_text_field($this->_req_data['organization_address_1'])
551
+			: EE_Registry::instance()->CFG->organization->address_1;
552
+		EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2'])
553
+			? sanitize_text_field($this->_req_data['organization_address_2'])
554
+			: EE_Registry::instance()->CFG->organization->address_2;
555
+		EE_Registry::instance()->CFG->organization->city      = isset($this->_req_data['organization_city'])
556
+			? sanitize_text_field($this->_req_data['organization_city'])
557
+			: EE_Registry::instance()->CFG->organization->city;
558
+		EE_Registry::instance()->CFG->organization->STA_ID    = isset($this->_req_data['organization_state'])
559
+			? absint($this->_req_data['organization_state'])
560
+			: EE_Registry::instance()->CFG->organization->STA_ID;
561
+		EE_Registry::instance()->CFG->organization->CNT_ISO   = isset($this->_req_data['organization_country'])
562
+			? sanitize_text_field($this->_req_data['organization_country'])
563
+			: EE_Registry::instance()->CFG->organization->CNT_ISO;
564
+		EE_Registry::instance()->CFG->organization->zip       = isset($this->_req_data['organization_zip'])
565
+			? sanitize_text_field($this->_req_data['organization_zip'])
566
+			: EE_Registry::instance()->CFG->organization->zip;
567
+		EE_Registry::instance()->CFG->organization->email     = isset($this->_req_data['organization_email'])
568
+			? sanitize_email($this->_req_data['organization_email'])
569
+			: EE_Registry::instance()->CFG->organization->email;
570
+		EE_Registry::instance()->CFG->organization->vat       = isset($this->_req_data['organization_vat'])
571
+			? sanitize_text_field($this->_req_data['organization_vat'])
572
+			: EE_Registry::instance()->CFG->organization->vat;
573
+		EE_Registry::instance()->CFG->organization->phone     = isset($this->_req_data['organization_phone'])
574
+			? sanitize_text_field($this->_req_data['organization_phone'])
575
+			: EE_Registry::instance()->CFG->organization->phone;
576
+		EE_Registry::instance()->CFG->organization->logo_url  = isset($this->_req_data['organization_logo_url'])
577
+			? esc_url_raw($this->_req_data['organization_logo_url'])
578
+			: EE_Registry::instance()->CFG->organization->logo_url;
579
+		EE_Registry::instance()->CFG->organization->facebook  = isset($this->_req_data['organization_facebook'])
580
+			? esc_url_raw($this->_req_data['organization_facebook'])
581
+			: EE_Registry::instance()->CFG->organization->facebook;
582
+		EE_Registry::instance()->CFG->organization->twitter   = isset($this->_req_data['organization_twitter'])
583
+			? esc_url_raw($this->_req_data['organization_twitter'])
584
+			: EE_Registry::instance()->CFG->organization->twitter;
585
+		EE_Registry::instance()->CFG->organization->linkedin  = isset($this->_req_data['organization_linkedin'])
586
+			? esc_url_raw($this->_req_data['organization_linkedin'])
587
+			: EE_Registry::instance()->CFG->organization->linkedin;
588
+		EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest'])
589
+			? esc_url_raw($this->_req_data['organization_pinterest'])
590
+			: EE_Registry::instance()->CFG->organization->pinterest;
591
+		EE_Registry::instance()->CFG->organization->google    = isset($this->_req_data['organization_google'])
592
+			? esc_url_raw($this->_req_data['organization_google'])
593
+			: EE_Registry::instance()->CFG->organization->google;
594
+		EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram'])
595
+			? esc_url_raw($this->_req_data['organization_instagram'])
596
+			: EE_Registry::instance()->CFG->organization->instagram;
597
+		EE_Registry::instance()->CFG->core->ee_ueip_optin     = isset($this->_req_data['ueip_optin'])
598
+																&& ! empty($this->_req_data['ueip_optin'])
599
+			? $this->_req_data['ueip_optin']
600
+			: EE_Registry::instance()->CFG->core->ee_ueip_optin;
601
+
602
+		EE_Registry::instance()->CFG->currency = new EE_Currency_Config(
603
+			EE_Registry::instance()->CFG->organization->CNT_ISO
604
+		);
605
+
606
+		EE_Registry::instance()->CFG = apply_filters(
607
+			'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
608
+			EE_Registry::instance()->CFG
609
+		);
610
+
611
+		$what    = 'Your Organization Settings';
612
+		$success = $this->_update_espresso_configuration(
613
+			$what,
614
+			EE_Registry::instance()->CFG,
615
+			__FILE__,
616
+			__FUNCTION__,
617
+			__LINE__
618
+		);
619
+
620
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
621
+	}
622
+
623
+
624
+
625
+	/*************        Admin Options        *************/
626
+
627
+
628
+	/**
629
+	 * _admin_option_settings
630
+	 *
631
+	 * @throws \EE_Error
632
+	 * @throws \LogicException
633
+	 */
634
+	protected function _admin_option_settings()
635
+	{
636
+		$this->_template_args['admin_page_content'] = '';
637
+		try {
638
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
639
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
640
+			$this->_template_args['values'] = $this->_yes_no_values;
641
+			// also need to account for the do_action that was in the old template
642
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
643
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
644
+		} catch (Exception $e) {
645
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
646
+		}
647
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
648
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
649
+		$this->display_admin_page_with_sidebar();
650
+	}
651
+
652
+
653
+	/**
654
+	 * _update_admin_option_settings
655
+	 *
656
+	 * @throws \EE_Error
657
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
658
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
659
+	 * @throws \InvalidArgumentException
660
+	 * @throws \LogicException
661
+	 */
662
+	protected function _update_admin_option_settings()
663
+	{
664
+		try {
665
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
666
+			$admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
667
+			EE_Registry::instance()->CFG->admin = apply_filters(
668
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
669
+				EE_Registry::instance()->CFG->admin
670
+			);
671
+		} catch (Exception $e) {
672
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
673
+		}
674
+		$this->_redirect_after_action(
675
+			apply_filters(
676
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
677
+				$this->_update_espresso_configuration(
678
+					'Admin Options',
679
+					EE_Registry::instance()->CFG->admin,
680
+					__FILE__, __FUNCTION__, __LINE__
681
+				)
682
+			),
683
+			'Admin Options',
684
+			'updated',
685
+			array('action' => 'admin_option_settings')
686
+		);
687
+
688
+	}
689
+
690
+
691
+	/*************        Countries        *************/
692
+
693
+
694
+	/**
695
+	 * Output Country Settings view.
696
+	 * @throws DomainException
697
+	 * @throws EE_Error
698
+	 */
699
+	protected function _country_settings()
700
+	{
701
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
702
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
703
+			: 'US';
704
+		$CNT_ISO = isset($this->_req_data['country'])
705
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
706
+			: $CNT_ISO;
707
+
708
+		//load field generator helper
709
+
710
+		$this->_template_args['values'] = $this->_yes_no_values;
711
+
712
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
713
+			EE_Question::new_instance(array(
714
+				'QST_ID'           => 0,
715
+				'QST_display_text' => __('Select Country', 'event_espresso'),
716
+				'QST_system'       => 'admin-country',
717
+			)),
718
+			EE_Answer::new_instance(array(
719
+				'ANS_ID'    => 0,
720
+				'ANS_value' => $CNT_ISO,
721
+			)),
722
+			array(
723
+				'input_id'       => 'country',
724
+				'input_name'     => 'country',
725
+				'input_prefix'   => '',
726
+				'append_qstn_id' => false,
727
+			)
728
+		);
729
+
730
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
731
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
732
+		$this->_template_args['country_details_settings'] = $this->display_country_settings();
733
+		$this->_template_args['country_states_settings']  = $this->display_country_states();
734
+
735
+		$this->_set_add_edit_form_tags('update_country_settings');
736
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
737
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
738
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
739
+			$this->_template_args,
740
+			true
741
+		);
742
+		$this->display_admin_page_with_no_sidebar();
743
+	}
744
+
745
+
746
+	/**
747
+	 *        display_country_settings
748
+	 *
749
+	 * @access    public
750
+	 * @param    string $CNT_ISO
751
+	 * @return mixed string | array
752
+	 * @throws DomainException
753
+	 */
754
+	public function display_country_settings($CNT_ISO = '')
755
+	{
756
+
757
+		$CNT_ISO = isset($this->_req_data['country'])
758
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
759
+			: $CNT_ISO;
760
+		if (! $CNT_ISO) {
761
+			return '';
762
+		}
763
+
764
+		// for ajax
765
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
766
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
767
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
768
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
769
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
770
+
771
+		$country_input_types            = array(
772
+			'CNT_active'      => array(
773
+				'type'             => 'RADIO_BTN',
774
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
775
+				'class'            => '',
776
+				'options'          => $this->_yes_no_values,
777
+				'use_desc_4_label' => true,
778
+			),
779
+			'CNT_ISO'         => array(
780
+				'type'       => 'TEXT',
781
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
782
+				'class'      => 'small-text',
783
+			),
784
+			'CNT_ISO3'        => array(
785
+				'type'       => 'TEXT',
786
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
787
+				'class'      => 'small-text',
788
+			),
789
+			'RGN_ID'          => array(
790
+				'type'       => 'TEXT',
791
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
792
+				'class'      => 'small-text',
793
+			),
794
+			'CNT_name'        => array(
795
+				'type'       => 'TEXT',
796
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
797
+				'class'      => 'regular-text',
798
+			),
799
+			'CNT_cur_code'    => array(
800
+				'type'       => 'TEXT',
801
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
802
+				'class'      => 'small-text',
803
+			),
804
+			'CNT_cur_single'  => array(
805
+				'type'       => 'TEXT',
806
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
807
+				'class'      => 'medium-text',
808
+			),
809
+			'CNT_cur_plural'  => array(
810
+				'type'       => 'TEXT',
811
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
812
+				'class'      => 'medium-text',
813
+			),
814
+			'CNT_cur_sign'    => array(
815
+				'type'         => 'TEXT',
816
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
817
+				'class'        => 'small-text',
818
+				'htmlentities' => false,
819
+			),
820
+			'CNT_cur_sign_b4' => array(
821
+				'type'             => 'RADIO_BTN',
822
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
823
+				'class'            => '',
824
+				'options'          => $this->_yes_no_values,
825
+				'use_desc_4_label' => true,
826
+			),
827
+			'CNT_cur_dec_plc' => array(
828
+				'type'       => 'RADIO_BTN',
829
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
830
+				'class'      => '',
831
+				'options'    => array(
832
+					array('id' => 0, 'text' => ''),
833
+					array('id' => 1, 'text' => ''),
834
+					array('id' => 2, 'text' => ''),
835
+					array('id' => 3, 'text' => ''),
836
+				),
837
+			),
838
+			'CNT_cur_dec_mrk' => array(
839
+				'type'             => 'RADIO_BTN',
840
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
841
+				'class'            => '',
842
+				'options'          => array(
843
+					array(
844
+						'id'   => ',',
845
+						'text' => __(', (comma)', 'event_espresso'),
846
+					),
847
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
848
+				),
849
+				'use_desc_4_label' => true,
850
+			),
851
+			'CNT_cur_thsnds'  => array(
852
+				'type'             => 'RADIO_BTN',
853
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
854
+				'class'            => '',
855
+				'options'          => array(
856
+					array(
857
+						'id'   => ',',
858
+						'text' => __(', (comma)', 'event_espresso'),
859
+					),
860
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
861
+				),
862
+				'use_desc_4_label' => true,
863
+			),
864
+			'CNT_tel_code'    => array(
865
+				'type'       => 'TEXT',
866
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
867
+				'class'      => 'small-text',
868
+			),
869
+			'CNT_is_EU'       => array(
870
+				'type'             => 'RADIO_BTN',
871
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
872
+				'class'            => '',
873
+				'options'          => $this->_yes_no_values,
874
+				'use_desc_4_label' => true,
875
+			),
876
+		);
877
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
878
+			$country,
879
+			$country_input_types
880
+		);
881
+		$country_details_settings       = EEH_Template::display_template(
882
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
883
+			$this->_template_args,
884
+			true
885
+		);
886
+
887
+		if (defined('DOING_AJAX')) {
888
+			$notices = EE_Error::get_notices(false, false, false);
889
+			echo wp_json_encode(array(
890
+				'return_data' => $country_details_settings,
891
+				'success'     => $notices['success'],
892
+				'errors'      => $notices['errors'],
893
+			));
894
+			die();
895
+		} else {
896
+			return $country_details_settings;
897
+		}
898
+	}
899
+
900
+
901
+	/**
902
+	 *        display_country_states
903
+	 *
904
+	 * @access    public
905
+	 * @param    string $CNT_ISO
906
+	 * @return string
907
+	 * @throws DomainException
908
+	 */
909
+	public function display_country_states($CNT_ISO = '')
910
+	{
911
+
912
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
913
+
914
+		if (! $CNT_ISO) {
915
+			return '';
916
+		}
917
+		// for ajax
918
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
919
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
920
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
921
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
922
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
923
+
924
+		if ($states) {
925
+			foreach ($states as $STA_ID => $state) {
926
+				if ($state instanceof EE_State) {
927
+					//STA_abbrev 	STA_name 	STA_active
928
+					$state_input_types                                           = array(
929
+						'STA_abbrev' => array(
930
+							'type'       => 'TEXT',
931
+							'input_name' => 'states[' . $STA_ID . ']',
932
+							'class'      => 'mid-text',
933
+						),
934
+						'STA_name'   => array(
935
+							'type'       => 'TEXT',
936
+							'input_name' => 'states[' . $STA_ID . ']',
937
+							'class'      => 'regular-text',
938
+						),
939
+						'STA_active' => array(
940
+							'type'             => 'RADIO_BTN',
941
+							'input_name'       => 'states[' . $STA_ID . ']',
942
+							'options'          => $this->_yes_no_values,
943
+							'use_desc_4_label' => true,
944
+						),
945
+					);
946
+					$this->_template_args['states'][$STA_ID]['inputs'] =
947
+						EE_Question_Form_Input::generate_question_form_inputs_for_object(
948
+							$state,
949
+							$state_input_types
950
+						);
951
+					$query_args                                                  = array(
952
+						'action'     => 'delete_state',
953
+						'STA_ID'     => $STA_ID,
954
+						'CNT_ISO'    => $CNT_ISO,
955
+						'STA_abbrev' => $state->abbrev(),
956
+					);
957
+					$this->_template_args['states'][$STA_ID]['delete_state_url'] =
958
+						EE_Admin_Page::add_query_args_and_nonce(
959
+							$query_args,
960
+							GEN_SET_ADMIN_URL
961
+						);
962
+				}
963
+			}
964
+		} else {
965
+			$this->_template_args['states'] = false;
966
+		}
967
+
968
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
969
+			array('action' => 'add_new_state'),
970
+			GEN_SET_ADMIN_URL
971
+		);
972
+
973
+		$state_details_settings = EEH_Template::display_template(
974
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
975
+			$this->_template_args,
976
+			true
977
+		);
978
+
979
+		if (defined('DOING_AJAX')) {
980
+			$notices = EE_Error::get_notices(false, false, false);
981
+			echo wp_json_encode(array(
982
+				'return_data' => $state_details_settings,
983
+				'success'     => $notices['success'],
984
+				'errors'      => $notices['errors'],
985
+			));
986
+			die();
987
+		} else {
988
+			return $state_details_settings;
989
+		}
990
+	}
991
+
992
+
993
+	/**
994
+	 *        add_new_state
995
+	 *
996
+	 * @access    public
997
+	 * @return void
998
+	 * @throws EE_Error
999
+	 */
1000
+	public function add_new_state()
1001
+	{
1002
+
1003
+		$success = true;
1004
+
1005
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
1006
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1007
+			: false;
1008
+		if (! $CNT_ISO) {
1009
+			EE_Error::add_error(
1010
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1011
+				__FILE__,
1012
+				__FUNCTION__,
1013
+				__LINE__
1014
+			);
1015
+			$success = false;
1016
+		}
1017
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
1018
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
1019
+			: false;
1020
+		if (! $STA_abbrev) {
1021
+			EE_Error::add_error(
1022
+				__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1023
+				__FILE__,
1024
+				__FUNCTION__,
1025
+				__LINE__
1026
+			);
1027
+			$success = false;
1028
+		}
1029
+		$STA_name = isset($this->_req_data['STA_name'])
1030
+			? sanitize_text_field($this->_req_data['STA_name'])
1031
+			: false;
1032
+		if (! $STA_name) {
1033
+			EE_Error::add_error(
1034
+				__('No State name or an invalid State name was received.', 'event_espresso'),
1035
+				__FILE__,
1036
+				__FUNCTION__,
1037
+				__LINE__
1038
+			);
1039
+			$success = false;
1040
+		}
1041
+
1042
+		if ($success) {
1043
+			$cols_n_values = array(
1044
+				'CNT_ISO'    => $CNT_ISO,
1045
+				'STA_abbrev' => $STA_abbrev,
1046
+				'STA_name'   => $STA_name,
1047
+				'STA_active' => true,
1048
+			);
1049
+			$success       = EEM_State::instance()->insert($cols_n_values);
1050
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1051
+		}
1052
+
1053
+		if (defined('DOING_AJAX')) {
1054
+			$notices = EE_Error::get_notices(false, false, false);
1055
+			echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
1056
+			die();
1057
+		} else {
1058
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
1059
+		}
1060
+	}
1061
+
1062
+
1063
+	/**
1064
+	 *        delete_state
1065
+	 *
1066
+	 * @access    public
1067
+	 * @return        boolean
1068
+	 */
1069
+	public function delete_state()
1070
+	{
1071
+		$CNT_ISO    = isset($this->_req_data['CNT_ISO'])
1072
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1073
+			: false;
1074
+		$STA_ID     = isset($this->_req_data['STA_ID'])
1075
+			? sanitize_text_field($this->_req_data['STA_ID'])
1076
+			: false;
1077
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
1078
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
1079
+			: false;
1080
+		if (! $STA_ID) {
1081
+			EE_Error::add_error(
1082
+				__('No State ID or an invalid State ID was received.', 'event_espresso'),
1083
+				__FILE__,
1084
+				__FUNCTION__,
1085
+				__LINE__
1086
+			);
1087
+			return false;
1088
+		}
1089
+
1090
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1091
+		if ($success !== false) {
1092
+			do_action(
1093
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1094
+				$CNT_ISO,
1095
+				$STA_ID,
1096
+				array('STA_abbrev' => $STA_abbrev)
1097
+			);
1098
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1099
+		}
1100
+		if (defined('DOING_AJAX')) {
1101
+			$notices                = EE_Error::get_notices(false, false);
1102
+			$notices['return_data'] = true;
1103
+			echo wp_json_encode($notices);
1104
+			die();
1105
+		} else {
1106
+			$this->_redirect_after_action(
1107
+				$success,
1108
+				'State',
1109
+				'deleted',
1110
+				array('action' => 'country_settings')
1111
+			);
1112
+		}
1113
+	}
1114
+
1115
+
1116
+	/**
1117
+	 *        _update_country_settings
1118
+	 *
1119
+	 * @access    protected
1120
+	 * @return void
1121
+	 * @throws EE_Error
1122
+	 */
1123
+	protected function _update_country_settings()
1124
+	{
1125
+		// grab the country ISO code
1126
+		$CNT_ISO = isset($this->_req_data['country'])
1127
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
1128
+			: false;
1129
+		if (! $CNT_ISO) {
1130
+			EE_Error::add_error(
1131
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1132
+				__FILE__,
1133
+				__FUNCTION__,
1134
+				__LINE__
1135
+			);
1136
+
1137
+			return;
1138
+		}
1139
+		$cols_n_values                    = array();
1140
+		$cols_n_values['CNT_ISO3']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])
1141
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']))
1142
+			: false;
1143
+		$cols_n_values['RGN_ID']          = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1144
+			? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1145
+			: null;
1146
+		$cols_n_values['CNT_name']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1147
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1148
+			: null;
1149
+		$cols_n_values['CNT_cur_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])
1150
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']))
1151
+			: 'USD';
1152
+		$cols_n_values['CNT_cur_single']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1153
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1154
+			: 'dollar';
1155
+		$cols_n_values['CNT_cur_plural']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1156
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1157
+			: 'dollars';
1158
+		$cols_n_values['CNT_cur_sign']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1159
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1160
+			: '$';
1161
+		$cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1162
+			? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1163
+			: true;
1164
+		$cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1165
+			? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1166
+			: 2;
1167
+		$cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1168
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1169
+			: '.';
1170
+		$cols_n_values['CNT_cur_thsnds']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1171
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1172
+			: ',';
1173
+		$cols_n_values['CNT_tel_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1174
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1175
+			: null;
1176
+		$cols_n_values['CNT_is_EU']       = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1177
+			? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1178
+			: false;
1179
+		$cols_n_values['CNT_active']      = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1180
+			? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1181
+			: false;
1182
+		// allow filtering of country data
1183
+		$cols_n_values = apply_filters(
1184
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1185
+			$cols_n_values
1186
+		);
1187
+
1188
+		// where values
1189
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1190
+		// run the update
1191
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1192
+
1193
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1194
+			// allow filtering of states data
1195
+			$states = apply_filters(
1196
+				'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1197
+				$this->_req_data['states']
1198
+			);
1199
+
1200
+			// loop thru state data ( looks like : states[75][STA_name] )
1201
+			foreach ($states as $STA_ID => $state) {
1202
+				$cols_n_values = array(
1203
+					'CNT_ISO'    => $CNT_ISO,
1204
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1205
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1206
+					'STA_active' => (bool)absint($state['STA_active']),
1207
+				);
1208
+				// where values
1209
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
1210
+				// run the update
1211
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1212
+				if ($success !== false) {
1213
+					do_action(
1214
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1215
+						$CNT_ISO,
1216
+						$STA_ID,
1217
+						$cols_n_values
1218
+					);
1219
+				}
1220
+			}
1221
+		}
1222
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1223
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1224
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1225
+		) {
1226
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1227
+			EE_Registry::instance()->CFG->update_espresso_config();
1228
+		}
1229
+
1230
+		if ($success !== false) {
1231
+			EE_Error::add_success(
1232
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1233
+			);
1234
+		}
1235
+		$this->_redirect_after_action(
1236
+			$success,
1237
+			'',
1238
+			'',
1239
+			array('action' => 'country_settings', 'country' => $CNT_ISO),
1240
+			true
1241
+		);
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 *        form_form_field_label_wrap
1247
+	 *
1248
+	 * @access        public
1249
+	 * @param        string $label
1250
+	 * @return        string
1251
+	 */
1252
+	public function country_form_field_label_wrap($label, $required_text)
1253
+	{
1254
+		return '
1255 1255
 			<tr>
1256 1256
 				<th>
1257 1257
 					' . $label . '
1258 1258
 				</th>';
1259
-    }
1260
-
1261
-
1262
-    /**
1263
-     *        form_form_field_input__wrap
1264
-     *
1265
-     * @access        public
1266
-     * @param        string $label
1267
-     * @return        string
1268
-     */
1269
-    public function country_form_field_input__wrap($input, $label)
1270
-    {
1271
-        return '
1259
+	}
1260
+
1261
+
1262
+	/**
1263
+	 *        form_form_field_input__wrap
1264
+	 *
1265
+	 * @access        public
1266
+	 * @param        string $label
1267
+	 * @return        string
1268
+	 */
1269
+	public function country_form_field_input__wrap($input, $label)
1270
+	{
1271
+		return '
1272 1272
 				<td class="general-settings-country-input-td">
1273 1273
 					' . $input . '
1274 1274
 				</td>
1275 1275
 			</tr>';
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     *        form_form_field_label_wrap
1281
-     *
1282
-     * @access        public
1283
-     * @param        string $label
1284
-     * @param        string $required_text
1285
-     * @return        string
1286
-     */
1287
-    public function state_form_field_label_wrap($label, $required_text)
1288
-    {
1289
-        return $required_text;
1290
-    }
1291
-
1292
-
1293
-    /**
1294
-     *        form_form_field_input__wrap
1295
-     *
1296
-     * @access        public
1297
-     * @param        string $label
1298
-     * @return        string
1299
-     */
1300
-    public function state_form_field_input__wrap($input, $label)
1301
-    {
1302
-        return '
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 *        form_form_field_label_wrap
1281
+	 *
1282
+	 * @access        public
1283
+	 * @param        string $label
1284
+	 * @param        string $required_text
1285
+	 * @return        string
1286
+	 */
1287
+	public function state_form_field_label_wrap($label, $required_text)
1288
+	{
1289
+		return $required_text;
1290
+	}
1291
+
1292
+
1293
+	/**
1294
+	 *        form_form_field_input__wrap
1295
+	 *
1296
+	 * @access        public
1297
+	 * @param        string $label
1298
+	 * @return        string
1299
+	 */
1300
+	public function state_form_field_input__wrap($input, $label)
1301
+	{
1302
+		return '
1303 1303
 				<td class="general-settings-country-state-input-td">
1304 1304
 					' . $input . '
1305 1305
 				</td>';
1306
-    }
1307
-
1308
-
1309
-    /***********/
1310
-
1311
-
1312
-    /**
1313
-     * displays edit and view links for critical EE pages
1314
-     *
1315
-     * @access public
1316
-     * @param int $ee_page_id
1317
-     * @return string
1318
-     */
1319
-    public static function edit_view_links($ee_page_id)
1320
-    {
1321
-        $links = '<a href="'
1322
-                 . add_query_arg(
1323
-                     array('post' => $ee_page_id, 'action' => 'edit'),
1324
-                     admin_url('post.php')
1325
-                 )
1326
-                 . '" >'
1327
-                 . __('Edit', 'event_espresso')
1328
-                 . '</a>';
1329
-        $links .= ' &nbsp;|&nbsp; ';
1330
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1331
-
1332
-        return $links;
1333
-    }
1334
-
1335
-
1336
-    /**
1337
-     * displays page and shortcode status for critical EE pages
1338
-     *
1339
-     * @param WP page object $ee_page
1340
-     * @return string
1341
-     */
1342
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1343
-    {
1344
-
1345
-        // page status
1346
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1347
-            $pg_colour = 'green';
1348
-            $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1349
-        } else {
1350
-            $pg_colour = 'red';
1351
-            $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1352
-        }
1353
-
1354
-        // shortcode status
1355
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1356
-            $sc_colour = 'green';
1357
-            $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1358
-        } else {
1359
-            $sc_colour = 'red';
1360
-            $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1361
-        }
1362
-
1363
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1364
-               . $pg_status
1365
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     * generates a dropdown of all parent pages - copied from WP core
1371
-     *
1372
-     * @param int $default
1373
-     * @param int $parent
1374
-     * @param int $level
1375
-     */
1376
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1377
-    {
1378
-        global $wpdb;
1379
-        $items = $wpdb->get_results(
1380
-            $wpdb->prepare(
1381
-                "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",
1382
-                $parent
1383
-            )
1384
-        );
1385
-
1386
-        if ($items) {
1387
-            foreach ($items as $item) {
1388
-                $pad = str_repeat('&nbsp;', $level * 3);
1389
-                if ($item->ID == $default) {
1390
-                    $current = ' selected="selected"';
1391
-                } else {
1392
-                    $current = '';
1393
-                }
1394
-
1395
-                echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1396
-                     . esc_html($item->post_title)
1397
-                     . "</option>";
1398
-                parent_dropdown($default, $item->ID, $level + 1);
1399
-            }
1400
-        }
1401
-    }
1306
+	}
1307
+
1308
+
1309
+	/***********/
1310
+
1311
+
1312
+	/**
1313
+	 * displays edit and view links for critical EE pages
1314
+	 *
1315
+	 * @access public
1316
+	 * @param int $ee_page_id
1317
+	 * @return string
1318
+	 */
1319
+	public static function edit_view_links($ee_page_id)
1320
+	{
1321
+		$links = '<a href="'
1322
+				 . add_query_arg(
1323
+					 array('post' => $ee_page_id, 'action' => 'edit'),
1324
+					 admin_url('post.php')
1325
+				 )
1326
+				 . '" >'
1327
+				 . __('Edit', 'event_espresso')
1328
+				 . '</a>';
1329
+		$links .= ' &nbsp;|&nbsp; ';
1330
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1331
+
1332
+		return $links;
1333
+	}
1334
+
1335
+
1336
+	/**
1337
+	 * displays page and shortcode status for critical EE pages
1338
+	 *
1339
+	 * @param WP page object $ee_page
1340
+	 * @return string
1341
+	 */
1342
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1343
+	{
1344
+
1345
+		// page status
1346
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1347
+			$pg_colour = 'green';
1348
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1349
+		} else {
1350
+			$pg_colour = 'red';
1351
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1352
+		}
1353
+
1354
+		// shortcode status
1355
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1356
+			$sc_colour = 'green';
1357
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1358
+		} else {
1359
+			$sc_colour = 'red';
1360
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1361
+		}
1362
+
1363
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1364
+			   . $pg_status
1365
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 * generates a dropdown of all parent pages - copied from WP core
1371
+	 *
1372
+	 * @param int $default
1373
+	 * @param int $parent
1374
+	 * @param int $level
1375
+	 */
1376
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1377
+	{
1378
+		global $wpdb;
1379
+		$items = $wpdb->get_results(
1380
+			$wpdb->prepare(
1381
+				"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",
1382
+				$parent
1383
+			)
1384
+		);
1385
+
1386
+		if ($items) {
1387
+			foreach ($items as $item) {
1388
+				$pad = str_repeat('&nbsp;', $level * 3);
1389
+				if ($item->ID == $default) {
1390
+					$current = ' selected="selected"';
1391
+				} else {
1392
+					$current = '';
1393
+				}
1394
+
1395
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1396
+					 . esc_html($item->post_title)
1397
+					 . "</option>";
1398
+				parent_dropdown($default, $item->ID, $level + 1);
1399
+			}
1400
+		}
1401
+	}
1402 1402
 }
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
             '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.',
233 233
             'event_espresso'
234 234
         );
235
-        EE_Registry::$i18n_js_strings['error_occurred']          = __(
235
+        EE_Registry::$i18n_js_strings['error_occurred'] = __(
236 236
             'An error occurred! Please refresh the page and try again.',
237 237
             'event_espresso'
238 238
         );
239
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = __(
239
+        EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
240 240
             'Are you sure you want to delete this State / Province?',
241 241
             'event_espresso'
242 242
         );
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
         wp_enqueue_script('thickbox');
269 269
         wp_register_script(
270 270
             'organization_settings',
271
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
271
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
272 272
             array('jquery', 'media-upload', 'thickbox'),
273 273
             EVENT_ESPRESSO_VERSION,
274 274
             true
275 275
         );
276
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
276
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
277 277
         wp_enqueue_script('organization_settings');
278 278
         wp_enqueue_style('organization-css');
279 279
         $confirm_image_delete = array(
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
         //scripts
295 295
         wp_register_script(
296 296
             'gen_settings_countries',
297
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
297
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
298 298
             array('ee_admin_js'),
299 299
             EVENT_ESPRESSO_VERSION,
300 300
             true
301 301
         );
302
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
302
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
303 303
         wp_enqueue_script('gen_settings_countries');
304 304
         wp_enqueue_style('organization-css');
305 305
     }
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
346 346
         $this->_set_publish_post_box_vars(null, false, false, null, false);
347 347
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
348
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
348
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
349 349
             $this->_template_args,
350 350
             true
351 351
         );
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
             EE_Registry::instance()->CFG->core,
378 378
             $this->_req_data
379 379
         );
380
-        $what                              = __('Critical Pages & Shortcodes', 'event_espresso');
380
+        $what = __('Critical Pages & Shortcodes', 'event_espresso');
381 381
         $this->_redirect_after_action(
382 382
             $this->_update_espresso_configuration(
383 383
                 $what,
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     protected function _your_organization_settings()
408 408
     {
409 409
 
410
-        $this->_template_args['site_license_key']       = isset(
410
+        $this->_template_args['site_license_key'] = isset(
411 411
             EE_Registry::instance()->NET_CFG->core->site_license_key
412 412
         )
413 413
             ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key')
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
512 512
 
513 513
         //PUE verification stuff
514
-        $ver_option_key                                    = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
514
+        $ver_option_key                                    = 'puvererr_'.basename(EE_PLUGIN_BASENAME);
515 515
         $verify_fail                                       = get_option($ver_option_key);
516 516
         $this->_template_args['site_license_key_verified'] = $verify_fail
517 517
                                                              || ! empty($verify_fail)
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
         $this->_set_add_edit_form_tags('update_your_organization_settings');
525 525
         $this->_set_publish_post_box_vars(null, false, false, null, false);
526 526
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
527
-            GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
527
+            GEN_SET_TEMPLATE_PATH.'your_organization_settings.template.php',
528 528
             $this->_template_args,
529 529
             true
530 530
         );
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
         $this->_set_add_edit_form_tags('update_country_settings');
736 736
         $this->_set_publish_post_box_vars(null, false, false, null, false);
737 737
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
738
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
738
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
739 739
             $this->_template_args,
740 740
             true
741 741
         );
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
         $CNT_ISO = isset($this->_req_data['country'])
758 758
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
759 759
             : $CNT_ISO;
760
-        if (! $CNT_ISO) {
760
+        if ( ! $CNT_ISO) {
761 761
             return '';
762 762
         }
763 763
 
@@ -768,65 +768,65 @@  discard block
 block discarded – undo
768 768
         add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
769 769
         $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
770 770
 
771
-        $country_input_types            = array(
771
+        $country_input_types = array(
772 772
             'CNT_active'      => array(
773 773
                 'type'             => 'RADIO_BTN',
774
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
774
+                'input_name'       => 'cntry['.$CNT_ISO.']',
775 775
                 'class'            => '',
776 776
                 'options'          => $this->_yes_no_values,
777 777
                 'use_desc_4_label' => true,
778 778
             ),
779 779
             'CNT_ISO'         => array(
780 780
                 'type'       => 'TEXT',
781
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
781
+                'input_name' => 'cntry['.$CNT_ISO.']',
782 782
                 'class'      => 'small-text',
783 783
             ),
784 784
             'CNT_ISO3'        => array(
785 785
                 'type'       => 'TEXT',
786
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
786
+                'input_name' => 'cntry['.$CNT_ISO.']',
787 787
                 'class'      => 'small-text',
788 788
             ),
789 789
             'RGN_ID'          => array(
790 790
                 'type'       => 'TEXT',
791
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
791
+                'input_name' => 'cntry['.$CNT_ISO.']',
792 792
                 'class'      => 'small-text',
793 793
             ),
794 794
             'CNT_name'        => array(
795 795
                 'type'       => 'TEXT',
796
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
796
+                'input_name' => 'cntry['.$CNT_ISO.']',
797 797
                 'class'      => 'regular-text',
798 798
             ),
799 799
             'CNT_cur_code'    => array(
800 800
                 'type'       => 'TEXT',
801
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
801
+                'input_name' => 'cntry['.$CNT_ISO.']',
802 802
                 'class'      => 'small-text',
803 803
             ),
804 804
             'CNT_cur_single'  => array(
805 805
                 'type'       => 'TEXT',
806
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
806
+                'input_name' => 'cntry['.$CNT_ISO.']',
807 807
                 'class'      => 'medium-text',
808 808
             ),
809 809
             'CNT_cur_plural'  => array(
810 810
                 'type'       => 'TEXT',
811
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
811
+                'input_name' => 'cntry['.$CNT_ISO.']',
812 812
                 'class'      => 'medium-text',
813 813
             ),
814 814
             'CNT_cur_sign'    => array(
815 815
                 'type'         => 'TEXT',
816
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
816
+                'input_name'   => 'cntry['.$CNT_ISO.']',
817 817
                 'class'        => 'small-text',
818 818
                 'htmlentities' => false,
819 819
             ),
820 820
             'CNT_cur_sign_b4' => array(
821 821
                 'type'             => 'RADIO_BTN',
822
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
822
+                'input_name'       => 'cntry['.$CNT_ISO.']',
823 823
                 'class'            => '',
824 824
                 'options'          => $this->_yes_no_values,
825 825
                 'use_desc_4_label' => true,
826 826
             ),
827 827
             'CNT_cur_dec_plc' => array(
828 828
                 'type'       => 'RADIO_BTN',
829
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
829
+                'input_name' => 'cntry['.$CNT_ISO.']',
830 830
                 'class'      => '',
831 831
                 'options'    => array(
832 832
                     array('id' => 0, 'text' => ''),
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
             ),
838 838
             'CNT_cur_dec_mrk' => array(
839 839
                 'type'             => 'RADIO_BTN',
840
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
840
+                'input_name'       => 'cntry['.$CNT_ISO.']',
841 841
                 'class'            => '',
842 842
                 'options'          => array(
843 843
                     array(
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
             ),
851 851
             'CNT_cur_thsnds'  => array(
852 852
                 'type'             => 'RADIO_BTN',
853
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
853
+                'input_name'       => 'cntry['.$CNT_ISO.']',
854 854
                 'class'            => '',
855 855
                 'options'          => array(
856 856
                     array(
@@ -863,12 +863,12 @@  discard block
 block discarded – undo
863 863
             ),
864 864
             'CNT_tel_code'    => array(
865 865
                 'type'       => 'TEXT',
866
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
866
+                'input_name' => 'cntry['.$CNT_ISO.']',
867 867
                 'class'      => 'small-text',
868 868
             ),
869 869
             'CNT_is_EU'       => array(
870 870
                 'type'             => 'RADIO_BTN',
871
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
871
+                'input_name'       => 'cntry['.$CNT_ISO.']',
872 872
                 'class'            => '',
873 873
                 'options'          => $this->_yes_no_values,
874 874
                 'use_desc_4_label' => true,
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
             $country,
879 879
             $country_input_types
880 880
         );
881
-        $country_details_settings       = EEH_Template::display_template(
882
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
881
+        $country_details_settings = EEH_Template::display_template(
882
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
883 883
             $this->_template_args,
884 884
             true
885 885
         );
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 
912 912
         $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
913 913
 
914
-        if (! $CNT_ISO) {
914
+        if ( ! $CNT_ISO) {
915 915
             return '';
916 916
         }
917 917
         // for ajax
@@ -925,20 +925,20 @@  discard block
 block discarded – undo
925 925
             foreach ($states as $STA_ID => $state) {
926 926
                 if ($state instanceof EE_State) {
927 927
                     //STA_abbrev 	STA_name 	STA_active
928
-                    $state_input_types                                           = array(
928
+                    $state_input_types = array(
929 929
                         'STA_abbrev' => array(
930 930
                             'type'       => 'TEXT',
931
-                            'input_name' => 'states[' . $STA_ID . ']',
931
+                            'input_name' => 'states['.$STA_ID.']',
932 932
                             'class'      => 'mid-text',
933 933
                         ),
934 934
                         'STA_name'   => array(
935 935
                             'type'       => 'TEXT',
936
-                            'input_name' => 'states[' . $STA_ID . ']',
936
+                            'input_name' => 'states['.$STA_ID.']',
937 937
                             'class'      => 'regular-text',
938 938
                         ),
939 939
                         'STA_active' => array(
940 940
                             'type'             => 'RADIO_BTN',
941
-                            'input_name'       => 'states[' . $STA_ID . ']',
941
+                            'input_name'       => 'states['.$STA_ID.']',
942 942
                             'options'          => $this->_yes_no_values,
943 943
                             'use_desc_4_label' => true,
944 944
                         ),
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
                             $state,
949 949
                             $state_input_types
950 950
                         );
951
-                    $query_args                                                  = array(
951
+                    $query_args = array(
952 952
                         'action'     => 'delete_state',
953 953
                         'STA_ID'     => $STA_ID,
954 954
                         'CNT_ISO'    => $CNT_ISO,
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
         );
972 972
 
973 973
         $state_details_settings = EEH_Template::display_template(
974
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
974
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
975 975
             $this->_template_args,
976 976
             true
977 977
         );
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
         $CNT_ISO = isset($this->_req_data['CNT_ISO'])
1006 1006
             ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1007 1007
             : false;
1008
-        if (! $CNT_ISO) {
1008
+        if ( ! $CNT_ISO) {
1009 1009
             EE_Error::add_error(
1010 1010
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1011 1011
                 __FILE__,
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1018 1018
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
1019 1019
             : false;
1020
-        if (! $STA_abbrev) {
1020
+        if ( ! $STA_abbrev) {
1021 1021
             EE_Error::add_error(
1022 1022
                 __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1023 1023
                 __FILE__,
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
         $STA_name = isset($this->_req_data['STA_name'])
1030 1030
             ? sanitize_text_field($this->_req_data['STA_name'])
1031 1031
             : false;
1032
-        if (! $STA_name) {
1032
+        if ( ! $STA_name) {
1033 1033
             EE_Error::add_error(
1034 1034
                 __('No State name or an invalid State name was received.', 'event_espresso'),
1035 1035
                 __FILE__,
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
                 'STA_name'   => $STA_name,
1047 1047
                 'STA_active' => true,
1048 1048
             );
1049
-            $success       = EEM_State::instance()->insert($cols_n_values);
1049
+            $success = EEM_State::instance()->insert($cols_n_values);
1050 1050
             EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1051 1051
         }
1052 1052
 
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1078 1078
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
1079 1079
             : false;
1080
-        if (! $STA_ID) {
1080
+        if ( ! $STA_ID) {
1081 1081
             EE_Error::add_error(
1082 1082
                 __('No State ID or an invalid State ID was received.', 'event_espresso'),
1083 1083
                 __FILE__,
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
         $CNT_ISO = isset($this->_req_data['country'])
1127 1127
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
1128 1128
             : false;
1129
-        if (! $CNT_ISO) {
1129
+        if ( ! $CNT_ISO) {
1130 1130
             EE_Error::add_error(
1131 1131
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1132 1132
                 __FILE__,
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
                     'CNT_ISO'    => $CNT_ISO,
1204 1204
                     'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1205 1205
                     'STA_name'   => sanitize_text_field($state['STA_name']),
1206
-                    'STA_active' => (bool)absint($state['STA_active']),
1206
+                    'STA_active' => (bool) absint($state['STA_active']),
1207 1207
                 );
1208 1208
                 // where values
1209 1209
                 $where_cols_n_values = array(array('STA_ID' => $STA_ID));
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
         return '
1255 1255
 			<tr>
1256 1256
 				<th>
1257
-					' . $label . '
1257
+					' . $label.'
1258 1258
 				</th>';
1259 1259
     }
1260 1260
 
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
     {
1271 1271
         return '
1272 1272
 				<td class="general-settings-country-input-td">
1273
-					' . $input . '
1273
+					' . $input.'
1274 1274
 				</td>
1275 1275
 			</tr>';
1276 1276
     }
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
     {
1302 1302
         return '
1303 1303
 				<td class="general-settings-country-state-input-td">
1304
-					' . $input . '
1304
+					' . $input.'
1305 1305
 				</td>';
1306 1306
     }
1307 1307
 
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
                  . __('Edit', 'event_espresso')
1328 1328
                  . '</a>';
1329 1329
         $links .= ' &nbsp;|&nbsp; ';
1330
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1330
+        $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>';
1331 1331
 
1332 1332
         return $links;
1333 1333
     }
@@ -1360,9 +1360,9 @@  discard block
 block discarded – undo
1360 1360
             $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1361 1361
         }
1362 1362
 
1363
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1363
+        return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'
1364 1364
                . $pg_status
1365
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1365
+               . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
1366 1366
     }
1367 1367
 
1368 1368
 
Please login to merge, or discard this patch.
core/services/assets/Registry.php 1 patch
Indentation   +439 added lines, -439 removed lines patch added patch discarded remove patch
@@ -23,449 +23,449 @@
 block discarded – undo
23 23
 class Registry
24 24
 {
25 25
 
26
-    /**
27
-     * @var EE_Template_Config $template_config
28
-     */
29
-    protected $template_config;
30
-
31
-    /**
32
-     * @var EE_Currency_Config $currency_config
33
-     */
34
-    protected $currency_config;
35
-
36
-    /**
37
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
38
-     *
39
-     * @var array
40
-     */
41
-    protected $jsdata = array();
42
-
43
-
44
-    /**
45
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
46
-     * page source.
47
-     * @var array
48
-     */
49
-    protected $script_handles_with_data = array();
50
-
51
-
52
-
53
-    /**
54
-     * Registry constructor.
55
-     * Hooking into WP actions for script registry.
56
-     *
57
-     * @param EE_Template_Config $template_config
58
-     * @param EE_Currency_Config $currency_config
59
-     */
60
-    public function __construct(EE_Template_Config $template_config, EE_Currency_Config $currency_config)
61
-    {
62
-        $this->template_config = $template_config;
63
-        $this->currency_config = $currency_config;
64
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
65
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
66
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
67
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
68
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
69
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
70
-    }
71
-
72
-
73
-
74
-    /**
75
-     * Callback for the WP script actions.
76
-     * Used to register globally accessible core scripts.
77
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
78
-     */
79
-    public function scripts()
80
-    {
81
-        global $wp_version;
82
-        wp_register_script(
83
-            'eejs-core',
84
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
85
-            array(),
86
-            EVENT_ESPRESSO_VERSION,
87
-            true
88
-        );
89
-        //only run this if WordPress 4.4.0 > is in use.
90
-        if (version_compare($wp_version, '4.4.0', '>')) {
91
-            //js.api
92
-            wp_register_script(
93
-                'eejs-api',
94
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
95
-                array('underscore', 'eejs-core'),
96
-                EVENT_ESPRESSO_VERSION,
97
-                true
98
-            );
99
-            $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
100
-            $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
101
-        }
102
-        if (! is_admin()) {
103
-            $this->loadCoreCss();
104
-        }
105
-        $this->loadCoreJs();
106
-        $this->loadJqueryValidate();
107
-        $this->loadAccountingJs();
108
-        $this->loadQtipJs();
109
-    }
110
-
111
-
112
-
113
-    /**
114
-     * Call back for the script print in frontend and backend.
115
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
116
-     *
117
-     * @since 4.9.31.rc.015
118
-     */
119
-    public function enqueueData()
120
-    {
121
-        $this->removeAlreadyRegisteredDataForScriptHandles();
122
-        wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
123
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
124
-        $this->localizeAccountingJs();
125
-        $this->addRegisteredScriptHandlesWithData('eejs-core');
126
-        $this->addRegisteredScriptHandlesWithData('espresso_core');
127
-    }
128
-
129
-
130
-
131
-    /**
132
-     * Used to add data to eejs.data object.
133
-     * Note:  Overriding existing data is not allowed.
134
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
135
-     * If the data you add is something like this:
136
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
137
-     * It will be exposed in the page source as:
138
-     *  eejs.data.my_plugin_data.foo == gar
139
-     *
140
-     * @param string       $key   Key used to access your data
141
-     * @param string|array $value Value to attach to key
142
-     * @throws InvalidArgumentException
143
-     */
144
-    public function addData($key, $value)
145
-    {
146
-        if ($this->verifyDataNotExisting($key)) {
147
-            $this->jsdata[$key] = $value;
148
-        }
149
-    }
150
-
151
-
152
-
153
-    /**
154
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
155
-     * elements in an array.
156
-     * When you use this method, the value you include will be appended to the end of an array on $key.
157
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
158
-     * object like this, eejs.data.test = [ my_data,
159
-     * ]
160
-     * If there has already been a scalar value attached to the data object given key, then
161
-     * this will throw an exception.
162
-     *
163
-     * @param string       $key   Key to attach data to.
164
-     * @param string|array $value Value being registered.
165
-     * @throws InvalidArgumentException
166
-     */
167
-    public function pushData($key, $value)
168
-    {
169
-        if (isset($this->jsdata[$key])
170
-            && ! is_array($this->jsdata[$key])
171
-        ) {
172
-            throw new invalidArgumentException(
173
-                sprintf(
174
-                    __(
175
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
26
+	/**
27
+	 * @var EE_Template_Config $template_config
28
+	 */
29
+	protected $template_config;
30
+
31
+	/**
32
+	 * @var EE_Currency_Config $currency_config
33
+	 */
34
+	protected $currency_config;
35
+
36
+	/**
37
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
38
+	 *
39
+	 * @var array
40
+	 */
41
+	protected $jsdata = array();
42
+
43
+
44
+	/**
45
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
46
+	 * page source.
47
+	 * @var array
48
+	 */
49
+	protected $script_handles_with_data = array();
50
+
51
+
52
+
53
+	/**
54
+	 * Registry constructor.
55
+	 * Hooking into WP actions for script registry.
56
+	 *
57
+	 * @param EE_Template_Config $template_config
58
+	 * @param EE_Currency_Config $currency_config
59
+	 */
60
+	public function __construct(EE_Template_Config $template_config, EE_Currency_Config $currency_config)
61
+	{
62
+		$this->template_config = $template_config;
63
+		$this->currency_config = $currency_config;
64
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
65
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
66
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
67
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
68
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
69
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
70
+	}
71
+
72
+
73
+
74
+	/**
75
+	 * Callback for the WP script actions.
76
+	 * Used to register globally accessible core scripts.
77
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
78
+	 */
79
+	public function scripts()
80
+	{
81
+		global $wp_version;
82
+		wp_register_script(
83
+			'eejs-core',
84
+			EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
85
+			array(),
86
+			EVENT_ESPRESSO_VERSION,
87
+			true
88
+		);
89
+		//only run this if WordPress 4.4.0 > is in use.
90
+		if (version_compare($wp_version, '4.4.0', '>')) {
91
+			//js.api
92
+			wp_register_script(
93
+				'eejs-api',
94
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
95
+				array('underscore', 'eejs-core'),
96
+				EVENT_ESPRESSO_VERSION,
97
+				true
98
+			);
99
+			$this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
100
+			$this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
101
+		}
102
+		if (! is_admin()) {
103
+			$this->loadCoreCss();
104
+		}
105
+		$this->loadCoreJs();
106
+		$this->loadJqueryValidate();
107
+		$this->loadAccountingJs();
108
+		$this->loadQtipJs();
109
+	}
110
+
111
+
112
+
113
+	/**
114
+	 * Call back for the script print in frontend and backend.
115
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
116
+	 *
117
+	 * @since 4.9.31.rc.015
118
+	 */
119
+	public function enqueueData()
120
+	{
121
+		$this->removeAlreadyRegisteredDataForScriptHandles();
122
+		wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
123
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
124
+		$this->localizeAccountingJs();
125
+		$this->addRegisteredScriptHandlesWithData('eejs-core');
126
+		$this->addRegisteredScriptHandlesWithData('espresso_core');
127
+	}
128
+
129
+
130
+
131
+	/**
132
+	 * Used to add data to eejs.data object.
133
+	 * Note:  Overriding existing data is not allowed.
134
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
135
+	 * If the data you add is something like this:
136
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
137
+	 * It will be exposed in the page source as:
138
+	 *  eejs.data.my_plugin_data.foo == gar
139
+	 *
140
+	 * @param string       $key   Key used to access your data
141
+	 * @param string|array $value Value to attach to key
142
+	 * @throws InvalidArgumentException
143
+	 */
144
+	public function addData($key, $value)
145
+	{
146
+		if ($this->verifyDataNotExisting($key)) {
147
+			$this->jsdata[$key] = $value;
148
+		}
149
+	}
150
+
151
+
152
+
153
+	/**
154
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
155
+	 * elements in an array.
156
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
157
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
158
+	 * object like this, eejs.data.test = [ my_data,
159
+	 * ]
160
+	 * If there has already been a scalar value attached to the data object given key, then
161
+	 * this will throw an exception.
162
+	 *
163
+	 * @param string       $key   Key to attach data to.
164
+	 * @param string|array $value Value being registered.
165
+	 * @throws InvalidArgumentException
166
+	 */
167
+	public function pushData($key, $value)
168
+	{
169
+		if (isset($this->jsdata[$key])
170
+			&& ! is_array($this->jsdata[$key])
171
+		) {
172
+			throw new invalidArgumentException(
173
+				sprintf(
174
+					__(
175
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
176 176
                          push values to this data element when it is an array.',
177
-                        'event_espresso'
178
-                    ),
179
-                    $key,
180
-                    __METHOD__
181
-                )
182
-            );
183
-        }
184
-        $this->jsdata[$key][] = $value;
185
-    }
186
-
187
-
188
-
189
-    /**
190
-     * Used to set content used by javascript for a template.
191
-     * Note: Overrides of existing registered templates are not allowed.
192
-     *
193
-     * @param string $template_reference
194
-     * @param string $template_content
195
-     * @throws InvalidArgumentException
196
-     */
197
-    public function addTemplate($template_reference, $template_content)
198
-    {
199
-        if (! isset($this->jsdata['templates'])) {
200
-            $this->jsdata['templates'] = array();
201
-        }
202
-        //no overrides allowed.
203
-        if (isset($this->jsdata['templates'][$template_reference])) {
204
-            throw new invalidArgumentException(
205
-                sprintf(
206
-                    __(
207
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
208
-                        'event_espresso'
209
-                    ),
210
-                    $template_reference
211
-                )
212
-            );
213
-        }
214
-        $this->jsdata['templates'][$template_reference] = $template_content;
215
-    }
216
-
217
-
218
-
219
-    /**
220
-     * Retrieve the template content already registered for the given reference.
221
-     *
222
-     * @param string $template_reference
223
-     * @return string
224
-     */
225
-    public function getTemplate($template_reference)
226
-    {
227
-        return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
228
-            ? $this->jsdata['templates'][$template_reference]
229
-            : '';
230
-    }
231
-
232
-
233
-
234
-    /**
235
-     * Retrieve registered data.
236
-     *
237
-     * @param string $key Name of key to attach data to.
238
-     * @return mixed                If there is no for the given key, then false is returned.
239
-     */
240
-    public function getData($key)
241
-    {
242
-        return isset($this->jsdata[$key])
243
-            ? $this->jsdata[$key]
244
-            : false;
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * Verifies whether the given data exists already on the jsdata array.
251
-     * Overriding data is not allowed.
252
-     *
253
-     * @param string $key Index for data.
254
-     * @return bool        If valid then return true.
255
-     * @throws InvalidArgumentException if data already exists.
256
-     */
257
-    protected function verifyDataNotExisting($key)
258
-    {
259
-        if (isset($this->jsdata[$key])) {
260
-            if (is_array($this->jsdata[$key])) {
261
-                throw new InvalidArgumentException(
262
-                    sprintf(
263
-                        __(
264
-                            'The value for %1$s already exists in the Registry::eejs object.
177
+						'event_espresso'
178
+					),
179
+					$key,
180
+					__METHOD__
181
+				)
182
+			);
183
+		}
184
+		$this->jsdata[$key][] = $value;
185
+	}
186
+
187
+
188
+
189
+	/**
190
+	 * Used to set content used by javascript for a template.
191
+	 * Note: Overrides of existing registered templates are not allowed.
192
+	 *
193
+	 * @param string $template_reference
194
+	 * @param string $template_content
195
+	 * @throws InvalidArgumentException
196
+	 */
197
+	public function addTemplate($template_reference, $template_content)
198
+	{
199
+		if (! isset($this->jsdata['templates'])) {
200
+			$this->jsdata['templates'] = array();
201
+		}
202
+		//no overrides allowed.
203
+		if (isset($this->jsdata['templates'][$template_reference])) {
204
+			throw new invalidArgumentException(
205
+				sprintf(
206
+					__(
207
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
208
+						'event_espresso'
209
+					),
210
+					$template_reference
211
+				)
212
+			);
213
+		}
214
+		$this->jsdata['templates'][$template_reference] = $template_content;
215
+	}
216
+
217
+
218
+
219
+	/**
220
+	 * Retrieve the template content already registered for the given reference.
221
+	 *
222
+	 * @param string $template_reference
223
+	 * @return string
224
+	 */
225
+	public function getTemplate($template_reference)
226
+	{
227
+		return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
228
+			? $this->jsdata['templates'][$template_reference]
229
+			: '';
230
+	}
231
+
232
+
233
+
234
+	/**
235
+	 * Retrieve registered data.
236
+	 *
237
+	 * @param string $key Name of key to attach data to.
238
+	 * @return mixed                If there is no for the given key, then false is returned.
239
+	 */
240
+	public function getData($key)
241
+	{
242
+		return isset($this->jsdata[$key])
243
+			? $this->jsdata[$key]
244
+			: false;
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * Verifies whether the given data exists already on the jsdata array.
251
+	 * Overriding data is not allowed.
252
+	 *
253
+	 * @param string $key Index for data.
254
+	 * @return bool        If valid then return true.
255
+	 * @throws InvalidArgumentException if data already exists.
256
+	 */
257
+	protected function verifyDataNotExisting($key)
258
+	{
259
+		if (isset($this->jsdata[$key])) {
260
+			if (is_array($this->jsdata[$key])) {
261
+				throw new InvalidArgumentException(
262
+					sprintf(
263
+						__(
264
+							'The value for %1$s already exists in the Registry::eejs object.
265 265
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
266 266
                             %2$s method to push your value to the array.',
267
-                            'event_espresso'
268
-                        ),
269
-                        $key,
270
-                        'pushData()'
271
-                    )
272
-                );
273
-            }
274
-            throw new InvalidArgumentException(
275
-                sprintf(
276
-                    __(
277
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
267
+							'event_espresso'
268
+						),
269
+						$key,
270
+						'pushData()'
271
+					)
272
+				);
273
+			}
274
+			throw new InvalidArgumentException(
275
+				sprintf(
276
+					__(
277
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
278 278
                         allowed.  Consider attaching your value to a different key',
279
-                        'event_espresso'
280
-                    ),
281
-                    $key
282
-                )
283
-            );
284
-        }
285
-        return true;
286
-    }
287
-
288
-
289
-
290
-    /**
291
-     * registers core default stylesheets
292
-     */
293
-    private function loadCoreCss()
294
-    {
295
-        if ($this->template_config->enable_default_style) {
296
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
297
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
298
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
299
-            wp_register_style(
300
-                'espresso_default',
301
-                $default_stylesheet_path,
302
-                array('dashicons'),
303
-                EVENT_ESPRESSO_VERSION
304
-            );
305
-            //Load custom style sheet if available
306
-            if ($this->template_config->custom_style_sheet !== null) {
307
-                wp_register_style(
308
-                    'espresso_custom_css',
309
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
310
-                    array('espresso_default'),
311
-                    EVENT_ESPRESSO_VERSION
312
-                );
313
-            }
314
-        }
315
-    }
316
-
317
-
318
-
319
-    /**
320
-     * registers core default javascript
321
-     */
322
-    private function loadCoreJs()
323
-    {
324
-        // load core js
325
-        wp_register_script(
326
-            'espresso_core',
327
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
328
-            array('jquery'),
329
-            EVENT_ESPRESSO_VERSION,
330
-            true
331
-        );
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * registers jQuery Validate for form validation
338
-     */
339
-    private function loadJqueryValidate()
340
-    {
341
-        // register jQuery Validate and additional methods
342
-        wp_register_script(
343
-            'jquery-validate',
344
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
345
-            array('jquery'),
346
-            '1.15.0',
347
-            true
348
-        );
349
-        wp_register_script(
350
-            'jquery-validate-extra-methods',
351
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
352
-            array('jquery', 'jquery-validate'),
353
-            '1.15.0',
354
-            true
355
-        );
356
-    }
357
-
358
-
359
-
360
-    /**
361
-     * registers accounting.js for performing client-side calculations
362
-     */
363
-    private function loadAccountingJs()
364
-    {
365
-        //accounting.js library
366
-        // @link http://josscrowcroft.github.io/accounting.js/
367
-        wp_register_script(
368
-            'ee-accounting-core',
369
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
370
-            array('underscore'),
371
-            '0.3.2',
372
-            true
373
-        );
374
-        wp_register_script(
375
-            'ee-accounting',
376
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
377
-            array('ee-accounting-core'),
378
-            EVENT_ESPRESSO_VERSION,
379
-            true
380
-        );
381
-    }
382
-
383
-
384
-
385
-    /**
386
-     * registers accounting.js for performing client-side calculations
387
-     */
388
-    private function localizeAccountingJs()
389
-    {
390
-        wp_localize_script(
391
-            'ee-accounting',
392
-            'EE_ACCOUNTING_CFG',
393
-            array(
394
-                'currency' => array(
395
-                    'symbol'    => $this->currency_config->sign,
396
-                    'format'    => array(
397
-                        'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
398
-                        'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
399
-                        'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
400
-                    ),
401
-                    'decimal'   => $this->currency_config->dec_mrk,
402
-                    'thousand'  => $this->currency_config->thsnds,
403
-                    'precision' => $this->currency_config->dec_plc,
404
-                ),
405
-                'number'   => array(
406
-                    'precision' => $this->currency_config->dec_plc,
407
-                    'thousand'  => $this->currency_config->thsnds,
408
-                    'decimal'   => $this->currency_config->dec_mrk,
409
-                ),
410
-            )
411
-        );
412
-        $this->addRegisteredScriptHandlesWithData('ee-accounting');
413
-    }
414
-
415
-
416
-
417
-    /**
418
-     * registers assets for cleaning your ears
419
-     */
420
-    private function loadQtipJs()
421
-    {
422
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
423
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
424
-        if (apply_filters('FHEE_load_qtip', false)) {
425
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
426
-        }
427
-    }
428
-
429
-
430
-    /**
431
-     * This is used to set registered script handles that have data.
432
-     * @param string $script_handle
433
-     */
434
-    private function addRegisteredScriptHandlesWithData($script_handle)
435
-    {
436
-        $this->script_handles_with_data[$script_handle] = $script_handle;
437
-    }
438
-
439
-
440
-    /**
441
-     * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
442
-     * Dependency stored in WP_Scripts if its set.
443
-     */
444
-    private function removeAlreadyRegisteredDataForScriptHandles()
445
-    {
446
-        if (empty($this->script_handles_with_data)) {
447
-            return;
448
-        }
449
-        foreach ($this->script_handles_with_data as $script_handle) {
450
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
451
-        }
452
-    }
453
-
454
-
455
-    /**
456
-     * Removes any data dependency registered in WP_Scripts if its set.
457
-     * @param string $script_handle
458
-     */
459
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
460
-    {
461
-        if (isset($this->script_handles_with_data[$script_handle])) {
462
-            global $wp_scripts;
463
-            if ($wp_scripts->get_data($script_handle, 'data')) {
464
-                unset($wp_scripts->registered[$script_handle]->extra['data']);
465
-                unset($this->script_handles_with_data[$script_handle]);
466
-            }
467
-        }
468
-    }
279
+						'event_espresso'
280
+					),
281
+					$key
282
+				)
283
+			);
284
+		}
285
+		return true;
286
+	}
287
+
288
+
289
+
290
+	/**
291
+	 * registers core default stylesheets
292
+	 */
293
+	private function loadCoreCss()
294
+	{
295
+		if ($this->template_config->enable_default_style) {
296
+			$default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
297
+				? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
298
+				: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
299
+			wp_register_style(
300
+				'espresso_default',
301
+				$default_stylesheet_path,
302
+				array('dashicons'),
303
+				EVENT_ESPRESSO_VERSION
304
+			);
305
+			//Load custom style sheet if available
306
+			if ($this->template_config->custom_style_sheet !== null) {
307
+				wp_register_style(
308
+					'espresso_custom_css',
309
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
310
+					array('espresso_default'),
311
+					EVENT_ESPRESSO_VERSION
312
+				);
313
+			}
314
+		}
315
+	}
316
+
317
+
318
+
319
+	/**
320
+	 * registers core default javascript
321
+	 */
322
+	private function loadCoreJs()
323
+	{
324
+		// load core js
325
+		wp_register_script(
326
+			'espresso_core',
327
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
328
+			array('jquery'),
329
+			EVENT_ESPRESSO_VERSION,
330
+			true
331
+		);
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * registers jQuery Validate for form validation
338
+	 */
339
+	private function loadJqueryValidate()
340
+	{
341
+		// register jQuery Validate and additional methods
342
+		wp_register_script(
343
+			'jquery-validate',
344
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
345
+			array('jquery'),
346
+			'1.15.0',
347
+			true
348
+		);
349
+		wp_register_script(
350
+			'jquery-validate-extra-methods',
351
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
352
+			array('jquery', 'jquery-validate'),
353
+			'1.15.0',
354
+			true
355
+		);
356
+	}
357
+
358
+
359
+
360
+	/**
361
+	 * registers accounting.js for performing client-side calculations
362
+	 */
363
+	private function loadAccountingJs()
364
+	{
365
+		//accounting.js library
366
+		// @link http://josscrowcroft.github.io/accounting.js/
367
+		wp_register_script(
368
+			'ee-accounting-core',
369
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
370
+			array('underscore'),
371
+			'0.3.2',
372
+			true
373
+		);
374
+		wp_register_script(
375
+			'ee-accounting',
376
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
377
+			array('ee-accounting-core'),
378
+			EVENT_ESPRESSO_VERSION,
379
+			true
380
+		);
381
+	}
382
+
383
+
384
+
385
+	/**
386
+	 * registers accounting.js for performing client-side calculations
387
+	 */
388
+	private function localizeAccountingJs()
389
+	{
390
+		wp_localize_script(
391
+			'ee-accounting',
392
+			'EE_ACCOUNTING_CFG',
393
+			array(
394
+				'currency' => array(
395
+					'symbol'    => $this->currency_config->sign,
396
+					'format'    => array(
397
+						'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
398
+						'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
399
+						'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
400
+					),
401
+					'decimal'   => $this->currency_config->dec_mrk,
402
+					'thousand'  => $this->currency_config->thsnds,
403
+					'precision' => $this->currency_config->dec_plc,
404
+				),
405
+				'number'   => array(
406
+					'precision' => $this->currency_config->dec_plc,
407
+					'thousand'  => $this->currency_config->thsnds,
408
+					'decimal'   => $this->currency_config->dec_mrk,
409
+				),
410
+			)
411
+		);
412
+		$this->addRegisteredScriptHandlesWithData('ee-accounting');
413
+	}
414
+
415
+
416
+
417
+	/**
418
+	 * registers assets for cleaning your ears
419
+	 */
420
+	private function loadQtipJs()
421
+	{
422
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
423
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
424
+		if (apply_filters('FHEE_load_qtip', false)) {
425
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
426
+		}
427
+	}
428
+
429
+
430
+	/**
431
+	 * This is used to set registered script handles that have data.
432
+	 * @param string $script_handle
433
+	 */
434
+	private function addRegisteredScriptHandlesWithData($script_handle)
435
+	{
436
+		$this->script_handles_with_data[$script_handle] = $script_handle;
437
+	}
438
+
439
+
440
+	/**
441
+	 * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
442
+	 * Dependency stored in WP_Scripts if its set.
443
+	 */
444
+	private function removeAlreadyRegisteredDataForScriptHandles()
445
+	{
446
+		if (empty($this->script_handles_with_data)) {
447
+			return;
448
+		}
449
+		foreach ($this->script_handles_with_data as $script_handle) {
450
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
451
+		}
452
+	}
453
+
454
+
455
+	/**
456
+	 * Removes any data dependency registered in WP_Scripts if its set.
457
+	 * @param string $script_handle
458
+	 */
459
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
460
+	{
461
+		if (isset($this->script_handles_with_data[$script_handle])) {
462
+			global $wp_scripts;
463
+			if ($wp_scripts->get_data($script_handle, 'data')) {
464
+				unset($wp_scripts->registered[$script_handle]->extra['data']);
465
+				unset($this->script_handles_with_data[$script_handle]);
466
+			}
467
+		}
468
+	}
469 469
 
470 470
 
471 471
 }
Please login to merge, or discard this patch.
core/services/cache/PostRelatedCacheManager.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -18,92 +18,92 @@
 block discarded – undo
18 18
 class PostRelatedCacheManager extends BasicCacheManager
19 19
 {
20 20
 
21
-    /**
22
-     * @type string
23
-     */
24
-    const POST_CACHE_PREFIX = 'ee_cache_post_';
25
-
26
-    /**
27
-     * wp-option option_name for tracking post related cache
28
-     *
29
-     * @type string
30
-     */
31
-    const POST_CACHE_OPTIONS_KEY = 'ee_post_cache';
32
-
33
-
34
-
35
-    /**
36
-     * PostRelatedCacheManager constructor.
37
-     *
38
-     * @param CacheStorageInterface      $cache_storage
39
-     */
40
-    public function __construct(CacheStorageInterface $cache_storage)
41
-    {
42
-        parent::__construct($cache_storage);
43
-        add_action('save_post', array($this, 'clearPostRelatedCache'));
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * returns a string that will be prepended to all cache identifiers
50
-     *
51
-     * @return string
52
-     */
53
-    public function cachePrefix()
54
-    {
55
-        return PostRelatedCacheManager::POST_CACHE_PREFIX;
56
-    }
57
-
58
-
59
-
60
-    /**
61
-     * If you are caching content that pertains to a Post of any type,
62
-     * then it is recommended to pass the post id and cache id prefix to this method
63
-     * so that it can be added to the post related cache tracking.
64
-     * Then, whenever that post is updated, the cache will automatically be deleted,
65
-     * which helps to ensure that outdated cache content will not be served
66
-     *
67
-     * @param int    $post_ID    [required]
68
-     * @param string $id_prefix  [required] Appended to all cache IDs. Can be helpful in finding specific cache types.
69
-     *                           May also be helpful to include an additional specific identifier,
70
-     *                           such as a post ID as part of the $id_prefix so that individual caches
71
-     *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
72
-     *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
73
-     */
74
-    public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix)
75
-    {
76
-        $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
77
-        // if post is not already being tracked
78
-        if ( ! isset($post_related_cache[$post_ID])) {
79
-            // add array to add cache ids to
80
-            $post_related_cache[$post_ID] = array();
81
-        }
82
-        // add cache id to be tracked
83
-        $post_related_cache[$post_ID][] = $id_prefix;
84
-        update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * callback hooked into the WordPress "save_post" action
91
-     * deletes any cache content associated with the post
92
-     *
93
-     * @param int $post_ID [required]
94
-     */
95
-    public function clearPostRelatedCache($post_ID)
96
-    {
97
-        $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
98
-        // if post is not being tracked
99
-        if ( ! isset($post_related_cache[$post_ID])) {
100
-            return;
101
-        }
102
-        // get cache id prefixes for post, and delete their corresponding transients
103
-        $this->clear($post_related_cache[$post_ID]);
104
-        unset($post_related_cache[$post_ID]);
105
-        update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
106
-    }
21
+	/**
22
+	 * @type string
23
+	 */
24
+	const POST_CACHE_PREFIX = 'ee_cache_post_';
25
+
26
+	/**
27
+	 * wp-option option_name for tracking post related cache
28
+	 *
29
+	 * @type string
30
+	 */
31
+	const POST_CACHE_OPTIONS_KEY = 'ee_post_cache';
32
+
33
+
34
+
35
+	/**
36
+	 * PostRelatedCacheManager constructor.
37
+	 *
38
+	 * @param CacheStorageInterface      $cache_storage
39
+	 */
40
+	public function __construct(CacheStorageInterface $cache_storage)
41
+	{
42
+		parent::__construct($cache_storage);
43
+		add_action('save_post', array($this, 'clearPostRelatedCache'));
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * returns a string that will be prepended to all cache identifiers
50
+	 *
51
+	 * @return string
52
+	 */
53
+	public function cachePrefix()
54
+	{
55
+		return PostRelatedCacheManager::POST_CACHE_PREFIX;
56
+	}
57
+
58
+
59
+
60
+	/**
61
+	 * If you are caching content that pertains to a Post of any type,
62
+	 * then it is recommended to pass the post id and cache id prefix to this method
63
+	 * so that it can be added to the post related cache tracking.
64
+	 * Then, whenever that post is updated, the cache will automatically be deleted,
65
+	 * which helps to ensure that outdated cache content will not be served
66
+	 *
67
+	 * @param int    $post_ID    [required]
68
+	 * @param string $id_prefix  [required] Appended to all cache IDs. Can be helpful in finding specific cache types.
69
+	 *                           May also be helpful to include an additional specific identifier,
70
+	 *                           such as a post ID as part of the $id_prefix so that individual caches
71
+	 *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
72
+	 *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
73
+	 */
74
+	public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix)
75
+	{
76
+		$post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
77
+		// if post is not already being tracked
78
+		if ( ! isset($post_related_cache[$post_ID])) {
79
+			// add array to add cache ids to
80
+			$post_related_cache[$post_ID] = array();
81
+		}
82
+		// add cache id to be tracked
83
+		$post_related_cache[$post_ID][] = $id_prefix;
84
+		update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * callback hooked into the WordPress "save_post" action
91
+	 * deletes any cache content associated with the post
92
+	 *
93
+	 * @param int $post_ID [required]
94
+	 */
95
+	public function clearPostRelatedCache($post_ID)
96
+	{
97
+		$post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
98
+		// if post is not being tracked
99
+		if ( ! isset($post_related_cache[$post_ID])) {
100
+			return;
101
+		}
102
+		// get cache id prefixes for post, and delete their corresponding transients
103
+		$this->clear($post_related_cache[$post_ID]);
104
+		unset($post_related_cache[$post_ID]);
105
+		update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
106
+	}
107 107
 
108 108
 
109 109
 }
Please login to merge, or discard this patch.