@@ -7,133 +7,133 @@ |
||
7 | 7 | */ |
8 | 8 | class EE_Post_Content_Field extends EE_Text_Field_Base |
9 | 9 | { |
10 | - static protected $_added_the_content_basic_filters = false; |
|
10 | + static protected $_added_the_content_basic_filters = false; |
|
11 | 11 | |
12 | - /** |
|
13 | - * @param string $table_column |
|
14 | - * @param string $nicename |
|
15 | - * @param bool $nullable |
|
16 | - * @param null $default_value |
|
17 | - */ |
|
18 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
19 | - { |
|
20 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
21 | - $this->setSchemaType('object'); |
|
22 | - } |
|
12 | + /** |
|
13 | + * @param string $table_column |
|
14 | + * @param string $nicename |
|
15 | + * @param bool $nullable |
|
16 | + * @param null $default_value |
|
17 | + */ |
|
18 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
19 | + { |
|
20 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
21 | + $this->setSchemaType('object'); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * removes all tags which a WP Post wouldn't allow in its content normally |
|
27 | - * |
|
28 | - * @param string $value |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - function prepare_for_set($value) |
|
32 | - { |
|
33 | - if (! current_user_can('unfiltered_html')) { |
|
34 | - $value = wp_kses("$value", wp_kses_allowed_html('post')); |
|
35 | - } |
|
36 | - return parent::prepare_for_set($value); |
|
37 | - } |
|
25 | + /** |
|
26 | + * removes all tags which a WP Post wouldn't allow in its content normally |
|
27 | + * |
|
28 | + * @param string $value |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + function prepare_for_set($value) |
|
32 | + { |
|
33 | + if (! current_user_can('unfiltered_html')) { |
|
34 | + $value = wp_kses("$value", wp_kses_allowed_html('post')); |
|
35 | + } |
|
36 | + return parent::prepare_for_set($value); |
|
37 | + } |
|
38 | 38 | |
39 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
40 | - { |
|
41 | - return $value_found_in_db_for_model_object; |
|
42 | - } |
|
39 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
40 | + { |
|
41 | + return $value_found_in_db_for_model_object; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Runs the content through `the_content`, or if prepares the content for placing in a form input |
|
48 | - * @param string $value_on_field_to_be_outputted |
|
49 | - * @param string $schema possible values: 'form_input' or null (if null, will run through 'the_content') |
|
50 | - * @return string |
|
51 | - * @throws EE_Error when WP_DEBUG is on and recursive calling is detected |
|
52 | - */ |
|
53 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
54 | - { |
|
55 | - switch($schema){ |
|
56 | - case 'form_input': |
|
57 | - return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
58 | - case 'the_content': |
|
46 | + /** |
|
47 | + * Runs the content through `the_content`, or if prepares the content for placing in a form input |
|
48 | + * @param string $value_on_field_to_be_outputted |
|
49 | + * @param string $schema possible values: 'form_input' or null (if null, will run through 'the_content') |
|
50 | + * @return string |
|
51 | + * @throws EE_Error when WP_DEBUG is on and recursive calling is detected |
|
52 | + */ |
|
53 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
54 | + { |
|
55 | + switch($schema){ |
|
56 | + case 'form_input': |
|
57 | + return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
58 | + case 'the_content': |
|
59 | 59 | |
60 | - if(doing_filter( 'the_content')){ |
|
61 | - if( defined('WP_DEBUG') && WP_DEBUG){ |
|
62 | - throw new EE_Error( |
|
63 | - sprintf( |
|
64 | - esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'), |
|
65 | - 'EE_Post_Content_Field::prepare_for_pretty_echoing', |
|
66 | - '$schema', |
|
67 | - 'the_content', |
|
68 | - 'the_content_wp_core_only' |
|
69 | - ) |
|
70 | - ); |
|
71 | - } else { |
|
72 | - return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only'); |
|
73 | - } |
|
74 | - } |
|
75 | - return apply_filters( |
|
76 | - 'the_content', |
|
77 | - parent::prepare_for_pretty_echoing( |
|
78 | - $value_on_field_to_be_outputted, |
|
79 | - $schema |
|
80 | - ) |
|
81 | - ); |
|
82 | - case 'the_content_wp_core_only': |
|
83 | - default: |
|
84 | - self::_ensure_filters_setup(); |
|
85 | - return apply_filters( |
|
86 | - 'the_content_wp_core_only', |
|
87 | - parent::prepare_for_pretty_echoing( |
|
88 | - $value_on_field_to_be_outputted, |
|
89 | - $schema |
|
90 | - ) |
|
91 | - ); |
|
92 | - } |
|
93 | - } |
|
60 | + if(doing_filter( 'the_content')){ |
|
61 | + if( defined('WP_DEBUG') && WP_DEBUG){ |
|
62 | + throw new EE_Error( |
|
63 | + sprintf( |
|
64 | + esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'), |
|
65 | + 'EE_Post_Content_Field::prepare_for_pretty_echoing', |
|
66 | + '$schema', |
|
67 | + 'the_content', |
|
68 | + 'the_content_wp_core_only' |
|
69 | + ) |
|
70 | + ); |
|
71 | + } else { |
|
72 | + return $this->prepare_for_pretty_echoing($value_on_field_to_be_outputted, 'the_content_wp_core_only'); |
|
73 | + } |
|
74 | + } |
|
75 | + return apply_filters( |
|
76 | + 'the_content', |
|
77 | + parent::prepare_for_pretty_echoing( |
|
78 | + $value_on_field_to_be_outputted, |
|
79 | + $schema |
|
80 | + ) |
|
81 | + ); |
|
82 | + case 'the_content_wp_core_only': |
|
83 | + default: |
|
84 | + self::_ensure_filters_setup(); |
|
85 | + return apply_filters( |
|
86 | + 'the_content_wp_core_only', |
|
87 | + parent::prepare_for_pretty_echoing( |
|
88 | + $value_on_field_to_be_outputted, |
|
89 | + $schema |
|
90 | + ) |
|
91 | + ); |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | 95 | |
96 | 96 | |
97 | - /** |
|
98 | - * Verifies we've setup the standard WP core filters on 'the_content_wp_core_only' filter |
|
99 | - */ |
|
100 | - protected static function _ensure_filters_setup() |
|
101 | - { |
|
102 | - if( !self::$_added_the_content_basic_filters){ |
|
103 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
104 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8); |
|
105 | - add_filter('the_content_wp_core_only', 'wptexturize', 10); |
|
106 | - add_filter('the_content_wp_core_only', 'wpautop', 10); |
|
107 | - add_filter('the_content_wp_core_only', 'shortcode_unautop', 10); |
|
108 | - add_filter('the_content_wp_core_only', 'prepend_attachment', 10); |
|
109 | - if(function_exists('wp_make_content_images_responsive')) { |
|
110 | - add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10); |
|
111 | - } |
|
112 | - add_filter('the_content_wp_core_only', 'do_shortcode', 11); |
|
113 | - add_filter('the_content_wp_core_only', 'convert_smilies', 20); |
|
114 | - self::$_added_the_content_basic_filters = true; |
|
115 | - } |
|
116 | - } |
|
97 | + /** |
|
98 | + * Verifies we've setup the standard WP core filters on 'the_content_wp_core_only' filter |
|
99 | + */ |
|
100 | + protected static function _ensure_filters_setup() |
|
101 | + { |
|
102 | + if( !self::$_added_the_content_basic_filters){ |
|
103 | + add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
104 | + add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8); |
|
105 | + add_filter('the_content_wp_core_only', 'wptexturize', 10); |
|
106 | + add_filter('the_content_wp_core_only', 'wpautop', 10); |
|
107 | + add_filter('the_content_wp_core_only', 'shortcode_unautop', 10); |
|
108 | + add_filter('the_content_wp_core_only', 'prepend_attachment', 10); |
|
109 | + if(function_exists('wp_make_content_images_responsive')) { |
|
110 | + add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10); |
|
111 | + } |
|
112 | + add_filter('the_content_wp_core_only', 'do_shortcode', 11); |
|
113 | + add_filter('the_content_wp_core_only', 'convert_smilies', 20); |
|
114 | + self::$_added_the_content_basic_filters = true; |
|
115 | + } |
|
116 | + } |
|
117 | 117 | |
118 | 118 | |
119 | 119 | |
120 | - public function getSchemaProperties() |
|
121 | - { |
|
122 | - return array( |
|
123 | - 'raw' => array( |
|
124 | - 'description' => sprintf( |
|
125 | - __('%s - the content as it exists in the database.', 'event_espresso'), |
|
126 | - $this->get_nicename() |
|
127 | - ), |
|
128 | - 'type' => 'string' |
|
129 | - ), |
|
130 | - 'rendered' => array( |
|
131 | - 'description' => sprintf( |
|
132 | - __('%s - the content rendered for display.', 'event_espresso'), |
|
133 | - $this->get_nicename() |
|
134 | - ), |
|
135 | - 'type' => 'string' |
|
136 | - ) |
|
137 | - ); |
|
138 | - } |
|
120 | + public function getSchemaProperties() |
|
121 | + { |
|
122 | + return array( |
|
123 | + 'raw' => array( |
|
124 | + 'description' => sprintf( |
|
125 | + __('%s - the content as it exists in the database.', 'event_espresso'), |
|
126 | + $this->get_nicename() |
|
127 | + ), |
|
128 | + 'type' => 'string' |
|
129 | + ), |
|
130 | + 'rendered' => array( |
|
131 | + 'description' => sprintf( |
|
132 | + __('%s - the content rendered for display.', 'event_espresso'), |
|
133 | + $this->get_nicename() |
|
134 | + ), |
|
135 | + 'type' => 'string' |
|
136 | + ) |
|
137 | + ); |
|
138 | + } |
|
139 | 139 | } |
140 | 140 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function prepare_for_set($value) |
32 | 32 | { |
33 | - if (! current_user_can('unfiltered_html')) { |
|
33 | + if ( ! current_user_can('unfiltered_html')) { |
|
34 | 34 | $value = wp_kses("$value", wp_kses_allowed_html('post')); |
35 | 35 | } |
36 | 36 | return parent::prepare_for_set($value); |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
54 | 54 | { |
55 | - switch($schema){ |
|
55 | + switch ($schema) { |
|
56 | 56 | case 'form_input': |
57 | 57 | return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
58 | 58 | case 'the_content': |
59 | 59 | |
60 | - if(doing_filter( 'the_content')){ |
|
61 | - if( defined('WP_DEBUG') && WP_DEBUG){ |
|
60 | + if (doing_filter('the_content')) { |
|
61 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
62 | 62 | throw new EE_Error( |
63 | 63 | sprintf( |
64 | 64 | esc_html__('You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.', 'event_espresso'), |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | */ |
100 | 100 | protected static function _ensure_filters_setup() |
101 | 101 | { |
102 | - if( !self::$_added_the_content_basic_filters){ |
|
103 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
104 | - add_filter('the_content_wp_core_only', array( $GLOBALS['wp_embed'], 'autoembed'), 8); |
|
102 | + if ( ! self::$_added_the_content_basic_filters) { |
|
103 | + add_filter('the_content_wp_core_only', array($GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
104 | + add_filter('the_content_wp_core_only', array($GLOBALS['wp_embed'], 'autoembed'), 8); |
|
105 | 105 | add_filter('the_content_wp_core_only', 'wptexturize', 10); |
106 | 106 | add_filter('the_content_wp_core_only', 'wpautop', 10); |
107 | 107 | add_filter('the_content_wp_core_only', 'shortcode_unautop', 10); |
108 | 108 | add_filter('the_content_wp_core_only', 'prepend_attachment', 10); |
109 | - if(function_exists('wp_make_content_images_responsive')) { |
|
109 | + if (function_exists('wp_make_content_images_responsive')) { |
|
110 | 110 | add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10); |
111 | 111 | } |
112 | 112 | add_filter('the_content_wp_core_only', 'do_shortcode', 11); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.38.rc.041'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.38.rc.041'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -16,687 +16,687 @@ discard block |
||
16 | 16 | |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @return EED_Module|EED_Add_New_State |
|
21 | - */ |
|
22 | - public static function instance() |
|
23 | - { |
|
24 | - return parent::get_instance(__CLASS__); |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
31 | - * |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public static function set_hooks() |
|
35 | - { |
|
36 | - add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
37 | - add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0); |
|
38 | - add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10); |
|
39 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
40 | - array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
41 | - add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
42 | - array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
43 | - add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
44 | - array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
45 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
46 | - array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
47 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
48 | - array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
49 | - add_filter('FHEE__EE_State_Select_Input____construct__state_options', |
|
50 | - array('EED_Add_New_State', 'state_options'), 10, 1); |
|
51 | - add_filter('FHEE__EE_Country_Select_Input____construct__country_options', |
|
52 | - array('EED_Add_New_State', 'country_options'), 10, 1); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
59 | - * |
|
60 | - * @return void |
|
61 | - */ |
|
62 | - public static function set_hooks_admin() |
|
63 | - { |
|
64 | - add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
65 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
66 | - array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
67 | - add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
68 | - array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
69 | - add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
70 | - add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
71 | - add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
72 | - array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
73 | - add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
74 | - array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
75 | - add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
76 | - array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
77 | - add_filter('FHEE__EE_State_Select_Input____construct__state_options', |
|
78 | - array('EED_Add_New_State', 'state_options'), 10, 1); |
|
79 | - add_filter('FHEE__EE_Country_Select_Input____construct__country_options', |
|
80 | - array('EED_Add_New_State', 'country_options'), 10, 1); |
|
81 | - add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', |
|
82 | - array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1); |
|
83 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
84 | - array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
85 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
86 | - array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @return void |
|
93 | - */ |
|
94 | - public static function set_definitions() |
|
95 | - { |
|
96 | - define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
97 | - define('ANS_TEMPLATES_PATH', str_replace( |
|
98 | - '\\', |
|
99 | - DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
100 | - ); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @param WP $WP |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public function run($WP) |
|
110 | - { |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - public static function translate_js_strings() |
|
119 | - { |
|
120 | - EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__( |
|
121 | - 'In order to proceed, you need to select the Country that your State/Province belongs to.', |
|
122 | - 'event_espresso' |
|
123 | - ); |
|
124 | - EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__( |
|
125 | - 'In order to proceed, you need to enter the name of your State/Province.', |
|
126 | - 'event_espresso' |
|
127 | - ); |
|
128 | - EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__( |
|
129 | - 'In order to proceed, you need to enter an abbreviation for the name of your State/Province.', |
|
130 | - 'event_espresso' |
|
131 | - ); |
|
132 | - EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__( |
|
133 | - 'The new state was successfully saved to the database.', |
|
134 | - 'event_espresso' |
|
135 | - ); |
|
136 | - EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__( |
|
137 | - 'An unknown error has occurred on the server while saving the new state to the database.', |
|
138 | - 'event_espresso' |
|
139 | - ); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @return void |
|
146 | - */ |
|
147 | - public static function wp_enqueue_scripts() |
|
148 | - { |
|
149 | - if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
|
150 | - wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js', |
|
151 | - array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
|
152 | - wp_enqueue_script('add_new_state'); |
|
153 | - } |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * display_add_new_state_micro_form |
|
160 | - * |
|
161 | - * @param EE_Form_Section_Proper $question_group_reg_form |
|
162 | - * @return string |
|
163 | - * @throws EE_Error |
|
164 | - */ |
|
165 | - // public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){ |
|
166 | - public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form) |
|
167 | - { |
|
168 | - // only add the 'new_state_micro_form' when displaying reg forms, |
|
169 | - // not during processing since we process the 'new_state_micro_form' in it's own AJAX request |
|
170 | - $action = EE_Registry::instance()->REQ->get('action', ''); |
|
171 | - // is the "state" question in this form section? |
|
172 | - $input = $question_group_reg_form->get_subsection('state'); |
|
173 | - if ($action === 'process_reg_step' || $action === 'update_reg_step') { |
|
174 | - //ok then all we need to do is make sure the input's HTML name is consistent |
|
175 | - //by forcing it to set it now, like it did while getting the form for display |
|
176 | - if ($input instanceof EE_State_Select_Input) { |
|
177 | - $input->html_name(); |
|
178 | - } |
|
179 | - return $question_group_reg_form; |
|
180 | - } |
|
181 | - // we're only doing this for state select inputs |
|
182 | - if ($input instanceof EE_State_Select_Input) { |
|
183 | - // grab any set values from the request |
|
184 | - $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name()); |
|
185 | - $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name()); |
|
186 | - $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name()); |
|
187 | - $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
|
188 | - $country_options = array(); |
|
189 | - $countries = EEM_Country::instance()->get_all_countries(); |
|
190 | - if (! empty($countries)) { |
|
191 | - foreach ($countries as $country) { |
|
192 | - if ($country instanceof EE_Country) { |
|
193 | - $country_options[$country->ID()] = $country->name(); |
|
194 | - } |
|
195 | - } |
|
196 | - } |
|
197 | - $new_state_micro_form = new EE_Form_Section_Proper( |
|
198 | - array( |
|
199 | - 'name' => 'new_state_micro_form', |
|
200 | - 'html_id' => 'new_state_micro_form', |
|
201 | - 'layout_strategy' => new EE_No_Layout(), |
|
202 | - 'subsections' => array( |
|
203 | - // add hidden input to indicate that a new state is being added |
|
204 | - 'add_new_state' => new EE_Hidden_Input( |
|
205 | - array( |
|
206 | - 'html_name' => str_replace( |
|
207 | - 'state', |
|
208 | - 'nsmf_add_new_state', $input->html_name() |
|
209 | - ), |
|
210 | - 'html_id' => str_replace( |
|
211 | - 'state', |
|
212 | - 'nsmf_add_new_state', $input->html_id() |
|
213 | - ), |
|
214 | - 'default' => 0, |
|
215 | - ) |
|
216 | - ), |
|
217 | - // add link for displaying hidden container |
|
218 | - 'click_here_link' => new EE_Form_Section_HTML( |
|
219 | - apply_filters( |
|
220 | - 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link', |
|
221 | - EEH_HTML::link( |
|
222 | - '', |
|
223 | - esc_html__('click here to add a new State/Province', 'event_espresso'), |
|
224 | - '', |
|
225 | - 'display-' . $input->html_id(), |
|
226 | - 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
|
227 | - '', |
|
228 | - 'data-target="' . $input->html_id() . '"' |
|
229 | - ) |
|
230 | - ) |
|
231 | - ), |
|
232 | - // add initial html for hidden container |
|
233 | - 'add_new_state_micro_form' => new EE_Form_Section_HTML( |
|
234 | - apply_filters( |
|
235 | - 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
|
236 | - EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', |
|
237 | - 'display: none;') . |
|
238 | - EEH_HTML::h6( |
|
239 | - esc_html__( |
|
240 | - 'Is your State/Province missing from the dropdown menu above? You can add it by completing the following steps:', |
|
241 | - 'event_espresso' |
|
242 | - ) |
|
243 | - ) . |
|
244 | - EEH_HTML::ul() . |
|
245 | - EEH_HTML::li(esc_html__('First select your Country from the dropdown menu below', |
|
246 | - 'event_espresso')) . |
|
247 | - EEH_HTML::li( |
|
248 | - esc_html__('Enter the name of your State/Province', 'event_espresso') |
|
249 | - ) . |
|
250 | - EEH_HTML::li(esc_html__( |
|
251 | - 'Enter the abbreviation (usually two to six letters) for your State/Province', |
|
252 | - 'event_espresso') |
|
253 | - ) . |
|
254 | - EEH_HTML::li(esc_html__('Then click the ADD button', 'event_espresso')) . |
|
255 | - EEH_HTML::ulx() |
|
256 | - ) |
|
257 | - ), |
|
258 | - // NEW STATE COUNTRY |
|
259 | - 'new_state_country' => new EE_Country_Select_Input( |
|
260 | - $country_options, |
|
261 | - array( |
|
262 | - 'html_name' => $country_name, |
|
263 | - 'html_id' => str_replace( |
|
264 | - 'state', |
|
265 | - 'nsmf_new_state_country', $input->html_id() |
|
266 | - ), |
|
267 | - 'html_class' => $input->html_class() . ' new-state-country', |
|
268 | - 'html_label_text' => esc_html__('Select your Country', 'event_espresso'), |
|
269 | - 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
|
270 | - 'required' => false, |
|
271 | - ) |
|
272 | - ), |
|
273 | - // NEW STATE NAME |
|
274 | - 'new_state_name' => new EE_Text_Input( |
|
275 | - array( |
|
276 | - 'html_name' => $state_name, |
|
277 | - 'html_id' => str_replace( |
|
278 | - 'state', |
|
279 | - 'nsmf_new_state_name', $input->html_id() |
|
280 | - ), |
|
281 | - 'html_class' => $input->html_class() . ' new-state-state', |
|
282 | - 'html_label_text' => esc_html__(' Enter the Name for your State/Province', |
|
283 | - 'event_espresso'), |
|
284 | - 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
|
285 | - 'required' => false, |
|
286 | - ) |
|
287 | - ), |
|
288 | - 'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()), |
|
289 | - // NEW STATE NAME |
|
290 | - 'new_state_abbrv' => new EE_Text_Input( |
|
291 | - array( |
|
292 | - 'html_name' => $abbrv_name, |
|
293 | - 'html_id' => str_replace('state', 'nsmf_new_state_abbrv', |
|
294 | - $input->html_id()), |
|
295 | - 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
296 | - 'html_label_text' => esc_html__( |
|
297 | - 'Enter the Abbreviation for your State/Province*', |
|
298 | - 'event_espresso' |
|
299 | - ), |
|
300 | - 'html_other_attributes' => 'size="24"', |
|
301 | - 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), |
|
302 | - 'required' => false, |
|
303 | - ) |
|
304 | - ), |
|
305 | - // "submit" button |
|
306 | - 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
|
307 | - apply_filters( |
|
308 | - 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
|
309 | - EEH_HTML::nbsp(3) . |
|
310 | - EEH_HTML::link( |
|
311 | - '', |
|
312 | - esc_html__('ADD', 'event_espresso'), |
|
313 | - '', |
|
314 | - 'submit-' . $new_state_submit_id, |
|
315 | - 'ee-form-add-new-state-submit button button-secondary', |
|
316 | - '', |
|
317 | - 'data-target="' . $new_state_submit_id . '"' |
|
318 | - ) |
|
319 | - ) |
|
320 | - ), |
|
321 | - // extra info |
|
322 | - 'add_new_state_extra' => new EE_Form_Section_HTML( |
|
323 | - apply_filters( |
|
324 | - 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra', |
|
325 | - EEH_HTML::br(2) |
|
326 | - . |
|
327 | - EEH_HTML::div('', '', 'small-text') |
|
328 | - . |
|
329 | - EEH_HTML::strong(esc_html__('* Don\'t know your State/Province Abbreviation?', |
|
330 | - 'event_espresso')) |
|
331 | - . |
|
332 | - EEH_HTML::br() |
|
333 | - . |
|
334 | - sprintf( |
|
335 | - esc_html__( |
|
336 | - 'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', |
|
337 | - 'event_espresso' |
|
338 | - ), |
|
339 | - EEH_HTML::link( |
|
340 | - 'http://en.wikipedia.org/wiki/ISO_3166-2', |
|
341 | - 'http://en.wikipedia.org/wiki/ISO_3166-2', |
|
342 | - '', |
|
343 | - '', |
|
344 | - 'ee-form-add-new-state-wiki-lnk', |
|
345 | - '', |
|
346 | - 'target="_blank"' |
|
347 | - ) |
|
348 | - ) |
|
349 | - . |
|
350 | - EEH_HTML::divx() |
|
351 | - . |
|
352 | - EEH_HTML::br() |
|
353 | - . |
|
354 | - EEH_HTML::link( |
|
355 | - '', |
|
356 | - esc_html__('cancel new State/Province', 'event_espresso'), |
|
357 | - '', |
|
358 | - 'hide-' . $input->html_id(), |
|
359 | - 'ee-form-cancel-new-state-lnk smaller-text', |
|
360 | - '', |
|
361 | - 'data-target="' . $input->html_id() . '"' |
|
362 | - ) |
|
363 | - . |
|
364 | - EEH_HTML::divx() |
|
365 | - . |
|
366 | - EEH_HTML::br() |
|
367 | - ) |
|
368 | - ), |
|
369 | - ), |
|
370 | - ) |
|
371 | - ); |
|
372 | - $question_group_reg_form->add_subsections( |
|
373 | - array('new_state_micro_form' => $new_state_micro_form), |
|
374 | - 'state', |
|
375 | - false |
|
376 | - ); |
|
377 | - } |
|
378 | - return $question_group_reg_form; |
|
379 | - } |
|
380 | - |
|
381 | - |
|
382 | - |
|
383 | - /** |
|
384 | - * set_new_state_input_width |
|
385 | - * |
|
386 | - * @return int|string |
|
387 | - * @throws EE_Error |
|
388 | - */ |
|
389 | - public static function add_new_state() |
|
390 | - { |
|
391 | - $REQ = EE_Registry::instance()->load_core('Request_Handler'); |
|
392 | - if (absint($REQ->get('nsmf_add_new_state')) === 1) { |
|
393 | - EE_Registry::instance()->load_model('State'); |
|
394 | - // grab country ISO code, new state name, and new state abbreviation |
|
395 | - $state_country = $REQ->is_set('nsmf_new_state_country') |
|
396 | - ? sanitize_text_field($REQ->get('nsmf_new_state_country')) |
|
397 | - : false; |
|
398 | - $state_name = $REQ->is_set('nsmf_new_state_name') |
|
399 | - ? sanitize_text_field($REQ->get('nsmf_new_state_name')) |
|
400 | - : false; |
|
401 | - $state_abbr = $REQ->is_set('nsmf_new_state_abbrv') |
|
402 | - ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv')) |
|
403 | - : false; |
|
404 | - if ($state_country && $state_name && $state_abbr) { |
|
405 | - $new_state = EED_Add_New_State::save_new_state_to_db(array( |
|
406 | - 'CNT_ISO' => strtoupper($state_country), |
|
407 | - 'STA_abbrev' => strtoupper($state_abbr), |
|
408 | - 'STA_name' => ucwords($state_name), |
|
409 | - 'STA_active' => false, |
|
410 | - )); |
|
411 | - if ($new_state instanceof EE_State) { |
|
412 | - // clean house |
|
413 | - EE_Registry::instance()->REQ->un_set('nsmf_add_new_state'); |
|
414 | - EE_Registry::instance()->REQ->un_set('nsmf_new_state_country'); |
|
415 | - EE_Registry::instance()->REQ->un_set('nsmf_new_state_name'); |
|
416 | - EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv'); |
|
417 | - // get any existing new states |
|
418 | - $new_states = EE_Registry::instance()->SSN->get_session_data( |
|
419 | - 'nsmf_new_states' |
|
420 | - ); |
|
421 | - $new_states[$new_state->ID()] = $new_state; |
|
422 | - EE_Registry::instance()->SSN->set_session_data( |
|
423 | - array('nsmf_new_states' => $new_states) |
|
424 | - ); |
|
425 | - if (EE_Registry::instance()->REQ->ajax) { |
|
426 | - echo wp_json_encode(array( |
|
427 | - 'success' => true, |
|
428 | - 'id' => $new_state->ID(), |
|
429 | - 'name' => $new_state->name(), |
|
430 | - 'abbrev' => $new_state->abbrev(), |
|
431 | - 'country_iso' => $new_state->country_iso(), |
|
432 | - 'country_name' => $new_state->country()->name(), |
|
433 | - )); |
|
434 | - exit(); |
|
435 | - } |
|
436 | - return $new_state->ID(); |
|
437 | - } |
|
438 | - } else { |
|
439 | - $error = esc_html__( |
|
440 | - 'A new State/Province could not be added because invalid or missing data was received.', |
|
441 | - 'event_espresso' |
|
442 | - ); |
|
443 | - if (EE_Registry::instance()->REQ->ajax) { |
|
444 | - echo wp_json_encode(array('error' => $error)); |
|
445 | - exit(); |
|
446 | - } |
|
447 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
448 | - } |
|
449 | - } |
|
450 | - return false; |
|
451 | - } |
|
452 | - |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * recursively drills down through request params to remove any that were added by this module |
|
457 | - * |
|
458 | - * @param array $request_params |
|
459 | - * @return array |
|
460 | - */ |
|
461 | - public static function filter_checkout_request_params($request_params) |
|
462 | - { |
|
463 | - foreach ($request_params as $form_section) { |
|
464 | - if (is_array($form_section)) { |
|
465 | - EED_Add_New_State::unset_new_state_request_params($form_section); |
|
466 | - EED_Add_New_State::filter_checkout_request_params($form_section); |
|
467 | - } |
|
468 | - } |
|
469 | - return $request_params; |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - |
|
474 | - /** |
|
475 | - * @param array $request_params |
|
476 | - * @return array |
|
477 | - */ |
|
478 | - public static function unset_new_state_request_params($request_params) |
|
479 | - { |
|
480 | - unset( |
|
481 | - $request_params['new_state_micro_form'], |
|
482 | - $request_params['new_state_micro_add_new_state'], |
|
483 | - $request_params['new_state_micro_new_state_country'], |
|
484 | - $request_params['new_state_micro_new_state_name'], |
|
485 | - $request_params['new_state_micro_new_state_abbrv'] |
|
486 | - ); |
|
487 | - return $request_params; |
|
488 | - } |
|
489 | - |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * @param array $props_n_values |
|
494 | - * @return bool |
|
495 | - * @throws EE_Error |
|
496 | - */ |
|
497 | - public static function save_new_state_to_db($props_n_values = array()) |
|
498 | - { |
|
499 | - $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
|
500 | - if (! empty($existing_state)) { |
|
501 | - return array_pop($existing_state); |
|
502 | - } |
|
503 | - $new_state = EE_State::new_instance($props_n_values); |
|
504 | - if ($new_state instanceof EE_State) { |
|
505 | - // if not non-ajax admin |
|
506 | - $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
507 | - $new_state_notice = sprintf( |
|
508 | - esc_html__( |
|
509 | - 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', |
|
510 | - 'event_espresso' |
|
511 | - ), |
|
512 | - '<b>' . $new_state->name() . '</b>', |
|
513 | - '<b>' . $new_state->abbrev() . '</b>', |
|
514 | - '<b>' . $new_state->country()->name() . '</b>', |
|
515 | - '<a href="' . add_query_arg(array( |
|
516 | - 'page' => 'espresso_general_settings', |
|
517 | - 'action' => 'country_settings', |
|
518 | - 'country' => $new_state->country_iso(), |
|
519 | - ), admin_url('admin.php')) . '">' . esc_html__('Event Espresso - General Settings > Countries Tab', |
|
520 | - 'event_espresso') . '</a>', |
|
521 | - '<br />' |
|
522 | - ); |
|
523 | - EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
|
524 | - $new_state->save(); |
|
525 | - EEM_State::instance()->reset_cached_states(); |
|
526 | - return $new_state; |
|
527 | - } |
|
528 | - return false; |
|
529 | - } |
|
530 | - |
|
531 | - |
|
532 | - |
|
533 | - /** |
|
534 | - * @param string $CNT_ISO |
|
535 | - * @param string $STA_ID |
|
536 | - * @param array $cols_n_values |
|
537 | - * @return void |
|
538 | - */ |
|
539 | - public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) |
|
540 | - { |
|
541 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false; |
|
542 | - if (! $CNT_ISO) { |
|
543 | - EE_Error::add_error( |
|
544 | - esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'), |
|
545 | - __FILE__, |
|
546 | - __FUNCTION__, |
|
547 | - __LINE__ |
|
548 | - ); |
|
549 | - } |
|
550 | - $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] |
|
551 | - : false; |
|
552 | - if (! $STA_abbrev && ! empty($STA_ID)) { |
|
553 | - $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
554 | - if ($state instanceof EE_State) { |
|
555 | - $STA_abbrev = $state->abbrev(); |
|
556 | - } |
|
557 | - } |
|
558 | - if (! $STA_abbrev) { |
|
559 | - EE_Error::add_error( |
|
560 | - esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'), |
|
561 | - __FILE__, |
|
562 | - __FUNCTION__, |
|
563 | - __LINE__ |
|
564 | - ); |
|
565 | - } |
|
566 | - EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true); |
|
567 | - } |
|
568 | - |
|
569 | - |
|
570 | - |
|
571 | - /** |
|
572 | - * @param EE_State[] $state_options |
|
573 | - * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
574 | - * @param EE_Registration $registration |
|
575 | - * @param EE_Question $question |
|
576 | - * @param $answer |
|
577 | - * @return array |
|
578 | - */ |
|
579 | - public static function inject_new_reg_state_into_options( |
|
580 | - $state_options = array(), |
|
581 | - EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
582 | - EE_Registration $registration, |
|
583 | - EE_Question $question, |
|
584 | - $answer |
|
585 | - ) { |
|
586 | - if ($answer instanceof EE_Answer && $question instanceof EE_Question |
|
587 | - && $question->type() |
|
588 | - === EEM_Question::QST_type_state |
|
589 | - ) { |
|
590 | - $STA_ID = $answer->value(); |
|
591 | - if (! empty($STA_ID)) { |
|
592 | - $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
593 | - if ($state instanceof EE_State) { |
|
594 | - $country = $state->country(); |
|
595 | - if ($country instanceof EE_Country) { |
|
596 | - if (! isset($state_options[$country->name()])) { |
|
597 | - $state_options[$country->name()] = array(); |
|
598 | - } |
|
599 | - if (! isset($state_options[$country->name()][$STA_ID])) { |
|
600 | - $state_options[$country->name()][$STA_ID] = $state->name(); |
|
601 | - } |
|
602 | - } |
|
603 | - } |
|
604 | - } |
|
605 | - } |
|
606 | - return $state_options; |
|
607 | - } |
|
608 | - |
|
609 | - |
|
610 | - |
|
611 | - /** |
|
612 | - * @param EE_Country[] $country_options |
|
613 | - * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
614 | - * @param EE_Registration $registration |
|
615 | - * @param EE_Question $question |
|
616 | - * @param $answer |
|
617 | - * @return array |
|
618 | - */ |
|
619 | - public static function inject_new_reg_country_into_options( |
|
620 | - $country_options = array(), |
|
621 | - EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
622 | - EE_Registration $registration, |
|
623 | - EE_Question $question, |
|
624 | - $answer |
|
625 | - ) { |
|
626 | - if ($answer instanceof EE_Answer && $question instanceof EE_Question |
|
627 | - && $question->type() |
|
628 | - === EEM_Question::QST_type_country |
|
629 | - ) { |
|
630 | - $CNT_ISO = $answer->value(); |
|
631 | - if (! empty($CNT_ISO)) { |
|
632 | - $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
633 | - if ($country instanceof EE_Country) { |
|
634 | - if (! isset($country_options[$CNT_ISO])) { |
|
635 | - $country_options[$CNT_ISO] = $country->name(); |
|
636 | - } |
|
637 | - } |
|
638 | - } |
|
639 | - } |
|
640 | - return $country_options; |
|
641 | - } |
|
642 | - |
|
643 | - |
|
644 | - |
|
645 | - /** |
|
646 | - * @param EE_State[] $state_options |
|
647 | - * @return array |
|
648 | - * @throws EE_Error |
|
649 | - */ |
|
650 | - public static function state_options($state_options = array()) |
|
651 | - { |
|
652 | - $new_states = EED_Add_New_State::_get_new_states(); |
|
653 | - foreach ($new_states as $new_state) { |
|
654 | - if ( |
|
655 | - $new_state instanceof EE_State |
|
656 | - && $new_state->country() instanceof EE_Country |
|
657 | - ) { |
|
658 | - $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name(); |
|
659 | - } |
|
660 | - } |
|
661 | - return $state_options; |
|
662 | - } |
|
663 | - |
|
664 | - |
|
665 | - |
|
666 | - /** |
|
667 | - * @return array |
|
668 | - */ |
|
669 | - protected static function _get_new_states() |
|
670 | - { |
|
671 | - $new_states = array(); |
|
672 | - if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
673 | - $new_states = EE_Registry::instance()->SSN->get_session_data( |
|
674 | - 'nsmf_new_states' |
|
675 | - ); |
|
676 | - } |
|
677 | - return is_array($new_states) ? $new_states : array(); |
|
678 | - } |
|
679 | - |
|
680 | - |
|
681 | - |
|
682 | - /** |
|
683 | - * @param EE_Country[] $country_options |
|
684 | - * @return array |
|
685 | - * @throws EE_Error |
|
686 | - */ |
|
687 | - public static function country_options($country_options = array()) |
|
688 | - { |
|
689 | - $new_states = EED_Add_New_State::_get_new_states(); |
|
690 | - foreach ($new_states as $new_state) { |
|
691 | - if ( |
|
692 | - $new_state instanceof EE_State |
|
693 | - && $new_state->country() instanceof EE_Country |
|
694 | - ) { |
|
695 | - $country_options[$new_state->country()->ID()] = $new_state->country()->name(); |
|
696 | - } |
|
697 | - } |
|
698 | - return $country_options; |
|
699 | - } |
|
19 | + /** |
|
20 | + * @return EED_Module|EED_Add_New_State |
|
21 | + */ |
|
22 | + public static function instance() |
|
23 | + { |
|
24 | + return parent::get_instance(__CLASS__); |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
31 | + * |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public static function set_hooks() |
|
35 | + { |
|
36 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
37 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0); |
|
38 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10); |
|
39 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
40 | + array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
41 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
42 | + array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
43 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
44 | + array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
45 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
46 | + array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
47 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
48 | + array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
49 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', |
|
50 | + array('EED_Add_New_State', 'state_options'), 10, 1); |
|
51 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', |
|
52 | + array('EED_Add_New_State', 'country_options'), 10, 1); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
59 | + * |
|
60 | + * @return void |
|
61 | + */ |
|
62 | + public static function set_hooks_admin() |
|
63 | + { |
|
64 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
65 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
66 | + array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
67 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
68 | + array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
69 | + add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
70 | + add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
71 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
72 | + array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
73 | + add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
74 | + array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
75 | + add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
76 | + array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
77 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', |
|
78 | + array('EED_Add_New_State', 'state_options'), 10, 1); |
|
79 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', |
|
80 | + array('EED_Add_New_State', 'country_options'), 10, 1); |
|
81 | + add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', |
|
82 | + array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1); |
|
83 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
84 | + array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
85 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
86 | + array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @return void |
|
93 | + */ |
|
94 | + public static function set_definitions() |
|
95 | + { |
|
96 | + define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
97 | + define('ANS_TEMPLATES_PATH', str_replace( |
|
98 | + '\\', |
|
99 | + DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
100 | + ); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @param WP $WP |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public function run($WP) |
|
110 | + { |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + public static function translate_js_strings() |
|
119 | + { |
|
120 | + EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__( |
|
121 | + 'In order to proceed, you need to select the Country that your State/Province belongs to.', |
|
122 | + 'event_espresso' |
|
123 | + ); |
|
124 | + EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__( |
|
125 | + 'In order to proceed, you need to enter the name of your State/Province.', |
|
126 | + 'event_espresso' |
|
127 | + ); |
|
128 | + EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__( |
|
129 | + 'In order to proceed, you need to enter an abbreviation for the name of your State/Province.', |
|
130 | + 'event_espresso' |
|
131 | + ); |
|
132 | + EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__( |
|
133 | + 'The new state was successfully saved to the database.', |
|
134 | + 'event_espresso' |
|
135 | + ); |
|
136 | + EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__( |
|
137 | + 'An unknown error has occurred on the server while saving the new state to the database.', |
|
138 | + 'event_espresso' |
|
139 | + ); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @return void |
|
146 | + */ |
|
147 | + public static function wp_enqueue_scripts() |
|
148 | + { |
|
149 | + if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
|
150 | + wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js', |
|
151 | + array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
|
152 | + wp_enqueue_script('add_new_state'); |
|
153 | + } |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * display_add_new_state_micro_form |
|
160 | + * |
|
161 | + * @param EE_Form_Section_Proper $question_group_reg_form |
|
162 | + * @return string |
|
163 | + * @throws EE_Error |
|
164 | + */ |
|
165 | + // public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){ |
|
166 | + public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form) |
|
167 | + { |
|
168 | + // only add the 'new_state_micro_form' when displaying reg forms, |
|
169 | + // not during processing since we process the 'new_state_micro_form' in it's own AJAX request |
|
170 | + $action = EE_Registry::instance()->REQ->get('action', ''); |
|
171 | + // is the "state" question in this form section? |
|
172 | + $input = $question_group_reg_form->get_subsection('state'); |
|
173 | + if ($action === 'process_reg_step' || $action === 'update_reg_step') { |
|
174 | + //ok then all we need to do is make sure the input's HTML name is consistent |
|
175 | + //by forcing it to set it now, like it did while getting the form for display |
|
176 | + if ($input instanceof EE_State_Select_Input) { |
|
177 | + $input->html_name(); |
|
178 | + } |
|
179 | + return $question_group_reg_form; |
|
180 | + } |
|
181 | + // we're only doing this for state select inputs |
|
182 | + if ($input instanceof EE_State_Select_Input) { |
|
183 | + // grab any set values from the request |
|
184 | + $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name()); |
|
185 | + $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name()); |
|
186 | + $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name()); |
|
187 | + $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
|
188 | + $country_options = array(); |
|
189 | + $countries = EEM_Country::instance()->get_all_countries(); |
|
190 | + if (! empty($countries)) { |
|
191 | + foreach ($countries as $country) { |
|
192 | + if ($country instanceof EE_Country) { |
|
193 | + $country_options[$country->ID()] = $country->name(); |
|
194 | + } |
|
195 | + } |
|
196 | + } |
|
197 | + $new_state_micro_form = new EE_Form_Section_Proper( |
|
198 | + array( |
|
199 | + 'name' => 'new_state_micro_form', |
|
200 | + 'html_id' => 'new_state_micro_form', |
|
201 | + 'layout_strategy' => new EE_No_Layout(), |
|
202 | + 'subsections' => array( |
|
203 | + // add hidden input to indicate that a new state is being added |
|
204 | + 'add_new_state' => new EE_Hidden_Input( |
|
205 | + array( |
|
206 | + 'html_name' => str_replace( |
|
207 | + 'state', |
|
208 | + 'nsmf_add_new_state', $input->html_name() |
|
209 | + ), |
|
210 | + 'html_id' => str_replace( |
|
211 | + 'state', |
|
212 | + 'nsmf_add_new_state', $input->html_id() |
|
213 | + ), |
|
214 | + 'default' => 0, |
|
215 | + ) |
|
216 | + ), |
|
217 | + // add link for displaying hidden container |
|
218 | + 'click_here_link' => new EE_Form_Section_HTML( |
|
219 | + apply_filters( |
|
220 | + 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link', |
|
221 | + EEH_HTML::link( |
|
222 | + '', |
|
223 | + esc_html__('click here to add a new State/Province', 'event_espresso'), |
|
224 | + '', |
|
225 | + 'display-' . $input->html_id(), |
|
226 | + 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
|
227 | + '', |
|
228 | + 'data-target="' . $input->html_id() . '"' |
|
229 | + ) |
|
230 | + ) |
|
231 | + ), |
|
232 | + // add initial html for hidden container |
|
233 | + 'add_new_state_micro_form' => new EE_Form_Section_HTML( |
|
234 | + apply_filters( |
|
235 | + 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
|
236 | + EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', |
|
237 | + 'display: none;') . |
|
238 | + EEH_HTML::h6( |
|
239 | + esc_html__( |
|
240 | + 'Is your State/Province missing from the dropdown menu above? You can add it by completing the following steps:', |
|
241 | + 'event_espresso' |
|
242 | + ) |
|
243 | + ) . |
|
244 | + EEH_HTML::ul() . |
|
245 | + EEH_HTML::li(esc_html__('First select your Country from the dropdown menu below', |
|
246 | + 'event_espresso')) . |
|
247 | + EEH_HTML::li( |
|
248 | + esc_html__('Enter the name of your State/Province', 'event_espresso') |
|
249 | + ) . |
|
250 | + EEH_HTML::li(esc_html__( |
|
251 | + 'Enter the abbreviation (usually two to six letters) for your State/Province', |
|
252 | + 'event_espresso') |
|
253 | + ) . |
|
254 | + EEH_HTML::li(esc_html__('Then click the ADD button', 'event_espresso')) . |
|
255 | + EEH_HTML::ulx() |
|
256 | + ) |
|
257 | + ), |
|
258 | + // NEW STATE COUNTRY |
|
259 | + 'new_state_country' => new EE_Country_Select_Input( |
|
260 | + $country_options, |
|
261 | + array( |
|
262 | + 'html_name' => $country_name, |
|
263 | + 'html_id' => str_replace( |
|
264 | + 'state', |
|
265 | + 'nsmf_new_state_country', $input->html_id() |
|
266 | + ), |
|
267 | + 'html_class' => $input->html_class() . ' new-state-country', |
|
268 | + 'html_label_text' => esc_html__('Select your Country', 'event_espresso'), |
|
269 | + 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
|
270 | + 'required' => false, |
|
271 | + ) |
|
272 | + ), |
|
273 | + // NEW STATE NAME |
|
274 | + 'new_state_name' => new EE_Text_Input( |
|
275 | + array( |
|
276 | + 'html_name' => $state_name, |
|
277 | + 'html_id' => str_replace( |
|
278 | + 'state', |
|
279 | + 'nsmf_new_state_name', $input->html_id() |
|
280 | + ), |
|
281 | + 'html_class' => $input->html_class() . ' new-state-state', |
|
282 | + 'html_label_text' => esc_html__(' Enter the Name for your State/Province', |
|
283 | + 'event_espresso'), |
|
284 | + 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
|
285 | + 'required' => false, |
|
286 | + ) |
|
287 | + ), |
|
288 | + 'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()), |
|
289 | + // NEW STATE NAME |
|
290 | + 'new_state_abbrv' => new EE_Text_Input( |
|
291 | + array( |
|
292 | + 'html_name' => $abbrv_name, |
|
293 | + 'html_id' => str_replace('state', 'nsmf_new_state_abbrv', |
|
294 | + $input->html_id()), |
|
295 | + 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
296 | + 'html_label_text' => esc_html__( |
|
297 | + 'Enter the Abbreviation for your State/Province*', |
|
298 | + 'event_espresso' |
|
299 | + ), |
|
300 | + 'html_other_attributes' => 'size="24"', |
|
301 | + 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), |
|
302 | + 'required' => false, |
|
303 | + ) |
|
304 | + ), |
|
305 | + // "submit" button |
|
306 | + 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
|
307 | + apply_filters( |
|
308 | + 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
|
309 | + EEH_HTML::nbsp(3) . |
|
310 | + EEH_HTML::link( |
|
311 | + '', |
|
312 | + esc_html__('ADD', 'event_espresso'), |
|
313 | + '', |
|
314 | + 'submit-' . $new_state_submit_id, |
|
315 | + 'ee-form-add-new-state-submit button button-secondary', |
|
316 | + '', |
|
317 | + 'data-target="' . $new_state_submit_id . '"' |
|
318 | + ) |
|
319 | + ) |
|
320 | + ), |
|
321 | + // extra info |
|
322 | + 'add_new_state_extra' => new EE_Form_Section_HTML( |
|
323 | + apply_filters( |
|
324 | + 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra', |
|
325 | + EEH_HTML::br(2) |
|
326 | + . |
|
327 | + EEH_HTML::div('', '', 'small-text') |
|
328 | + . |
|
329 | + EEH_HTML::strong(esc_html__('* Don\'t know your State/Province Abbreviation?', |
|
330 | + 'event_espresso')) |
|
331 | + . |
|
332 | + EEH_HTML::br() |
|
333 | + . |
|
334 | + sprintf( |
|
335 | + esc_html__( |
|
336 | + 'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', |
|
337 | + 'event_espresso' |
|
338 | + ), |
|
339 | + EEH_HTML::link( |
|
340 | + 'http://en.wikipedia.org/wiki/ISO_3166-2', |
|
341 | + 'http://en.wikipedia.org/wiki/ISO_3166-2', |
|
342 | + '', |
|
343 | + '', |
|
344 | + 'ee-form-add-new-state-wiki-lnk', |
|
345 | + '', |
|
346 | + 'target="_blank"' |
|
347 | + ) |
|
348 | + ) |
|
349 | + . |
|
350 | + EEH_HTML::divx() |
|
351 | + . |
|
352 | + EEH_HTML::br() |
|
353 | + . |
|
354 | + EEH_HTML::link( |
|
355 | + '', |
|
356 | + esc_html__('cancel new State/Province', 'event_espresso'), |
|
357 | + '', |
|
358 | + 'hide-' . $input->html_id(), |
|
359 | + 'ee-form-cancel-new-state-lnk smaller-text', |
|
360 | + '', |
|
361 | + 'data-target="' . $input->html_id() . '"' |
|
362 | + ) |
|
363 | + . |
|
364 | + EEH_HTML::divx() |
|
365 | + . |
|
366 | + EEH_HTML::br() |
|
367 | + ) |
|
368 | + ), |
|
369 | + ), |
|
370 | + ) |
|
371 | + ); |
|
372 | + $question_group_reg_form->add_subsections( |
|
373 | + array('new_state_micro_form' => $new_state_micro_form), |
|
374 | + 'state', |
|
375 | + false |
|
376 | + ); |
|
377 | + } |
|
378 | + return $question_group_reg_form; |
|
379 | + } |
|
380 | + |
|
381 | + |
|
382 | + |
|
383 | + /** |
|
384 | + * set_new_state_input_width |
|
385 | + * |
|
386 | + * @return int|string |
|
387 | + * @throws EE_Error |
|
388 | + */ |
|
389 | + public static function add_new_state() |
|
390 | + { |
|
391 | + $REQ = EE_Registry::instance()->load_core('Request_Handler'); |
|
392 | + if (absint($REQ->get('nsmf_add_new_state')) === 1) { |
|
393 | + EE_Registry::instance()->load_model('State'); |
|
394 | + // grab country ISO code, new state name, and new state abbreviation |
|
395 | + $state_country = $REQ->is_set('nsmf_new_state_country') |
|
396 | + ? sanitize_text_field($REQ->get('nsmf_new_state_country')) |
|
397 | + : false; |
|
398 | + $state_name = $REQ->is_set('nsmf_new_state_name') |
|
399 | + ? sanitize_text_field($REQ->get('nsmf_new_state_name')) |
|
400 | + : false; |
|
401 | + $state_abbr = $REQ->is_set('nsmf_new_state_abbrv') |
|
402 | + ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv')) |
|
403 | + : false; |
|
404 | + if ($state_country && $state_name && $state_abbr) { |
|
405 | + $new_state = EED_Add_New_State::save_new_state_to_db(array( |
|
406 | + 'CNT_ISO' => strtoupper($state_country), |
|
407 | + 'STA_abbrev' => strtoupper($state_abbr), |
|
408 | + 'STA_name' => ucwords($state_name), |
|
409 | + 'STA_active' => false, |
|
410 | + )); |
|
411 | + if ($new_state instanceof EE_State) { |
|
412 | + // clean house |
|
413 | + EE_Registry::instance()->REQ->un_set('nsmf_add_new_state'); |
|
414 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_country'); |
|
415 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_name'); |
|
416 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv'); |
|
417 | + // get any existing new states |
|
418 | + $new_states = EE_Registry::instance()->SSN->get_session_data( |
|
419 | + 'nsmf_new_states' |
|
420 | + ); |
|
421 | + $new_states[$new_state->ID()] = $new_state; |
|
422 | + EE_Registry::instance()->SSN->set_session_data( |
|
423 | + array('nsmf_new_states' => $new_states) |
|
424 | + ); |
|
425 | + if (EE_Registry::instance()->REQ->ajax) { |
|
426 | + echo wp_json_encode(array( |
|
427 | + 'success' => true, |
|
428 | + 'id' => $new_state->ID(), |
|
429 | + 'name' => $new_state->name(), |
|
430 | + 'abbrev' => $new_state->abbrev(), |
|
431 | + 'country_iso' => $new_state->country_iso(), |
|
432 | + 'country_name' => $new_state->country()->name(), |
|
433 | + )); |
|
434 | + exit(); |
|
435 | + } |
|
436 | + return $new_state->ID(); |
|
437 | + } |
|
438 | + } else { |
|
439 | + $error = esc_html__( |
|
440 | + 'A new State/Province could not be added because invalid or missing data was received.', |
|
441 | + 'event_espresso' |
|
442 | + ); |
|
443 | + if (EE_Registry::instance()->REQ->ajax) { |
|
444 | + echo wp_json_encode(array('error' => $error)); |
|
445 | + exit(); |
|
446 | + } |
|
447 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
448 | + } |
|
449 | + } |
|
450 | + return false; |
|
451 | + } |
|
452 | + |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * recursively drills down through request params to remove any that were added by this module |
|
457 | + * |
|
458 | + * @param array $request_params |
|
459 | + * @return array |
|
460 | + */ |
|
461 | + public static function filter_checkout_request_params($request_params) |
|
462 | + { |
|
463 | + foreach ($request_params as $form_section) { |
|
464 | + if (is_array($form_section)) { |
|
465 | + EED_Add_New_State::unset_new_state_request_params($form_section); |
|
466 | + EED_Add_New_State::filter_checkout_request_params($form_section); |
|
467 | + } |
|
468 | + } |
|
469 | + return $request_params; |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + |
|
474 | + /** |
|
475 | + * @param array $request_params |
|
476 | + * @return array |
|
477 | + */ |
|
478 | + public static function unset_new_state_request_params($request_params) |
|
479 | + { |
|
480 | + unset( |
|
481 | + $request_params['new_state_micro_form'], |
|
482 | + $request_params['new_state_micro_add_new_state'], |
|
483 | + $request_params['new_state_micro_new_state_country'], |
|
484 | + $request_params['new_state_micro_new_state_name'], |
|
485 | + $request_params['new_state_micro_new_state_abbrv'] |
|
486 | + ); |
|
487 | + return $request_params; |
|
488 | + } |
|
489 | + |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * @param array $props_n_values |
|
494 | + * @return bool |
|
495 | + * @throws EE_Error |
|
496 | + */ |
|
497 | + public static function save_new_state_to_db($props_n_values = array()) |
|
498 | + { |
|
499 | + $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
|
500 | + if (! empty($existing_state)) { |
|
501 | + return array_pop($existing_state); |
|
502 | + } |
|
503 | + $new_state = EE_State::new_instance($props_n_values); |
|
504 | + if ($new_state instanceof EE_State) { |
|
505 | + // if not non-ajax admin |
|
506 | + $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
507 | + $new_state_notice = sprintf( |
|
508 | + esc_html__( |
|
509 | + 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', |
|
510 | + 'event_espresso' |
|
511 | + ), |
|
512 | + '<b>' . $new_state->name() . '</b>', |
|
513 | + '<b>' . $new_state->abbrev() . '</b>', |
|
514 | + '<b>' . $new_state->country()->name() . '</b>', |
|
515 | + '<a href="' . add_query_arg(array( |
|
516 | + 'page' => 'espresso_general_settings', |
|
517 | + 'action' => 'country_settings', |
|
518 | + 'country' => $new_state->country_iso(), |
|
519 | + ), admin_url('admin.php')) . '">' . esc_html__('Event Espresso - General Settings > Countries Tab', |
|
520 | + 'event_espresso') . '</a>', |
|
521 | + '<br />' |
|
522 | + ); |
|
523 | + EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
|
524 | + $new_state->save(); |
|
525 | + EEM_State::instance()->reset_cached_states(); |
|
526 | + return $new_state; |
|
527 | + } |
|
528 | + return false; |
|
529 | + } |
|
530 | + |
|
531 | + |
|
532 | + |
|
533 | + /** |
|
534 | + * @param string $CNT_ISO |
|
535 | + * @param string $STA_ID |
|
536 | + * @param array $cols_n_values |
|
537 | + * @return void |
|
538 | + */ |
|
539 | + public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) |
|
540 | + { |
|
541 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false; |
|
542 | + if (! $CNT_ISO) { |
|
543 | + EE_Error::add_error( |
|
544 | + esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'), |
|
545 | + __FILE__, |
|
546 | + __FUNCTION__, |
|
547 | + __LINE__ |
|
548 | + ); |
|
549 | + } |
|
550 | + $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] |
|
551 | + : false; |
|
552 | + if (! $STA_abbrev && ! empty($STA_ID)) { |
|
553 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
554 | + if ($state instanceof EE_State) { |
|
555 | + $STA_abbrev = $state->abbrev(); |
|
556 | + } |
|
557 | + } |
|
558 | + if (! $STA_abbrev) { |
|
559 | + EE_Error::add_error( |
|
560 | + esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'), |
|
561 | + __FILE__, |
|
562 | + __FUNCTION__, |
|
563 | + __LINE__ |
|
564 | + ); |
|
565 | + } |
|
566 | + EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true); |
|
567 | + } |
|
568 | + |
|
569 | + |
|
570 | + |
|
571 | + /** |
|
572 | + * @param EE_State[] $state_options |
|
573 | + * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
574 | + * @param EE_Registration $registration |
|
575 | + * @param EE_Question $question |
|
576 | + * @param $answer |
|
577 | + * @return array |
|
578 | + */ |
|
579 | + public static function inject_new_reg_state_into_options( |
|
580 | + $state_options = array(), |
|
581 | + EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
582 | + EE_Registration $registration, |
|
583 | + EE_Question $question, |
|
584 | + $answer |
|
585 | + ) { |
|
586 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question |
|
587 | + && $question->type() |
|
588 | + === EEM_Question::QST_type_state |
|
589 | + ) { |
|
590 | + $STA_ID = $answer->value(); |
|
591 | + if (! empty($STA_ID)) { |
|
592 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
593 | + if ($state instanceof EE_State) { |
|
594 | + $country = $state->country(); |
|
595 | + if ($country instanceof EE_Country) { |
|
596 | + if (! isset($state_options[$country->name()])) { |
|
597 | + $state_options[$country->name()] = array(); |
|
598 | + } |
|
599 | + if (! isset($state_options[$country->name()][$STA_ID])) { |
|
600 | + $state_options[$country->name()][$STA_ID] = $state->name(); |
|
601 | + } |
|
602 | + } |
|
603 | + } |
|
604 | + } |
|
605 | + } |
|
606 | + return $state_options; |
|
607 | + } |
|
608 | + |
|
609 | + |
|
610 | + |
|
611 | + /** |
|
612 | + * @param EE_Country[] $country_options |
|
613 | + * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
614 | + * @param EE_Registration $registration |
|
615 | + * @param EE_Question $question |
|
616 | + * @param $answer |
|
617 | + * @return array |
|
618 | + */ |
|
619 | + public static function inject_new_reg_country_into_options( |
|
620 | + $country_options = array(), |
|
621 | + EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
622 | + EE_Registration $registration, |
|
623 | + EE_Question $question, |
|
624 | + $answer |
|
625 | + ) { |
|
626 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question |
|
627 | + && $question->type() |
|
628 | + === EEM_Question::QST_type_country |
|
629 | + ) { |
|
630 | + $CNT_ISO = $answer->value(); |
|
631 | + if (! empty($CNT_ISO)) { |
|
632 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
633 | + if ($country instanceof EE_Country) { |
|
634 | + if (! isset($country_options[$CNT_ISO])) { |
|
635 | + $country_options[$CNT_ISO] = $country->name(); |
|
636 | + } |
|
637 | + } |
|
638 | + } |
|
639 | + } |
|
640 | + return $country_options; |
|
641 | + } |
|
642 | + |
|
643 | + |
|
644 | + |
|
645 | + /** |
|
646 | + * @param EE_State[] $state_options |
|
647 | + * @return array |
|
648 | + * @throws EE_Error |
|
649 | + */ |
|
650 | + public static function state_options($state_options = array()) |
|
651 | + { |
|
652 | + $new_states = EED_Add_New_State::_get_new_states(); |
|
653 | + foreach ($new_states as $new_state) { |
|
654 | + if ( |
|
655 | + $new_state instanceof EE_State |
|
656 | + && $new_state->country() instanceof EE_Country |
|
657 | + ) { |
|
658 | + $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name(); |
|
659 | + } |
|
660 | + } |
|
661 | + return $state_options; |
|
662 | + } |
|
663 | + |
|
664 | + |
|
665 | + |
|
666 | + /** |
|
667 | + * @return array |
|
668 | + */ |
|
669 | + protected static function _get_new_states() |
|
670 | + { |
|
671 | + $new_states = array(); |
|
672 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
673 | + $new_states = EE_Registry::instance()->SSN->get_session_data( |
|
674 | + 'nsmf_new_states' |
|
675 | + ); |
|
676 | + } |
|
677 | + return is_array($new_states) ? $new_states : array(); |
|
678 | + } |
|
679 | + |
|
680 | + |
|
681 | + |
|
682 | + /** |
|
683 | + * @param EE_Country[] $country_options |
|
684 | + * @return array |
|
685 | + * @throws EE_Error |
|
686 | + */ |
|
687 | + public static function country_options($country_options = array()) |
|
688 | + { |
|
689 | + $new_states = EED_Add_New_State::_get_new_states(); |
|
690 | + foreach ($new_states as $new_state) { |
|
691 | + if ( |
|
692 | + $new_state instanceof EE_State |
|
693 | + && $new_state->country() instanceof EE_Country |
|
694 | + ) { |
|
695 | + $country_options[$new_state->country()->ID()] = $new_state->country()->name(); |
|
696 | + } |
|
697 | + } |
|
698 | + return $country_options; |
|
699 | + } |
|
700 | 700 | |
701 | 701 | |
702 | 702 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public static function set_definitions() |
95 | 95 | { |
96 | - define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
96 | + define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
97 | 97 | define('ANS_TEMPLATES_PATH', str_replace( |
98 | 98 | '\\', |
99 | - DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
99 | + DS, plugin_dir_path(__FILE__)).'templates'.DS |
|
100 | 100 | ); |
101 | 101 | } |
102 | 102 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | public static function wp_enqueue_scripts() |
148 | 148 | { |
149 | 149 | if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
150 | - wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js', |
|
150 | + wp_register_script('add_new_state', ANS_ASSETS_URL.'add_new_state.js', |
|
151 | 151 | array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
152 | 152 | wp_enqueue_script('add_new_state'); |
153 | 153 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
188 | 188 | $country_options = array(); |
189 | 189 | $countries = EEM_Country::instance()->get_all_countries(); |
190 | - if (! empty($countries)) { |
|
190 | + if ( ! empty($countries)) { |
|
191 | 191 | foreach ($countries as $country) { |
192 | 192 | if ($country instanceof EE_Country) { |
193 | 193 | $country_options[$country->ID()] = $country->name(); |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | '', |
223 | 223 | esc_html__('click here to add a new State/Province', 'event_espresso'), |
224 | 224 | '', |
225 | - 'display-' . $input->html_id(), |
|
225 | + 'display-'.$input->html_id(), |
|
226 | 226 | 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
227 | 227 | '', |
228 | - 'data-target="' . $input->html_id() . '"' |
|
228 | + 'data-target="'.$input->html_id().'"' |
|
229 | 229 | ) |
230 | 230 | ) |
231 | 231 | ), |
@@ -233,25 +233,25 @@ discard block |
||
233 | 233 | 'add_new_state_micro_form' => new EE_Form_Section_HTML( |
234 | 234 | apply_filters( |
235 | 235 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
236 | - EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', |
|
237 | - 'display: none;') . |
|
236 | + EEH_HTML::div('', $input->html_id().'-dv', 'ee-form-add-new-state-dv', |
|
237 | + 'display: none;'). |
|
238 | 238 | EEH_HTML::h6( |
239 | 239 | esc_html__( |
240 | 240 | 'Is your State/Province missing from the dropdown menu above? You can add it by completing the following steps:', |
241 | 241 | 'event_espresso' |
242 | 242 | ) |
243 | - ) . |
|
244 | - EEH_HTML::ul() . |
|
243 | + ). |
|
244 | + EEH_HTML::ul(). |
|
245 | 245 | EEH_HTML::li(esc_html__('First select your Country from the dropdown menu below', |
246 | - 'event_espresso')) . |
|
246 | + 'event_espresso')). |
|
247 | 247 | EEH_HTML::li( |
248 | 248 | esc_html__('Enter the name of your State/Province', 'event_espresso') |
249 | - ) . |
|
249 | + ). |
|
250 | 250 | EEH_HTML::li(esc_html__( |
251 | 251 | 'Enter the abbreviation (usually two to six letters) for your State/Province', |
252 | 252 | 'event_espresso') |
253 | - ) . |
|
254 | - EEH_HTML::li(esc_html__('Then click the ADD button', 'event_espresso')) . |
|
253 | + ). |
|
254 | + EEH_HTML::li(esc_html__('Then click the ADD button', 'event_espresso')). |
|
255 | 255 | EEH_HTML::ulx() |
256 | 256 | ) |
257 | 257 | ), |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | 'state', |
265 | 265 | 'nsmf_new_state_country', $input->html_id() |
266 | 266 | ), |
267 | - 'html_class' => $input->html_class() . ' new-state-country', |
|
267 | + 'html_class' => $input->html_class().' new-state-country', |
|
268 | 268 | 'html_label_text' => esc_html__('Select your Country', 'event_espresso'), |
269 | 269 | 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
270 | 270 | 'required' => false, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | 'state', |
279 | 279 | 'nsmf_new_state_name', $input->html_id() |
280 | 280 | ), |
281 | - 'html_class' => $input->html_class() . ' new-state-state', |
|
281 | + 'html_class' => $input->html_class().' new-state-state', |
|
282 | 282 | 'html_label_text' => esc_html__(' Enter the Name for your State/Province', |
283 | 283 | 'event_espresso'), |
284 | 284 | 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | 'html_name' => $abbrv_name, |
293 | 293 | 'html_id' => str_replace('state', 'nsmf_new_state_abbrv', |
294 | 294 | $input->html_id()), |
295 | - 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
295 | + 'html_class' => $input->html_class().' new-state-abbrv', |
|
296 | 296 | 'html_label_text' => esc_html__( |
297 | 297 | 'Enter the Abbreviation for your State/Province*', |
298 | 298 | 'event_espresso' |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
307 | 307 | apply_filters( |
308 | 308 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
309 | - EEH_HTML::nbsp(3) . |
|
309 | + EEH_HTML::nbsp(3). |
|
310 | 310 | EEH_HTML::link( |
311 | 311 | '', |
312 | 312 | esc_html__('ADD', 'event_espresso'), |
313 | 313 | '', |
314 | - 'submit-' . $new_state_submit_id, |
|
314 | + 'submit-'.$new_state_submit_id, |
|
315 | 315 | 'ee-form-add-new-state-submit button button-secondary', |
316 | 316 | '', |
317 | - 'data-target="' . $new_state_submit_id . '"' |
|
317 | + 'data-target="'.$new_state_submit_id.'"' |
|
318 | 318 | ) |
319 | 319 | ) |
320 | 320 | ), |
@@ -355,10 +355,10 @@ discard block |
||
355 | 355 | '', |
356 | 356 | esc_html__('cancel new State/Province', 'event_espresso'), |
357 | 357 | '', |
358 | - 'hide-' . $input->html_id(), |
|
358 | + 'hide-'.$input->html_id(), |
|
359 | 359 | 'ee-form-cancel-new-state-lnk smaller-text', |
360 | 360 | '', |
361 | - 'data-target="' . $input->html_id() . '"' |
|
361 | + 'data-target="'.$input->html_id().'"' |
|
362 | 362 | ) |
363 | 363 | . |
364 | 364 | EEH_HTML::divx() |
@@ -497,27 +497,27 @@ discard block |
||
497 | 497 | public static function save_new_state_to_db($props_n_values = array()) |
498 | 498 | { |
499 | 499 | $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
500 | - if (! empty($existing_state)) { |
|
500 | + if ( ! empty($existing_state)) { |
|
501 | 501 | return array_pop($existing_state); |
502 | 502 | } |
503 | 503 | $new_state = EE_State::new_instance($props_n_values); |
504 | 504 | if ($new_state instanceof EE_State) { |
505 | 505 | // if not non-ajax admin |
506 | - $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
506 | + $new_state_key = 'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev(); |
|
507 | 507 | $new_state_notice = sprintf( |
508 | 508 | esc_html__( |
509 | 509 | 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', |
510 | 510 | 'event_espresso' |
511 | 511 | ), |
512 | - '<b>' . $new_state->name() . '</b>', |
|
513 | - '<b>' . $new_state->abbrev() . '</b>', |
|
514 | - '<b>' . $new_state->country()->name() . '</b>', |
|
515 | - '<a href="' . add_query_arg(array( |
|
512 | + '<b>'.$new_state->name().'</b>', |
|
513 | + '<b>'.$new_state->abbrev().'</b>', |
|
514 | + '<b>'.$new_state->country()->name().'</b>', |
|
515 | + '<a href="'.add_query_arg(array( |
|
516 | 516 | 'page' => 'espresso_general_settings', |
517 | 517 | 'action' => 'country_settings', |
518 | 518 | 'country' => $new_state->country_iso(), |
519 | - ), admin_url('admin.php')) . '">' . esc_html__('Event Espresso - General Settings > Countries Tab', |
|
520 | - 'event_espresso') . '</a>', |
|
519 | + ), admin_url('admin.php')).'">'.esc_html__('Event Espresso - General Settings > Countries Tab', |
|
520 | + 'event_espresso').'</a>', |
|
521 | 521 | '<br />' |
522 | 522 | ); |
523 | 523 | EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) |
540 | 540 | { |
541 | 541 | $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false; |
542 | - if (! $CNT_ISO) { |
|
542 | + if ( ! $CNT_ISO) { |
|
543 | 543 | EE_Error::add_error( |
544 | 544 | esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'), |
545 | 545 | __FILE__, |
@@ -549,13 +549,13 @@ discard block |
||
549 | 549 | } |
550 | 550 | $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] |
551 | 551 | : false; |
552 | - if (! $STA_abbrev && ! empty($STA_ID)) { |
|
552 | + if ( ! $STA_abbrev && ! empty($STA_ID)) { |
|
553 | 553 | $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
554 | 554 | if ($state instanceof EE_State) { |
555 | 555 | $STA_abbrev = $state->abbrev(); |
556 | 556 | } |
557 | 557 | } |
558 | - if (! $STA_abbrev) { |
|
558 | + if ( ! $STA_abbrev) { |
|
559 | 559 | EE_Error::add_error( |
560 | 560 | esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'), |
561 | 561 | __FILE__, |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | __LINE__ |
564 | 564 | ); |
565 | 565 | } |
566 | - EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true); |
|
566 | + EE_Error::dismiss_persistent_admin_notice($CNT_ISO.'-'.$STA_abbrev, true, true); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -588,15 +588,15 @@ discard block |
||
588 | 588 | === EEM_Question::QST_type_state |
589 | 589 | ) { |
590 | 590 | $STA_ID = $answer->value(); |
591 | - if (! empty($STA_ID)) { |
|
591 | + if ( ! empty($STA_ID)) { |
|
592 | 592 | $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
593 | 593 | if ($state instanceof EE_State) { |
594 | 594 | $country = $state->country(); |
595 | 595 | if ($country instanceof EE_Country) { |
596 | - if (! isset($state_options[$country->name()])) { |
|
596 | + if ( ! isset($state_options[$country->name()])) { |
|
597 | 597 | $state_options[$country->name()] = array(); |
598 | 598 | } |
599 | - if (! isset($state_options[$country->name()][$STA_ID])) { |
|
599 | + if ( ! isset($state_options[$country->name()][$STA_ID])) { |
|
600 | 600 | $state_options[$country->name()][$STA_ID] = $state->name(); |
601 | 601 | } |
602 | 602 | } |
@@ -628,10 +628,10 @@ discard block |
||
628 | 628 | === EEM_Question::QST_type_country |
629 | 629 | ) { |
630 | 630 | $CNT_ISO = $answer->value(); |
631 | - if (! empty($CNT_ISO)) { |
|
631 | + if ( ! empty($CNT_ISO)) { |
|
632 | 632 | $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
633 | 633 | if ($country instanceof EE_Country) { |
634 | - if (! isset($country_options[$CNT_ISO])) { |
|
634 | + if ( ! isset($country_options[$CNT_ISO])) { |
|
635 | 635 | $country_options[$CNT_ISO] = $country->name(); |
636 | 636 | } |
637 | 637 | } |