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