@@ -1,7 +1,6 @@ |
||
| 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 |
@@ -6,59 +6,59 @@ |
||
| 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(10); |
|
| 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(10); |
|
| 63 | + } |
|
| 64 | 64 | } |
| 65 | 65 | \ No newline at end of file |
@@ -14,51 +14,51 @@ |
||
| 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 |
@@ -748,7 +748,7 @@ discard block |
||
| 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 |
||
| 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 | { |
@@ -16,1404 +16,1404 @@ |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * _question_group |
|
| 21 | - * holds the specific question group object for the question group details screen |
|
| 22 | - * |
|
| 23 | - * @var object |
|
| 24 | - */ |
|
| 25 | - protected $_question_group; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Initialize basic properties. |
|
| 30 | - */ |
|
| 31 | - protected function _init_page_props() |
|
| 32 | - { |
|
| 33 | - $this->page_slug = GEN_SET_PG_SLUG; |
|
| 34 | - $this->page_label = GEN_SET_LABEL; |
|
| 35 | - $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
| 36 | - $this->_admin_base_path = GEN_SET_ADMIN; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Set ajax hooks |
|
| 42 | - */ |
|
| 43 | - protected function _ajax_hooks() |
|
| 44 | - { |
|
| 45 | - add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
| 46 | - add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
| 47 | - add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
| 48 | - add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * More page properties initialization. |
|
| 54 | - */ |
|
| 55 | - protected function _define_page_props() |
|
| 56 | - { |
|
| 57 | - $this->_admin_page_title = GEN_SET_LABEL; |
|
| 58 | - $this->_labels = array( |
|
| 59 | - 'publishbox' => __('Update Settings', 'event_espresso'), |
|
| 60 | - ); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Set page routes property. |
|
| 66 | - */ |
|
| 67 | - protected function _set_page_routes() |
|
| 68 | - { |
|
| 69 | - $this->_page_routes = array( |
|
| 70 | - |
|
| 71 | - 'critical_pages' => array( |
|
| 72 | - 'func' => '_espresso_page_settings', |
|
| 73 | - 'capability' => 'manage_options', |
|
| 74 | - ), |
|
| 75 | - 'update_espresso_page_settings' => array( |
|
| 76 | - 'func' => '_update_espresso_page_settings', |
|
| 77 | - 'capability' => 'manage_options', |
|
| 78 | - 'noheader' => true, |
|
| 79 | - ), |
|
| 80 | - 'default' => array( |
|
| 81 | - 'func' => '_your_organization_settings', |
|
| 82 | - 'capability' => 'manage_options', |
|
| 83 | - ), |
|
| 84 | - |
|
| 85 | - 'update_your_organization_settings' => array( |
|
| 86 | - 'func' => '_update_your_organization_settings', |
|
| 87 | - 'capability' => 'manage_options', |
|
| 88 | - 'noheader' => true, |
|
| 89 | - ), |
|
| 90 | - |
|
| 91 | - 'admin_option_settings' => array( |
|
| 92 | - 'func' => '_admin_option_settings', |
|
| 93 | - 'capability' => 'manage_options', |
|
| 94 | - ), |
|
| 95 | - |
|
| 96 | - 'update_admin_option_settings' => array( |
|
| 97 | - 'func' => '_update_admin_option_settings', |
|
| 98 | - 'capability' => 'manage_options', |
|
| 99 | - 'noheader' => true, |
|
| 100 | - ), |
|
| 101 | - |
|
| 102 | - 'country_settings' => array( |
|
| 103 | - 'func' => '_country_settings', |
|
| 104 | - 'capability' => 'manage_options', |
|
| 105 | - ), |
|
| 106 | - |
|
| 107 | - 'update_country_settings' => array( |
|
| 108 | - 'func' => '_update_country_settings', |
|
| 109 | - 'capability' => 'manage_options', |
|
| 110 | - 'noheader' => true, |
|
| 111 | - ), |
|
| 112 | - |
|
| 113 | - 'display_country_settings' => array( |
|
| 114 | - 'func' => 'display_country_settings', |
|
| 115 | - 'capability' => 'manage_options', |
|
| 116 | - 'noheader' => true, |
|
| 117 | - ), |
|
| 118 | - |
|
| 119 | - 'add_new_state' => array( |
|
| 120 | - 'func' => 'add_new_state', |
|
| 121 | - 'capability' => 'manage_options', |
|
| 122 | - 'noheader' => true, |
|
| 123 | - ), |
|
| 124 | - |
|
| 125 | - 'delete_state' => array( |
|
| 126 | - 'func' => 'delete_state', |
|
| 127 | - 'capability' => 'manage_options', |
|
| 128 | - 'noheader' => true, |
|
| 129 | - ), |
|
| 130 | - ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * Set page configuration property |
|
| 136 | - */ |
|
| 137 | - protected function _set_page_config() |
|
| 138 | - { |
|
| 139 | - $this->_page_config = array( |
|
| 140 | - 'critical_pages' => array( |
|
| 141 | - 'nav' => array( |
|
| 142 | - 'label' => __('Critical Pages', 'event_espresso'), |
|
| 143 | - 'order' => 50, |
|
| 144 | - ), |
|
| 145 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 146 | - 'help_tabs' => array( |
|
| 147 | - 'general_settings_critical_pages_help_tab' => array( |
|
| 148 | - 'title' => __('Critical Pages', 'event_espresso'), |
|
| 149 | - 'filename' => 'general_settings_critical_pages', |
|
| 150 | - ), |
|
| 151 | - ), |
|
| 152 | - 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
| 153 | - 'require_nonce' => false, |
|
| 154 | - ), |
|
| 155 | - 'default' => array( |
|
| 156 | - 'nav' => array( |
|
| 157 | - 'label' => __('Your Organization', 'event_espresso'), |
|
| 158 | - 'order' => 20, |
|
| 159 | - ), |
|
| 160 | - 'help_tabs' => array( |
|
| 161 | - 'general_settings_your_organization_help_tab' => array( |
|
| 162 | - 'title' => __('Your Organization', 'event_espresso'), |
|
| 163 | - 'filename' => 'general_settings_your_organization', |
|
| 164 | - ), |
|
| 165 | - ), |
|
| 166 | - 'help_tour' => array('Your_Organization_Help_Tour'), |
|
| 167 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 168 | - 'require_nonce' => false, |
|
| 169 | - ), |
|
| 170 | - 'admin_option_settings' => array( |
|
| 171 | - 'nav' => array( |
|
| 172 | - 'label' => __('Admin Options', 'event_espresso'), |
|
| 173 | - 'order' => 60, |
|
| 174 | - ), |
|
| 175 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 176 | - 'help_tabs' => array( |
|
| 177 | - 'general_settings_admin_options_help_tab' => array( |
|
| 178 | - 'title' => __('Admin Options', 'event_espresso'), |
|
| 179 | - 'filename' => 'general_settings_admin_options', |
|
| 180 | - ), |
|
| 181 | - ), |
|
| 182 | - 'help_tour' => array('Admin_Options_Help_Tour'), |
|
| 183 | - 'require_nonce' => false, |
|
| 184 | - ), |
|
| 185 | - 'country_settings' => array( |
|
| 186 | - 'nav' => array( |
|
| 187 | - 'label' => __('Countries', 'event_espresso'), |
|
| 188 | - 'order' => 70, |
|
| 189 | - ), |
|
| 190 | - 'help_tabs' => array( |
|
| 191 | - 'general_settings_countries_help_tab' => array( |
|
| 192 | - 'title' => __('Countries', 'event_espresso'), |
|
| 193 | - 'filename' => 'general_settings_countries', |
|
| 194 | - ), |
|
| 195 | - ), |
|
| 196 | - 'help_tour' => array('Countries_Help_Tour'), |
|
| 197 | - 'require_nonce' => false, |
|
| 198 | - ), |
|
| 199 | - ); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - protected function _add_screen_options() |
|
| 204 | - { |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - protected function _add_feature_pointers() |
|
| 208 | - { |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
| 214 | - */ |
|
| 215 | - public function load_scripts_styles() |
|
| 216 | - { |
|
| 217 | - // styles |
|
| 218 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 219 | - // scripts |
|
| 220 | - wp_enqueue_script('ee_admin_js'); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Execute logic running on `admin_init` |
|
| 226 | - */ |
|
| 227 | - public function admin_init() |
|
| 228 | - { |
|
| 229 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = __( |
|
| 230 | - '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.', |
|
| 231 | - 'event_espresso' |
|
| 232 | - ); |
|
| 233 | - EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
| 234 | - 'An error occurred! Please refresh the page and try again.', |
|
| 235 | - 'event_espresso' |
|
| 236 | - ); |
|
| 237 | - EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
| 238 | - 'Are you sure you want to delete this State / Province?', |
|
| 239 | - 'event_espresso' |
|
| 240 | - ); |
|
| 241 | - $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
| 242 | - EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
| 243 | - 'admin-ajax.php?page=espresso_general_settings', |
|
| 244 | - $protocol |
|
| 245 | - ); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - public function admin_notices() |
|
| 249 | - { |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - public function admin_footer_scripts() |
|
| 253 | - { |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * Enqueue scripts and styles for the default route. |
|
| 259 | - */ |
|
| 260 | - public function load_scripts_styles_default() |
|
| 261 | - { |
|
| 262 | - // styles |
|
| 263 | - wp_enqueue_style('thickbox'); |
|
| 264 | - // scripts |
|
| 265 | - wp_enqueue_script('media-upload'); |
|
| 266 | - wp_enqueue_script('thickbox'); |
|
| 267 | - wp_register_script( |
|
| 268 | - 'organization_settings', |
|
| 269 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
| 270 | - array('jquery', 'media-upload', 'thickbox'), |
|
| 271 | - EVENT_ESPRESSO_VERSION, |
|
| 272 | - true |
|
| 273 | - ); |
|
| 274 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 275 | - wp_enqueue_script('organization_settings'); |
|
| 276 | - wp_enqueue_style('organization-css'); |
|
| 277 | - $confirm_image_delete = array( |
|
| 278 | - 'text' => __( |
|
| 279 | - 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
| 280 | - 'event_espresso' |
|
| 281 | - ), |
|
| 282 | - ); |
|
| 283 | - wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * Enqueue scripts and styles for the country settings route. |
|
| 289 | - */ |
|
| 290 | - public function load_scripts_styles_country_settings() |
|
| 291 | - { |
|
| 292 | - // scripts |
|
| 293 | - wp_register_script( |
|
| 294 | - 'gen_settings_countries', |
|
| 295 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
| 296 | - array('ee_admin_js'), |
|
| 297 | - EVENT_ESPRESSO_VERSION, |
|
| 298 | - true |
|
| 299 | - ); |
|
| 300 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 301 | - wp_enqueue_script('gen_settings_countries'); |
|
| 302 | - wp_enqueue_style('organization-css'); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - |
|
| 306 | - /************* Espresso Pages *************/ |
|
| 307 | - /** |
|
| 308 | - * _espresso_page_settings |
|
| 309 | - * |
|
| 310 | - * @throws \EE_Error |
|
| 311 | - */ |
|
| 312 | - protected function _espresso_page_settings() |
|
| 313 | - { |
|
| 314 | - // Check to make sure all of the main pages are setup properly, |
|
| 315 | - // if not create the default pages and display an admin notice |
|
| 316 | - EEH_Activation::verify_default_pages_exist(); |
|
| 317 | - $this->_transient_garbage_collection(); |
|
| 318 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
| 319 | - $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
| 320 | - ? EE_Registry::instance()->CFG->core->reg_page_id |
|
| 321 | - : null; |
|
| 322 | - $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
| 323 | - ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
| 324 | - : false; |
|
| 325 | - $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
| 326 | - ? EE_Registry::instance()->CFG->core->txn_page_id |
|
| 327 | - : null; |
|
| 328 | - $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
| 329 | - ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
| 330 | - : false; |
|
| 331 | - $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
| 332 | - ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
| 333 | - : null; |
|
| 334 | - $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
| 335 | - ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
| 336 | - : false; |
|
| 337 | - $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
| 338 | - ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
| 339 | - : null; |
|
| 340 | - $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
| 341 | - ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
| 342 | - : false; |
|
| 343 | - $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
| 344 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 345 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 346 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
| 347 | - $this->_template_args, |
|
| 348 | - true |
|
| 349 | - ); |
|
| 350 | - $this->display_admin_page_with_sidebar(); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - |
|
| 354 | - /** |
|
| 355 | - * Handler for updating espresso page settings. |
|
| 356 | - */ |
|
| 357 | - protected function _update_espresso_page_settings() |
|
| 358 | - { |
|
| 359 | - // capture incoming request data && set page IDs |
|
| 360 | - EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
| 361 | - ? absint($this->_req_data['reg_page_id']) |
|
| 362 | - : EE_Registry::instance()->CFG->core->reg_page_id; |
|
| 363 | - EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
| 364 | - ? absint($this->_req_data['txn_page_id']) |
|
| 365 | - : EE_Registry::instance()->CFG->core->txn_page_id; |
|
| 366 | - EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
| 367 | - ? absint($this->_req_data['thank_you_page_id']) |
|
| 368 | - : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
| 369 | - EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
| 370 | - ? absint($this->_req_data['cancel_page_id']) |
|
| 371 | - : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
| 372 | - |
|
| 373 | - EE_Registry::instance()->CFG->core = apply_filters( |
|
| 374 | - 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
| 375 | - EE_Registry::instance()->CFG->core, |
|
| 376 | - $this->_req_data |
|
| 377 | - ); |
|
| 378 | - $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
| 379 | - $this->_redirect_after_action( |
|
| 380 | - $this->_update_espresso_configuration( |
|
| 381 | - $what, |
|
| 382 | - EE_Registry::instance()->CFG->core, |
|
| 383 | - __FILE__, |
|
| 384 | - __FUNCTION__, |
|
| 385 | - __LINE__ |
|
| 386 | - ), |
|
| 387 | - $what, |
|
| 388 | - '', |
|
| 389 | - array( |
|
| 390 | - 'action' => 'critical_pages', |
|
| 391 | - ), |
|
| 392 | - true |
|
| 393 | - ); |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - |
|
| 397 | - /************* Your Organization *************/ |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * Output for the Your Organization settings route. |
|
| 402 | - * |
|
| 403 | - * @throws DomainException |
|
| 404 | - * @throws EE_Error |
|
| 405 | - */ |
|
| 406 | - protected function _your_organization_settings() |
|
| 407 | - { |
|
| 408 | - |
|
| 409 | - $this->_template_args['site_license_key'] = isset( |
|
| 410 | - EE_Registry::instance()->NET_CFG->core->site_license_key |
|
| 411 | - ) |
|
| 412 | - ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') |
|
| 413 | - : ''; |
|
| 414 | - $this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name) |
|
| 415 | - ? EE_Registry::instance()->CFG->organization->get_pretty('name') |
|
| 416 | - : ''; |
|
| 417 | - $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) |
|
| 418 | - ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') |
|
| 419 | - : ''; |
|
| 420 | - $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) |
|
| 421 | - ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') |
|
| 422 | - : ''; |
|
| 423 | - $this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city) |
|
| 424 | - ? EE_Registry::instance()->CFG->organization->get_pretty('city') |
|
| 425 | - : ''; |
|
| 426 | - $this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip) |
|
| 427 | - ? EE_Registry::instance()->CFG->organization->get_pretty('zip') |
|
| 428 | - : ''; |
|
| 429 | - $this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email) |
|
| 430 | - ? EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 431 | - : ''; |
|
| 432 | - $this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone) |
|
| 433 | - ? EE_Registry::instance()->CFG->organization->get_pretty('phone') |
|
| 434 | - : ''; |
|
| 435 | - $this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat) |
|
| 436 | - ? EE_Registry::instance()->CFG->organization->get_pretty('vat') |
|
| 437 | - : ''; |
|
| 438 | - $this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign) |
|
| 439 | - ? EE_Registry::instance()->CFG->currency->get_pretty('sign') |
|
| 440 | - : '$'; |
|
| 441 | - $this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url) |
|
| 442 | - ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') |
|
| 443 | - : false; |
|
| 444 | - $this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook) |
|
| 445 | - ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') |
|
| 446 | - : ''; |
|
| 447 | - $this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter) |
|
| 448 | - ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') |
|
| 449 | - : ''; |
|
| 450 | - $this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin) |
|
| 451 | - ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') |
|
| 452 | - : ''; |
|
| 453 | - $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) |
|
| 454 | - ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') |
|
| 455 | - : ''; |
|
| 456 | - $this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google) |
|
| 457 | - ? EE_Registry::instance()->CFG->organization->get_pretty('google') |
|
| 458 | - : ''; |
|
| 459 | - $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) |
|
| 460 | - ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') |
|
| 461 | - : ''; |
|
| 462 | - // UXIP settings |
|
| 463 | - $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) |
|
| 464 | - ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') |
|
| 465 | - : 'yes'; |
|
| 466 | - |
|
| 467 | - $STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID) |
|
| 468 | - ? EE_Registry::instance()->CFG->organization->STA_ID |
|
| 469 | - : 4; |
|
| 470 | - $this->_template_args['states'] = new EE_Question_Form_Input( |
|
| 471 | - EE_Question::new_instance( |
|
| 472 | - array( |
|
| 473 | - 'QST_ID' => 0, |
|
| 474 | - 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
| 475 | - 'QST_system' => 'admin-state', |
|
| 476 | - ) |
|
| 477 | - ), |
|
| 478 | - EE_Answer::new_instance( |
|
| 479 | - array( |
|
| 480 | - 'ANS_ID' => 0, |
|
| 481 | - 'ANS_value' => $STA_ID, |
|
| 482 | - ) |
|
| 483 | - ), |
|
| 484 | - array( |
|
| 485 | - 'input_id' => 'organization_state', |
|
| 486 | - 'input_name' => 'organization_state', |
|
| 487 | - 'input_prefix' => '', |
|
| 488 | - 'append_qstn_id' => false, |
|
| 489 | - ) |
|
| 490 | - ); |
|
| 491 | - |
|
| 492 | - $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
| 493 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 494 | - : 'US'; |
|
| 495 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
| 496 | - EE_Question::new_instance( |
|
| 497 | - array( |
|
| 498 | - 'QST_ID' => 0, |
|
| 499 | - 'QST_display_text' => __('Country', 'event_espresso'), |
|
| 500 | - 'QST_system' => 'admin-country', |
|
| 501 | - ) |
|
| 502 | - ), |
|
| 503 | - EE_Answer::new_instance( |
|
| 504 | - array( |
|
| 505 | - 'ANS_ID' => 0, |
|
| 506 | - 'ANS_value' => $CNT_ISO, |
|
| 507 | - ) |
|
| 508 | - ), |
|
| 509 | - array( |
|
| 510 | - 'input_id' => 'organization_country', |
|
| 511 | - 'input_name' => 'organization_country', |
|
| 512 | - 'input_prefix' => '', |
|
| 513 | - 'append_qstn_id' => false, |
|
| 514 | - ) |
|
| 515 | - ); |
|
| 516 | - |
|
| 517 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
| 518 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
| 519 | - |
|
| 520 | - // PUE verification stuff |
|
| 521 | - $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
| 522 | - $verify_fail = get_option($ver_option_key); |
|
| 523 | - $this->_template_args['site_license_key_verified'] = $verify_fail |
|
| 524 | - || ! empty($verify_fail) |
|
| 525 | - || (empty($this->_template_args['site_license_key']) |
|
| 526 | - && empty($verify_fail) |
|
| 527 | - ) |
|
| 528 | - ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' |
|
| 529 | - : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>'; |
|
| 530 | - |
|
| 531 | - $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
| 532 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 533 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 534 | - GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', |
|
| 535 | - $this->_template_args, |
|
| 536 | - true |
|
| 537 | - ); |
|
| 538 | - |
|
| 539 | - $this->display_admin_page_with_sidebar(); |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - |
|
| 543 | - /** |
|
| 544 | - * Handler for updating organziation settings. |
|
| 545 | - */ |
|
| 546 | - protected function _update_your_organization_settings() |
|
| 547 | - { |
|
| 548 | - if (is_main_site()) { |
|
| 549 | - EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) |
|
| 550 | - ? sanitize_text_field($this->_req_data['site_license_key']) |
|
| 551 | - : EE_Registry::instance()->NET_CFG->core->site_license_key; |
|
| 552 | - } |
|
| 553 | - EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name']) |
|
| 554 | - ? sanitize_text_field($this->_req_data['organization_name']) |
|
| 555 | - : EE_Registry::instance()->CFG->organization->name; |
|
| 556 | - EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) |
|
| 557 | - ? sanitize_text_field($this->_req_data['organization_address_1']) |
|
| 558 | - : EE_Registry::instance()->CFG->organization->address_1; |
|
| 559 | - EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) |
|
| 560 | - ? sanitize_text_field($this->_req_data['organization_address_2']) |
|
| 561 | - : EE_Registry::instance()->CFG->organization->address_2; |
|
| 562 | - EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city']) |
|
| 563 | - ? sanitize_text_field($this->_req_data['organization_city']) |
|
| 564 | - : EE_Registry::instance()->CFG->organization->city; |
|
| 565 | - EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state']) |
|
| 566 | - ? absint($this->_req_data['organization_state']) |
|
| 567 | - : EE_Registry::instance()->CFG->organization->STA_ID; |
|
| 568 | - EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country']) |
|
| 569 | - ? sanitize_text_field($this->_req_data['organization_country']) |
|
| 570 | - : EE_Registry::instance()->CFG->organization->CNT_ISO; |
|
| 571 | - EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip']) |
|
| 572 | - ? sanitize_text_field($this->_req_data['organization_zip']) |
|
| 573 | - : EE_Registry::instance()->CFG->organization->zip; |
|
| 574 | - EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email']) |
|
| 575 | - ? sanitize_email($this->_req_data['organization_email']) |
|
| 576 | - : EE_Registry::instance()->CFG->organization->email; |
|
| 577 | - EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat']) |
|
| 578 | - ? sanitize_text_field($this->_req_data['organization_vat']) |
|
| 579 | - : EE_Registry::instance()->CFG->organization->vat; |
|
| 580 | - EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone']) |
|
| 581 | - ? sanitize_text_field($this->_req_data['organization_phone']) |
|
| 582 | - : EE_Registry::instance()->CFG->organization->phone; |
|
| 583 | - EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url']) |
|
| 584 | - ? esc_url_raw($this->_req_data['organization_logo_url']) |
|
| 585 | - : EE_Registry::instance()->CFG->organization->logo_url; |
|
| 586 | - EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook']) |
|
| 587 | - ? esc_url_raw($this->_req_data['organization_facebook']) |
|
| 588 | - : EE_Registry::instance()->CFG->organization->facebook; |
|
| 589 | - EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter']) |
|
| 590 | - ? esc_url_raw($this->_req_data['organization_twitter']) |
|
| 591 | - : EE_Registry::instance()->CFG->organization->twitter; |
|
| 592 | - EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin']) |
|
| 593 | - ? esc_url_raw($this->_req_data['organization_linkedin']) |
|
| 594 | - : EE_Registry::instance()->CFG->organization->linkedin; |
|
| 595 | - EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) |
|
| 596 | - ? esc_url_raw($this->_req_data['organization_pinterest']) |
|
| 597 | - : EE_Registry::instance()->CFG->organization->pinterest; |
|
| 598 | - EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google']) |
|
| 599 | - ? esc_url_raw($this->_req_data['organization_google']) |
|
| 600 | - : EE_Registry::instance()->CFG->organization->google; |
|
| 601 | - EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) |
|
| 602 | - ? esc_url_raw($this->_req_data['organization_instagram']) |
|
| 603 | - : EE_Registry::instance()->CFG->organization->instagram; |
|
| 604 | - EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin']) |
|
| 605 | - && ! empty($this->_req_data['ueip_optin']) |
|
| 606 | - ? filter_var($this->_req_data['ueip_optin'], FILTER_VALIDATE_BOOLEAN) |
|
| 607 | - : EE_Registry::instance()->CFG->core->ee_ueip_optin; |
|
| 608 | - |
|
| 609 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config( |
|
| 610 | - EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 611 | - ); |
|
| 612 | - |
|
| 613 | - EE_Registry::instance()->CFG = apply_filters( |
|
| 614 | - 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
| 615 | - EE_Registry::instance()->CFG |
|
| 616 | - ); |
|
| 617 | - |
|
| 618 | - $what = 'Your Organization Settings'; |
|
| 619 | - $success = $this->_update_espresso_configuration( |
|
| 620 | - $what, |
|
| 621 | - EE_Registry::instance()->CFG, |
|
| 622 | - __FILE__, |
|
| 623 | - __FUNCTION__, |
|
| 624 | - __LINE__ |
|
| 625 | - ); |
|
| 626 | - |
|
| 627 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default')); |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - |
|
| 631 | - |
|
| 632 | - /************* Admin Options *************/ |
|
| 633 | - |
|
| 634 | - |
|
| 635 | - /** |
|
| 636 | - * _admin_option_settings |
|
| 637 | - * |
|
| 638 | - * @throws \EE_Error |
|
| 639 | - * @throws \LogicException |
|
| 640 | - */ |
|
| 641 | - protected function _admin_option_settings() |
|
| 642 | - { |
|
| 643 | - $this->_template_args['admin_page_content'] = ''; |
|
| 644 | - try { |
|
| 645 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
| 646 | - // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
| 647 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
| 648 | - // also need to account for the do_action that was in the old template |
|
| 649 | - $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
| 650 | - $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
| 651 | - } catch (Exception $e) { |
|
| 652 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 653 | - } |
|
| 654 | - $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
| 655 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 656 | - $this->display_admin_page_with_sidebar(); |
|
| 657 | - } |
|
| 658 | - |
|
| 659 | - |
|
| 660 | - /** |
|
| 661 | - * _update_admin_option_settings |
|
| 662 | - * |
|
| 663 | - * @throws \EE_Error |
|
| 664 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 665 | - * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
| 666 | - * @throws \InvalidArgumentException |
|
| 667 | - * @throws \LogicException |
|
| 668 | - */ |
|
| 669 | - protected function _update_admin_option_settings() |
|
| 670 | - { |
|
| 671 | - try { |
|
| 672 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
| 673 | - $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
| 674 | - EE_Registry::instance()->CFG->admin = apply_filters( |
|
| 675 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
| 676 | - EE_Registry::instance()->CFG->admin |
|
| 677 | - ); |
|
| 678 | - } catch (Exception $e) { |
|
| 679 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 680 | - } |
|
| 681 | - $this->_redirect_after_action( |
|
| 682 | - apply_filters( |
|
| 683 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
| 684 | - $this->_update_espresso_configuration( |
|
| 685 | - 'Admin Options', |
|
| 686 | - EE_Registry::instance()->CFG->admin, |
|
| 687 | - __FILE__, |
|
| 688 | - __FUNCTION__, |
|
| 689 | - __LINE__ |
|
| 690 | - ) |
|
| 691 | - ), |
|
| 692 | - 'Admin Options', |
|
| 693 | - 'updated', |
|
| 694 | - array('action' => 'admin_option_settings') |
|
| 695 | - ); |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - |
|
| 699 | - /************* Countries *************/ |
|
| 700 | - |
|
| 701 | - |
|
| 702 | - /** |
|
| 703 | - * Output Country Settings view. |
|
| 704 | - * |
|
| 705 | - * @throws DomainException |
|
| 706 | - * @throws EE_Error |
|
| 707 | - */ |
|
| 708 | - protected function _country_settings() |
|
| 709 | - { |
|
| 710 | - $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
| 711 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 712 | - : 'US'; |
|
| 713 | - $CNT_ISO = isset($this->_req_data['country']) |
|
| 714 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
| 715 | - : $CNT_ISO; |
|
| 716 | - |
|
| 717 | - // load field generator helper |
|
| 718 | - |
|
| 719 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
| 720 | - |
|
| 721 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
| 722 | - EE_Question::new_instance( |
|
| 723 | - array( |
|
| 724 | - 'QST_ID' => 0, |
|
| 725 | - 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
| 726 | - 'QST_system' => 'admin-country', |
|
| 727 | - ) |
|
| 728 | - ), |
|
| 729 | - EE_Answer::new_instance( |
|
| 730 | - array( |
|
| 731 | - 'ANS_ID' => 0, |
|
| 732 | - 'ANS_value' => $CNT_ISO, |
|
| 733 | - ) |
|
| 734 | - ), |
|
| 735 | - array( |
|
| 736 | - 'input_id' => 'country', |
|
| 737 | - 'input_name' => 'country', |
|
| 738 | - 'input_prefix' => '', |
|
| 739 | - 'append_qstn_id' => false, |
|
| 740 | - ) |
|
| 741 | - ); |
|
| 742 | - |
|
| 743 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
| 744 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
| 745 | - $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
| 746 | - $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
| 747 | - |
|
| 748 | - $this->_set_add_edit_form_tags('update_country_settings'); |
|
| 749 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 750 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 751 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
| 752 | - $this->_template_args, |
|
| 753 | - true |
|
| 754 | - ); |
|
| 755 | - $this->display_admin_page_with_no_sidebar(); |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - |
|
| 759 | - /** |
|
| 760 | - * display_country_settings |
|
| 761 | - * |
|
| 762 | - * @access public |
|
| 763 | - * @param string $CNT_ISO |
|
| 764 | - * @return mixed string | array |
|
| 765 | - * @throws DomainException |
|
| 766 | - */ |
|
| 767 | - public function display_country_settings($CNT_ISO = '') |
|
| 768 | - { |
|
| 769 | - |
|
| 770 | - $CNT_ISO = isset($this->_req_data['country']) |
|
| 771 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
| 772 | - : $CNT_ISO; |
|
| 773 | - if (! $CNT_ISO) { |
|
| 774 | - return ''; |
|
| 775 | - } |
|
| 776 | - |
|
| 777 | - // for ajax |
|
| 778 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
| 779 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
| 780 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
| 781 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
| 782 | - $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
| 783 | - |
|
| 784 | - $country_input_types = array( |
|
| 785 | - 'CNT_active' => array( |
|
| 786 | - 'type' => 'RADIO_BTN', |
|
| 787 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 788 | - 'class' => '', |
|
| 789 | - 'options' => $this->_yes_no_values, |
|
| 790 | - 'use_desc_4_label' => true, |
|
| 791 | - ), |
|
| 792 | - 'CNT_ISO' => array( |
|
| 793 | - 'type' => 'TEXT', |
|
| 794 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 795 | - 'class' => 'small-text', |
|
| 796 | - ), |
|
| 797 | - 'CNT_ISO3' => array( |
|
| 798 | - 'type' => 'TEXT', |
|
| 799 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 800 | - 'class' => 'small-text', |
|
| 801 | - ), |
|
| 802 | - 'RGN_ID' => array( |
|
| 803 | - 'type' => 'TEXT', |
|
| 804 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 805 | - 'class' => 'small-text', |
|
| 806 | - ), |
|
| 807 | - 'CNT_name' => array( |
|
| 808 | - 'type' => 'TEXT', |
|
| 809 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 810 | - 'class' => 'regular-text', |
|
| 811 | - ), |
|
| 812 | - 'CNT_cur_code' => array( |
|
| 813 | - 'type' => 'TEXT', |
|
| 814 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 815 | - 'class' => 'small-text', |
|
| 816 | - ), |
|
| 817 | - 'CNT_cur_single' => array( |
|
| 818 | - 'type' => 'TEXT', |
|
| 819 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 820 | - 'class' => 'medium-text', |
|
| 821 | - ), |
|
| 822 | - 'CNT_cur_plural' => array( |
|
| 823 | - 'type' => 'TEXT', |
|
| 824 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 825 | - 'class' => 'medium-text', |
|
| 826 | - ), |
|
| 827 | - 'CNT_cur_sign' => array( |
|
| 828 | - 'type' => 'TEXT', |
|
| 829 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 830 | - 'class' => 'small-text', |
|
| 831 | - 'htmlentities' => false, |
|
| 832 | - ), |
|
| 833 | - 'CNT_cur_sign_b4' => array( |
|
| 834 | - 'type' => 'RADIO_BTN', |
|
| 835 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 836 | - 'class' => '', |
|
| 837 | - 'options' => $this->_yes_no_values, |
|
| 838 | - 'use_desc_4_label' => true, |
|
| 839 | - ), |
|
| 840 | - 'CNT_cur_dec_plc' => array( |
|
| 841 | - 'type' => 'RADIO_BTN', |
|
| 842 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 843 | - 'class' => '', |
|
| 844 | - 'options' => array( |
|
| 845 | - array('id' => 0, 'text' => ''), |
|
| 846 | - array('id' => 1, 'text' => ''), |
|
| 847 | - array('id' => 2, 'text' => ''), |
|
| 848 | - array('id' => 3, 'text' => ''), |
|
| 849 | - ), |
|
| 850 | - ), |
|
| 851 | - 'CNT_cur_dec_mrk' => 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_cur_thsnds' => array( |
|
| 865 | - 'type' => 'RADIO_BTN', |
|
| 866 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 867 | - 'class' => '', |
|
| 868 | - 'options' => array( |
|
| 869 | - array( |
|
| 870 | - 'id' => ',', |
|
| 871 | - 'text' => __(', (comma)', 'event_espresso'), |
|
| 872 | - ), |
|
| 873 | - array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
| 874 | - ), |
|
| 875 | - 'use_desc_4_label' => true, |
|
| 876 | - ), |
|
| 877 | - 'CNT_tel_code' => array( |
|
| 878 | - 'type' => 'TEXT', |
|
| 879 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 880 | - 'class' => 'small-text', |
|
| 881 | - ), |
|
| 882 | - 'CNT_is_EU' => array( |
|
| 883 | - 'type' => 'RADIO_BTN', |
|
| 884 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 885 | - 'class' => '', |
|
| 886 | - 'options' => $this->_yes_no_values, |
|
| 887 | - 'use_desc_4_label' => true, |
|
| 888 | - ), |
|
| 889 | - ); |
|
| 890 | - $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
| 891 | - $country, |
|
| 892 | - $country_input_types |
|
| 893 | - ); |
|
| 894 | - $country_details_settings = EEH_Template::display_template( |
|
| 895 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
| 896 | - $this->_template_args, |
|
| 897 | - true |
|
| 898 | - ); |
|
| 899 | - |
|
| 900 | - if (defined('DOING_AJAX')) { |
|
| 901 | - $notices = EE_Error::get_notices(false, false, false); |
|
| 902 | - echo wp_json_encode( |
|
| 903 | - array( |
|
| 904 | - 'return_data' => $country_details_settings, |
|
| 905 | - 'success' => $notices['success'], |
|
| 906 | - 'errors' => $notices['errors'], |
|
| 907 | - ) |
|
| 908 | - ); |
|
| 909 | - die(); |
|
| 910 | - } else { |
|
| 911 | - return $country_details_settings; |
|
| 912 | - } |
|
| 913 | - } |
|
| 914 | - |
|
| 915 | - |
|
| 916 | - /** |
|
| 917 | - * display_country_states |
|
| 918 | - * |
|
| 919 | - * @access public |
|
| 920 | - * @param string $CNT_ISO |
|
| 921 | - * @return string |
|
| 922 | - * @throws DomainException |
|
| 923 | - */ |
|
| 924 | - public function display_country_states($CNT_ISO = '') |
|
| 925 | - { |
|
| 926 | - |
|
| 927 | - $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
| 928 | - |
|
| 929 | - if (! $CNT_ISO) { |
|
| 930 | - return ''; |
|
| 931 | - } |
|
| 932 | - // for ajax |
|
| 933 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
| 934 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
| 935 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
| 936 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
| 937 | - $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
| 938 | - |
|
| 939 | - if ($states) { |
|
| 940 | - foreach ($states as $STA_ID => $state) { |
|
| 941 | - if ($state instanceof EE_State) { |
|
| 942 | - // STA_abbrev STA_name STA_active |
|
| 943 | - $state_input_types = array( |
|
| 944 | - 'STA_abbrev' => array( |
|
| 945 | - 'type' => 'TEXT', |
|
| 946 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
| 947 | - 'class' => 'mid-text', |
|
| 948 | - ), |
|
| 949 | - 'STA_name' => array( |
|
| 950 | - 'type' => 'TEXT', |
|
| 951 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
| 952 | - 'class' => 'regular-text', |
|
| 953 | - ), |
|
| 954 | - 'STA_active' => array( |
|
| 955 | - 'type' => 'RADIO_BTN', |
|
| 956 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
| 957 | - 'options' => $this->_yes_no_values, |
|
| 958 | - 'use_desc_4_label' => true, |
|
| 959 | - ), |
|
| 960 | - ); |
|
| 961 | - $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
| 962 | - EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
| 963 | - $state, |
|
| 964 | - $state_input_types |
|
| 965 | - ); |
|
| 966 | - $query_args = array( |
|
| 967 | - 'action' => 'delete_state', |
|
| 968 | - 'STA_ID' => $STA_ID, |
|
| 969 | - 'CNT_ISO' => $CNT_ISO, |
|
| 970 | - 'STA_abbrev' => $state->abbrev(), |
|
| 971 | - ); |
|
| 972 | - $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
| 973 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 974 | - $query_args, |
|
| 975 | - GEN_SET_ADMIN_URL |
|
| 976 | - ); |
|
| 977 | - } |
|
| 978 | - } |
|
| 979 | - } else { |
|
| 980 | - $this->_template_args['states'] = false; |
|
| 981 | - } |
|
| 982 | - |
|
| 983 | - $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 984 | - array('action' => 'add_new_state'), |
|
| 985 | - GEN_SET_ADMIN_URL |
|
| 986 | - ); |
|
| 987 | - |
|
| 988 | - $state_details_settings = EEH_Template::display_template( |
|
| 989 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
| 990 | - $this->_template_args, |
|
| 991 | - true |
|
| 992 | - ); |
|
| 993 | - |
|
| 994 | - if (defined('DOING_AJAX')) { |
|
| 995 | - $notices = EE_Error::get_notices(false, false, false); |
|
| 996 | - echo wp_json_encode( |
|
| 997 | - array( |
|
| 998 | - 'return_data' => $state_details_settings, |
|
| 999 | - 'success' => $notices['success'], |
|
| 1000 | - 'errors' => $notices['errors'], |
|
| 1001 | - ) |
|
| 1002 | - ); |
|
| 1003 | - die(); |
|
| 1004 | - } else { |
|
| 1005 | - return $state_details_settings; |
|
| 1006 | - } |
|
| 1007 | - } |
|
| 1008 | - |
|
| 1009 | - |
|
| 1010 | - /** |
|
| 1011 | - * add_new_state |
|
| 1012 | - * |
|
| 1013 | - * @access public |
|
| 1014 | - * @return void |
|
| 1015 | - * @throws EE_Error |
|
| 1016 | - */ |
|
| 1017 | - public function add_new_state() |
|
| 1018 | - { |
|
| 1019 | - |
|
| 1020 | - $success = true; |
|
| 1021 | - |
|
| 1022 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
| 1023 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
| 1024 | - : false; |
|
| 1025 | - if (! $CNT_ISO) { |
|
| 1026 | - EE_Error::add_error( |
|
| 1027 | - __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
| 1028 | - __FILE__, |
|
| 1029 | - __FUNCTION__, |
|
| 1030 | - __LINE__ |
|
| 1031 | - ); |
|
| 1032 | - $success = false; |
|
| 1033 | - } |
|
| 1034 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
| 1035 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
| 1036 | - : false; |
|
| 1037 | - if (! $STA_abbrev) { |
|
| 1038 | - EE_Error::add_error( |
|
| 1039 | - __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
| 1040 | - __FILE__, |
|
| 1041 | - __FUNCTION__, |
|
| 1042 | - __LINE__ |
|
| 1043 | - ); |
|
| 1044 | - $success = false; |
|
| 1045 | - } |
|
| 1046 | - $STA_name = isset($this->_req_data['STA_name']) |
|
| 1047 | - ? sanitize_text_field($this->_req_data['STA_name']) |
|
| 1048 | - : false; |
|
| 1049 | - if (! $STA_name) { |
|
| 1050 | - EE_Error::add_error( |
|
| 1051 | - __('No State name or an invalid State name was received.', 'event_espresso'), |
|
| 1052 | - __FILE__, |
|
| 1053 | - __FUNCTION__, |
|
| 1054 | - __LINE__ |
|
| 1055 | - ); |
|
| 1056 | - $success = false; |
|
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - if ($success) { |
|
| 1060 | - $cols_n_values = array( |
|
| 1061 | - 'CNT_ISO' => $CNT_ISO, |
|
| 1062 | - 'STA_abbrev' => $STA_abbrev, |
|
| 1063 | - 'STA_name' => $STA_name, |
|
| 1064 | - 'STA_active' => true, |
|
| 1065 | - ); |
|
| 1066 | - $success = EEM_State::instance()->insert($cols_n_values); |
|
| 1067 | - EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
| 1068 | - } |
|
| 1069 | - |
|
| 1070 | - if (defined('DOING_AJAX')) { |
|
| 1071 | - $notices = EE_Error::get_notices(false, false, false); |
|
| 1072 | - echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
| 1073 | - die(); |
|
| 1074 | - } else { |
|
| 1075 | - $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
| 1076 | - } |
|
| 1077 | - } |
|
| 1078 | - |
|
| 1079 | - |
|
| 1080 | - /** |
|
| 1081 | - * delete_state |
|
| 1082 | - * |
|
| 1083 | - * @access public |
|
| 1084 | - * @return boolean |
|
| 1085 | - */ |
|
| 1086 | - public function delete_state() |
|
| 1087 | - { |
|
| 1088 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
| 1089 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
| 1090 | - : false; |
|
| 1091 | - $STA_ID = isset($this->_req_data['STA_ID']) |
|
| 1092 | - ? sanitize_text_field($this->_req_data['STA_ID']) |
|
| 1093 | - : false; |
|
| 1094 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
| 1095 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
| 1096 | - : false; |
|
| 1097 | - if (! $STA_ID) { |
|
| 1098 | - EE_Error::add_error( |
|
| 1099 | - __('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
| 1100 | - __FILE__, |
|
| 1101 | - __FUNCTION__, |
|
| 1102 | - __LINE__ |
|
| 1103 | - ); |
|
| 1104 | - return false; |
|
| 1105 | - } |
|
| 1106 | - |
|
| 1107 | - $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
| 1108 | - if ($success !== false) { |
|
| 1109 | - do_action( |
|
| 1110 | - 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
| 1111 | - $CNT_ISO, |
|
| 1112 | - $STA_ID, |
|
| 1113 | - array('STA_abbrev' => $STA_abbrev) |
|
| 1114 | - ); |
|
| 1115 | - EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
| 1116 | - } |
|
| 1117 | - if (defined('DOING_AJAX')) { |
|
| 1118 | - $notices = EE_Error::get_notices(false, false); |
|
| 1119 | - $notices['return_data'] = true; |
|
| 1120 | - echo wp_json_encode($notices); |
|
| 1121 | - die(); |
|
| 1122 | - } else { |
|
| 1123 | - $this->_redirect_after_action( |
|
| 1124 | - $success, |
|
| 1125 | - 'State', |
|
| 1126 | - 'deleted', |
|
| 1127 | - array('action' => 'country_settings') |
|
| 1128 | - ); |
|
| 1129 | - } |
|
| 1130 | - } |
|
| 1131 | - |
|
| 1132 | - |
|
| 1133 | - /** |
|
| 1134 | - * _update_country_settings |
|
| 1135 | - * |
|
| 1136 | - * @access protected |
|
| 1137 | - * @return void |
|
| 1138 | - * @throws EE_Error |
|
| 1139 | - */ |
|
| 1140 | - protected function _update_country_settings() |
|
| 1141 | - { |
|
| 1142 | - // grab the country ISO code |
|
| 1143 | - $CNT_ISO = isset($this->_req_data['country']) |
|
| 1144 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
| 1145 | - : false; |
|
| 1146 | - if (! $CNT_ISO) { |
|
| 1147 | - EE_Error::add_error( |
|
| 1148 | - __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
| 1149 | - __FILE__, |
|
| 1150 | - __FUNCTION__, |
|
| 1151 | - __LINE__ |
|
| 1152 | - ); |
|
| 1153 | - |
|
| 1154 | - return; |
|
| 1155 | - } |
|
| 1156 | - $cols_n_values = array(); |
|
| 1157 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
| 1158 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
| 1159 | - : false; |
|
| 1160 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
| 1161 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
| 1162 | - : null; |
|
| 1163 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
| 1164 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
| 1165 | - : null; |
|
| 1166 | - $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
| 1167 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) |
|
| 1168 | - : 'USD'; |
|
| 1169 | - $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
| 1170 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
| 1171 | - : 'dollar'; |
|
| 1172 | - $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
| 1173 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
| 1174 | - : 'dollars'; |
|
| 1175 | - $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
| 1176 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
| 1177 | - : '$'; |
|
| 1178 | - $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
| 1179 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
| 1180 | - : true; |
|
| 1181 | - $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
| 1182 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
| 1183 | - : 2; |
|
| 1184 | - $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
| 1185 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
| 1186 | - : '.'; |
|
| 1187 | - $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
| 1188 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
| 1189 | - : ','; |
|
| 1190 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
| 1191 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
| 1192 | - : null; |
|
| 1193 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
| 1194 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
| 1195 | - : false; |
|
| 1196 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
| 1197 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
| 1198 | - : false; |
|
| 1199 | - // allow filtering of country data |
|
| 1200 | - $cols_n_values = apply_filters( |
|
| 1201 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
| 1202 | - $cols_n_values |
|
| 1203 | - ); |
|
| 1204 | - |
|
| 1205 | - // where values |
|
| 1206 | - $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
| 1207 | - // run the update |
|
| 1208 | - $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
| 1209 | - |
|
| 1210 | - if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
| 1211 | - // allow filtering of states data |
|
| 1212 | - $states = apply_filters( |
|
| 1213 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
| 1214 | - $this->_req_data['states'] |
|
| 1215 | - ); |
|
| 1216 | - |
|
| 1217 | - // loop thru state data ( looks like : states[75][STA_name] ) |
|
| 1218 | - foreach ($states as $STA_ID => $state) { |
|
| 1219 | - $cols_n_values = array( |
|
| 1220 | - 'CNT_ISO' => $CNT_ISO, |
|
| 1221 | - 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
| 1222 | - 'STA_name' => sanitize_text_field($state['STA_name']), |
|
| 1223 | - 'STA_active' => (bool) absint($state['STA_active']), |
|
| 1224 | - ); |
|
| 1225 | - // where values |
|
| 1226 | - $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
| 1227 | - // run the update |
|
| 1228 | - $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
| 1229 | - if ($success !== false) { |
|
| 1230 | - do_action( |
|
| 1231 | - 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
| 1232 | - $CNT_ISO, |
|
| 1233 | - $STA_ID, |
|
| 1234 | - $cols_n_values |
|
| 1235 | - ); |
|
| 1236 | - } |
|
| 1237 | - } |
|
| 1238 | - } |
|
| 1239 | - // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
| 1240 | - if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
| 1241 | - && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 1242 | - ) { |
|
| 1243 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
| 1244 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
| 1245 | - } |
|
| 1246 | - |
|
| 1247 | - if ($success !== false) { |
|
| 1248 | - EE_Error::add_success( |
|
| 1249 | - esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
| 1250 | - ); |
|
| 1251 | - } |
|
| 1252 | - $this->_redirect_after_action( |
|
| 1253 | - $success, |
|
| 1254 | - '', |
|
| 1255 | - '', |
|
| 1256 | - array('action' => 'country_settings', 'country' => $CNT_ISO), |
|
| 1257 | - true |
|
| 1258 | - ); |
|
| 1259 | - } |
|
| 1260 | - |
|
| 1261 | - |
|
| 1262 | - /** |
|
| 1263 | - * form_form_field_label_wrap |
|
| 1264 | - * |
|
| 1265 | - * @access public |
|
| 1266 | - * @param string $label |
|
| 1267 | - * @return string |
|
| 1268 | - */ |
|
| 1269 | - public function country_form_field_label_wrap($label, $required_text) |
|
| 1270 | - { |
|
| 1271 | - return ' |
|
| 19 | + /** |
|
| 20 | + * _question_group |
|
| 21 | + * holds the specific question group object for the question group details screen |
|
| 22 | + * |
|
| 23 | + * @var object |
|
| 24 | + */ |
|
| 25 | + protected $_question_group; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Initialize basic properties. |
|
| 30 | + */ |
|
| 31 | + protected function _init_page_props() |
|
| 32 | + { |
|
| 33 | + $this->page_slug = GEN_SET_PG_SLUG; |
|
| 34 | + $this->page_label = GEN_SET_LABEL; |
|
| 35 | + $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
| 36 | + $this->_admin_base_path = GEN_SET_ADMIN; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Set ajax hooks |
|
| 42 | + */ |
|
| 43 | + protected function _ajax_hooks() |
|
| 44 | + { |
|
| 45 | + add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
| 46 | + add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
| 47 | + add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
| 48 | + add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * More page properties initialization. |
|
| 54 | + */ |
|
| 55 | + protected function _define_page_props() |
|
| 56 | + { |
|
| 57 | + $this->_admin_page_title = GEN_SET_LABEL; |
|
| 58 | + $this->_labels = array( |
|
| 59 | + 'publishbox' => __('Update Settings', 'event_espresso'), |
|
| 60 | + ); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Set page routes property. |
|
| 66 | + */ |
|
| 67 | + protected function _set_page_routes() |
|
| 68 | + { |
|
| 69 | + $this->_page_routes = array( |
|
| 70 | + |
|
| 71 | + 'critical_pages' => array( |
|
| 72 | + 'func' => '_espresso_page_settings', |
|
| 73 | + 'capability' => 'manage_options', |
|
| 74 | + ), |
|
| 75 | + 'update_espresso_page_settings' => array( |
|
| 76 | + 'func' => '_update_espresso_page_settings', |
|
| 77 | + 'capability' => 'manage_options', |
|
| 78 | + 'noheader' => true, |
|
| 79 | + ), |
|
| 80 | + 'default' => array( |
|
| 81 | + 'func' => '_your_organization_settings', |
|
| 82 | + 'capability' => 'manage_options', |
|
| 83 | + ), |
|
| 84 | + |
|
| 85 | + 'update_your_organization_settings' => array( |
|
| 86 | + 'func' => '_update_your_organization_settings', |
|
| 87 | + 'capability' => 'manage_options', |
|
| 88 | + 'noheader' => true, |
|
| 89 | + ), |
|
| 90 | + |
|
| 91 | + 'admin_option_settings' => array( |
|
| 92 | + 'func' => '_admin_option_settings', |
|
| 93 | + 'capability' => 'manage_options', |
|
| 94 | + ), |
|
| 95 | + |
|
| 96 | + 'update_admin_option_settings' => array( |
|
| 97 | + 'func' => '_update_admin_option_settings', |
|
| 98 | + 'capability' => 'manage_options', |
|
| 99 | + 'noheader' => true, |
|
| 100 | + ), |
|
| 101 | + |
|
| 102 | + 'country_settings' => array( |
|
| 103 | + 'func' => '_country_settings', |
|
| 104 | + 'capability' => 'manage_options', |
|
| 105 | + ), |
|
| 106 | + |
|
| 107 | + 'update_country_settings' => array( |
|
| 108 | + 'func' => '_update_country_settings', |
|
| 109 | + 'capability' => 'manage_options', |
|
| 110 | + 'noheader' => true, |
|
| 111 | + ), |
|
| 112 | + |
|
| 113 | + 'display_country_settings' => array( |
|
| 114 | + 'func' => 'display_country_settings', |
|
| 115 | + 'capability' => 'manage_options', |
|
| 116 | + 'noheader' => true, |
|
| 117 | + ), |
|
| 118 | + |
|
| 119 | + 'add_new_state' => array( |
|
| 120 | + 'func' => 'add_new_state', |
|
| 121 | + 'capability' => 'manage_options', |
|
| 122 | + 'noheader' => true, |
|
| 123 | + ), |
|
| 124 | + |
|
| 125 | + 'delete_state' => array( |
|
| 126 | + 'func' => 'delete_state', |
|
| 127 | + 'capability' => 'manage_options', |
|
| 128 | + 'noheader' => true, |
|
| 129 | + ), |
|
| 130 | + ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * Set page configuration property |
|
| 136 | + */ |
|
| 137 | + protected function _set_page_config() |
|
| 138 | + { |
|
| 139 | + $this->_page_config = array( |
|
| 140 | + 'critical_pages' => array( |
|
| 141 | + 'nav' => array( |
|
| 142 | + 'label' => __('Critical Pages', 'event_espresso'), |
|
| 143 | + 'order' => 50, |
|
| 144 | + ), |
|
| 145 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 146 | + 'help_tabs' => array( |
|
| 147 | + 'general_settings_critical_pages_help_tab' => array( |
|
| 148 | + 'title' => __('Critical Pages', 'event_espresso'), |
|
| 149 | + 'filename' => 'general_settings_critical_pages', |
|
| 150 | + ), |
|
| 151 | + ), |
|
| 152 | + 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
| 153 | + 'require_nonce' => false, |
|
| 154 | + ), |
|
| 155 | + 'default' => array( |
|
| 156 | + 'nav' => array( |
|
| 157 | + 'label' => __('Your Organization', 'event_espresso'), |
|
| 158 | + 'order' => 20, |
|
| 159 | + ), |
|
| 160 | + 'help_tabs' => array( |
|
| 161 | + 'general_settings_your_organization_help_tab' => array( |
|
| 162 | + 'title' => __('Your Organization', 'event_espresso'), |
|
| 163 | + 'filename' => 'general_settings_your_organization', |
|
| 164 | + ), |
|
| 165 | + ), |
|
| 166 | + 'help_tour' => array('Your_Organization_Help_Tour'), |
|
| 167 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 168 | + 'require_nonce' => false, |
|
| 169 | + ), |
|
| 170 | + 'admin_option_settings' => array( |
|
| 171 | + 'nav' => array( |
|
| 172 | + 'label' => __('Admin Options', 'event_espresso'), |
|
| 173 | + 'order' => 60, |
|
| 174 | + ), |
|
| 175 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 176 | + 'help_tabs' => array( |
|
| 177 | + 'general_settings_admin_options_help_tab' => array( |
|
| 178 | + 'title' => __('Admin Options', 'event_espresso'), |
|
| 179 | + 'filename' => 'general_settings_admin_options', |
|
| 180 | + ), |
|
| 181 | + ), |
|
| 182 | + 'help_tour' => array('Admin_Options_Help_Tour'), |
|
| 183 | + 'require_nonce' => false, |
|
| 184 | + ), |
|
| 185 | + 'country_settings' => array( |
|
| 186 | + 'nav' => array( |
|
| 187 | + 'label' => __('Countries', 'event_espresso'), |
|
| 188 | + 'order' => 70, |
|
| 189 | + ), |
|
| 190 | + 'help_tabs' => array( |
|
| 191 | + 'general_settings_countries_help_tab' => array( |
|
| 192 | + 'title' => __('Countries', 'event_espresso'), |
|
| 193 | + 'filename' => 'general_settings_countries', |
|
| 194 | + ), |
|
| 195 | + ), |
|
| 196 | + 'help_tour' => array('Countries_Help_Tour'), |
|
| 197 | + 'require_nonce' => false, |
|
| 198 | + ), |
|
| 199 | + ); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + protected function _add_screen_options() |
|
| 204 | + { |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + protected function _add_feature_pointers() |
|
| 208 | + { |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
| 214 | + */ |
|
| 215 | + public function load_scripts_styles() |
|
| 216 | + { |
|
| 217 | + // styles |
|
| 218 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 219 | + // scripts |
|
| 220 | + wp_enqueue_script('ee_admin_js'); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Execute logic running on `admin_init` |
|
| 226 | + */ |
|
| 227 | + public function admin_init() |
|
| 228 | + { |
|
| 229 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = __( |
|
| 230 | + '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.', |
|
| 231 | + 'event_espresso' |
|
| 232 | + ); |
|
| 233 | + EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
| 234 | + 'An error occurred! Please refresh the page and try again.', |
|
| 235 | + 'event_espresso' |
|
| 236 | + ); |
|
| 237 | + EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
| 238 | + 'Are you sure you want to delete this State / Province?', |
|
| 239 | + 'event_espresso' |
|
| 240 | + ); |
|
| 241 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
| 242 | + EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
| 243 | + 'admin-ajax.php?page=espresso_general_settings', |
|
| 244 | + $protocol |
|
| 245 | + ); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + public function admin_notices() |
|
| 249 | + { |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + public function admin_footer_scripts() |
|
| 253 | + { |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * Enqueue scripts and styles for the default route. |
|
| 259 | + */ |
|
| 260 | + public function load_scripts_styles_default() |
|
| 261 | + { |
|
| 262 | + // styles |
|
| 263 | + wp_enqueue_style('thickbox'); |
|
| 264 | + // scripts |
|
| 265 | + wp_enqueue_script('media-upload'); |
|
| 266 | + wp_enqueue_script('thickbox'); |
|
| 267 | + wp_register_script( |
|
| 268 | + 'organization_settings', |
|
| 269 | + GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
| 270 | + array('jquery', 'media-upload', 'thickbox'), |
|
| 271 | + EVENT_ESPRESSO_VERSION, |
|
| 272 | + true |
|
| 273 | + ); |
|
| 274 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 275 | + wp_enqueue_script('organization_settings'); |
|
| 276 | + wp_enqueue_style('organization-css'); |
|
| 277 | + $confirm_image_delete = array( |
|
| 278 | + 'text' => __( |
|
| 279 | + 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
| 280 | + 'event_espresso' |
|
| 281 | + ), |
|
| 282 | + ); |
|
| 283 | + wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * Enqueue scripts and styles for the country settings route. |
|
| 289 | + */ |
|
| 290 | + public function load_scripts_styles_country_settings() |
|
| 291 | + { |
|
| 292 | + // scripts |
|
| 293 | + wp_register_script( |
|
| 294 | + 'gen_settings_countries', |
|
| 295 | + GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
| 296 | + array('ee_admin_js'), |
|
| 297 | + EVENT_ESPRESSO_VERSION, |
|
| 298 | + true |
|
| 299 | + ); |
|
| 300 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 301 | + wp_enqueue_script('gen_settings_countries'); |
|
| 302 | + wp_enqueue_style('organization-css'); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + |
|
| 306 | + /************* Espresso Pages *************/ |
|
| 307 | + /** |
|
| 308 | + * _espresso_page_settings |
|
| 309 | + * |
|
| 310 | + * @throws \EE_Error |
|
| 311 | + */ |
|
| 312 | + protected function _espresso_page_settings() |
|
| 313 | + { |
|
| 314 | + // Check to make sure all of the main pages are setup properly, |
|
| 315 | + // if not create the default pages and display an admin notice |
|
| 316 | + EEH_Activation::verify_default_pages_exist(); |
|
| 317 | + $this->_transient_garbage_collection(); |
|
| 318 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
| 319 | + $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
| 320 | + ? EE_Registry::instance()->CFG->core->reg_page_id |
|
| 321 | + : null; |
|
| 322 | + $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
| 323 | + ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
| 324 | + : false; |
|
| 325 | + $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
| 326 | + ? EE_Registry::instance()->CFG->core->txn_page_id |
|
| 327 | + : null; |
|
| 328 | + $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
| 329 | + ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
| 330 | + : false; |
|
| 331 | + $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
| 332 | + ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
| 333 | + : null; |
|
| 334 | + $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
| 335 | + ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
| 336 | + : false; |
|
| 337 | + $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
| 338 | + ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
| 339 | + : null; |
|
| 340 | + $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
| 341 | + ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
| 342 | + : false; |
|
| 343 | + $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
| 344 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 345 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 346 | + GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
| 347 | + $this->_template_args, |
|
| 348 | + true |
|
| 349 | + ); |
|
| 350 | + $this->display_admin_page_with_sidebar(); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * Handler for updating espresso page settings. |
|
| 356 | + */ |
|
| 357 | + protected function _update_espresso_page_settings() |
|
| 358 | + { |
|
| 359 | + // capture incoming request data && set page IDs |
|
| 360 | + EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
| 361 | + ? absint($this->_req_data['reg_page_id']) |
|
| 362 | + : EE_Registry::instance()->CFG->core->reg_page_id; |
|
| 363 | + EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
| 364 | + ? absint($this->_req_data['txn_page_id']) |
|
| 365 | + : EE_Registry::instance()->CFG->core->txn_page_id; |
|
| 366 | + EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
| 367 | + ? absint($this->_req_data['thank_you_page_id']) |
|
| 368 | + : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
| 369 | + EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
| 370 | + ? absint($this->_req_data['cancel_page_id']) |
|
| 371 | + : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
| 372 | + |
|
| 373 | + EE_Registry::instance()->CFG->core = apply_filters( |
|
| 374 | + 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
| 375 | + EE_Registry::instance()->CFG->core, |
|
| 376 | + $this->_req_data |
|
| 377 | + ); |
|
| 378 | + $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
| 379 | + $this->_redirect_after_action( |
|
| 380 | + $this->_update_espresso_configuration( |
|
| 381 | + $what, |
|
| 382 | + EE_Registry::instance()->CFG->core, |
|
| 383 | + __FILE__, |
|
| 384 | + __FUNCTION__, |
|
| 385 | + __LINE__ |
|
| 386 | + ), |
|
| 387 | + $what, |
|
| 388 | + '', |
|
| 389 | + array( |
|
| 390 | + 'action' => 'critical_pages', |
|
| 391 | + ), |
|
| 392 | + true |
|
| 393 | + ); |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + |
|
| 397 | + /************* Your Organization *************/ |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * Output for the Your Organization settings route. |
|
| 402 | + * |
|
| 403 | + * @throws DomainException |
|
| 404 | + * @throws EE_Error |
|
| 405 | + */ |
|
| 406 | + protected function _your_organization_settings() |
|
| 407 | + { |
|
| 408 | + |
|
| 409 | + $this->_template_args['site_license_key'] = isset( |
|
| 410 | + EE_Registry::instance()->NET_CFG->core->site_license_key |
|
| 411 | + ) |
|
| 412 | + ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') |
|
| 413 | + : ''; |
|
| 414 | + $this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name) |
|
| 415 | + ? EE_Registry::instance()->CFG->organization->get_pretty('name') |
|
| 416 | + : ''; |
|
| 417 | + $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) |
|
| 418 | + ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') |
|
| 419 | + : ''; |
|
| 420 | + $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) |
|
| 421 | + ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') |
|
| 422 | + : ''; |
|
| 423 | + $this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city) |
|
| 424 | + ? EE_Registry::instance()->CFG->organization->get_pretty('city') |
|
| 425 | + : ''; |
|
| 426 | + $this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip) |
|
| 427 | + ? EE_Registry::instance()->CFG->organization->get_pretty('zip') |
|
| 428 | + : ''; |
|
| 429 | + $this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email) |
|
| 430 | + ? EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 431 | + : ''; |
|
| 432 | + $this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone) |
|
| 433 | + ? EE_Registry::instance()->CFG->organization->get_pretty('phone') |
|
| 434 | + : ''; |
|
| 435 | + $this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat) |
|
| 436 | + ? EE_Registry::instance()->CFG->organization->get_pretty('vat') |
|
| 437 | + : ''; |
|
| 438 | + $this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign) |
|
| 439 | + ? EE_Registry::instance()->CFG->currency->get_pretty('sign') |
|
| 440 | + : '$'; |
|
| 441 | + $this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url) |
|
| 442 | + ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') |
|
| 443 | + : false; |
|
| 444 | + $this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook) |
|
| 445 | + ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') |
|
| 446 | + : ''; |
|
| 447 | + $this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter) |
|
| 448 | + ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') |
|
| 449 | + : ''; |
|
| 450 | + $this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin) |
|
| 451 | + ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') |
|
| 452 | + : ''; |
|
| 453 | + $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) |
|
| 454 | + ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') |
|
| 455 | + : ''; |
|
| 456 | + $this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google) |
|
| 457 | + ? EE_Registry::instance()->CFG->organization->get_pretty('google') |
|
| 458 | + : ''; |
|
| 459 | + $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) |
|
| 460 | + ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') |
|
| 461 | + : ''; |
|
| 462 | + // UXIP settings |
|
| 463 | + $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) |
|
| 464 | + ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') |
|
| 465 | + : 'yes'; |
|
| 466 | + |
|
| 467 | + $STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID) |
|
| 468 | + ? EE_Registry::instance()->CFG->organization->STA_ID |
|
| 469 | + : 4; |
|
| 470 | + $this->_template_args['states'] = new EE_Question_Form_Input( |
|
| 471 | + EE_Question::new_instance( |
|
| 472 | + array( |
|
| 473 | + 'QST_ID' => 0, |
|
| 474 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
| 475 | + 'QST_system' => 'admin-state', |
|
| 476 | + ) |
|
| 477 | + ), |
|
| 478 | + EE_Answer::new_instance( |
|
| 479 | + array( |
|
| 480 | + 'ANS_ID' => 0, |
|
| 481 | + 'ANS_value' => $STA_ID, |
|
| 482 | + ) |
|
| 483 | + ), |
|
| 484 | + array( |
|
| 485 | + 'input_id' => 'organization_state', |
|
| 486 | + 'input_name' => 'organization_state', |
|
| 487 | + 'input_prefix' => '', |
|
| 488 | + 'append_qstn_id' => false, |
|
| 489 | + ) |
|
| 490 | + ); |
|
| 491 | + |
|
| 492 | + $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
| 493 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 494 | + : 'US'; |
|
| 495 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
| 496 | + EE_Question::new_instance( |
|
| 497 | + array( |
|
| 498 | + 'QST_ID' => 0, |
|
| 499 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
| 500 | + 'QST_system' => 'admin-country', |
|
| 501 | + ) |
|
| 502 | + ), |
|
| 503 | + EE_Answer::new_instance( |
|
| 504 | + array( |
|
| 505 | + 'ANS_ID' => 0, |
|
| 506 | + 'ANS_value' => $CNT_ISO, |
|
| 507 | + ) |
|
| 508 | + ), |
|
| 509 | + array( |
|
| 510 | + 'input_id' => 'organization_country', |
|
| 511 | + 'input_name' => 'organization_country', |
|
| 512 | + 'input_prefix' => '', |
|
| 513 | + 'append_qstn_id' => false, |
|
| 514 | + ) |
|
| 515 | + ); |
|
| 516 | + |
|
| 517 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
| 518 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
| 519 | + |
|
| 520 | + // PUE verification stuff |
|
| 521 | + $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
| 522 | + $verify_fail = get_option($ver_option_key); |
|
| 523 | + $this->_template_args['site_license_key_verified'] = $verify_fail |
|
| 524 | + || ! empty($verify_fail) |
|
| 525 | + || (empty($this->_template_args['site_license_key']) |
|
| 526 | + && empty($verify_fail) |
|
| 527 | + ) |
|
| 528 | + ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' |
|
| 529 | + : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>'; |
|
| 530 | + |
|
| 531 | + $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
| 532 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 533 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 534 | + GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', |
|
| 535 | + $this->_template_args, |
|
| 536 | + true |
|
| 537 | + ); |
|
| 538 | + |
|
| 539 | + $this->display_admin_page_with_sidebar(); |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + |
|
| 543 | + /** |
|
| 544 | + * Handler for updating organziation settings. |
|
| 545 | + */ |
|
| 546 | + protected function _update_your_organization_settings() |
|
| 547 | + { |
|
| 548 | + if (is_main_site()) { |
|
| 549 | + EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) |
|
| 550 | + ? sanitize_text_field($this->_req_data['site_license_key']) |
|
| 551 | + : EE_Registry::instance()->NET_CFG->core->site_license_key; |
|
| 552 | + } |
|
| 553 | + EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name']) |
|
| 554 | + ? sanitize_text_field($this->_req_data['organization_name']) |
|
| 555 | + : EE_Registry::instance()->CFG->organization->name; |
|
| 556 | + EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) |
|
| 557 | + ? sanitize_text_field($this->_req_data['organization_address_1']) |
|
| 558 | + : EE_Registry::instance()->CFG->organization->address_1; |
|
| 559 | + EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) |
|
| 560 | + ? sanitize_text_field($this->_req_data['organization_address_2']) |
|
| 561 | + : EE_Registry::instance()->CFG->organization->address_2; |
|
| 562 | + EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city']) |
|
| 563 | + ? sanitize_text_field($this->_req_data['organization_city']) |
|
| 564 | + : EE_Registry::instance()->CFG->organization->city; |
|
| 565 | + EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state']) |
|
| 566 | + ? absint($this->_req_data['organization_state']) |
|
| 567 | + : EE_Registry::instance()->CFG->organization->STA_ID; |
|
| 568 | + EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country']) |
|
| 569 | + ? sanitize_text_field($this->_req_data['organization_country']) |
|
| 570 | + : EE_Registry::instance()->CFG->organization->CNT_ISO; |
|
| 571 | + EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip']) |
|
| 572 | + ? sanitize_text_field($this->_req_data['organization_zip']) |
|
| 573 | + : EE_Registry::instance()->CFG->organization->zip; |
|
| 574 | + EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email']) |
|
| 575 | + ? sanitize_email($this->_req_data['organization_email']) |
|
| 576 | + : EE_Registry::instance()->CFG->organization->email; |
|
| 577 | + EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat']) |
|
| 578 | + ? sanitize_text_field($this->_req_data['organization_vat']) |
|
| 579 | + : EE_Registry::instance()->CFG->organization->vat; |
|
| 580 | + EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone']) |
|
| 581 | + ? sanitize_text_field($this->_req_data['organization_phone']) |
|
| 582 | + : EE_Registry::instance()->CFG->organization->phone; |
|
| 583 | + EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url']) |
|
| 584 | + ? esc_url_raw($this->_req_data['organization_logo_url']) |
|
| 585 | + : EE_Registry::instance()->CFG->organization->logo_url; |
|
| 586 | + EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook']) |
|
| 587 | + ? esc_url_raw($this->_req_data['organization_facebook']) |
|
| 588 | + : EE_Registry::instance()->CFG->organization->facebook; |
|
| 589 | + EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter']) |
|
| 590 | + ? esc_url_raw($this->_req_data['organization_twitter']) |
|
| 591 | + : EE_Registry::instance()->CFG->organization->twitter; |
|
| 592 | + EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin']) |
|
| 593 | + ? esc_url_raw($this->_req_data['organization_linkedin']) |
|
| 594 | + : EE_Registry::instance()->CFG->organization->linkedin; |
|
| 595 | + EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) |
|
| 596 | + ? esc_url_raw($this->_req_data['organization_pinterest']) |
|
| 597 | + : EE_Registry::instance()->CFG->organization->pinterest; |
|
| 598 | + EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google']) |
|
| 599 | + ? esc_url_raw($this->_req_data['organization_google']) |
|
| 600 | + : EE_Registry::instance()->CFG->organization->google; |
|
| 601 | + EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) |
|
| 602 | + ? esc_url_raw($this->_req_data['organization_instagram']) |
|
| 603 | + : EE_Registry::instance()->CFG->organization->instagram; |
|
| 604 | + EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin']) |
|
| 605 | + && ! empty($this->_req_data['ueip_optin']) |
|
| 606 | + ? filter_var($this->_req_data['ueip_optin'], FILTER_VALIDATE_BOOLEAN) |
|
| 607 | + : EE_Registry::instance()->CFG->core->ee_ueip_optin; |
|
| 608 | + |
|
| 609 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config( |
|
| 610 | + EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 611 | + ); |
|
| 612 | + |
|
| 613 | + EE_Registry::instance()->CFG = apply_filters( |
|
| 614 | + 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
| 615 | + EE_Registry::instance()->CFG |
|
| 616 | + ); |
|
| 617 | + |
|
| 618 | + $what = 'Your Organization Settings'; |
|
| 619 | + $success = $this->_update_espresso_configuration( |
|
| 620 | + $what, |
|
| 621 | + EE_Registry::instance()->CFG, |
|
| 622 | + __FILE__, |
|
| 623 | + __FUNCTION__, |
|
| 624 | + __LINE__ |
|
| 625 | + ); |
|
| 626 | + |
|
| 627 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default')); |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + |
|
| 631 | + |
|
| 632 | + /************* Admin Options *************/ |
|
| 633 | + |
|
| 634 | + |
|
| 635 | + /** |
|
| 636 | + * _admin_option_settings |
|
| 637 | + * |
|
| 638 | + * @throws \EE_Error |
|
| 639 | + * @throws \LogicException |
|
| 640 | + */ |
|
| 641 | + protected function _admin_option_settings() |
|
| 642 | + { |
|
| 643 | + $this->_template_args['admin_page_content'] = ''; |
|
| 644 | + try { |
|
| 645 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
| 646 | + // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
| 647 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
| 648 | + // also need to account for the do_action that was in the old template |
|
| 649 | + $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
| 650 | + $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
| 651 | + } catch (Exception $e) { |
|
| 652 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 653 | + } |
|
| 654 | + $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
| 655 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 656 | + $this->display_admin_page_with_sidebar(); |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + |
|
| 660 | + /** |
|
| 661 | + * _update_admin_option_settings |
|
| 662 | + * |
|
| 663 | + * @throws \EE_Error |
|
| 664 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 665 | + * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
| 666 | + * @throws \InvalidArgumentException |
|
| 667 | + * @throws \LogicException |
|
| 668 | + */ |
|
| 669 | + protected function _update_admin_option_settings() |
|
| 670 | + { |
|
| 671 | + try { |
|
| 672 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
| 673 | + $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
| 674 | + EE_Registry::instance()->CFG->admin = apply_filters( |
|
| 675 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
| 676 | + EE_Registry::instance()->CFG->admin |
|
| 677 | + ); |
|
| 678 | + } catch (Exception $e) { |
|
| 679 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 680 | + } |
|
| 681 | + $this->_redirect_after_action( |
|
| 682 | + apply_filters( |
|
| 683 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
| 684 | + $this->_update_espresso_configuration( |
|
| 685 | + 'Admin Options', |
|
| 686 | + EE_Registry::instance()->CFG->admin, |
|
| 687 | + __FILE__, |
|
| 688 | + __FUNCTION__, |
|
| 689 | + __LINE__ |
|
| 690 | + ) |
|
| 691 | + ), |
|
| 692 | + 'Admin Options', |
|
| 693 | + 'updated', |
|
| 694 | + array('action' => 'admin_option_settings') |
|
| 695 | + ); |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + |
|
| 699 | + /************* Countries *************/ |
|
| 700 | + |
|
| 701 | + |
|
| 702 | + /** |
|
| 703 | + * Output Country Settings view. |
|
| 704 | + * |
|
| 705 | + * @throws DomainException |
|
| 706 | + * @throws EE_Error |
|
| 707 | + */ |
|
| 708 | + protected function _country_settings() |
|
| 709 | + { |
|
| 710 | + $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
| 711 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 712 | + : 'US'; |
|
| 713 | + $CNT_ISO = isset($this->_req_data['country']) |
|
| 714 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
| 715 | + : $CNT_ISO; |
|
| 716 | + |
|
| 717 | + // load field generator helper |
|
| 718 | + |
|
| 719 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
| 720 | + |
|
| 721 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
| 722 | + EE_Question::new_instance( |
|
| 723 | + array( |
|
| 724 | + 'QST_ID' => 0, |
|
| 725 | + 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
| 726 | + 'QST_system' => 'admin-country', |
|
| 727 | + ) |
|
| 728 | + ), |
|
| 729 | + EE_Answer::new_instance( |
|
| 730 | + array( |
|
| 731 | + 'ANS_ID' => 0, |
|
| 732 | + 'ANS_value' => $CNT_ISO, |
|
| 733 | + ) |
|
| 734 | + ), |
|
| 735 | + array( |
|
| 736 | + 'input_id' => 'country', |
|
| 737 | + 'input_name' => 'country', |
|
| 738 | + 'input_prefix' => '', |
|
| 739 | + 'append_qstn_id' => false, |
|
| 740 | + ) |
|
| 741 | + ); |
|
| 742 | + |
|
| 743 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
| 744 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
| 745 | + $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
| 746 | + $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
| 747 | + |
|
| 748 | + $this->_set_add_edit_form_tags('update_country_settings'); |
|
| 749 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 750 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 751 | + GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
| 752 | + $this->_template_args, |
|
| 753 | + true |
|
| 754 | + ); |
|
| 755 | + $this->display_admin_page_with_no_sidebar(); |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + |
|
| 759 | + /** |
|
| 760 | + * display_country_settings |
|
| 761 | + * |
|
| 762 | + * @access public |
|
| 763 | + * @param string $CNT_ISO |
|
| 764 | + * @return mixed string | array |
|
| 765 | + * @throws DomainException |
|
| 766 | + */ |
|
| 767 | + public function display_country_settings($CNT_ISO = '') |
|
| 768 | + { |
|
| 769 | + |
|
| 770 | + $CNT_ISO = isset($this->_req_data['country']) |
|
| 771 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
| 772 | + : $CNT_ISO; |
|
| 773 | + if (! $CNT_ISO) { |
|
| 774 | + return ''; |
|
| 775 | + } |
|
| 776 | + |
|
| 777 | + // for ajax |
|
| 778 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
| 779 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
| 780 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
| 781 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
| 782 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
| 783 | + |
|
| 784 | + $country_input_types = array( |
|
| 785 | + 'CNT_active' => array( |
|
| 786 | + 'type' => 'RADIO_BTN', |
|
| 787 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 788 | + 'class' => '', |
|
| 789 | + 'options' => $this->_yes_no_values, |
|
| 790 | + 'use_desc_4_label' => true, |
|
| 791 | + ), |
|
| 792 | + 'CNT_ISO' => array( |
|
| 793 | + 'type' => 'TEXT', |
|
| 794 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 795 | + 'class' => 'small-text', |
|
| 796 | + ), |
|
| 797 | + 'CNT_ISO3' => array( |
|
| 798 | + 'type' => 'TEXT', |
|
| 799 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 800 | + 'class' => 'small-text', |
|
| 801 | + ), |
|
| 802 | + 'RGN_ID' => array( |
|
| 803 | + 'type' => 'TEXT', |
|
| 804 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 805 | + 'class' => 'small-text', |
|
| 806 | + ), |
|
| 807 | + 'CNT_name' => array( |
|
| 808 | + 'type' => 'TEXT', |
|
| 809 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 810 | + 'class' => 'regular-text', |
|
| 811 | + ), |
|
| 812 | + 'CNT_cur_code' => array( |
|
| 813 | + 'type' => 'TEXT', |
|
| 814 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 815 | + 'class' => 'small-text', |
|
| 816 | + ), |
|
| 817 | + 'CNT_cur_single' => array( |
|
| 818 | + 'type' => 'TEXT', |
|
| 819 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 820 | + 'class' => 'medium-text', |
|
| 821 | + ), |
|
| 822 | + 'CNT_cur_plural' => array( |
|
| 823 | + 'type' => 'TEXT', |
|
| 824 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 825 | + 'class' => 'medium-text', |
|
| 826 | + ), |
|
| 827 | + 'CNT_cur_sign' => array( |
|
| 828 | + 'type' => 'TEXT', |
|
| 829 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 830 | + 'class' => 'small-text', |
|
| 831 | + 'htmlentities' => false, |
|
| 832 | + ), |
|
| 833 | + 'CNT_cur_sign_b4' => array( |
|
| 834 | + 'type' => 'RADIO_BTN', |
|
| 835 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 836 | + 'class' => '', |
|
| 837 | + 'options' => $this->_yes_no_values, |
|
| 838 | + 'use_desc_4_label' => true, |
|
| 839 | + ), |
|
| 840 | + 'CNT_cur_dec_plc' => array( |
|
| 841 | + 'type' => 'RADIO_BTN', |
|
| 842 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 843 | + 'class' => '', |
|
| 844 | + 'options' => array( |
|
| 845 | + array('id' => 0, 'text' => ''), |
|
| 846 | + array('id' => 1, 'text' => ''), |
|
| 847 | + array('id' => 2, 'text' => ''), |
|
| 848 | + array('id' => 3, 'text' => ''), |
|
| 849 | + ), |
|
| 850 | + ), |
|
| 851 | + 'CNT_cur_dec_mrk' => 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_cur_thsnds' => array( |
|
| 865 | + 'type' => 'RADIO_BTN', |
|
| 866 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 867 | + 'class' => '', |
|
| 868 | + 'options' => array( |
|
| 869 | + array( |
|
| 870 | + 'id' => ',', |
|
| 871 | + 'text' => __(', (comma)', 'event_espresso'), |
|
| 872 | + ), |
|
| 873 | + array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
| 874 | + ), |
|
| 875 | + 'use_desc_4_label' => true, |
|
| 876 | + ), |
|
| 877 | + 'CNT_tel_code' => array( |
|
| 878 | + 'type' => 'TEXT', |
|
| 879 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 880 | + 'class' => 'small-text', |
|
| 881 | + ), |
|
| 882 | + 'CNT_is_EU' => array( |
|
| 883 | + 'type' => 'RADIO_BTN', |
|
| 884 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 885 | + 'class' => '', |
|
| 886 | + 'options' => $this->_yes_no_values, |
|
| 887 | + 'use_desc_4_label' => true, |
|
| 888 | + ), |
|
| 889 | + ); |
|
| 890 | + $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
| 891 | + $country, |
|
| 892 | + $country_input_types |
|
| 893 | + ); |
|
| 894 | + $country_details_settings = EEH_Template::display_template( |
|
| 895 | + GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
| 896 | + $this->_template_args, |
|
| 897 | + true |
|
| 898 | + ); |
|
| 899 | + |
|
| 900 | + if (defined('DOING_AJAX')) { |
|
| 901 | + $notices = EE_Error::get_notices(false, false, false); |
|
| 902 | + echo wp_json_encode( |
|
| 903 | + array( |
|
| 904 | + 'return_data' => $country_details_settings, |
|
| 905 | + 'success' => $notices['success'], |
|
| 906 | + 'errors' => $notices['errors'], |
|
| 907 | + ) |
|
| 908 | + ); |
|
| 909 | + die(); |
|
| 910 | + } else { |
|
| 911 | + return $country_details_settings; |
|
| 912 | + } |
|
| 913 | + } |
|
| 914 | + |
|
| 915 | + |
|
| 916 | + /** |
|
| 917 | + * display_country_states |
|
| 918 | + * |
|
| 919 | + * @access public |
|
| 920 | + * @param string $CNT_ISO |
|
| 921 | + * @return string |
|
| 922 | + * @throws DomainException |
|
| 923 | + */ |
|
| 924 | + public function display_country_states($CNT_ISO = '') |
|
| 925 | + { |
|
| 926 | + |
|
| 927 | + $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
| 928 | + |
|
| 929 | + if (! $CNT_ISO) { |
|
| 930 | + return ''; |
|
| 931 | + } |
|
| 932 | + // for ajax |
|
| 933 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
| 934 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
| 935 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
| 936 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
| 937 | + $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
| 938 | + |
|
| 939 | + if ($states) { |
|
| 940 | + foreach ($states as $STA_ID => $state) { |
|
| 941 | + if ($state instanceof EE_State) { |
|
| 942 | + // STA_abbrev STA_name STA_active |
|
| 943 | + $state_input_types = array( |
|
| 944 | + 'STA_abbrev' => array( |
|
| 945 | + 'type' => 'TEXT', |
|
| 946 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
| 947 | + 'class' => 'mid-text', |
|
| 948 | + ), |
|
| 949 | + 'STA_name' => array( |
|
| 950 | + 'type' => 'TEXT', |
|
| 951 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
| 952 | + 'class' => 'regular-text', |
|
| 953 | + ), |
|
| 954 | + 'STA_active' => array( |
|
| 955 | + 'type' => 'RADIO_BTN', |
|
| 956 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
| 957 | + 'options' => $this->_yes_no_values, |
|
| 958 | + 'use_desc_4_label' => true, |
|
| 959 | + ), |
|
| 960 | + ); |
|
| 961 | + $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
| 962 | + EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
| 963 | + $state, |
|
| 964 | + $state_input_types |
|
| 965 | + ); |
|
| 966 | + $query_args = array( |
|
| 967 | + 'action' => 'delete_state', |
|
| 968 | + 'STA_ID' => $STA_ID, |
|
| 969 | + 'CNT_ISO' => $CNT_ISO, |
|
| 970 | + 'STA_abbrev' => $state->abbrev(), |
|
| 971 | + ); |
|
| 972 | + $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
| 973 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 974 | + $query_args, |
|
| 975 | + GEN_SET_ADMIN_URL |
|
| 976 | + ); |
|
| 977 | + } |
|
| 978 | + } |
|
| 979 | + } else { |
|
| 980 | + $this->_template_args['states'] = false; |
|
| 981 | + } |
|
| 982 | + |
|
| 983 | + $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 984 | + array('action' => 'add_new_state'), |
|
| 985 | + GEN_SET_ADMIN_URL |
|
| 986 | + ); |
|
| 987 | + |
|
| 988 | + $state_details_settings = EEH_Template::display_template( |
|
| 989 | + GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
| 990 | + $this->_template_args, |
|
| 991 | + true |
|
| 992 | + ); |
|
| 993 | + |
|
| 994 | + if (defined('DOING_AJAX')) { |
|
| 995 | + $notices = EE_Error::get_notices(false, false, false); |
|
| 996 | + echo wp_json_encode( |
|
| 997 | + array( |
|
| 998 | + 'return_data' => $state_details_settings, |
|
| 999 | + 'success' => $notices['success'], |
|
| 1000 | + 'errors' => $notices['errors'], |
|
| 1001 | + ) |
|
| 1002 | + ); |
|
| 1003 | + die(); |
|
| 1004 | + } else { |
|
| 1005 | + return $state_details_settings; |
|
| 1006 | + } |
|
| 1007 | + } |
|
| 1008 | + |
|
| 1009 | + |
|
| 1010 | + /** |
|
| 1011 | + * add_new_state |
|
| 1012 | + * |
|
| 1013 | + * @access public |
|
| 1014 | + * @return void |
|
| 1015 | + * @throws EE_Error |
|
| 1016 | + */ |
|
| 1017 | + public function add_new_state() |
|
| 1018 | + { |
|
| 1019 | + |
|
| 1020 | + $success = true; |
|
| 1021 | + |
|
| 1022 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
| 1023 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
| 1024 | + : false; |
|
| 1025 | + if (! $CNT_ISO) { |
|
| 1026 | + EE_Error::add_error( |
|
| 1027 | + __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
| 1028 | + __FILE__, |
|
| 1029 | + __FUNCTION__, |
|
| 1030 | + __LINE__ |
|
| 1031 | + ); |
|
| 1032 | + $success = false; |
|
| 1033 | + } |
|
| 1034 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
| 1035 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
| 1036 | + : false; |
|
| 1037 | + if (! $STA_abbrev) { |
|
| 1038 | + EE_Error::add_error( |
|
| 1039 | + __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
| 1040 | + __FILE__, |
|
| 1041 | + __FUNCTION__, |
|
| 1042 | + __LINE__ |
|
| 1043 | + ); |
|
| 1044 | + $success = false; |
|
| 1045 | + } |
|
| 1046 | + $STA_name = isset($this->_req_data['STA_name']) |
|
| 1047 | + ? sanitize_text_field($this->_req_data['STA_name']) |
|
| 1048 | + : false; |
|
| 1049 | + if (! $STA_name) { |
|
| 1050 | + EE_Error::add_error( |
|
| 1051 | + __('No State name or an invalid State name was received.', 'event_espresso'), |
|
| 1052 | + __FILE__, |
|
| 1053 | + __FUNCTION__, |
|
| 1054 | + __LINE__ |
|
| 1055 | + ); |
|
| 1056 | + $success = false; |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + if ($success) { |
|
| 1060 | + $cols_n_values = array( |
|
| 1061 | + 'CNT_ISO' => $CNT_ISO, |
|
| 1062 | + 'STA_abbrev' => $STA_abbrev, |
|
| 1063 | + 'STA_name' => $STA_name, |
|
| 1064 | + 'STA_active' => true, |
|
| 1065 | + ); |
|
| 1066 | + $success = EEM_State::instance()->insert($cols_n_values); |
|
| 1067 | + EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
| 1068 | + } |
|
| 1069 | + |
|
| 1070 | + if (defined('DOING_AJAX')) { |
|
| 1071 | + $notices = EE_Error::get_notices(false, false, false); |
|
| 1072 | + echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
| 1073 | + die(); |
|
| 1074 | + } else { |
|
| 1075 | + $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
| 1076 | + } |
|
| 1077 | + } |
|
| 1078 | + |
|
| 1079 | + |
|
| 1080 | + /** |
|
| 1081 | + * delete_state |
|
| 1082 | + * |
|
| 1083 | + * @access public |
|
| 1084 | + * @return boolean |
|
| 1085 | + */ |
|
| 1086 | + public function delete_state() |
|
| 1087 | + { |
|
| 1088 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
| 1089 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
| 1090 | + : false; |
|
| 1091 | + $STA_ID = isset($this->_req_data['STA_ID']) |
|
| 1092 | + ? sanitize_text_field($this->_req_data['STA_ID']) |
|
| 1093 | + : false; |
|
| 1094 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
| 1095 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
| 1096 | + : false; |
|
| 1097 | + if (! $STA_ID) { |
|
| 1098 | + EE_Error::add_error( |
|
| 1099 | + __('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
| 1100 | + __FILE__, |
|
| 1101 | + __FUNCTION__, |
|
| 1102 | + __LINE__ |
|
| 1103 | + ); |
|
| 1104 | + return false; |
|
| 1105 | + } |
|
| 1106 | + |
|
| 1107 | + $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
| 1108 | + if ($success !== false) { |
|
| 1109 | + do_action( |
|
| 1110 | + 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
| 1111 | + $CNT_ISO, |
|
| 1112 | + $STA_ID, |
|
| 1113 | + array('STA_abbrev' => $STA_abbrev) |
|
| 1114 | + ); |
|
| 1115 | + EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
| 1116 | + } |
|
| 1117 | + if (defined('DOING_AJAX')) { |
|
| 1118 | + $notices = EE_Error::get_notices(false, false); |
|
| 1119 | + $notices['return_data'] = true; |
|
| 1120 | + echo wp_json_encode($notices); |
|
| 1121 | + die(); |
|
| 1122 | + } else { |
|
| 1123 | + $this->_redirect_after_action( |
|
| 1124 | + $success, |
|
| 1125 | + 'State', |
|
| 1126 | + 'deleted', |
|
| 1127 | + array('action' => 'country_settings') |
|
| 1128 | + ); |
|
| 1129 | + } |
|
| 1130 | + } |
|
| 1131 | + |
|
| 1132 | + |
|
| 1133 | + /** |
|
| 1134 | + * _update_country_settings |
|
| 1135 | + * |
|
| 1136 | + * @access protected |
|
| 1137 | + * @return void |
|
| 1138 | + * @throws EE_Error |
|
| 1139 | + */ |
|
| 1140 | + protected function _update_country_settings() |
|
| 1141 | + { |
|
| 1142 | + // grab the country ISO code |
|
| 1143 | + $CNT_ISO = isset($this->_req_data['country']) |
|
| 1144 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
| 1145 | + : false; |
|
| 1146 | + if (! $CNT_ISO) { |
|
| 1147 | + EE_Error::add_error( |
|
| 1148 | + __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
| 1149 | + __FILE__, |
|
| 1150 | + __FUNCTION__, |
|
| 1151 | + __LINE__ |
|
| 1152 | + ); |
|
| 1153 | + |
|
| 1154 | + return; |
|
| 1155 | + } |
|
| 1156 | + $cols_n_values = array(); |
|
| 1157 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
| 1158 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
| 1159 | + : false; |
|
| 1160 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
| 1161 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
| 1162 | + : null; |
|
| 1163 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
| 1164 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
| 1165 | + : null; |
|
| 1166 | + $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
| 1167 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) |
|
| 1168 | + : 'USD'; |
|
| 1169 | + $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
| 1170 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
| 1171 | + : 'dollar'; |
|
| 1172 | + $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
| 1173 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
| 1174 | + : 'dollars'; |
|
| 1175 | + $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
| 1176 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
| 1177 | + : '$'; |
|
| 1178 | + $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
| 1179 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
| 1180 | + : true; |
|
| 1181 | + $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
| 1182 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
| 1183 | + : 2; |
|
| 1184 | + $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
| 1185 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
| 1186 | + : '.'; |
|
| 1187 | + $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
| 1188 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
| 1189 | + : ','; |
|
| 1190 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
| 1191 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
| 1192 | + : null; |
|
| 1193 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
| 1194 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
| 1195 | + : false; |
|
| 1196 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
| 1197 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
| 1198 | + : false; |
|
| 1199 | + // allow filtering of country data |
|
| 1200 | + $cols_n_values = apply_filters( |
|
| 1201 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
| 1202 | + $cols_n_values |
|
| 1203 | + ); |
|
| 1204 | + |
|
| 1205 | + // where values |
|
| 1206 | + $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
| 1207 | + // run the update |
|
| 1208 | + $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
| 1209 | + |
|
| 1210 | + if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
| 1211 | + // allow filtering of states data |
|
| 1212 | + $states = apply_filters( |
|
| 1213 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
| 1214 | + $this->_req_data['states'] |
|
| 1215 | + ); |
|
| 1216 | + |
|
| 1217 | + // loop thru state data ( looks like : states[75][STA_name] ) |
|
| 1218 | + foreach ($states as $STA_ID => $state) { |
|
| 1219 | + $cols_n_values = array( |
|
| 1220 | + 'CNT_ISO' => $CNT_ISO, |
|
| 1221 | + 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
| 1222 | + 'STA_name' => sanitize_text_field($state['STA_name']), |
|
| 1223 | + 'STA_active' => (bool) absint($state['STA_active']), |
|
| 1224 | + ); |
|
| 1225 | + // where values |
|
| 1226 | + $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
| 1227 | + // run the update |
|
| 1228 | + $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
| 1229 | + if ($success !== false) { |
|
| 1230 | + do_action( |
|
| 1231 | + 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
| 1232 | + $CNT_ISO, |
|
| 1233 | + $STA_ID, |
|
| 1234 | + $cols_n_values |
|
| 1235 | + ); |
|
| 1236 | + } |
|
| 1237 | + } |
|
| 1238 | + } |
|
| 1239 | + // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
| 1240 | + if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
| 1241 | + && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 1242 | + ) { |
|
| 1243 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
| 1244 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
| 1245 | + } |
|
| 1246 | + |
|
| 1247 | + if ($success !== false) { |
|
| 1248 | + EE_Error::add_success( |
|
| 1249 | + esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
| 1250 | + ); |
|
| 1251 | + } |
|
| 1252 | + $this->_redirect_after_action( |
|
| 1253 | + $success, |
|
| 1254 | + '', |
|
| 1255 | + '', |
|
| 1256 | + array('action' => 'country_settings', 'country' => $CNT_ISO), |
|
| 1257 | + true |
|
| 1258 | + ); |
|
| 1259 | + } |
|
| 1260 | + |
|
| 1261 | + |
|
| 1262 | + /** |
|
| 1263 | + * form_form_field_label_wrap |
|
| 1264 | + * |
|
| 1265 | + * @access public |
|
| 1266 | + * @param string $label |
|
| 1267 | + * @return string |
|
| 1268 | + */ |
|
| 1269 | + public function country_form_field_label_wrap($label, $required_text) |
|
| 1270 | + { |
|
| 1271 | + return ' |
|
| 1272 | 1272 | <tr> |
| 1273 | 1273 | <th> |
| 1274 | 1274 | ' . $label . ' |
| 1275 | 1275 | </th>'; |
| 1276 | - } |
|
| 1277 | - |
|
| 1278 | - |
|
| 1279 | - /** |
|
| 1280 | - * form_form_field_input__wrap |
|
| 1281 | - * |
|
| 1282 | - * @access public |
|
| 1283 | - * @param string $label |
|
| 1284 | - * @return string |
|
| 1285 | - */ |
|
| 1286 | - public function country_form_field_input__wrap($input, $label) |
|
| 1287 | - { |
|
| 1288 | - return ' |
|
| 1276 | + } |
|
| 1277 | + |
|
| 1278 | + |
|
| 1279 | + /** |
|
| 1280 | + * form_form_field_input__wrap |
|
| 1281 | + * |
|
| 1282 | + * @access public |
|
| 1283 | + * @param string $label |
|
| 1284 | + * @return string |
|
| 1285 | + */ |
|
| 1286 | + public function country_form_field_input__wrap($input, $label) |
|
| 1287 | + { |
|
| 1288 | + return ' |
|
| 1289 | 1289 | <td class="general-settings-country-input-td"> |
| 1290 | 1290 | ' . $input . ' |
| 1291 | 1291 | </td> |
| 1292 | 1292 | </tr>'; |
| 1293 | - } |
|
| 1294 | - |
|
| 1295 | - |
|
| 1296 | - /** |
|
| 1297 | - * form_form_field_label_wrap |
|
| 1298 | - * |
|
| 1299 | - * @access public |
|
| 1300 | - * @param string $label |
|
| 1301 | - * @param string $required_text |
|
| 1302 | - * @return string |
|
| 1303 | - */ |
|
| 1304 | - public function state_form_field_label_wrap($label, $required_text) |
|
| 1305 | - { |
|
| 1306 | - return $required_text; |
|
| 1307 | - } |
|
| 1308 | - |
|
| 1309 | - |
|
| 1310 | - /** |
|
| 1311 | - * form_form_field_input__wrap |
|
| 1312 | - * |
|
| 1313 | - * @access public |
|
| 1314 | - * @param string $label |
|
| 1315 | - * @return string |
|
| 1316 | - */ |
|
| 1317 | - public function state_form_field_input__wrap($input, $label) |
|
| 1318 | - { |
|
| 1319 | - return ' |
|
| 1293 | + } |
|
| 1294 | + |
|
| 1295 | + |
|
| 1296 | + /** |
|
| 1297 | + * form_form_field_label_wrap |
|
| 1298 | + * |
|
| 1299 | + * @access public |
|
| 1300 | + * @param string $label |
|
| 1301 | + * @param string $required_text |
|
| 1302 | + * @return string |
|
| 1303 | + */ |
|
| 1304 | + public function state_form_field_label_wrap($label, $required_text) |
|
| 1305 | + { |
|
| 1306 | + return $required_text; |
|
| 1307 | + } |
|
| 1308 | + |
|
| 1309 | + |
|
| 1310 | + /** |
|
| 1311 | + * form_form_field_input__wrap |
|
| 1312 | + * |
|
| 1313 | + * @access public |
|
| 1314 | + * @param string $label |
|
| 1315 | + * @return string |
|
| 1316 | + */ |
|
| 1317 | + public function state_form_field_input__wrap($input, $label) |
|
| 1318 | + { |
|
| 1319 | + return ' |
|
| 1320 | 1320 | <td class="general-settings-country-state-input-td"> |
| 1321 | 1321 | ' . $input . ' |
| 1322 | 1322 | </td>'; |
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - |
|
| 1326 | - /***********/ |
|
| 1327 | - |
|
| 1328 | - |
|
| 1329 | - /** |
|
| 1330 | - * displays edit and view links for critical EE pages |
|
| 1331 | - * |
|
| 1332 | - * @access public |
|
| 1333 | - * @param int $ee_page_id |
|
| 1334 | - * @return string |
|
| 1335 | - */ |
|
| 1336 | - public static function edit_view_links($ee_page_id) |
|
| 1337 | - { |
|
| 1338 | - $links = '<a href="' |
|
| 1339 | - . add_query_arg( |
|
| 1340 | - array('post' => $ee_page_id, 'action' => 'edit'), |
|
| 1341 | - admin_url('post.php') |
|
| 1342 | - ) |
|
| 1343 | - . '" >' |
|
| 1344 | - . __('Edit', 'event_espresso') |
|
| 1345 | - . '</a>'; |
|
| 1346 | - $links .= ' | '; |
|
| 1347 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
| 1348 | - |
|
| 1349 | - return $links; |
|
| 1350 | - } |
|
| 1351 | - |
|
| 1352 | - |
|
| 1353 | - /** |
|
| 1354 | - * displays page and shortcode status for critical EE pages |
|
| 1355 | - * |
|
| 1356 | - * @param WP page object $ee_page |
|
| 1357 | - * @return string |
|
| 1358 | - */ |
|
| 1359 | - public static function page_and_shortcode_status($ee_page, $shortcode) |
|
| 1360 | - { |
|
| 1361 | - |
|
| 1362 | - // page status |
|
| 1363 | - if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
| 1364 | - $pg_colour = 'green'; |
|
| 1365 | - $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
| 1366 | - } else { |
|
| 1367 | - $pg_colour = 'red'; |
|
| 1368 | - $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
| 1369 | - } |
|
| 1370 | - |
|
| 1371 | - // shortcode status |
|
| 1372 | - if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
| 1373 | - $sc_colour = 'green'; |
|
| 1374 | - $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
| 1375 | - } else { |
|
| 1376 | - $sc_colour = 'red'; |
|
| 1377 | - $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
| 1378 | - } |
|
| 1379 | - |
|
| 1380 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
| 1381 | - . $pg_status |
|
| 1382 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
| 1383 | - } |
|
| 1384 | - |
|
| 1385 | - |
|
| 1386 | - /** |
|
| 1387 | - * generates a dropdown of all parent pages - copied from WP core |
|
| 1388 | - * |
|
| 1389 | - * @param int $default |
|
| 1390 | - * @param int $parent |
|
| 1391 | - * @param int $level |
|
| 1392 | - */ |
|
| 1393 | - public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
| 1394 | - { |
|
| 1395 | - global $wpdb; |
|
| 1396 | - $items = $wpdb->get_results( |
|
| 1397 | - $wpdb->prepare( |
|
| 1398 | - "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", |
|
| 1399 | - $parent |
|
| 1400 | - ) |
|
| 1401 | - ); |
|
| 1402 | - |
|
| 1403 | - if ($items) { |
|
| 1404 | - foreach ($items as $item) { |
|
| 1405 | - $pad = str_repeat(' ', $level * 3); |
|
| 1406 | - if ($item->ID == $default) { |
|
| 1407 | - $current = ' selected="selected"'; |
|
| 1408 | - } else { |
|
| 1409 | - $current = ''; |
|
| 1410 | - } |
|
| 1411 | - |
|
| 1412 | - echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " |
|
| 1413 | - . esc_html($item->post_title) |
|
| 1414 | - . "</option>"; |
|
| 1415 | - parent_dropdown($default, $item->ID, $level + 1); |
|
| 1416 | - } |
|
| 1417 | - } |
|
| 1418 | - } |
|
| 1323 | + } |
|
| 1324 | + |
|
| 1325 | + |
|
| 1326 | + /***********/ |
|
| 1327 | + |
|
| 1328 | + |
|
| 1329 | + /** |
|
| 1330 | + * displays edit and view links for critical EE pages |
|
| 1331 | + * |
|
| 1332 | + * @access public |
|
| 1333 | + * @param int $ee_page_id |
|
| 1334 | + * @return string |
|
| 1335 | + */ |
|
| 1336 | + public static function edit_view_links($ee_page_id) |
|
| 1337 | + { |
|
| 1338 | + $links = '<a href="' |
|
| 1339 | + . add_query_arg( |
|
| 1340 | + array('post' => $ee_page_id, 'action' => 'edit'), |
|
| 1341 | + admin_url('post.php') |
|
| 1342 | + ) |
|
| 1343 | + . '" >' |
|
| 1344 | + . __('Edit', 'event_espresso') |
|
| 1345 | + . '</a>'; |
|
| 1346 | + $links .= ' | '; |
|
| 1347 | + $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
| 1348 | + |
|
| 1349 | + return $links; |
|
| 1350 | + } |
|
| 1351 | + |
|
| 1352 | + |
|
| 1353 | + /** |
|
| 1354 | + * displays page and shortcode status for critical EE pages |
|
| 1355 | + * |
|
| 1356 | + * @param WP page object $ee_page |
|
| 1357 | + * @return string |
|
| 1358 | + */ |
|
| 1359 | + public static function page_and_shortcode_status($ee_page, $shortcode) |
|
| 1360 | + { |
|
| 1361 | + |
|
| 1362 | + // page status |
|
| 1363 | + if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
| 1364 | + $pg_colour = 'green'; |
|
| 1365 | + $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
| 1366 | + } else { |
|
| 1367 | + $pg_colour = 'red'; |
|
| 1368 | + $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
| 1369 | + } |
|
| 1370 | + |
|
| 1371 | + // shortcode status |
|
| 1372 | + if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
| 1373 | + $sc_colour = 'green'; |
|
| 1374 | + $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
| 1375 | + } else { |
|
| 1376 | + $sc_colour = 'red'; |
|
| 1377 | + $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
| 1378 | + } |
|
| 1379 | + |
|
| 1380 | + return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
| 1381 | + . $pg_status |
|
| 1382 | + . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
| 1383 | + } |
|
| 1384 | + |
|
| 1385 | + |
|
| 1386 | + /** |
|
| 1387 | + * generates a dropdown of all parent pages - copied from WP core |
|
| 1388 | + * |
|
| 1389 | + * @param int $default |
|
| 1390 | + * @param int $parent |
|
| 1391 | + * @param int $level |
|
| 1392 | + */ |
|
| 1393 | + public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
| 1394 | + { |
|
| 1395 | + global $wpdb; |
|
| 1396 | + $items = $wpdb->get_results( |
|
| 1397 | + $wpdb->prepare( |
|
| 1398 | + "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", |
|
| 1399 | + $parent |
|
| 1400 | + ) |
|
| 1401 | + ); |
|
| 1402 | + |
|
| 1403 | + if ($items) { |
|
| 1404 | + foreach ($items as $item) { |
|
| 1405 | + $pad = str_repeat(' ', $level * 3); |
|
| 1406 | + if ($item->ID == $default) { |
|
| 1407 | + $current = ' selected="selected"'; |
|
| 1408 | + } else { |
|
| 1409 | + $current = ''; |
|
| 1410 | + } |
|
| 1411 | + |
|
| 1412 | + echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " |
|
| 1413 | + . esc_html($item->post_title) |
|
| 1414 | + . "</option>"; |
|
| 1415 | + parent_dropdown($default, $item->ID, $level + 1); |
|
| 1416 | + } |
|
| 1417 | + } |
|
| 1418 | + } |
|
| 1419 | 1419 | } |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | wp_enqueue_script('thickbox'); |
| 267 | 267 | wp_register_script( |
| 268 | 268 | 'organization_settings', |
| 269 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
| 269 | + GEN_SET_ASSETS_URL.'your_organization_settings.js', |
|
| 270 | 270 | array('jquery', 'media-upload', 'thickbox'), |
| 271 | 271 | EVENT_ESPRESSO_VERSION, |
| 272 | 272 | true |
| 273 | 273 | ); |
| 274 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 274 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 275 | 275 | wp_enqueue_script('organization_settings'); |
| 276 | 276 | wp_enqueue_style('organization-css'); |
| 277 | 277 | $confirm_image_delete = array( |
@@ -292,12 +292,12 @@ discard block |
||
| 292 | 292 | // scripts |
| 293 | 293 | wp_register_script( |
| 294 | 294 | 'gen_settings_countries', |
| 295 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
| 295 | + GEN_SET_ASSETS_URL.'gen_settings_countries.js', |
|
| 296 | 296 | array('ee_admin_js'), |
| 297 | 297 | EVENT_ESPRESSO_VERSION, |
| 298 | 298 | true |
| 299 | 299 | ); |
| 300 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 300 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 301 | 301 | wp_enqueue_script('gen_settings_countries'); |
| 302 | 302 | wp_enqueue_style('organization-css'); |
| 303 | 303 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
| 344 | 344 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
| 345 | 345 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 346 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
| 346 | + GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php', |
|
| 347 | 347 | $this->_template_args, |
| 348 | 348 | true |
| 349 | 349 | ); |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
| 519 | 519 | |
| 520 | 520 | // PUE verification stuff |
| 521 | - $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
| 521 | + $ver_option_key = 'puvererr_'.basename(EE_PLUGIN_BASENAME); |
|
| 522 | 522 | $verify_fail = get_option($ver_option_key); |
| 523 | 523 | $this->_template_args['site_license_key_verified'] = $verify_fail |
| 524 | 524 | || ! empty($verify_fail) |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | $this->_set_add_edit_form_tags('update_your_organization_settings'); |
| 532 | 532 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
| 533 | 533 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 534 | - GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', |
|
| 534 | + GEN_SET_TEMPLATE_PATH.'your_organization_settings.template.php', |
|
| 535 | 535 | $this->_template_args, |
| 536 | 536 | true |
| 537 | 537 | ); |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | { |
| 671 | 671 | try { |
| 672 | 672 | $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
| 673 | - $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
| 673 | + $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]); |
|
| 674 | 674 | EE_Registry::instance()->CFG->admin = apply_filters( |
| 675 | 675 | 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
| 676 | 676 | EE_Registry::instance()->CFG->admin |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | $this->_set_add_edit_form_tags('update_country_settings'); |
| 749 | 749 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
| 750 | 750 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 751 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
| 751 | + GEN_SET_TEMPLATE_PATH.'countries_settings.template.php', |
|
| 752 | 752 | $this->_template_args, |
| 753 | 753 | true |
| 754 | 754 | ); |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | $CNT_ISO = isset($this->_req_data['country']) |
| 771 | 771 | ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
| 772 | 772 | : $CNT_ISO; |
| 773 | - if (! $CNT_ISO) { |
|
| 773 | + if ( ! $CNT_ISO) { |
|
| 774 | 774 | return ''; |
| 775 | 775 | } |
| 776 | 776 | |
@@ -784,62 +784,62 @@ discard block |
||
| 784 | 784 | $country_input_types = array( |
| 785 | 785 | 'CNT_active' => array( |
| 786 | 786 | 'type' => 'RADIO_BTN', |
| 787 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 787 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 788 | 788 | 'class' => '', |
| 789 | 789 | 'options' => $this->_yes_no_values, |
| 790 | 790 | 'use_desc_4_label' => true, |
| 791 | 791 | ), |
| 792 | 792 | 'CNT_ISO' => array( |
| 793 | 793 | 'type' => 'TEXT', |
| 794 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 794 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 795 | 795 | 'class' => 'small-text', |
| 796 | 796 | ), |
| 797 | 797 | 'CNT_ISO3' => array( |
| 798 | 798 | 'type' => 'TEXT', |
| 799 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 799 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 800 | 800 | 'class' => 'small-text', |
| 801 | 801 | ), |
| 802 | 802 | 'RGN_ID' => array( |
| 803 | 803 | 'type' => 'TEXT', |
| 804 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 804 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 805 | 805 | 'class' => 'small-text', |
| 806 | 806 | ), |
| 807 | 807 | 'CNT_name' => array( |
| 808 | 808 | 'type' => 'TEXT', |
| 809 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 809 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 810 | 810 | 'class' => 'regular-text', |
| 811 | 811 | ), |
| 812 | 812 | 'CNT_cur_code' => array( |
| 813 | 813 | 'type' => 'TEXT', |
| 814 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 814 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 815 | 815 | 'class' => 'small-text', |
| 816 | 816 | ), |
| 817 | 817 | 'CNT_cur_single' => array( |
| 818 | 818 | 'type' => 'TEXT', |
| 819 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 819 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 820 | 820 | 'class' => 'medium-text', |
| 821 | 821 | ), |
| 822 | 822 | 'CNT_cur_plural' => array( |
| 823 | 823 | 'type' => 'TEXT', |
| 824 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 824 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 825 | 825 | 'class' => 'medium-text', |
| 826 | 826 | ), |
| 827 | 827 | 'CNT_cur_sign' => array( |
| 828 | 828 | 'type' => 'TEXT', |
| 829 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 829 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 830 | 830 | 'class' => 'small-text', |
| 831 | 831 | 'htmlentities' => false, |
| 832 | 832 | ), |
| 833 | 833 | 'CNT_cur_sign_b4' => array( |
| 834 | 834 | 'type' => 'RADIO_BTN', |
| 835 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 835 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 836 | 836 | 'class' => '', |
| 837 | 837 | 'options' => $this->_yes_no_values, |
| 838 | 838 | 'use_desc_4_label' => true, |
| 839 | 839 | ), |
| 840 | 840 | 'CNT_cur_dec_plc' => array( |
| 841 | 841 | 'type' => 'RADIO_BTN', |
| 842 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 842 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 843 | 843 | 'class' => '', |
| 844 | 844 | 'options' => array( |
| 845 | 845 | array('id' => 0, 'text' => ''), |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | ), |
| 851 | 851 | 'CNT_cur_dec_mrk' => 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,7 +863,7 @@ discard block |
||
| 863 | 863 | ), |
| 864 | 864 | 'CNT_cur_thsnds' => array( |
| 865 | 865 | 'type' => 'RADIO_BTN', |
| 866 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 866 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 867 | 867 | 'class' => '', |
| 868 | 868 | 'options' => array( |
| 869 | 869 | array( |
@@ -876,12 +876,12 @@ discard block |
||
| 876 | 876 | ), |
| 877 | 877 | 'CNT_tel_code' => array( |
| 878 | 878 | 'type' => 'TEXT', |
| 879 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 879 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 880 | 880 | 'class' => 'small-text', |
| 881 | 881 | ), |
| 882 | 882 | 'CNT_is_EU' => array( |
| 883 | 883 | 'type' => 'RADIO_BTN', |
| 884 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
| 884 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
| 885 | 885 | 'class' => '', |
| 886 | 886 | 'options' => $this->_yes_no_values, |
| 887 | 887 | 'use_desc_4_label' => true, |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | $country_input_types |
| 893 | 893 | ); |
| 894 | 894 | $country_details_settings = EEH_Template::display_template( |
| 895 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
| 895 | + GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php', |
|
| 896 | 896 | $this->_template_args, |
| 897 | 897 | true |
| 898 | 898 | ); |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | |
| 927 | 927 | $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
| 928 | 928 | |
| 929 | - if (! $CNT_ISO) { |
|
| 929 | + if ( ! $CNT_ISO) { |
|
| 930 | 930 | return ''; |
| 931 | 931 | } |
| 932 | 932 | // for ajax |
@@ -943,22 +943,22 @@ discard block |
||
| 943 | 943 | $state_input_types = array( |
| 944 | 944 | 'STA_abbrev' => array( |
| 945 | 945 | 'type' => 'TEXT', |
| 946 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
| 946 | + 'input_name' => 'states['.$STA_ID.']', |
|
| 947 | 947 | 'class' => 'mid-text', |
| 948 | 948 | ), |
| 949 | 949 | 'STA_name' => array( |
| 950 | 950 | 'type' => 'TEXT', |
| 951 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
| 951 | + 'input_name' => 'states['.$STA_ID.']', |
|
| 952 | 952 | 'class' => 'regular-text', |
| 953 | 953 | ), |
| 954 | 954 | 'STA_active' => array( |
| 955 | 955 | 'type' => 'RADIO_BTN', |
| 956 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
| 956 | + 'input_name' => 'states['.$STA_ID.']', |
|
| 957 | 957 | 'options' => $this->_yes_no_values, |
| 958 | 958 | 'use_desc_4_label' => true, |
| 959 | 959 | ), |
| 960 | 960 | ); |
| 961 | - $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
| 961 | + $this->_template_args['states'][$STA_ID]['inputs'] = |
|
| 962 | 962 | EE_Question_Form_Input::generate_question_form_inputs_for_object( |
| 963 | 963 | $state, |
| 964 | 964 | $state_input_types |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | 'CNT_ISO' => $CNT_ISO, |
| 970 | 970 | 'STA_abbrev' => $state->abbrev(), |
| 971 | 971 | ); |
| 972 | - $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
| 972 | + $this->_template_args['states'][$STA_ID]['delete_state_url'] = |
|
| 973 | 973 | EE_Admin_Page::add_query_args_and_nonce( |
| 974 | 974 | $query_args, |
| 975 | 975 | GEN_SET_ADMIN_URL |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | ); |
| 987 | 987 | |
| 988 | 988 | $state_details_settings = EEH_Template::display_template( |
| 989 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
| 989 | + GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php', |
|
| 990 | 990 | $this->_template_args, |
| 991 | 991 | true |
| 992 | 992 | ); |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
| 1023 | 1023 | ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
| 1024 | 1024 | : false; |
| 1025 | - if (! $CNT_ISO) { |
|
| 1025 | + if ( ! $CNT_ISO) { |
|
| 1026 | 1026 | EE_Error::add_error( |
| 1027 | 1027 | __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
| 1028 | 1028 | __FILE__, |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
| 1035 | 1035 | ? sanitize_text_field($this->_req_data['STA_abbrev']) |
| 1036 | 1036 | : false; |
| 1037 | - if (! $STA_abbrev) { |
|
| 1037 | + if ( ! $STA_abbrev) { |
|
| 1038 | 1038 | EE_Error::add_error( |
| 1039 | 1039 | __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
| 1040 | 1040 | __FILE__, |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | $STA_name = isset($this->_req_data['STA_name']) |
| 1047 | 1047 | ? sanitize_text_field($this->_req_data['STA_name']) |
| 1048 | 1048 | : false; |
| 1049 | - if (! $STA_name) { |
|
| 1049 | + if ( ! $STA_name) { |
|
| 1050 | 1050 | EE_Error::add_error( |
| 1051 | 1051 | __('No State name or an invalid State name was received.', 'event_espresso'), |
| 1052 | 1052 | __FILE__, |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
| 1095 | 1095 | ? sanitize_text_field($this->_req_data['STA_abbrev']) |
| 1096 | 1096 | : false; |
| 1097 | - if (! $STA_ID) { |
|
| 1097 | + if ( ! $STA_ID) { |
|
| 1098 | 1098 | EE_Error::add_error( |
| 1099 | 1099 | __('No State ID or an invalid State ID was received.', 'event_espresso'), |
| 1100 | 1100 | __FILE__, |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | $CNT_ISO = isset($this->_req_data['country']) |
| 1144 | 1144 | ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
| 1145 | 1145 | : false; |
| 1146 | - if (! $CNT_ISO) { |
|
| 1146 | + if ( ! $CNT_ISO) { |
|
| 1147 | 1147 | EE_Error::add_error( |
| 1148 | 1148 | __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
| 1149 | 1149 | __FILE__, |
@@ -1154,47 +1154,47 @@ discard block |
||
| 1154 | 1154 | return; |
| 1155 | 1155 | } |
| 1156 | 1156 | $cols_n_values = array(); |
| 1157 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
| 1158 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
| 1157 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) |
|
| 1158 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) |
|
| 1159 | 1159 | : false; |
| 1160 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
| 1161 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
| 1160 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
| 1161 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
| 1162 | 1162 | : null; |
| 1163 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
| 1164 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
| 1163 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
| 1164 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
| 1165 | 1165 | : null; |
| 1166 | - $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
| 1167 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) |
|
| 1166 | + $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) |
|
| 1167 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) |
|
| 1168 | 1168 | : 'USD'; |
| 1169 | - $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
| 1170 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
| 1169 | + $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
| 1170 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
| 1171 | 1171 | : 'dollar'; |
| 1172 | - $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
| 1173 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
| 1172 | + $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
| 1173 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
| 1174 | 1174 | : 'dollars'; |
| 1175 | - $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
| 1176 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
| 1175 | + $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
| 1176 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
| 1177 | 1177 | : '$'; |
| 1178 | - $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
| 1179 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
| 1178 | + $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
| 1179 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
| 1180 | 1180 | : true; |
| 1181 | - $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
| 1182 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
| 1181 | + $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
| 1182 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
| 1183 | 1183 | : 2; |
| 1184 | - $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
| 1185 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
| 1184 | + $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
| 1185 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
| 1186 | 1186 | : '.'; |
| 1187 | - $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
| 1188 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
| 1187 | + $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
| 1188 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
| 1189 | 1189 | : ','; |
| 1190 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
| 1191 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
| 1190 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
| 1191 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
| 1192 | 1192 | : null; |
| 1193 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
| 1194 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
| 1193 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
| 1194 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
| 1195 | 1195 | : false; |
| 1196 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
| 1197 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
| 1196 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
| 1197 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
| 1198 | 1198 | : false; |
| 1199 | 1199 | // allow filtering of country data |
| 1200 | 1200 | $cols_n_values = apply_filters( |
@@ -1271,7 +1271,7 @@ discard block |
||
| 1271 | 1271 | return ' |
| 1272 | 1272 | <tr> |
| 1273 | 1273 | <th> |
| 1274 | - ' . $label . ' |
|
| 1274 | + ' . $label.' |
|
| 1275 | 1275 | </th>'; |
| 1276 | 1276 | } |
| 1277 | 1277 | |
@@ -1287,7 +1287,7 @@ discard block |
||
| 1287 | 1287 | { |
| 1288 | 1288 | return ' |
| 1289 | 1289 | <td class="general-settings-country-input-td"> |
| 1290 | - ' . $input . ' |
|
| 1290 | + ' . $input.' |
|
| 1291 | 1291 | </td> |
| 1292 | 1292 | </tr>'; |
| 1293 | 1293 | } |
@@ -1318,7 +1318,7 @@ discard block |
||
| 1318 | 1318 | { |
| 1319 | 1319 | return ' |
| 1320 | 1320 | <td class="general-settings-country-state-input-td"> |
| 1321 | - ' . $input . ' |
|
| 1321 | + ' . $input.' |
|
| 1322 | 1322 | </td>'; |
| 1323 | 1323 | } |
| 1324 | 1324 | |
@@ -1344,7 +1344,7 @@ discard block |
||
| 1344 | 1344 | . __('Edit', 'event_espresso') |
| 1345 | 1345 | . '</a>'; |
| 1346 | 1346 | $links .= ' | '; |
| 1347 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
| 1347 | + $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>'; |
|
| 1348 | 1348 | |
| 1349 | 1349 | return $links; |
| 1350 | 1350 | } |
@@ -1377,9 +1377,9 @@ discard block |
||
| 1377 | 1377 | $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
| 1380 | + return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>' |
|
| 1381 | 1381 | . $pg_status |
| 1382 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
| 1382 | + . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>'; |
|
| 1383 | 1383 | } |
| 1384 | 1384 | |
| 1385 | 1385 | |
@@ -16,38 +16,38 @@ |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @param string $table_column |
|
| 21 | - * @param string $nice_name |
|
| 22 | - * @param bool $nullable |
|
| 23 | - * @param null $default_value |
|
| 24 | - * @throws InvalidArgumentException |
|
| 25 | - */ |
|
| 26 | - public function __construct($table_column, $nice_name, $nullable, $default_value = null) |
|
| 27 | - { |
|
| 28 | - parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
| 29 | - $this->setSchemaFormat('email'); |
|
| 30 | - } |
|
| 19 | + /** |
|
| 20 | + * @param string $table_column |
|
| 21 | + * @param string $nice_name |
|
| 22 | + * @param bool $nullable |
|
| 23 | + * @param null $default_value |
|
| 24 | + * @throws InvalidArgumentException |
|
| 25 | + */ |
|
| 26 | + public function __construct($table_column, $nice_name, $nullable, $default_value = null) |
|
| 27 | + { |
|
| 28 | + parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
| 29 | + $this->setSchemaFormat('email'); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * In form inputs, we should have called htmlentities and addslashes() on form inputs, |
|
| 36 | - * so we need to undo that on setting of these fields |
|
| 37 | - * |
|
| 38 | - * @param string $email_address |
|
| 39 | - * @return string |
|
| 40 | - * @throws InvalidArgumentException |
|
| 41 | - * @throws InvalidInterfaceException |
|
| 42 | - * @throws InvalidDataTypeException |
|
| 43 | - */ |
|
| 44 | - public function prepare_for_set($email_address) |
|
| 45 | - { |
|
| 46 | - try { |
|
| 47 | - $email_address = EmailAddressFactory::create($email_address); |
|
| 48 | - return $email_address->get(); |
|
| 49 | - } catch (EmailValidationException $e) { |
|
| 50 | - return ''; |
|
| 51 | - } |
|
| 52 | - } |
|
| 34 | + /** |
|
| 35 | + * In form inputs, we should have called htmlentities and addslashes() on form inputs, |
|
| 36 | + * so we need to undo that on setting of these fields |
|
| 37 | + * |
|
| 38 | + * @param string $email_address |
|
| 39 | + * @return string |
|
| 40 | + * @throws InvalidArgumentException |
|
| 41 | + * @throws InvalidInterfaceException |
|
| 42 | + * @throws InvalidDataTypeException |
|
| 43 | + */ |
|
| 44 | + public function prepare_for_set($email_address) |
|
| 45 | + { |
|
| 46 | + try { |
|
| 47 | + $email_address = EmailAddressFactory::create($email_address); |
|
| 48 | + return $email_address->get(); |
|
| 49 | + } catch (EmailValidationException $e) { |
|
| 50 | + return ''; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | interface FactoryInterface |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @param mixed $arguments |
|
| 20 | - * @return mixed |
|
| 21 | - */ |
|
| 22 | - public static function create($arguments); |
|
| 18 | + /** |
|
| 19 | + * @param mixed $arguments |
|
| 20 | + * @return mixed |
|
| 21 | + */ |
|
| 22 | + public static function create($arguments); |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $email_address, |
| 35 | 35 | $this->getAtIndex($email_address) |
| 36 | 36 | ); |
| 37 | - if (! checkdnsrr($domain, 'MX')) { |
|
| 37 | + if ( ! checkdnsrr($domain, 'MX')) { |
|
| 38 | 38 | // domain not found in MX records |
| 39 | 39 | throw new EmailValidationException( |
| 40 | 40 | __( |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | ) |
| 46 | 46 | ); |
| 47 | 47 | } |
| 48 | - if (! checkdnsrr($domain, 'A')) { |
|
| 48 | + if ( ! checkdnsrr($domain, 'A')) { |
|
| 49 | 49 | // domain not found in A records |
| 50 | 50 | throw new EmailValidationException( |
| 51 | 51 | __( |
@@ -15,43 +15,43 @@ |
||
| 15 | 15 | class InternationalDNS extends International |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Validates the email in teh same way as the parent, but also |
|
| 20 | - * verifies the domain exists. |
|
| 21 | - * |
|
| 22 | - * @param string $email_address |
|
| 23 | - * @return bool |
|
| 24 | - * @throws EmailValidationException |
|
| 25 | - */ |
|
| 26 | - public function validate($email_address) |
|
| 27 | - { |
|
| 28 | - parent::validate($email_address); |
|
| 29 | - $domain = $this->getDomainPartOfEmail( |
|
| 30 | - $email_address, |
|
| 31 | - $this->getAtIndex($email_address) |
|
| 32 | - ); |
|
| 33 | - if (! checkdnsrr($domain, 'MX')) { |
|
| 34 | - // domain not found in MX records |
|
| 35 | - throw new EmailValidationException( |
|
| 36 | - __( |
|
| 37 | - // @codingStandardsIgnoreStart |
|
| 38 | - 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
| 39 | - // @codingStandardsIgnoreEnd |
|
| 40 | - 'event_espresso' |
|
| 41 | - ) |
|
| 42 | - ); |
|
| 43 | - } |
|
| 44 | - if (! checkdnsrr($domain, 'A')) { |
|
| 45 | - // domain not found in A records |
|
| 46 | - throw new EmailValidationException( |
|
| 47 | - __( |
|
| 48 | - // @codingStandardsIgnoreStart |
|
| 49 | - 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
| 50 | - // @codingStandardsIgnoreEnd |
|
| 51 | - 'event_espresso' |
|
| 52 | - ) |
|
| 53 | - ); |
|
| 54 | - } |
|
| 55 | - return true; |
|
| 56 | - } |
|
| 18 | + /** |
|
| 19 | + * Validates the email in teh same way as the parent, but also |
|
| 20 | + * verifies the domain exists. |
|
| 21 | + * |
|
| 22 | + * @param string $email_address |
|
| 23 | + * @return bool |
|
| 24 | + * @throws EmailValidationException |
|
| 25 | + */ |
|
| 26 | + public function validate($email_address) |
|
| 27 | + { |
|
| 28 | + parent::validate($email_address); |
|
| 29 | + $domain = $this->getDomainPartOfEmail( |
|
| 30 | + $email_address, |
|
| 31 | + $this->getAtIndex($email_address) |
|
| 32 | + ); |
|
| 33 | + if (! checkdnsrr($domain, 'MX')) { |
|
| 34 | + // domain not found in MX records |
|
| 35 | + throw new EmailValidationException( |
|
| 36 | + __( |
|
| 37 | + // @codingStandardsIgnoreStart |
|
| 38 | + 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
| 39 | + // @codingStandardsIgnoreEnd |
|
| 40 | + 'event_espresso' |
|
| 41 | + ) |
|
| 42 | + ); |
|
| 43 | + } |
|
| 44 | + if (! checkdnsrr($domain, 'A')) { |
|
| 45 | + // domain not found in A records |
|
| 46 | + throw new EmailValidationException( |
|
| 47 | + __( |
|
| 48 | + // @codingStandardsIgnoreStart |
|
| 49 | + 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
| 50 | + // @codingStandardsIgnoreEnd |
|
| 51 | + 'event_espresso' |
|
| 52 | + ) |
|
| 53 | + ); |
|
| 54 | + } |
|
| 55 | + return true; |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -18,14 +18,14 @@ |
||
| 18 | 18 | interface EmailValidatorInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Validates the supplied email address. If it is invalid, throws EmailValidationException |
|
| 23 | - * |
|
| 24 | - * @param string $email_address |
|
| 25 | - * @return boolean |
|
| 26 | - * @throws EmailValidationException |
|
| 27 | - */ |
|
| 28 | - public function validate($email_address); |
|
| 21 | + /** |
|
| 22 | + * Validates the supplied email address. If it is invalid, throws EmailValidationException |
|
| 23 | + * |
|
| 24 | + * @param string $email_address |
|
| 25 | + * @return boolean |
|
| 26 | + * @throws EmailValidationException |
|
| 27 | + */ |
|
| 28 | + public function validate($email_address); |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | } |
@@ -18,72 +18,72 @@ |
||
| 18 | 18 | { |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $validation_error_message |
|
| 23 | - */ |
|
| 24 | - public function __construct($validation_error_message = '') |
|
| 25 | - { |
|
| 26 | - if (! $validation_error_message) { |
|
| 27 | - $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
|
| 28 | - } |
|
| 29 | - parent::__construct($validation_error_message); |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * @param string $validation_error_message |
|
| 23 | + */ |
|
| 24 | + public function __construct($validation_error_message = '') |
|
| 25 | + { |
|
| 26 | + if (! $validation_error_message) { |
|
| 27 | + $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
|
| 28 | + } |
|
| 29 | + parent::__construct($validation_error_message); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * just checks the field isn't blank |
|
| 36 | - * |
|
| 37 | - * @param $normalized_value |
|
| 38 | - * @return bool |
|
| 39 | - * @throws InvalidArgumentException |
|
| 40 | - * @throws InvalidInterfaceException |
|
| 41 | - * @throws InvalidDataTypeException |
|
| 42 | - * @throws EE_Validation_Error |
|
| 43 | - */ |
|
| 44 | - public function validate($normalized_value) |
|
| 45 | - { |
|
| 46 | - if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
| 47 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
| 48 | - } |
|
| 49 | - return true; |
|
| 50 | - } |
|
| 34 | + /** |
|
| 35 | + * just checks the field isn't blank |
|
| 36 | + * |
|
| 37 | + * @param $normalized_value |
|
| 38 | + * @return bool |
|
| 39 | + * @throws InvalidArgumentException |
|
| 40 | + * @throws InvalidInterfaceException |
|
| 41 | + * @throws InvalidDataTypeException |
|
| 42 | + * @throws EE_Validation_Error |
|
| 43 | + */ |
|
| 44 | + public function validate($normalized_value) |
|
| 45 | + { |
|
| 46 | + if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
| 47 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
| 48 | + } |
|
| 49 | + return true; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function get_jquery_validation_rule_array() |
|
| 58 | - { |
|
| 59 | - return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
| 60 | - } |
|
| 54 | + /** |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function get_jquery_validation_rule_array() |
|
| 58 | + { |
|
| 59 | + return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Validate an email address. |
|
| 66 | - * Provide email address (raw input) |
|
| 67 | - * |
|
| 68 | - * @param $email |
|
| 69 | - * @return bool of whether the email is valid or not |
|
| 70 | - * @throws InvalidArgumentException |
|
| 71 | - * @throws InvalidInterfaceException |
|
| 72 | - * @throws InvalidDataTypeException |
|
| 73 | - * @throws EE_Validation_Error |
|
| 74 | - */ |
|
| 75 | - private function _validate_email($email) |
|
| 76 | - { |
|
| 77 | - try { |
|
| 78 | - EmailAddressFactory::create($email); |
|
| 79 | - } catch (EmailValidationException $e) { |
|
| 80 | - throw new EE_Validation_Error( |
|
| 81 | - $e->getMessage(), |
|
| 82 | - 'invalid_email', |
|
| 83 | - $this->_input, |
|
| 84 | - $e |
|
| 85 | - ); |
|
| 86 | - } |
|
| 87 | - return true; |
|
| 88 | - } |
|
| 64 | + /** |
|
| 65 | + * Validate an email address. |
|
| 66 | + * Provide email address (raw input) |
|
| 67 | + * |
|
| 68 | + * @param $email |
|
| 69 | + * @return bool of whether the email is valid or not |
|
| 70 | + * @throws InvalidArgumentException |
|
| 71 | + * @throws InvalidInterfaceException |
|
| 72 | + * @throws InvalidDataTypeException |
|
| 73 | + * @throws EE_Validation_Error |
|
| 74 | + */ |
|
| 75 | + private function _validate_email($email) |
|
| 76 | + { |
|
| 77 | + try { |
|
| 78 | + EmailAddressFactory::create($email); |
|
| 79 | + } catch (EmailValidationException $e) { |
|
| 80 | + throw new EE_Validation_Error( |
|
| 81 | + $e->getMessage(), |
|
| 82 | + 'invalid_email', |
|
| 83 | + $this->_input, |
|
| 84 | + $e |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | + return true; |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct($validation_error_message = '') |
| 25 | 25 | { |
| 26 | - if (! $validation_error_message) { |
|
| 26 | + if ( ! $validation_error_message) { |
|
| 27 | 27 | $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
| 28 | 28 | } |
| 29 | 29 | parent::__construct($validation_error_message); |
@@ -351,7 +351,7 @@ |
||
| 351 | 351 | * retrieve a single attendee from db via their ID |
| 352 | 352 | * |
| 353 | 353 | * @param $ATT_ID |
| 354 | - * @return mixed array on success, FALSE on fail |
|
| 354 | + * @return EE_Base_Class|null array on success, FALSE on fail |
|
| 355 | 355 | * @deprecated |
| 356 | 356 | */ |
| 357 | 357 | public function get_attendee_by_ID($ATT_ID = false) |
@@ -1,5 +1,4 @@ |
||
| 1 | 1 | <?php |
| 2 | -use EventEspresso\core\services\loaders\Loader; |
|
| 3 | 2 | use EventEspresso\core\services\orm\ModelFieldFactory; |
| 4 | 3 | |
| 5 | 4 | /** |
@@ -12,411 +12,411 @@ |
||
| 12 | 12 | class EEM_Attendee extends EEM_CPT_Base |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - // private instance of the Attendee object |
|
| 16 | - protected static $_instance = null; |
|
| 15 | + // private instance of the Attendee object |
|
| 16 | + protected static $_instance = null; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * QST_system for questions are strings not integers now, |
|
| 20 | - * so these constants are deprecated. |
|
| 21 | - * Please instead use the EEM_Attendee::system_question_* constants |
|
| 22 | - * |
|
| 23 | - * @deprecated |
|
| 24 | - */ |
|
| 25 | - const fname_question_id = 1; |
|
| 18 | + /** |
|
| 19 | + * QST_system for questions are strings not integers now, |
|
| 20 | + * so these constants are deprecated. |
|
| 21 | + * Please instead use the EEM_Attendee::system_question_* constants |
|
| 22 | + * |
|
| 23 | + * @deprecated |
|
| 24 | + */ |
|
| 25 | + const fname_question_id = 1; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @deprecated |
|
| 29 | - */ |
|
| 30 | - const lname_question_id = 2; |
|
| 27 | + /** |
|
| 28 | + * @deprecated |
|
| 29 | + */ |
|
| 30 | + const lname_question_id = 2; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @deprecated |
|
| 35 | - */ |
|
| 36 | - const email_question_id = 3; |
|
| 33 | + /** |
|
| 34 | + * @deprecated |
|
| 35 | + */ |
|
| 36 | + const email_question_id = 3; |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @deprecated |
|
| 41 | - */ |
|
| 42 | - const address_question_id = 4; |
|
| 39 | + /** |
|
| 40 | + * @deprecated |
|
| 41 | + */ |
|
| 42 | + const address_question_id = 4; |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @deprecated |
|
| 47 | - */ |
|
| 48 | - const address2_question_id = 5; |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @deprecated |
|
| 53 | - */ |
|
| 54 | - const city_question_id = 6; |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @deprecated |
|
| 59 | - */ |
|
| 60 | - const state_question_id = 7; |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @deprecated |
|
| 65 | - */ |
|
| 66 | - const country_question_id = 8; |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @deprecated |
|
| 71 | - */ |
|
| 72 | - const zip_question_id = 9; |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @deprecated |
|
| 77 | - */ |
|
| 78 | - const phone_question_id = 10; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * When looking for questions that correspond to attendee fields, |
|
| 82 | - * look for the question with this QST_system value. |
|
| 83 | - * These replace the old constants like EEM_Attendee::*_question_id |
|
| 84 | - */ |
|
| 85 | - const system_question_fname = 'fname'; |
|
| 86 | - |
|
| 87 | - const system_question_lname = 'lname'; |
|
| 88 | - |
|
| 89 | - const system_question_email = 'email'; |
|
| 90 | - |
|
| 91 | - const system_question_address = 'address'; |
|
| 92 | - |
|
| 93 | - const system_question_address2 = 'address2'; |
|
| 94 | - |
|
| 95 | - const system_question_city = 'city'; |
|
| 96 | - |
|
| 97 | - const system_question_state = 'state'; |
|
| 98 | - |
|
| 99 | - const system_question_country = 'country'; |
|
| 100 | - |
|
| 101 | - const system_question_zip = 'zip'; |
|
| 102 | - |
|
| 103 | - const system_question_phone = 'phone'; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
| 107 | - * also all the values of QST_system in the questions table, and values |
|
| 108 | - * are their corresponding Attendee field names |
|
| 109 | - * |
|
| 110 | - * @var array |
|
| 111 | - */ |
|
| 112 | - protected $_system_question_to_attendee_field_name = array( |
|
| 113 | - EEM_Attendee::system_question_fname => 'ATT_fname', |
|
| 114 | - EEM_Attendee::system_question_lname => 'ATT_lname', |
|
| 115 | - EEM_Attendee::system_question_email => 'ATT_email', |
|
| 116 | - EEM_Attendee::system_question_address => 'ATT_address', |
|
| 117 | - EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
| 118 | - EEM_Attendee::system_question_city => 'ATT_city', |
|
| 119 | - EEM_Attendee::system_question_state => 'STA_ID', |
|
| 120 | - EEM_Attendee::system_question_country => 'CNT_ISO', |
|
| 121 | - EEM_Attendee::system_question_zip => 'ATT_zip', |
|
| 122 | - EEM_Attendee::system_question_phone => 'ATT_phone', |
|
| 123 | - ); |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * EEM_Attendee constructor. |
|
| 129 | - * |
|
| 130 | - * @param null $timezone |
|
| 131 | - * @param ModelFieldFactory $model_field_factory |
|
| 132 | - * @throws EE_Error |
|
| 133 | - * @throws InvalidArgumentException |
|
| 134 | - */ |
|
| 135 | - protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
| 136 | - { |
|
| 137 | - $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
| 138 | - $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
| 139 | - $this->_tables = array( |
|
| 140 | - 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
| 141 | - 'Attendee_Meta' => new EE_Secondary_Table( |
|
| 142 | - 'esp_attendee_meta', |
|
| 143 | - 'ATTM_ID', |
|
| 144 | - 'ATT_ID' |
|
| 145 | - ), |
|
| 146 | - ); |
|
| 147 | - $this->_fields = array( |
|
| 148 | - 'Attendee_CPT' => array( |
|
| 149 | - 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
| 150 | - 'ID', |
|
| 151 | - esc_html__('Attendee ID', 'event_espresso') |
|
| 152 | - ), |
|
| 153 | - 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
| 154 | - 'post_title', |
|
| 155 | - esc_html__('Attendee Full Name', 'event_espresso'), |
|
| 156 | - false, |
|
| 157 | - esc_html__('Unknown', 'event_espresso') |
|
| 158 | - ), |
|
| 159 | - 'ATT_bio' => $model_field_factory->createPostContentField( |
|
| 160 | - 'post_content', |
|
| 161 | - esc_html__('Attendee Biography', 'event_espresso'), |
|
| 162 | - false, |
|
| 163 | - esc_html__('No Biography Provided', 'event_espresso') |
|
| 164 | - ), |
|
| 165 | - 'ATT_slug' => $model_field_factory->createSlugField( |
|
| 166 | - 'post_name', |
|
| 167 | - esc_html__('Attendee URL Slug', 'event_espresso') |
|
| 168 | - ), |
|
| 169 | - 'ATT_created' => $model_field_factory->createDatetimeField( |
|
| 170 | - 'post_date', |
|
| 171 | - esc_html__('Time Attendee Created', 'event_espresso') |
|
| 172 | - ), |
|
| 173 | - 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
| 174 | - 'post_excerpt', |
|
| 175 | - esc_html__('Attendee Short Biography', 'event_espresso'), |
|
| 176 | - true, |
|
| 177 | - esc_html__('No Biography Provided', 'event_espresso') |
|
| 178 | - ), |
|
| 179 | - 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
| 180 | - 'post_modified', |
|
| 181 | - esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
| 182 | - ), |
|
| 183 | - 'ATT_author' => $model_field_factory->createWpUserField( |
|
| 184 | - 'post_author', |
|
| 185 | - esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
| 186 | - false |
|
| 187 | - ), |
|
| 188 | - 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
| 189 | - 'post_parent', |
|
| 190 | - esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
| 191 | - false, |
|
| 192 | - 0 |
|
| 193 | - ), |
|
| 194 | - 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
| 195 | - 'status' => $model_field_factory->createWpPostStatusField( |
|
| 196 | - 'post_status', |
|
| 197 | - esc_html__('Attendee Status', 'event_espresso'), |
|
| 198 | - false, |
|
| 199 | - 'publish' |
|
| 200 | - ), |
|
| 201 | - ), |
|
| 202 | - 'Attendee_Meta' => array( |
|
| 203 | - 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
| 204 | - 'ATTM_ID', |
|
| 205 | - esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
| 206 | - false |
|
| 207 | - ), |
|
| 208 | - 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
| 209 | - 'ATT_ID', |
|
| 210 | - esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
| 211 | - false |
|
| 212 | - ), |
|
| 213 | - 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
| 214 | - 'ATT_fname', |
|
| 215 | - esc_html__('First Name', 'event_espresso') |
|
| 216 | - ), |
|
| 217 | - 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
| 218 | - 'ATT_lname', |
|
| 219 | - esc_html__('Last Name', 'event_espresso') |
|
| 220 | - ), |
|
| 221 | - 'ATT_address' => $model_field_factory->createPlainTextField( |
|
| 222 | - 'ATT_address', |
|
| 223 | - esc_html__('Address Part 1', 'event_espresso') |
|
| 224 | - ), |
|
| 225 | - 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
| 226 | - 'ATT_address2', |
|
| 227 | - esc_html__('Address Part 2', 'event_espresso') |
|
| 228 | - ), |
|
| 229 | - 'ATT_city' => $model_field_factory->createPlainTextField( |
|
| 230 | - 'ATT_city', |
|
| 231 | - esc_html__('City', 'event_espresso') |
|
| 232 | - ), |
|
| 233 | - 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
| 234 | - 'STA_ID', |
|
| 235 | - esc_html__('State', 'event_espresso'), |
|
| 236 | - true, |
|
| 237 | - 0, |
|
| 238 | - 'State' |
|
| 239 | - ), |
|
| 240 | - 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
| 241 | - 'CNT_ISO', |
|
| 242 | - esc_html__('Country', 'event_espresso'), |
|
| 243 | - true, |
|
| 244 | - '', |
|
| 245 | - 'Country' |
|
| 246 | - ), |
|
| 247 | - 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
| 248 | - 'ATT_zip', |
|
| 249 | - esc_html__('ZIP/Postal Code', 'event_espresso') |
|
| 250 | - ), |
|
| 251 | - 'ATT_email' => $model_field_factory->createEmailField( |
|
| 252 | - 'ATT_email', |
|
| 253 | - esc_html__('Email Address', 'event_espresso') |
|
| 254 | - ), |
|
| 255 | - 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
| 256 | - 'ATT_phone', |
|
| 257 | - esc_html__('Phone', 'event_espresso') |
|
| 258 | - ), |
|
| 259 | - ), |
|
| 260 | - ); |
|
| 261 | - $this->_model_relations = array( |
|
| 262 | - 'Registration' => new EE_Has_Many_Relation(), |
|
| 263 | - 'State' => new EE_Belongs_To_Relation(), |
|
| 264 | - 'Country' => new EE_Belongs_To_Relation(), |
|
| 265 | - 'Event' => new EE_HABTM_Relation('Registration', false), |
|
| 266 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
| 267 | - 'Message' => new EE_Has_Many_Any_Relation(false), |
|
| 268 | - // allow deletion of attendees even if they have messages in the queue for them. |
|
| 269 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
| 270 | - 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
| 271 | - ); |
|
| 272 | - $this->_caps_slug = 'contacts'; |
|
| 273 | - parent::__construct($timezone); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * Gets the name of the field on the attendee model corresponding to the system question string |
|
| 280 | - * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
| 281 | - * |
|
| 282 | - * @param string $system_question_string |
|
| 283 | - * @return string|null if not found |
|
| 284 | - */ |
|
| 285 | - public function get_attendee_field_for_system_question($system_question_string) |
|
| 286 | - { |
|
| 287 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
| 288 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
| 289 | - : null; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
| 296 | - * |
|
| 297 | - * @return array |
|
| 298 | - */ |
|
| 299 | - public function system_question_to_attendee_field_mapping() |
|
| 300 | - { |
|
| 301 | - return $this->_system_question_to_attendee_field_name; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
| 308 | - * |
|
| 309 | - * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
| 310 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
| 311 | - * @throws EE_Error |
|
| 312 | - */ |
|
| 313 | - public function get_attendees_for_transaction($transaction_id_or_obj) |
|
| 314 | - { |
|
| 315 | - return $this->get_all( |
|
| 316 | - array( |
|
| 317 | - array( |
|
| 318 | - 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
| 319 | - ? $transaction_id_or_obj->ID() |
|
| 320 | - : $transaction_id_or_obj, |
|
| 321 | - ), |
|
| 322 | - ) |
|
| 323 | - ); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * retrieve a single attendee from db via their ID |
|
| 330 | - * |
|
| 331 | - * @param $ATT_ID |
|
| 332 | - * @return mixed array on success, FALSE on fail |
|
| 333 | - * @deprecated |
|
| 334 | - */ |
|
| 335 | - public function get_attendee_by_ID($ATT_ID = false) |
|
| 336 | - { |
|
| 337 | - // retrieve a particular EE_Attendee |
|
| 338 | - return $this->get_one_by_ID($ATT_ID); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * retrieve a single attendee from db via their ID |
|
| 345 | - * |
|
| 346 | - * @param array $where_cols_n_values |
|
| 347 | - * @return mixed array on success, FALSE on fail |
|
| 348 | - * @throws EE_Error |
|
| 349 | - */ |
|
| 350 | - public function get_attendee($where_cols_n_values = array()) |
|
| 351 | - { |
|
| 352 | - if (empty($where_cols_n_values)) { |
|
| 353 | - return false; |
|
| 354 | - } |
|
| 355 | - $attendee = $this->get_all(array($where_cols_n_values)); |
|
| 356 | - if (! empty($attendee)) { |
|
| 357 | - return array_shift($attendee); |
|
| 358 | - } |
|
| 359 | - return false; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * Search for an existing Attendee record in the DB |
|
| 366 | - * |
|
| 367 | - * @param array $where_cols_n_values |
|
| 368 | - * @return bool|mixed |
|
| 369 | - * @throws EE_Error |
|
| 370 | - */ |
|
| 371 | - public function find_existing_attendee($where_cols_n_values = null) |
|
| 372 | - { |
|
| 373 | - // search by combo of first and last names plus the email address |
|
| 374 | - $attendee_data_keys = array( |
|
| 375 | - 'ATT_fname' => $this->_ATT_fname, |
|
| 376 | - 'ATT_lname' => $this->_ATT_lname, |
|
| 377 | - 'ATT_email' => $this->_ATT_email, |
|
| 378 | - ); |
|
| 379 | - // no search params means attendee object already exists. |
|
| 380 | - $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
| 381 | - ? $where_cols_n_values |
|
| 382 | - : $attendee_data_keys; |
|
| 383 | - $valid_data = true; |
|
| 384 | - // check for required values |
|
| 385 | - $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
| 386 | - ? $valid_data |
|
| 387 | - : false; |
|
| 388 | - $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
| 389 | - ? $valid_data |
|
| 390 | - : false; |
|
| 391 | - $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
| 392 | - ? $valid_data |
|
| 393 | - : false; |
|
| 394 | - if ($valid_data) { |
|
| 395 | - $attendee = $this->get_attendee($where_cols_n_values); |
|
| 396 | - if ($attendee instanceof EE_Attendee) { |
|
| 397 | - return $attendee; |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - return false; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * Takes an incoming array of EE_Registration ids |
|
| 407 | - * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
| 408 | - * |
|
| 409 | - * @since 4.3.0 |
|
| 410 | - * @param array $ids array of EE_Registration ids |
|
| 411 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
| 412 | - * @throws EE_Error |
|
| 413 | - */ |
|
| 414 | - public function get_array_of_contacts_from_reg_ids($ids) |
|
| 415 | - { |
|
| 416 | - $ids = (array) $ids; |
|
| 417 | - $_where = array( |
|
| 418 | - 'Registration.REG_ID' => array('in', $ids), |
|
| 419 | - ); |
|
| 420 | - return $this->get_all(array($_where)); |
|
| 421 | - } |
|
| 45 | + /** |
|
| 46 | + * @deprecated |
|
| 47 | + */ |
|
| 48 | + const address2_question_id = 5; |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @deprecated |
|
| 53 | + */ |
|
| 54 | + const city_question_id = 6; |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @deprecated |
|
| 59 | + */ |
|
| 60 | + const state_question_id = 7; |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @deprecated |
|
| 65 | + */ |
|
| 66 | + const country_question_id = 8; |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @deprecated |
|
| 71 | + */ |
|
| 72 | + const zip_question_id = 9; |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @deprecated |
|
| 77 | + */ |
|
| 78 | + const phone_question_id = 10; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * When looking for questions that correspond to attendee fields, |
|
| 82 | + * look for the question with this QST_system value. |
|
| 83 | + * These replace the old constants like EEM_Attendee::*_question_id |
|
| 84 | + */ |
|
| 85 | + const system_question_fname = 'fname'; |
|
| 86 | + |
|
| 87 | + const system_question_lname = 'lname'; |
|
| 88 | + |
|
| 89 | + const system_question_email = 'email'; |
|
| 90 | + |
|
| 91 | + const system_question_address = 'address'; |
|
| 92 | + |
|
| 93 | + const system_question_address2 = 'address2'; |
|
| 94 | + |
|
| 95 | + const system_question_city = 'city'; |
|
| 96 | + |
|
| 97 | + const system_question_state = 'state'; |
|
| 98 | + |
|
| 99 | + const system_question_country = 'country'; |
|
| 100 | + |
|
| 101 | + const system_question_zip = 'zip'; |
|
| 102 | + |
|
| 103 | + const system_question_phone = 'phone'; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
| 107 | + * also all the values of QST_system in the questions table, and values |
|
| 108 | + * are their corresponding Attendee field names |
|
| 109 | + * |
|
| 110 | + * @var array |
|
| 111 | + */ |
|
| 112 | + protected $_system_question_to_attendee_field_name = array( |
|
| 113 | + EEM_Attendee::system_question_fname => 'ATT_fname', |
|
| 114 | + EEM_Attendee::system_question_lname => 'ATT_lname', |
|
| 115 | + EEM_Attendee::system_question_email => 'ATT_email', |
|
| 116 | + EEM_Attendee::system_question_address => 'ATT_address', |
|
| 117 | + EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
| 118 | + EEM_Attendee::system_question_city => 'ATT_city', |
|
| 119 | + EEM_Attendee::system_question_state => 'STA_ID', |
|
| 120 | + EEM_Attendee::system_question_country => 'CNT_ISO', |
|
| 121 | + EEM_Attendee::system_question_zip => 'ATT_zip', |
|
| 122 | + EEM_Attendee::system_question_phone => 'ATT_phone', |
|
| 123 | + ); |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * EEM_Attendee constructor. |
|
| 129 | + * |
|
| 130 | + * @param null $timezone |
|
| 131 | + * @param ModelFieldFactory $model_field_factory |
|
| 132 | + * @throws EE_Error |
|
| 133 | + * @throws InvalidArgumentException |
|
| 134 | + */ |
|
| 135 | + protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
| 136 | + { |
|
| 137 | + $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
| 138 | + $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
| 139 | + $this->_tables = array( |
|
| 140 | + 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
| 141 | + 'Attendee_Meta' => new EE_Secondary_Table( |
|
| 142 | + 'esp_attendee_meta', |
|
| 143 | + 'ATTM_ID', |
|
| 144 | + 'ATT_ID' |
|
| 145 | + ), |
|
| 146 | + ); |
|
| 147 | + $this->_fields = array( |
|
| 148 | + 'Attendee_CPT' => array( |
|
| 149 | + 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
| 150 | + 'ID', |
|
| 151 | + esc_html__('Attendee ID', 'event_espresso') |
|
| 152 | + ), |
|
| 153 | + 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
| 154 | + 'post_title', |
|
| 155 | + esc_html__('Attendee Full Name', 'event_espresso'), |
|
| 156 | + false, |
|
| 157 | + esc_html__('Unknown', 'event_espresso') |
|
| 158 | + ), |
|
| 159 | + 'ATT_bio' => $model_field_factory->createPostContentField( |
|
| 160 | + 'post_content', |
|
| 161 | + esc_html__('Attendee Biography', 'event_espresso'), |
|
| 162 | + false, |
|
| 163 | + esc_html__('No Biography Provided', 'event_espresso') |
|
| 164 | + ), |
|
| 165 | + 'ATT_slug' => $model_field_factory->createSlugField( |
|
| 166 | + 'post_name', |
|
| 167 | + esc_html__('Attendee URL Slug', 'event_espresso') |
|
| 168 | + ), |
|
| 169 | + 'ATT_created' => $model_field_factory->createDatetimeField( |
|
| 170 | + 'post_date', |
|
| 171 | + esc_html__('Time Attendee Created', 'event_espresso') |
|
| 172 | + ), |
|
| 173 | + 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
| 174 | + 'post_excerpt', |
|
| 175 | + esc_html__('Attendee Short Biography', 'event_espresso'), |
|
| 176 | + true, |
|
| 177 | + esc_html__('No Biography Provided', 'event_espresso') |
|
| 178 | + ), |
|
| 179 | + 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
| 180 | + 'post_modified', |
|
| 181 | + esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
| 182 | + ), |
|
| 183 | + 'ATT_author' => $model_field_factory->createWpUserField( |
|
| 184 | + 'post_author', |
|
| 185 | + esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
| 186 | + false |
|
| 187 | + ), |
|
| 188 | + 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
| 189 | + 'post_parent', |
|
| 190 | + esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
| 191 | + false, |
|
| 192 | + 0 |
|
| 193 | + ), |
|
| 194 | + 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
| 195 | + 'status' => $model_field_factory->createWpPostStatusField( |
|
| 196 | + 'post_status', |
|
| 197 | + esc_html__('Attendee Status', 'event_espresso'), |
|
| 198 | + false, |
|
| 199 | + 'publish' |
|
| 200 | + ), |
|
| 201 | + ), |
|
| 202 | + 'Attendee_Meta' => array( |
|
| 203 | + 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
| 204 | + 'ATTM_ID', |
|
| 205 | + esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
| 206 | + false |
|
| 207 | + ), |
|
| 208 | + 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
| 209 | + 'ATT_ID', |
|
| 210 | + esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
| 211 | + false |
|
| 212 | + ), |
|
| 213 | + 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
| 214 | + 'ATT_fname', |
|
| 215 | + esc_html__('First Name', 'event_espresso') |
|
| 216 | + ), |
|
| 217 | + 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
| 218 | + 'ATT_lname', |
|
| 219 | + esc_html__('Last Name', 'event_espresso') |
|
| 220 | + ), |
|
| 221 | + 'ATT_address' => $model_field_factory->createPlainTextField( |
|
| 222 | + 'ATT_address', |
|
| 223 | + esc_html__('Address Part 1', 'event_espresso') |
|
| 224 | + ), |
|
| 225 | + 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
| 226 | + 'ATT_address2', |
|
| 227 | + esc_html__('Address Part 2', 'event_espresso') |
|
| 228 | + ), |
|
| 229 | + 'ATT_city' => $model_field_factory->createPlainTextField( |
|
| 230 | + 'ATT_city', |
|
| 231 | + esc_html__('City', 'event_espresso') |
|
| 232 | + ), |
|
| 233 | + 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
| 234 | + 'STA_ID', |
|
| 235 | + esc_html__('State', 'event_espresso'), |
|
| 236 | + true, |
|
| 237 | + 0, |
|
| 238 | + 'State' |
|
| 239 | + ), |
|
| 240 | + 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
| 241 | + 'CNT_ISO', |
|
| 242 | + esc_html__('Country', 'event_espresso'), |
|
| 243 | + true, |
|
| 244 | + '', |
|
| 245 | + 'Country' |
|
| 246 | + ), |
|
| 247 | + 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
| 248 | + 'ATT_zip', |
|
| 249 | + esc_html__('ZIP/Postal Code', 'event_espresso') |
|
| 250 | + ), |
|
| 251 | + 'ATT_email' => $model_field_factory->createEmailField( |
|
| 252 | + 'ATT_email', |
|
| 253 | + esc_html__('Email Address', 'event_espresso') |
|
| 254 | + ), |
|
| 255 | + 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
| 256 | + 'ATT_phone', |
|
| 257 | + esc_html__('Phone', 'event_espresso') |
|
| 258 | + ), |
|
| 259 | + ), |
|
| 260 | + ); |
|
| 261 | + $this->_model_relations = array( |
|
| 262 | + 'Registration' => new EE_Has_Many_Relation(), |
|
| 263 | + 'State' => new EE_Belongs_To_Relation(), |
|
| 264 | + 'Country' => new EE_Belongs_To_Relation(), |
|
| 265 | + 'Event' => new EE_HABTM_Relation('Registration', false), |
|
| 266 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
| 267 | + 'Message' => new EE_Has_Many_Any_Relation(false), |
|
| 268 | + // allow deletion of attendees even if they have messages in the queue for them. |
|
| 269 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
| 270 | + 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
| 271 | + ); |
|
| 272 | + $this->_caps_slug = 'contacts'; |
|
| 273 | + parent::__construct($timezone); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * Gets the name of the field on the attendee model corresponding to the system question string |
|
| 280 | + * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
| 281 | + * |
|
| 282 | + * @param string $system_question_string |
|
| 283 | + * @return string|null if not found |
|
| 284 | + */ |
|
| 285 | + public function get_attendee_field_for_system_question($system_question_string) |
|
| 286 | + { |
|
| 287 | + return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
| 288 | + ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
| 289 | + : null; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
| 296 | + * |
|
| 297 | + * @return array |
|
| 298 | + */ |
|
| 299 | + public function system_question_to_attendee_field_mapping() |
|
| 300 | + { |
|
| 301 | + return $this->_system_question_to_attendee_field_name; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
| 308 | + * |
|
| 309 | + * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
| 310 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
| 311 | + * @throws EE_Error |
|
| 312 | + */ |
|
| 313 | + public function get_attendees_for_transaction($transaction_id_or_obj) |
|
| 314 | + { |
|
| 315 | + return $this->get_all( |
|
| 316 | + array( |
|
| 317 | + array( |
|
| 318 | + 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
| 319 | + ? $transaction_id_or_obj->ID() |
|
| 320 | + : $transaction_id_or_obj, |
|
| 321 | + ), |
|
| 322 | + ) |
|
| 323 | + ); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * retrieve a single attendee from db via their ID |
|
| 330 | + * |
|
| 331 | + * @param $ATT_ID |
|
| 332 | + * @return mixed array on success, FALSE on fail |
|
| 333 | + * @deprecated |
|
| 334 | + */ |
|
| 335 | + public function get_attendee_by_ID($ATT_ID = false) |
|
| 336 | + { |
|
| 337 | + // retrieve a particular EE_Attendee |
|
| 338 | + return $this->get_one_by_ID($ATT_ID); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * retrieve a single attendee from db via their ID |
|
| 345 | + * |
|
| 346 | + * @param array $where_cols_n_values |
|
| 347 | + * @return mixed array on success, FALSE on fail |
|
| 348 | + * @throws EE_Error |
|
| 349 | + */ |
|
| 350 | + public function get_attendee($where_cols_n_values = array()) |
|
| 351 | + { |
|
| 352 | + if (empty($where_cols_n_values)) { |
|
| 353 | + return false; |
|
| 354 | + } |
|
| 355 | + $attendee = $this->get_all(array($where_cols_n_values)); |
|
| 356 | + if (! empty($attendee)) { |
|
| 357 | + return array_shift($attendee); |
|
| 358 | + } |
|
| 359 | + return false; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * Search for an existing Attendee record in the DB |
|
| 366 | + * |
|
| 367 | + * @param array $where_cols_n_values |
|
| 368 | + * @return bool|mixed |
|
| 369 | + * @throws EE_Error |
|
| 370 | + */ |
|
| 371 | + public function find_existing_attendee($where_cols_n_values = null) |
|
| 372 | + { |
|
| 373 | + // search by combo of first and last names plus the email address |
|
| 374 | + $attendee_data_keys = array( |
|
| 375 | + 'ATT_fname' => $this->_ATT_fname, |
|
| 376 | + 'ATT_lname' => $this->_ATT_lname, |
|
| 377 | + 'ATT_email' => $this->_ATT_email, |
|
| 378 | + ); |
|
| 379 | + // no search params means attendee object already exists. |
|
| 380 | + $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
| 381 | + ? $where_cols_n_values |
|
| 382 | + : $attendee_data_keys; |
|
| 383 | + $valid_data = true; |
|
| 384 | + // check for required values |
|
| 385 | + $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
| 386 | + ? $valid_data |
|
| 387 | + : false; |
|
| 388 | + $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
| 389 | + ? $valid_data |
|
| 390 | + : false; |
|
| 391 | + $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
| 392 | + ? $valid_data |
|
| 393 | + : false; |
|
| 394 | + if ($valid_data) { |
|
| 395 | + $attendee = $this->get_attendee($where_cols_n_values); |
|
| 396 | + if ($attendee instanceof EE_Attendee) { |
|
| 397 | + return $attendee; |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + return false; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Takes an incoming array of EE_Registration ids |
|
| 407 | + * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
| 408 | + * |
|
| 409 | + * @since 4.3.0 |
|
| 410 | + * @param array $ids array of EE_Registration ids |
|
| 411 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
| 412 | + * @throws EE_Error |
|
| 413 | + */ |
|
| 414 | + public function get_array_of_contacts_from_reg_ids($ids) |
|
| 415 | + { |
|
| 416 | + $ids = (array) $ids; |
|
| 417 | + $_where = array( |
|
| 418 | + 'Registration.REG_ID' => array('in', $ids), |
|
| 419 | + ); |
|
| 420 | + return $this->get_all(array($_where)); |
|
| 421 | + } |
|
| 422 | 422 | } |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function get_attendee_field_for_system_question($system_question_string) |
| 286 | 286 | { |
| 287 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
| 288 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
| 287 | + return isset($this->_system_question_to_attendee_field_name[$system_question_string]) |
|
| 288 | + ? $this->_system_question_to_attendee_field_name[$system_question_string] |
|
| 289 | 289 | : null; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | return false; |
| 354 | 354 | } |
| 355 | 355 | $attendee = $this->get_all(array($where_cols_n_values)); |
| 356 | - if (! empty($attendee)) { |
|
| 356 | + if ( ! empty($attendee)) { |
|
| 357 | 357 | return array_shift($attendee); |
| 358 | 358 | } |
| 359 | 359 | return false; |