@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | |
40 | 40 | /** |
41 | - * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
41 | + * @param string $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
42 | 42 | * or an array of capability strings |
43 | 43 | * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
44 | 44 | * @param int $ID - (optional) ID for item where current_user_can is being called from |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -20,71 +20,71 @@ discard block |
||
20 | 20 | class CapCheck implements CapCheckInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var string|array $capability |
|
25 | - */ |
|
26 | - private $capability; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string $context |
|
30 | - */ |
|
31 | - private $context; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var int|string $ID |
|
35 | - */ |
|
36 | - private $ID; |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
42 | - * or an array of capability strings |
|
43 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
44 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
45 | - */ |
|
46 | - public function __construct($capability, $context, $ID = 0) |
|
47 | - { |
|
48 | - if ( ! is_string($capability)) { |
|
49 | - throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
50 | - } |
|
51 | - if ( ! is_string($context)) { |
|
52 | - throw new InvalidDataTypeException('$context', $context, 'string'); |
|
53 | - } |
|
54 | - $this->capability = $capability; |
|
55 | - $this->context = strtolower(str_replace(' ', '_', $context)); |
|
56 | - $this->ID = $ID; |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @return string|array |
|
63 | - */ |
|
64 | - public function capability() |
|
65 | - { |
|
66 | - return $this->capability; |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function context() |
|
75 | - { |
|
76 | - return $this->context; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @return int|string |
|
83 | - */ |
|
84 | - public function ID() |
|
85 | - { |
|
86 | - return $this->ID; |
|
87 | - } |
|
23 | + /** |
|
24 | + * @var string|array $capability |
|
25 | + */ |
|
26 | + private $capability; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string $context |
|
30 | + */ |
|
31 | + private $context; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var int|string $ID |
|
35 | + */ |
|
36 | + private $ID; |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
42 | + * or an array of capability strings |
|
43 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
44 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
45 | + */ |
|
46 | + public function __construct($capability, $context, $ID = 0) |
|
47 | + { |
|
48 | + if ( ! is_string($capability)) { |
|
49 | + throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
50 | + } |
|
51 | + if ( ! is_string($context)) { |
|
52 | + throw new InvalidDataTypeException('$context', $context, 'string'); |
|
53 | + } |
|
54 | + $this->capability = $capability; |
|
55 | + $this->context = strtolower(str_replace(' ', '_', $context)); |
|
56 | + $this->ID = $ID; |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @return string|array |
|
63 | + */ |
|
64 | + public function capability() |
|
65 | + { |
|
66 | + return $this->capability; |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function context() |
|
75 | + { |
|
76 | + return $this->context; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @return int|string |
|
83 | + */ |
|
84 | + public function ID() |
|
85 | + { |
|
86 | + return $this->ID; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | 90 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | 60 | // check if class object is instantiated, and instantiated properly |
61 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Network_Config )) { |
|
61 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Network_Config)) { |
|
62 | 62 | self::$_instance = new self(); |
63 | 63 | } |
64 | 64 | return self::$_instance; |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | * @access private |
74 | 74 | */ |
75 | 75 | private function __construct() { |
76 | - do_action( 'AHEE__EE_Network_Config__construct__begin',$this ); |
|
76 | + do_action('AHEE__EE_Network_Config__construct__begin', $this); |
|
77 | 77 | //set defaults |
78 | - $this->core = apply_filters( 'FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config() ); |
|
78 | + $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config()); |
|
79 | 79 | $this->addons = array(); |
80 | 80 | |
81 | 81 | $this->_load_config(); |
82 | 82 | |
83 | 83 | // construct__end hook |
84 | - do_action( 'AHEE__EE_Network_Config__construct__end',$this ); |
|
84 | + do_action('AHEE__EE_Network_Config__construct__end', $this); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -94,25 +94,25 @@ discard block |
||
94 | 94 | */ |
95 | 95 | private function _load_config() { |
96 | 96 | //load network config start hook |
97 | - do_action( 'AHEE__EE_Network_Config___load_config__start', $this ); |
|
97 | + do_action('AHEE__EE_Network_Config___load_config__start', $this); |
|
98 | 98 | $config = $this->get_config(); |
99 | - foreach ( $config as $config_prop => $settings ) { |
|
100 | - if ( is_object( $settings ) && property_exists( $this, $config_prop ) ) { |
|
101 | - $this->{$config_prop} = apply_filters( 'FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this ); |
|
102 | - if ( method_exists( $settings, 'populate' ) ) { |
|
99 | + foreach ($config as $config_prop => $settings) { |
|
100 | + if (is_object($settings) && property_exists($this, $config_prop)) { |
|
101 | + $this->{$config_prop} = apply_filters('FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this); |
|
102 | + if (method_exists($settings, 'populate')) { |
|
103 | 103 | $this->{$config_prop}->populate(); |
104 | 104 | } |
105 | - if ( method_exists( $settings, 'do_hooks' ) ) { |
|
105 | + if (method_exists($settings, 'do_hooks')) { |
|
106 | 106 | $this->{$config_prop}->do_hooks(); |
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |
110 | - if ( apply_filters( 'FHEE__EE_Network_Config___load_config__update_network_config', false ) ) { |
|
110 | + if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) { |
|
111 | 111 | $this->update_config(); |
112 | 112 | } |
113 | 113 | |
114 | 114 | //load network config end hook |
115 | - do_action( 'AHEE__EE_Network_Config___load_config__end', $this ); |
|
115 | + do_action('AHEE__EE_Network_Config___load_config__end', $this); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function get_config() { |
128 | 128 | // grab network configuration |
129 | - $CFG = get_site_option( 'ee_network_config', array() ); |
|
130 | - $CFG = apply_filters( 'FHEE__EE_Network_Config__get_config__CFG', $CFG ); |
|
129 | + $CFG = get_site_option('ee_network_config', array()); |
|
130 | + $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG); |
|
131 | 131 | return $CFG; |
132 | 132 | } |
133 | 133 | |
@@ -141,39 +141,39 @@ discard block |
||
141 | 141 | * @param bool $add_error |
142 | 142 | * @return bool success |
143 | 143 | */ |
144 | - public function update_config( $add_success = FALSE, $add_error = TRUE ) { |
|
145 | - do_action( 'AHEE__EE_Network_Config__update_config__begin',$this ); |
|
144 | + public function update_config($add_success = FALSE, $add_error = TRUE) { |
|
145 | + do_action('AHEE__EE_Network_Config__update_config__begin', $this); |
|
146 | 146 | |
147 | 147 | //need to bust cache for comparing original if this is a multisite install |
148 | - if ( is_multisite() ) { |
|
148 | + if (is_multisite()) { |
|
149 | 149 | global $current_site; |
150 | - $cache_key = $current_site->id . ':ee_network_config'; |
|
151 | - wp_cache_delete( $cache_key, 'site-options' ); |
|
150 | + $cache_key = $current_site->id.':ee_network_config'; |
|
151 | + wp_cache_delete($cache_key, 'site-options'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | //we have to compare existing saved config with config in memory because if there is no difference that means |
155 | 155 | //that the method executed fine but there just was no update. WordPress doesn't distinguish between false because |
156 | 156 | //there were 0 records updated because of no change vs false because some error produced problems with the update. |
157 | - $original = get_site_option( 'ee_network_config' ); |
|
157 | + $original = get_site_option('ee_network_config'); |
|
158 | 158 | |
159 | - if ( $original == $this ) { |
|
159 | + if ($original == $this) { |
|
160 | 160 | return true; |
161 | 161 | } |
162 | 162 | // update |
163 | - $saved = update_site_option( 'ee_network_config', $this ); |
|
163 | + $saved = update_site_option('ee_network_config', $this); |
|
164 | 164 | |
165 | - do_action( 'AHEE__EE_Network_Config__update_config__end', $this, $saved ); |
|
165 | + do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved); |
|
166 | 166 | // if config remains the same or was updated successfully |
167 | - if ( $saved ) { |
|
168 | - if ( $add_success ) { |
|
169 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso' ) : __( 'Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso' ); |
|
170 | - EE_Error::add_success( $msg ); |
|
167 | + if ($saved) { |
|
168 | + if ($add_success) { |
|
169 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso') : __('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso'); |
|
170 | + EE_Error::add_success($msg); |
|
171 | 171 | } |
172 | 172 | return true; |
173 | 173 | } else { |
174 | - if ( $add_error ) { |
|
175 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings were not updated.', 'event_espresso' ) : __( 'Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso' ); |
|
176 | - EE_Error::add_error( $msg , __FILE__, __FUNCTION__, __LINE__ ); |
|
174 | + if ($add_error) { |
|
175 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings were not updated.', 'event_espresso') : __('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso'); |
|
176 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
177 | 177 | } |
178 | 178 | return false; |
179 | 179 | } |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * @return array |
188 | 188 | */ |
189 | 189 | public function __sleep() { |
190 | - return apply_filters( 'FHEE__EE_Network_Config__sleep',array( |
|
190 | + return apply_filters('FHEE__EE_Network_Config__sleep', array( |
|
191 | 191 | 'core', |
192 | - ) ); |
|
192 | + )); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | } //end EE_Network_Config. |
@@ -20,13 +20,13 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function capability() |
|
27 | - { |
|
28 | - return ''; |
|
29 | - } |
|
23 | + /** |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function capability() |
|
27 | + { |
|
28 | + return ''; |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | 32 | } |
@@ -13,20 +13,20 @@ |
||
13 | 13 | interface CapCheckInterface |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @return string |
|
18 | - */ |
|
19 | - public function capability(); |
|
16 | + /** |
|
17 | + * @return string |
|
18 | + */ |
|
19 | + public function capability(); |
|
20 | 20 | |
21 | - /** |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function context(); |
|
21 | + /** |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function context(); |
|
25 | 25 | |
26 | - /** |
|
27 | - * @return int|string |
|
28 | - */ |
|
29 | - public function ID(); |
|
26 | + /** |
|
27 | + * @return int|string |
|
28 | + */ |
|
29 | + public function ID(); |
|
30 | 30 | |
31 | 31 | } |
32 | 32 | // End of file CapCheckInterface.php |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use EventEspresso\core\services\commands\CommandRequiresCapCheckInterface; |
9 | 9 | |
10 | 10 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
11 | - exit('No direct script access allowed'); |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -24,142 +24,142 @@ discard block |
||
24 | 24 | class CreateRegistrationCommand extends Command implements CommandRequiresCapCheckInterface |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var \EE_Transaction $transaction |
|
29 | - */ |
|
30 | - private $transaction; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var \EE_Ticket $ticket |
|
34 | - */ |
|
35 | - private $ticket; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var \EE_Line_Item $ticket_line_item |
|
39 | - */ |
|
40 | - private $ticket_line_item; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var int $reg_count |
|
44 | - */ |
|
45 | - private $reg_count = 1; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var int $reg_group_size |
|
49 | - */ |
|
50 | - private $reg_group_size = 0; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var \EE_Registration $registration |
|
54 | - */ |
|
55 | - protected $registration; |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * CreateRegistrationCommand constructor. |
|
61 | - * |
|
62 | - * @param \EE_Transaction $transaction |
|
63 | - * @param \EE_Line_Item $ticket_line_item |
|
64 | - * @param int $reg_count |
|
65 | - * @param int $reg_group_size |
|
66 | - */ |
|
67 | - public function __construct( |
|
68 | - \EE_Transaction $transaction, |
|
69 | - \EE_Line_Item $ticket_line_item, |
|
70 | - $reg_count = 1, |
|
71 | - $reg_group_size = 0 |
|
72 | - ) { |
|
73 | - // grab the related ticket object for this line_item |
|
74 | - $this->ticket = $ticket_line_item->ticket(); |
|
75 | - if ( ! $this->ticket instanceof \EE_Ticket) { |
|
76 | - throw new InvalidEntityException( |
|
77 | - is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
|
78 | - 'EE_Ticket', |
|
79 | - sprintf( |
|
80 | - __("Line item %s did not contain a valid ticket", "event_espresso"), |
|
81 | - $ticket_line_item->ID() |
|
82 | - ) |
|
83 | - ); |
|
84 | - } |
|
85 | - $this->transaction = $transaction; |
|
86 | - $this->ticket_line_item = $ticket_line_item; |
|
87 | - $this->reg_count = absint($reg_count); |
|
88 | - $this->reg_group_size = absint($reg_group_size); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * @return \EventEspresso\core\domain\services\capabilities\CapCheckInterface |
|
95 | - */ |
|
96 | - public function getCapCheck() |
|
97 | - { |
|
98 | - if ( ! $this->cap_check instanceof CapCheckInterface) { |
|
99 | - return new CapCheck('ee_edit_registrations', 'create_new_registration'); |
|
100 | - } |
|
101 | - return $this->cap_check; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return \EE_Transaction |
|
108 | - */ |
|
109 | - public function transaction() |
|
110 | - { |
|
111 | - return $this->transaction; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return \EE_Ticket |
|
118 | - */ |
|
119 | - public function ticket() |
|
120 | - { |
|
121 | - return $this->ticket; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @return \EE_Line_Item |
|
128 | - */ |
|
129 | - public function ticketLineItem() |
|
130 | - { |
|
131 | - return $this->ticket_line_item; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @return int |
|
138 | - */ |
|
139 | - public function regCount() |
|
140 | - { |
|
141 | - return $this->reg_count; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return int |
|
148 | - */ |
|
149 | - public function regGroupSize() |
|
150 | - { |
|
151 | - return $this->reg_group_size; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @return \EE_Registration |
|
158 | - */ |
|
159 | - public function registration() |
|
160 | - { |
|
161 | - return $this->registration; |
|
162 | - } |
|
27 | + /** |
|
28 | + * @var \EE_Transaction $transaction |
|
29 | + */ |
|
30 | + private $transaction; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var \EE_Ticket $ticket |
|
34 | + */ |
|
35 | + private $ticket; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var \EE_Line_Item $ticket_line_item |
|
39 | + */ |
|
40 | + private $ticket_line_item; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var int $reg_count |
|
44 | + */ |
|
45 | + private $reg_count = 1; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var int $reg_group_size |
|
49 | + */ |
|
50 | + private $reg_group_size = 0; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var \EE_Registration $registration |
|
54 | + */ |
|
55 | + protected $registration; |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * CreateRegistrationCommand constructor. |
|
61 | + * |
|
62 | + * @param \EE_Transaction $transaction |
|
63 | + * @param \EE_Line_Item $ticket_line_item |
|
64 | + * @param int $reg_count |
|
65 | + * @param int $reg_group_size |
|
66 | + */ |
|
67 | + public function __construct( |
|
68 | + \EE_Transaction $transaction, |
|
69 | + \EE_Line_Item $ticket_line_item, |
|
70 | + $reg_count = 1, |
|
71 | + $reg_group_size = 0 |
|
72 | + ) { |
|
73 | + // grab the related ticket object for this line_item |
|
74 | + $this->ticket = $ticket_line_item->ticket(); |
|
75 | + if ( ! $this->ticket instanceof \EE_Ticket) { |
|
76 | + throw new InvalidEntityException( |
|
77 | + is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
|
78 | + 'EE_Ticket', |
|
79 | + sprintf( |
|
80 | + __("Line item %s did not contain a valid ticket", "event_espresso"), |
|
81 | + $ticket_line_item->ID() |
|
82 | + ) |
|
83 | + ); |
|
84 | + } |
|
85 | + $this->transaction = $transaction; |
|
86 | + $this->ticket_line_item = $ticket_line_item; |
|
87 | + $this->reg_count = absint($reg_count); |
|
88 | + $this->reg_group_size = absint($reg_group_size); |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * @return \EventEspresso\core\domain\services\capabilities\CapCheckInterface |
|
95 | + */ |
|
96 | + public function getCapCheck() |
|
97 | + { |
|
98 | + if ( ! $this->cap_check instanceof CapCheckInterface) { |
|
99 | + return new CapCheck('ee_edit_registrations', 'create_new_registration'); |
|
100 | + } |
|
101 | + return $this->cap_check; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return \EE_Transaction |
|
108 | + */ |
|
109 | + public function transaction() |
|
110 | + { |
|
111 | + return $this->transaction; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return \EE_Ticket |
|
118 | + */ |
|
119 | + public function ticket() |
|
120 | + { |
|
121 | + return $this->ticket; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @return \EE_Line_Item |
|
128 | + */ |
|
129 | + public function ticketLineItem() |
|
130 | + { |
|
131 | + return $this->ticket_line_item; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @return int |
|
138 | + */ |
|
139 | + public function regCount() |
|
140 | + { |
|
141 | + return $this->reg_count; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return int |
|
148 | + */ |
|
149 | + public function regGroupSize() |
|
150 | + { |
|
151 | + return $this->reg_group_size; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @return \EE_Registration |
|
158 | + */ |
|
159 | + public function registration() |
|
160 | + { |
|
161 | + return $this->registration; |
|
162 | + } |
|
163 | 163 | |
164 | 164 | |
165 | 165 |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | * process_ticket_selections |
487 | 487 | * |
488 | 488 | * @access public |
489 | - * @return array|boolean |
|
489 | + * @return boolean|null |
|
490 | 490 | */ |
491 | 491 | public function process_ticket_selections() { |
492 | 492 | do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | * validate_post_data |
632 | 632 | * |
633 | 633 | * @access private |
634 | - * @return array or FALSE |
|
634 | + * @return string or FALSE |
|
635 | 635 | */ |
636 | 636 | private static function _validate_post_data() { |
637 | 637 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | * @access private |
749 | 749 | * @param EE_Ticket $ticket |
750 | 750 | * @param int $qty |
751 | - * @return TRUE on success, FALSE on fail |
|
751 | + * @return boolean on success, FALSE on fail |
|
752 | 752 | */ |
753 | 753 | private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
754 | 754 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | protected static $_event = NULL; |
36 | 36 | |
37 | 37 | /** |
38 | - * array of datetimes and the spaces available for them |
|
39 | - * |
|
40 | - * @access private |
|
41 | - * @var array |
|
42 | - */ |
|
38 | + * array of datetimes and the spaces available for them |
|
39 | + * |
|
40 | + * @access private |
|
41 | + * @var array |
|
42 | + */ |
|
43 | 43 | private static $_available_spaces = array(); |
44 | 44 | |
45 | 45 | |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | return $permalink_string; |
209 | 209 | } |
210 | 210 | $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' |
211 | - . __( 'Embed', 'event_espresso' ) |
|
212 | - . '</a> '; |
|
211 | + . __( 'Embed', 'event_espresso' ) |
|
212 | + . '</a> '; |
|
213 | 213 | $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
214 | 214 | $iframe_string = esc_html( |
215 | 215 | '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>' |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | * @return array|boolean |
490 | 490 | */ |
491 | 491 | public function process_ticket_selections() { |
492 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
492 | + do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
493 | 493 | // check nonce |
494 | 494 | if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce' ) || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce' ), 'process_ticket_selections' ))) { |
495 | 495 | EE_Error::add_error( |
@@ -883,11 +883,11 @@ discard block |
||
883 | 883 | |
884 | 884 | |
885 | 885 | /** |
886 | - * load js |
|
887 | - * |
|
888 | - * @access public |
|
889 | - * @return void |
|
890 | - */ |
|
886 | + * load js |
|
887 | + * |
|
888 | + * @access public |
|
889 | + * @return void |
|
890 | + */ |
|
891 | 891 | public static function load_tckt_slctr_assets() { |
892 | 892 | // add some style |
893 | 893 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | * @return EED_Ticket_Selector |
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | - return parent::get_instance( __CLASS__ ); |
|
60 | + return parent::get_instance(__CLASS__); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - protected function set_config(){ |
|
66 | - $this->set_config_section( 'template_settings' ); |
|
67 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
68 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
65 | + protected function set_config() { |
|
66 | + $this->set_config_section('template_settings'); |
|
67 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
68 | + $this->set_config_name('EED_Ticket_Selector'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function set_hooks() { |
82 | 82 | // routing |
83 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
84 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
85 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
83 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
84 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
85 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
86 | 86 | //add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 ); |
87 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
87 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
88 | 88 | //add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 ); |
89 | 89 | //add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 ); |
90 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
90 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * @return void |
100 | 100 | */ |
101 | 101 | public static function set_hooks_admin() { |
102 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
102 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
103 | 103 | //add button for iframe code to event editor. |
104 | - add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 ); |
|
105 | - add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 ); |
|
104 | + add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4); |
|
105 | + add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @return void |
115 | 115 | */ |
116 | 116 | public static function set_definitions() { |
117 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
118 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
117 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
118 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
119 | 119 | |
120 | 120 | //if config is not set, initialize |
121 | 121 | //If config is not set, set it. |
122 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
|
122 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) { |
|
123 | 123 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
124 | 124 | } |
125 | - EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' ); |
|
125 | + EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param object $WP |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function run( $WP ) {} |
|
136 | + public function run($WP) {} |
|
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
@@ -145,23 +145,23 @@ discard block |
||
145 | 145 | public function ticket_selector_iframe() { |
146 | 146 | self::$_in_iframe = true; |
147 | 147 | /** @type EEM_Event $EEM_Event */ |
148 | - $EEM_Event = EE_Registry::instance()->load_model( 'Event' ); |
|
148 | + $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
149 | 149 | $event = $EEM_Event->get_one_by_ID( |
150 | - EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
150 | + EE_Registry::instance()->REQ->get('event', 0) |
|
151 | 151 | ); |
152 | - EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
153 | - $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event ); |
|
152 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
153 | + $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event); |
|
154 | 154 | $template_args['css'] = apply_filters( |
155 | 155 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
156 | 156 | array( |
157 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
158 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
159 | - includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ), |
|
160 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
157 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION, |
|
158 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION, |
|
159 | + includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']), |
|
160 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION |
|
161 | 161 | ) |
162 | 162 | ); |
163 | - EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true; |
|
164 | - EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' ); |
|
163 | + EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true; |
|
164 | + EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso'); |
|
165 | 165 | $template_args['eei18n'] = apply_filters( |
166 | 166 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings', |
167 | 167 | EE_Registry::localize_i18n_js_strings() |
@@ -169,18 +169,18 @@ discard block |
||
169 | 169 | $template_args['js'] = apply_filters( |
170 | 170 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
171 | 171 | array( |
172 | - includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ), |
|
173 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
174 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION |
|
172 | + includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']), |
|
173 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
174 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION |
|
175 | 175 | ) |
176 | 176 | ); |
177 | - $template_args[ 'notices' ] = EEH_Template::display_template( |
|
178 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
177 | + $template_args['notices'] = EEH_Template::display_template( |
|
178 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
179 | 179 | array(), |
180 | 180 | true |
181 | 181 | ); |
182 | 182 | EEH_Template::display_template( |
183 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php', |
|
183 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php', |
|
184 | 184 | $template_args |
185 | 185 | ); |
186 | 186 | exit; |
@@ -199,25 +199,25 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return string The new html string for the permalink area. |
201 | 201 | */ |
202 | - public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) { |
|
202 | + public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) { |
|
203 | 203 | //make sure this is ONLY when editing and the event id has been set. |
204 | - if ( ! empty( $id ) ) { |
|
205 | - $post = get_post( $id ); |
|
204 | + if ( ! empty($id)) { |
|
205 | + $post = get_post($id); |
|
206 | 206 | //if NOT event then let's get out. |
207 | - if ( $post->post_type !== 'espresso_events' ) { |
|
207 | + if ($post->post_type !== 'espresso_events') { |
|
208 | 208 | return $permalink_string; |
209 | 209 | } |
210 | 210 | $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' |
211 | - . __( 'Embed', 'event_espresso' ) |
|
211 | + . __('Embed', 'event_espresso') |
|
212 | 212 | . '</a> '; |
213 | - $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
|
213 | + $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url()); |
|
214 | 214 | $iframe_string = esc_html( |
215 | - '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>' |
|
215 | + '<iframe src="'.$ticket_selector_url.'" width="100%" height="100%"></iframe>' |
|
216 | 216 | ); |
217 | 217 | $permalink_string .= ' |
218 | 218 | <div id="js-ts-iframe" style="display:none"> |
219 | 219 | <div style="width:100%; height: 500px;"> |
220 | - ' . $iframe_string . ' |
|
220 | + ' . $iframe_string.' |
|
221 | 221 | </div> |
222 | 222 | </div>'; |
223 | 223 | } |
@@ -236,22 +236,22 @@ discard block |
||
236 | 236 | * @param mixed $event |
237 | 237 | * @return bool |
238 | 238 | */ |
239 | - protected static function set_event( $event = null ) { |
|
240 | - if( $event === null ) { |
|
239 | + protected static function set_event($event = null) { |
|
240 | + if ($event === null) { |
|
241 | 241 | global $post; |
242 | 242 | $event = $post; |
243 | 243 | } |
244 | - if ( $event instanceof EE_Event ) { |
|
244 | + if ($event instanceof EE_Event) { |
|
245 | 245 | self::$_event = $event; |
246 | - } else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
246 | + } else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
247 | 247 | self::$_event = $event->EE_Event; |
248 | - } else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) { |
|
249 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
248 | + } else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') { |
|
249 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
250 | 250 | self::$_event = $event->EE_Event; |
251 | 251 | } else { |
252 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
253 | - $dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' ); |
|
254 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
252 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
253 | + $dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso'); |
|
254 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | return true; |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | * @param bool $view_details |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
273 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
274 | 274 | // reset filter for displaying submit button |
275 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
275 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
276 | 276 | // poke and prod incoming event till it tells us what it is |
277 | - if ( ! EED_Ticket_Selector::set_event( $event )) { |
|
277 | + if ( ! EED_Ticket_Selector::set_event($event)) { |
|
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | && ( |
286 | 286 | ! self::$_event->display_ticket_selector() |
287 | 287 | || $view_details |
288 | - || post_password_required( $event_post ) |
|
288 | + || post_password_required($event_post) |
|
289 | 289 | || ( |
290 | 290 | $_event_active_status != EE_Datetime::active |
291 | 291 | && $_event_active_status != EE_Datetime::upcoming |
@@ -303,68 +303,68 @@ discard block |
||
303 | 303 | $template_args = array(); |
304 | 304 | $template_args['event_status'] = $_event_active_status; |
305 | 305 | |
306 | - $template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) ); |
|
307 | - $template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) ); |
|
306 | + $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format')); |
|
307 | + $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format')); |
|
308 | 308 | |
309 | 309 | $template_args['EVT_ID'] = self::$_event->ID(); |
310 | 310 | $template_args['event'] = self::$_event; |
311 | 311 | |
312 | 312 | // is the event expired ? |
313 | 313 | $template_args['event_is_expired'] = self::$_event->is_expired(); |
314 | - if ( $template_args['event_is_expired'] ) { |
|
315 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>'; |
|
314 | + if ($template_args['event_is_expired']) { |
|
315 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>'; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | $ticket_query_args = array( |
319 | - array( 'Datetime.EVT_ID' => self::$_event->ID() ), |
|
320 | - 'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' ) |
|
319 | + array('Datetime.EVT_ID' => self::$_event->ID()), |
|
320 | + 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC') |
|
321 | 321 | ); |
322 | 322 | |
323 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
|
323 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
324 | 324 | //use the correct applicable time query depending on what version of core is being run. |
325 | - $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp'); |
|
326 | - $ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time ); |
|
325 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp'); |
|
326 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | // get all tickets for this event ordered by the datetime |
330 | - $template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args ); |
|
330 | + $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args); |
|
331 | 331 | |
332 | - if ( count( $template_args['tickets'] ) < 1 ) { |
|
333 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>'; |
|
332 | + if (count($template_args['tickets']) < 1) { |
|
333 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>'; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
337 | - $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() ); |
|
338 | - if ( $template_args['max_atndz'] < 1 ) { |
|
339 | - $sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' ); |
|
340 | - if ( current_user_can( 'edit_post', self::$_event->ID() )) { |
|
341 | - $sales_closed_msg .= sprintf( |
|
342 | - __( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ), |
|
337 | + $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit()); |
|
338 | + if ($template_args['max_atndz'] < 1) { |
|
339 | + $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso'); |
|
340 | + if (current_user_can('edit_post', self::$_event->ID())) { |
|
341 | + $sales_closed_msg .= sprintf( |
|
342 | + __('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'), |
|
343 | 343 | '<div class="ee-attention" style="text-align: left;"><b>', |
344 | 344 | '</b><br />', |
345 | - $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">', |
|
345 | + $link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">', |
|
346 | 346 | '</a></span></div>' |
347 | 347 | ); |
348 | 348 | } |
349 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
349 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
350 | 350 | } |
351 | 351 | |
352 | - $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
|
353 | - $templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event ); |
|
352 | + $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php'; |
|
353 | + $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event); |
|
354 | 354 | |
355 | 355 | // redirecting to another site for registration ?? |
356 | 356 | $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; |
357 | 357 | // set up the form (but not for the admin) |
358 | - $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : ''; |
|
358 | + $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : ''; |
|
359 | 359 | // if not redirecting to another site for registration |
360 | - if ( ! $external_url ) { |
|
360 | + if ( ! $external_url) { |
|
361 | 361 | // then display the ticket selector |
362 | - $ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args ); |
|
362 | + $ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args); |
|
363 | 363 | } else { |
364 | 364 | // if not we still need to trigger the display of the submit button |
365 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
365 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
366 | 366 | //display notice to admin that registration is external |
367 | - $ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' ); |
|
367 | + $ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso'); |
|
368 | 368 | } |
369 | 369 | // submit button and form close tag |
370 | 370 | $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; |
@@ -384,25 +384,25 @@ discard block |
||
384 | 384 | * @param string $external_url |
385 | 385 | * @return string |
386 | 386 | */ |
387 | - public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) { |
|
387 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') { |
|
388 | 388 | // if redirecting, we don't need any anything else |
389 | - if ( $external_url ) { |
|
390 | - $html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">'; |
|
391 | - $query_args = EEH_URL::get_query_string( $external_url ); |
|
392 | - foreach ( $query_args as $query_arg => $value ) { |
|
393 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
389 | + if ($external_url) { |
|
390 | + $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">'; |
|
391 | + $query_args = EEH_URL::get_query_string($external_url); |
|
392 | + foreach ($query_args as $query_arg => $value) { |
|
393 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
394 | 394 | } |
395 | 395 | return $html; |
396 | 396 | } |
397 | - $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
398 | - if ( ! $checkout_url ) { |
|
399 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
397 | + $checkout_url = EEH_Event_View::event_link_url($ID); |
|
398 | + if ( ! $checkout_url) { |
|
399 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
400 | 400 | } |
401 | 401 | $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; |
402 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
403 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE ); |
|
402 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
403 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE); |
|
404 | 404 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
405 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event ); |
|
405 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event); |
|
406 | 406 | return $html; |
407 | 407 | } |
408 | 408 | |
@@ -417,23 +417,23 @@ discard block |
||
417 | 417 | * @return string |
418 | 418 | */ |
419 | 419 | public static function display_ticket_selector_submit() { |
420 | - if ( ! is_admin() ) { |
|
421 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) { |
|
420 | + if ( ! is_admin()) { |
|
421 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) { |
|
422 | 422 | $btn_text = apply_filters( |
423 | 423 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
424 | - __('Register Now', 'event_espresso' ), |
|
424 | + __('Register Now', 'event_espresso'), |
|
425 | 425 | self::$_event |
426 | 426 | ); |
427 | 427 | $external_url = self::$_event->external_url(); |
428 | - $html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"'; |
|
428 | + $html = '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn"'; |
|
429 | 429 | $html .= ' class="ticket-selector-submit-btn '; |
430 | - $html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"'; |
|
431 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
432 | - $html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event ); |
|
430 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
431 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
432 | + $html .= apply_filters('FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event); |
|
433 | 433 | $html .= '<div class="clear"><br/></div></form>'; |
434 | 434 | return $html; |
435 | - } else if ( is_archive() ) { |
|
436 | - return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn(); |
|
435 | + } else if (is_archive()) { |
|
436 | + return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn(); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | return ''; |
@@ -465,13 +465,13 @@ discard block |
||
465 | 465 | * @return string |
466 | 466 | */ |
467 | 467 | public static function display_view_details_btn() { |
468 | - if ( ! self::$_event->get_permalink() ) { |
|
469 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
468 | + if ( ! self::$_event->get_permalink()) { |
|
469 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
470 | 470 | } |
471 | - $view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">'; |
|
472 | - $btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event ); |
|
473 | - $view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />'; |
|
474 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event ); |
|
471 | + $view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">'; |
|
472 | + $btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event); |
|
473 | + $view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />'; |
|
474 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event); |
|
475 | 475 | $view_details_btn .= '<div class="clear"><br/></div>'; |
476 | 476 | $view_details_btn .= '</form>'; |
477 | 477 | return $view_details_btn; |
@@ -489,11 +489,11 @@ discard block |
||
489 | 489 | * @return array|boolean |
490 | 490 | */ |
491 | 491 | public function process_ticket_selections() { |
492 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
492 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
493 | 493 | // check nonce |
494 | - if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce' ) || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce' ), 'process_ticket_selections' ))) { |
|
494 | + if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce') || ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce'), 'process_ticket_selections'))) { |
|
495 | 495 | EE_Error::add_error( |
496 | - sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
496 | + sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
497 | 497 | __FILE__, __FUNCTION__, __LINE__ |
498 | 498 | ); |
499 | 499 | return FALSE; |
@@ -507,16 +507,16 @@ discard block |
||
507 | 507 | |
508 | 508 | //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart. |
509 | 509 | // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc. |
510 | - EE_Registry::instance()->load_core( 'Session' ); |
|
510 | + EE_Registry::instance()->load_core('Session'); |
|
511 | 511 | // unless otherwise requested, clear the session |
512 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) { |
|
513 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
512 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) { |
|
513 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
514 | 514 | } |
515 | 515 | //d( EE_Registry::instance()->SSN ); |
516 | 516 | |
517 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
517 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
518 | 518 | // do we have an event id? |
519 | - if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
|
519 | + if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) { |
|
520 | 520 | // validate/sanitize data |
521 | 521 | $valid = self::_validate_post_data(); |
522 | 522 | |
@@ -526,41 +526,41 @@ discard block |
||
526 | 526 | //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ ); |
527 | 527 | |
528 | 528 | //check total tickets ordered vs max number of attendees that can register |
529 | - if ( $valid['total_tickets'] > $valid['max_atndz'] ) { |
|
529 | + if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
530 | 530 | |
531 | 531 | // ordering too many tickets !!! |
532 | 532 | $total_tickets_string = _n('You have attempted to purchase %s ticket.', 'You have attempted to purchase %s tickets.', $valid['total_tickets'], 'event_espresso'); |
533 | - $limit_error_1 = sprintf( $total_tickets_string, $valid['total_tickets'] ); |
|
533 | + $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
534 | 534 | // dev only message |
535 | 535 | $max_atndz_string = _n('The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', $valid['max_atndz'], 'event_espresso'); |
536 | - $limit_error_2 = sprintf( $max_atndz_string, $valid['max_atndz'], $valid['max_atndz'] ); |
|
537 | - EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ ); |
|
536 | + $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']); |
|
537 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
538 | 538 | } else { |
539 | 539 | |
540 | 540 | // all data appears to be valid |
541 | 541 | $tckts_slctd = FALSE; |
542 | 542 | $success = TRUE; |
543 | 543 | // load cart |
544 | - EE_Registry::instance()->load_core( 'Cart' ); |
|
544 | + EE_Registry::instance()->load_core('Cart'); |
|
545 | 545 | |
546 | 546 | // cycle thru the number of data rows sent from the event listing |
547 | - for ( $x = 0; $x < $valid['rows']; $x++ ) { |
|
547 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
548 | 548 | // does this row actually contain a ticket quantity? |
549 | - if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) { |
|
549 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
550 | 550 | // YES we have a ticket quantity |
551 | 551 | $tckts_slctd = TRUE; |
552 | 552 | // d( $valid['ticket_obj'][$x] ); |
553 | - if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) { |
|
553 | + if ($valid['ticket_obj'][$x] instanceof EE_Ticket) { |
|
554 | 554 | // then add ticket to cart |
555 | - $ticket_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] ); |
|
555 | + $ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]); |
|
556 | 556 | $success = ! $ticket_added ? FALSE : $success; |
557 | - if ( EE_Error::has_error() ) { |
|
557 | + if (EE_Error::has_error()) { |
|
558 | 558 | break; |
559 | 559 | } |
560 | 560 | } else { |
561 | 561 | // nothing added to cart retrieved |
562 | 562 | EE_Error::add_error( |
563 | - sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
563 | + sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
564 | 564 | __FILE__, __FUNCTION__, __LINE__ |
565 | 565 | ); |
566 | 566 | } |
@@ -569,45 +569,45 @@ discard block |
||
569 | 569 | //d( EE_Registry::instance()->CART ); |
570 | 570 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
571 | 571 | |
572 | - if ( $tckts_slctd ) { |
|
573 | - if ( $success ) { |
|
574 | - do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this ); |
|
572 | + if ($tckts_slctd) { |
|
573 | + if ($success) { |
|
574 | + do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this); |
|
575 | 575 | EE_Registry::instance()->CART->recalculate_all_cart_totals(); |
576 | - EE_Registry::instance()->CART->save_cart( FALSE ); |
|
576 | + EE_Registry::instance()->CART->save_cart(FALSE); |
|
577 | 577 | EE_Registry::instance()->SSN->update(); |
578 | 578 | //d( EE_Registry::instance()->CART ); |
579 | 579 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
580 | 580 | // just return TRUE for registrations being made from admin |
581 | - if ( is_admin() ) { |
|
581 | + if (is_admin()) { |
|
582 | 582 | return TRUE; |
583 | 583 | } |
584 | - wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() )); |
|
584 | + wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url())); |
|
585 | 585 | exit(); |
586 | 586 | |
587 | 587 | } else { |
588 | - if ( ! EE_Error::has_error() ) { |
|
588 | + if ( ! EE_Error::has_error()) { |
|
589 | 589 | // nothing added to cart |
590 | - EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
590 | + EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
591 | 591 | } |
592 | 592 | } |
593 | 593 | |
594 | 594 | } else { |
595 | 595 | // no ticket quantities were selected |
596 | - EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
596 | + EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
600 | 600 | // at this point, just return if registration is being made from admin |
601 | - if ( is_admin() ) { |
|
601 | + if (is_admin()) { |
|
602 | 602 | return FALSE; |
603 | 603 | } |
604 | - if ( $valid['return_url'] ) { |
|
605 | - EE_Error::get_notices( FALSE, TRUE ); |
|
606 | - wp_safe_redirect( $valid['return_url'] ); |
|
604 | + if ($valid['return_url']) { |
|
605 | + EE_Error::get_notices(FALSE, TRUE); |
|
606 | + wp_safe_redirect($valid['return_url']); |
|
607 | 607 | exit(); |
608 | - } elseif ( isset( $event_to_add['id'] )) { |
|
609 | - EE_Error::get_notices( FALSE, TRUE ); |
|
610 | - wp_safe_redirect( get_permalink( $event_to_add['id'] )); |
|
608 | + } elseif (isset($event_to_add['id'])) { |
|
609 | + EE_Error::get_notices(FALSE, TRUE); |
|
610 | + wp_safe_redirect(get_permalink($event_to_add['id'])); |
|
611 | 611 | exit(); |
612 | 612 | } else { |
613 | 613 | echo EE_Error::get_notices(); |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | } else { |
617 | 617 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
618 | 618 | EE_Error::add_error( |
619 | - sprintf( __( 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
619 | + sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
620 | 620 | __FILE__, __FUNCTION__, __LINE__ |
621 | 621 | ); |
622 | 622 | } |
@@ -634,18 +634,18 @@ discard block |
||
634 | 634 | * @return array or FALSE |
635 | 635 | */ |
636 | 636 | private static function _validate_post_data() { |
637 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
637 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
638 | 638 | |
639 | 639 | // start with an empty array() |
640 | 640 | $valid_data = array(); |
641 | 641 | // d( $_POST ); |
642 | 642 | //if event id is valid |
643 | - $id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' )); |
|
644 | - if ( $id ) { |
|
643 | + $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id')); |
|
644 | + if ($id) { |
|
645 | 645 | // grab valid id |
646 | 646 | $valid_data['id'] = $id; |
647 | 647 | // grab and sanitize return-url |
648 | - $valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id )); |
|
648 | + $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id)); |
|
649 | 649 | // array of other form names |
650 | 650 | $inputs_to_clean = array( |
651 | 651 | 'event_id' => 'tkt-slctr-event-id', |
@@ -658,22 +658,22 @@ discard block |
||
658 | 658 | // let's track the total number of tickets ordered.' |
659 | 659 | $valid_data['total_tickets'] = 0; |
660 | 660 | // cycle through $inputs_to_clean array |
661 | - foreach ( $inputs_to_clean as $what => $input_to_clean ) { |
|
661 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
662 | 662 | // check for POST data |
663 | - if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) { |
|
663 | + if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) { |
|
664 | 664 | // grab value |
665 | - $input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id ); |
|
665 | + $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id); |
|
666 | 666 | switch ($what) { |
667 | 667 | |
668 | 668 | // integers |
669 | 669 | case 'event_id': |
670 | - $valid_data[$what] = absint( $input_value ); |
|
670 | + $valid_data[$what] = absint($input_value); |
|
671 | 671 | // get event via the event id we put in the form |
672 | - $valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] ); |
|
672 | + $valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']); |
|
673 | 673 | break; |
674 | 674 | case 'rows': |
675 | 675 | case 'max_atndz': |
676 | - $valid_data[$what] = absint( $input_value ); |
|
676 | + $valid_data[$what] = absint($input_value); |
|
677 | 677 | break; |
678 | 678 | |
679 | 679 | // arrays of integers |
@@ -681,27 +681,27 @@ discard block |
||
681 | 681 | // d( $input_value ); |
682 | 682 | $row_qty = $input_value; |
683 | 683 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
684 | - if( ! is_array( $row_qty )) { |
|
684 | + if ( ! is_array($row_qty)) { |
|
685 | 685 | // get number of rows |
686 | - $rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1; |
|
686 | + $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1; |
|
687 | 687 | // d( $rows ); |
688 | 688 | // explode ints by the dash |
689 | - $row_qty = explode( '-', $row_qty ); |
|
690 | - $row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1; |
|
691 | - $qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0; |
|
692 | - $row_qty = array( $row => $qty ); |
|
689 | + $row_qty = explode('-', $row_qty); |
|
690 | + $row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1; |
|
691 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
692 | + $row_qty = array($row => $qty); |
|
693 | 693 | // d( $row_qty ); |
694 | - for( $x = 1; $x <= $rows; $x++ ) { |
|
695 | - if ( ! isset( $row_qty[$x] )) { |
|
694 | + for ($x = 1; $x <= $rows; $x++) { |
|
695 | + if ( ! isset($row_qty[$x])) { |
|
696 | 696 | $row_qty[$x] = 0; |
697 | 697 | } |
698 | 698 | } |
699 | 699 | } |
700 | - ksort( $row_qty ); |
|
700 | + ksort($row_qty); |
|
701 | 701 | // d( $row_qty ); |
702 | 702 | // cycle thru values |
703 | - foreach ( $row_qty as $qty ) { |
|
704 | - $qty = absint( $qty ); |
|
703 | + foreach ($row_qty as $qty) { |
|
704 | + $qty = absint($qty); |
|
705 | 705 | // sanitize as integers |
706 | 706 | $valid_data[$what][] = $qty; |
707 | 707 | $valid_data['total_tickets'] += $qty; |
@@ -712,19 +712,19 @@ discard block |
||
712 | 712 | case 'ticket_id': |
713 | 713 | $value_array = array(); |
714 | 714 | // cycle thru values |
715 | - foreach ( $input_value as $key=>$value ) { |
|
715 | + foreach ($input_value as $key=>$value) { |
|
716 | 716 | // allow only numbers, letters, spaces, commas and dashes |
717 | - $value_array[ $key ] = wp_strip_all_tags( $value ); |
|
717 | + $value_array[$key] = wp_strip_all_tags($value); |
|
718 | 718 | // get ticket via the ticket id we put in the form |
719 | - $ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value ); |
|
720 | - $valid_data['ticket_obj'][ $key ] = $ticket_obj; |
|
719 | + $ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value); |
|
720 | + $valid_data['ticket_obj'][$key] = $ticket_obj; |
|
721 | 721 | } |
722 | - $valid_data[ $what ] = $value_array; |
|
722 | + $valid_data[$what] = $value_array; |
|
723 | 723 | break; |
724 | 724 | |
725 | 725 | case 'return_url' : |
726 | 726 | // grab and sanitize return-url |
727 | - $valid_data[$what] = esc_url_raw( $input_value ); |
|
727 | + $valid_data[$what] = esc_url_raw($input_value); |
|
728 | 728 | break; |
729 | 729 | |
730 | 730 | } // end switch $what |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | } // end foreach $inputs_to_clean |
733 | 733 | |
734 | 734 | } else { |
735 | - EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
735 | + EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
736 | 736 | return FALSE; |
737 | 737 | } |
738 | 738 | |
@@ -750,28 +750,28 @@ discard block |
||
750 | 750 | * @param int $qty |
751 | 751 | * @return TRUE on success, FALSE on fail |
752 | 752 | */ |
753 | - private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
|
754 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
753 | + private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) { |
|
754 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
755 | 755 | // get the number of spaces left for this datetime ticket |
756 | - $available_spaces = self::_ticket_datetime_availability( $ticket ); |
|
756 | + $available_spaces = self::_ticket_datetime_availability($ticket); |
|
757 | 757 | // compare available spaces against the number of tickets being purchased |
758 | - if ( $available_spaces >= $qty ) { |
|
758 | + if ($available_spaces >= $qty) { |
|
759 | 759 | // allow addons to prevent a ticket from being added to cart |
760 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) { |
|
760 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) { |
|
761 | 761 | return false; |
762 | 762 | } |
763 | 763 | // add event to cart |
764 | - if( EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) { |
|
765 | - self::_recalculate_ticket_datetime_availability( $ticket, $qty ); |
|
764 | + if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) { |
|
765 | + self::_recalculate_ticket_datetime_availability($ticket, $qty); |
|
766 | 766 | return true; |
767 | 767 | } else { |
768 | 768 | return false; |
769 | 769 | } |
770 | 770 | } else { |
771 | 771 | // tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets |
772 | - $available_spaces = self::_ticket_datetime_availability( $ticket, true ); |
|
772 | + $available_spaces = self::_ticket_datetime_availability($ticket, true); |
|
773 | 773 | // greedy greedy greedy eh? |
774 | - if ( $available_spaces > 0 ) { |
|
774 | + if ($available_spaces > 0) { |
|
775 | 775 | // add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces |
776 | 776 | EE_Error::add_error( |
777 | 777 | sprintf( |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | __FILE__, __FUNCTION__, __LINE__ |
788 | 788 | ); |
789 | 789 | } else { |
790 | - EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
790 | + EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
791 | 791 | } |
792 | 792 | return false; |
793 | 793 | } |
@@ -805,22 +805,22 @@ discard block |
||
805 | 805 | * @param bool $get_original_ticket_spaces |
806 | 806 | * @return int |
807 | 807 | */ |
808 | - private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) { |
|
808 | + private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) { |
|
809 | 809 | // if the $_available_spaces array has not been set up yet... |
810 | - if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
811 | - self::_set_initial_ticket_datetime_availability( $ticket ); |
|
810 | + if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
811 | + self::_set_initial_ticket_datetime_availability($ticket); |
|
812 | 812 | } |
813 | 813 | $available_spaces = $ticket->qty() - $ticket->sold(); |
814 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
814 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
815 | 815 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
816 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
816 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
817 | 817 | // if we want the original datetime availability BEFORE we started subtracting tickets ? |
818 | - if ( $get_original_ticket_spaces ) { |
|
818 | + if ($get_original_ticket_spaces) { |
|
819 | 819 | // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number |
820 | - $available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] ); |
|
820 | + $available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]); |
|
821 | 821 | } else { |
822 | 822 | // we want the updated ticket availability as stored in the "datetimes" array |
823 | - $available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] ); |
|
823 | + $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]); |
|
824 | 824 | } |
825 | 825 | } |
826 | 826 | } |
@@ -836,23 +836,23 @@ discard block |
||
836 | 836 | * @param EE_Ticket $ticket |
837 | 837 | * @return int |
838 | 838 | */ |
839 | - private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) { |
|
839 | + private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) { |
|
840 | 840 | // first, get all of the datetimes that are available to this ticket |
841 | 841 | $datetimes = $ticket->get_many_related( |
842 | 842 | 'Datetime', |
843 | - array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' )) |
|
843 | + array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC')) |
|
844 | 844 | ); |
845 | - if ( ! empty( $datetimes )) { |
|
845 | + if ( ! empty($datetimes)) { |
|
846 | 846 | // now loop thru all of the datetimes |
847 | - foreach ( $datetimes as $datetime ) { |
|
848 | - if ( $datetime instanceof EE_Datetime ) { |
|
847 | + foreach ($datetimes as $datetime) { |
|
848 | + if ($datetime instanceof EE_Datetime) { |
|
849 | 849 | // the number of spaces available for the datetime without considering individual ticket quantities |
850 | 850 | $spaces_remaining = $datetime->spaces_remaining(); |
851 | 851 | // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key |
852 | - self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining ); |
|
852 | + self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining); |
|
853 | 853 | // if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number, |
854 | 854 | // else just take the datetime spaces remaining, and assign to the datetimes array |
855 | - self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining; |
|
855 | + self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining; |
|
856 | 856 | } |
857 | 857 | } |
858 | 858 | } |
@@ -868,12 +868,12 @@ discard block |
||
868 | 868 | * @param int $qty |
869 | 869 | * @return int |
870 | 870 | */ |
871 | - private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) { |
|
872 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
871 | + private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) { |
|
872 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
873 | 873 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
874 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
874 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
875 | 875 | // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
876 | - self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty; |
|
876 | + self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty; |
|
877 | 877 | } |
878 | 878 | } |
879 | 879 | } |
@@ -890,8 +890,8 @@ discard block |
||
890 | 890 | */ |
891 | 891 | public static function load_tckt_slctr_assets() { |
892 | 892 | // add some style |
893 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
894 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
893 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
894 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
895 | 895 | wp_enqueue_style('ticket_selector'); |
896 | 896 | // make it dance |
897 | 897 | // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | |
906 | 906 | public static function load_tckt_slctr_assets_admin() { |
907 | 907 | //iframe button js on admin event editor page |
908 | - if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) { |
|
909 | - wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true ); |
|
910 | - wp_enqueue_script( 'ticket_selector_embed' ); |
|
908 | + if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') { |
|
909 | + wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
910 | + wp_enqueue_script('ticket_selector_embed'); |
|
911 | 911 | } |
912 | 912 | } |
913 | 913 |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * @return void |
31 | 31 | */ |
32 | 32 | public static function set_hooks() { |
33 | - if ( |
|
33 | + if ( |
|
34 | 34 | apply_filters( 'FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true ) && |
35 | 35 | \EE_Registry::instance()->CFG->registration->use_bot_trap |
36 | 36 | ) { |
37 | - \EED_Bot_Trap::set_trap(); |
|
37 | + \EED_Bot_Trap::set_trap(); |
|
38 | 38 | // redirect bots to bogus success page |
39 | 39 | \EE_Config::register_route( 'ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success' ); |
40 | 40 | } |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public static function set_trap() { |
52 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
53 | - add_action( |
|
54 | - 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
55 | - array('EED_Bot_Trap', 'generate_bot_trap'), |
|
56 | - 10, 2 |
|
57 | - ); |
|
58 | - add_action( |
|
59 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
60 | - array('EED_Bot_Trap', 'process_bot_trap'), |
|
61 | - 1, 2 |
|
62 | - ); |
|
63 | - } |
|
52 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
53 | + add_action( |
|
54 | + 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
55 | + array('EED_Bot_Trap', 'generate_bot_trap'), |
|
56 | + 10, 2 |
|
57 | + ); |
|
58 | + add_action( |
|
59 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
60 | + array('EED_Bot_Trap', 'process_bot_trap'), |
|
61 | + 1, 2 |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | * @return void |
72 | 72 | */ |
73 | 73 | public static function set_hooks_admin() { |
74 | - if ( |
|
75 | - defined('DOING_AJAX') |
|
76 | - && DOING_AJAX |
|
77 | - && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
78 | - && \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
79 | - ) { |
|
80 | - \EED_Bot_Trap::set_trap(); |
|
81 | - } |
|
82 | - add_action( |
|
74 | + if ( |
|
75 | + defined('DOING_AJAX') |
|
76 | + && DOING_AJAX |
|
77 | + && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
78 | + && \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
79 | + ) { |
|
80 | + \EED_Bot_Trap::set_trap(); |
|
81 | + } |
|
82 | + add_action( |
|
83 | 83 | 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
84 | 84 | array( 'EED_Bot_Trap', 'bot_trap_settings_form' ), |
85 | 85 | 10 |
@@ -129,23 +129,23 @@ discard block |
||
129 | 129 | |
130 | 130 | |
131 | 131 | /** |
132 | - * process_bot_trap |
|
133 | - * |
|
134 | - * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
135 | - * response if the bot trap is triggered. |
|
136 | - * It should receive one argument: a boolean indicating |
|
137 | - * whether the trap was triggered by suspicious timing or not. |
|
132 | + * process_bot_trap |
|
133 | + * |
|
134 | + * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
135 | + * response if the bot trap is triggered. |
|
136 | + * It should receive one argument: a boolean indicating |
|
137 | + * whether the trap was triggered by suspicious timing or not. |
|
138 | 138 | */ |
139 | 139 | public static function process_bot_trap( $triggered_trap_callback = array() ) { |
140 | - // what's your email address Mr. Bot ? |
|
140 | + // what's your email address Mr. Bot ? |
|
141 | 141 | $empty_trap = isset( $_REQUEST[ 'tkt-slctr-request-processor-email' ] ) |
142 | - && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === '' |
|
143 | - ? true |
|
144 | - : false; |
|
142 | + && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === '' |
|
143 | + ? true |
|
144 | + : false; |
|
145 | 145 | // get encrypted timestamp for when the form was originally displayed |
146 | 146 | $bot_trap_timestamp = isset( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
147 | - ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
148 | - : ''; |
|
147 | + ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
148 | + : ''; |
|
149 | 149 | // decrypt and convert to absolute integer |
150 | 150 | if ( EE_Registry::instance()->CFG->registration->use_encryption ) { |
151 | 151 | EE_Registry::instance()->load_core( 'EE_Encryption' ); |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | } |
156 | 156 | // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
157 | 157 | $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < ( time() - HOUR_IN_SECONDS ) |
158 | - ? true |
|
159 | - : false; |
|
158 | + ? true |
|
159 | + : false; |
|
160 | 160 | // are we human ? |
161 | 161 | if ( $empty_trap && ! $suspicious_timing ) { |
162 | - do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
162 | + do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | // check the given callback is valid first before executing |
166 | 166 | if ( ! is_callable($triggered_trap_callback ) ) { |
167 | 167 | // invalid callback so lets just sub in our default. |
168 | - $triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' ); |
|
168 | + $triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' ); |
|
169 | 169 | } |
170 | 170 | call_user_func_array($triggered_trap_callback, array( $suspicious_timing ) ); |
171 | 171 | } |
@@ -191,21 +191,21 @@ discard block |
||
191 | 191 | ); |
192 | 192 | } |
193 | 193 | $redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url); |
194 | - // if AJAX, return the redirect URL |
|
195 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
196 | - echo json_encode( |
|
197 | - array_merge( |
|
198 | - \EE_Error::get_notices(false), |
|
199 | - array( |
|
200 | - 'redirect_url' => $redirect_url |
|
201 | - ) |
|
202 | - ) |
|
203 | - ); |
|
204 | - exit(); |
|
205 | - } |
|
206 | - wp_safe_redirect($redirect_url); |
|
207 | - exit(); |
|
208 | - } |
|
194 | + // if AJAX, return the redirect URL |
|
195 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
196 | + echo json_encode( |
|
197 | + array_merge( |
|
198 | + \EE_Error::get_notices(false), |
|
199 | + array( |
|
200 | + 'redirect_url' => $redirect_url |
|
201 | + ) |
|
202 | + ) |
|
203 | + ); |
|
204 | + exit(); |
|
205 | + } |
|
206 | + wp_safe_redirect($redirect_url); |
|
207 | + exit(); |
|
208 | + } |
|
209 | 209 | |
210 | 210 | |
211 | 211 | |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @return void |
237 | 237 | */ |
238 | 238 | public static function bot_trap_settings_form() { |
239 | - EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
240 | - echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
241 | - } |
|
239 | + EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
240 | + echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
241 | + } |
|
242 | 242 | |
243 | 243 | |
244 | 244 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @return EED_Bot_Trap |
19 | 19 | */ |
20 | 20 | public static function instance() { |
21 | - return parent::get_instance( __CLASS__ ); |
|
21 | + return parent::get_instance(__CLASS__); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public static function set_hooks() { |
33 | 33 | if ( |
34 | - apply_filters( 'FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true ) && |
|
34 | + apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
35 | 35 | \EE_Registry::instance()->CFG->registration->use_bot_trap |
36 | 36 | ) { |
37 | 37 | \EED_Bot_Trap::set_trap(); |
38 | 38 | // redirect bots to bogus success page |
39 | - \EE_Config::register_route( 'ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success' ); |
|
39 | + \EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success'); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public static function set_trap() { |
52 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
52 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS); |
|
53 | 53 | add_action( |
54 | 54 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
55 | 55 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | } |
82 | 82 | add_action( |
83 | 83 | 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
84 | - array( 'EED_Bot_Trap', 'bot_trap_settings_form' ), |
|
84 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
85 | 85 | 10 |
86 | 86 | ); |
87 | 87 | add_filter( |
88 | 88 | 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
89 | - array( 'EED_Bot_Trap', 'update_bot_trap_settings_form' ), |
|
89 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
90 | 90 | 10, 1 |
91 | 91 | ); |
92 | 92 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param WP $WP |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public function run( $WP ) {} |
|
103 | + public function run($WP) {} |
|
104 | 104 | |
105 | 105 | |
106 | 106 | |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | */ |
113 | 113 | public static function generate_bot_trap() { |
114 | - $do_not_enter = esc_html__( 'please do not enter anything in this input', 'event_espresso' ); |
|
114 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
115 | 115 | $html = '<div id="tkt-slctr-request-processor-dv" style="float:left; margin-left:-999em;">'; |
116 | - $html .= '<label for="tkt-slctr-request-processor-email">' . $do_not_enter . '</label>'; |
|
116 | + $html .= '<label for="tkt-slctr-request-processor-email">'.$do_not_enter.'</label>'; |
|
117 | 117 | $html .= '<input type="email" name="tkt-slctr-request-processor-email" value=""/>'; |
118 | 118 | $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="'; |
119 | - if ( EE_Registry::instance()->CFG->registration->use_encryption ) { |
|
120 | - EE_Registry::instance()->load_core( 'EE_Encryption' ); |
|
121 | - $html .= EE_Encryption::instance()->encrypt( time() ); |
|
119 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
120 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
121 | + $html .= EE_Encryption::instance()->encrypt(time()); |
|
122 | 122 | } else { |
123 | 123 | $html .= time(); |
124 | 124 | } |
@@ -136,38 +136,38 @@ discard block |
||
136 | 136 | * It should receive one argument: a boolean indicating |
137 | 137 | * whether the trap was triggered by suspicious timing or not. |
138 | 138 | */ |
139 | - public static function process_bot_trap( $triggered_trap_callback = array() ) { |
|
139 | + public static function process_bot_trap($triggered_trap_callback = array()) { |
|
140 | 140 | // what's your email address Mr. Bot ? |
141 | - $empty_trap = isset( $_REQUEST[ 'tkt-slctr-request-processor-email' ] ) |
|
142 | - && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === '' |
|
141 | + $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
142 | + && $_REQUEST['tkt-slctr-request-processor-email'] === '' |
|
143 | 143 | ? true |
144 | 144 | : false; |
145 | 145 | // get encrypted timestamp for when the form was originally displayed |
146 | - $bot_trap_timestamp = isset( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
147 | - ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
146 | + $bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token']) |
|
147 | + ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token']) |
|
148 | 148 | : ''; |
149 | 149 | // decrypt and convert to absolute integer |
150 | - if ( EE_Registry::instance()->CFG->registration->use_encryption ) { |
|
151 | - EE_Registry::instance()->load_core( 'EE_Encryption' ); |
|
152 | - $bot_trap_timestamp = absint( EE_Encryption::instance()->decrypt( $bot_trap_timestamp ) ); |
|
150 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
151 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
152 | + $bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp)); |
|
153 | 153 | } else { |
154 | - $bot_trap_timestamp = absint( $bot_trap_timestamp ); |
|
154 | + $bot_trap_timestamp = absint($bot_trap_timestamp); |
|
155 | 155 | } |
156 | 156 | // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
157 | - $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < ( time() - HOUR_IN_SECONDS ) |
|
157 | + $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS) |
|
158 | 158 | ? true |
159 | 159 | : false; |
160 | 160 | // are we human ? |
161 | - if ( $empty_trap && ! $suspicious_timing ) { |
|
161 | + if ($empty_trap && ! $suspicious_timing) { |
|
162 | 162 | do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
163 | 163 | return; |
164 | 164 | } |
165 | 165 | // check the given callback is valid first before executing |
166 | - if ( ! is_callable($triggered_trap_callback ) ) { |
|
166 | + if ( ! is_callable($triggered_trap_callback)) { |
|
167 | 167 | // invalid callback so lets just sub in our default. |
168 | - $triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' ); |
|
168 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
169 | 169 | } |
170 | - call_user_func_array($triggered_trap_callback, array( $suspicious_timing ) ); |
|
170 | + call_user_func_array($triggered_trap_callback, array($suspicious_timing)); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test. |
180 | 180 | */ |
181 | - public static function triggered_trap_response( $suspicious_timing ) { |
|
181 | + public static function triggered_trap_response($suspicious_timing) { |
|
182 | 182 | // UH OH... |
183 | 183 | $redirect_url = add_query_arg( |
184 | - array( 'ee' => 'ticket_selection_received' ), |
|
184 | + array('ee' => 'ticket_selection_received'), |
|
185 | 185 | EE_Registry::instance()->CFG->core->reg_page_url() |
186 | 186 | ); |
187 | - if ( $suspicious_timing ) { |
|
187 | + if ($suspicious_timing) { |
|
188 | 188 | $redirect_url = add_query_arg( |
189 | - array( 'ee-notice' => urlencode( esc_html__( 'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso' ) ) ), |
|
189 | + array('ee-notice' => urlencode(esc_html__('We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso'))), |
|
190 | 190 | $redirect_url |
191 | 191 | ); |
192 | 192 | } |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | * @return void |
218 | 218 | */ |
219 | 219 | public static function display_bot_trap_success() { |
220 | - add_filter( 'FHEE__EED_Single_Page_Checkout__run', '__return_false' ); |
|
221 | - $bot_notice = esc_html__( 'Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso' ); |
|
222 | - $bot_notice = isset( $_REQUEST[ 'ee-notice' ] ) && $_REQUEST[ 'ee-notice' ] !== '' ? sanitize_text_field( stripslashes( $_REQUEST[ 'ee-notice' ] ) ) : $bot_notice; |
|
223 | - EE_Registry::instance()->REQ->add_output( EEH_HTML::div( $bot_notice, '', 'ee-attention' ) ); |
|
220 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
221 | + $bot_notice = esc_html__('Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso'); |
|
222 | + $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) : $bot_notice; |
|
223 | + EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -255,20 +255,20 @@ discard block |
||
255 | 255 | 'html_id' => 'bot_trap_settings', |
256 | 256 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
257 | 257 | 'subsections' => array( |
258 | - 'bot_trap_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( esc_html__( 'Bot Trap Settings', 'event_espresso' ) ) ), |
|
258 | + 'bot_trap_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))), |
|
259 | 259 | 'use_bot_trap' => new EE_Yes_No_Input( |
260 | 260 | array( |
261 | - 'html_label_text' => esc_html__( 'Enable Bot Trap', 'event_espresso' ), |
|
262 | - 'html_help_text' => esc_html__( 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso' ), |
|
263 | - 'default' => isset( EE_Registry::instance()->CFG->registration->use_bot_trap ) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true, |
|
261 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
262 | + 'html_help_text' => esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'), |
|
263 | + 'default' => isset(EE_Registry::instance()->CFG->registration->use_bot_trap) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true, |
|
264 | 264 | 'required' => false |
265 | 265 | ) |
266 | 266 | ), |
267 | 267 | 'use_encryption' => new EE_Yes_No_Input( |
268 | 268 | array( |
269 | - 'html_label_text' => esc_html__( 'Encrypt Bot Trap Data', 'event_espresso' ), |
|
270 | - 'html_help_text' => esc_html__( 'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso' ), |
|
271 | - 'default' => isset( EE_Registry::instance()->CFG->registration->use_encryption ) ? EE_Registry::instance()->CFG->registration->use_encryption : true, |
|
269 | + 'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'), |
|
270 | + 'html_help_text' => esc_html__('One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso'), |
|
271 | + 'default' => isset(EE_Registry::instance()->CFG->registration->use_encryption) ? EE_Registry::instance()->CFG->registration->use_encryption : true, |
|
272 | 272 | 'required' => false |
273 | 273 | ) |
274 | 274 | ), |
@@ -286,30 +286,30 @@ discard block |
||
286 | 286 | * @param \EE_Registration_Config $EE_Registration_Config |
287 | 287 | * @return \EE_Registration_Config |
288 | 288 | */ |
289 | - public static function update_bot_trap_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
|
289 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) { |
|
290 | 290 | try { |
291 | 291 | $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
292 | 292 | // if not displaying a form, then check for form submission |
293 | - if ( $bot_trap_settings_form->was_submitted() ) { |
|
293 | + if ($bot_trap_settings_form->was_submitted()) { |
|
294 | 294 | // capture form data |
295 | 295 | $bot_trap_settings_form->receive_form_submission(); |
296 | 296 | // validate form data |
297 | - if ( $bot_trap_settings_form->is_valid() ) { |
|
297 | + if ($bot_trap_settings_form->is_valid()) { |
|
298 | 298 | // grab validated data from form |
299 | 299 | $valid_data = $bot_trap_settings_form->valid_data(); |
300 | - if ( isset( $valid_data[ 'use_bot_trap' ], $valid_data[ 'use_encryption' ] ) ) { |
|
301 | - $EE_Registration_Config->use_bot_trap = $valid_data[ 'use_bot_trap' ]; |
|
302 | - $EE_Registration_Config->use_encryption = $valid_data[ 'use_encryption' ]; |
|
300 | + if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) { |
|
301 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
302 | + $EE_Registration_Config->use_encryption = $valid_data['use_encryption']; |
|
303 | 303 | } else { |
304 | - EE_Error::add_error( esc_html__( 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
304 | + EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
305 | 305 | } |
306 | 306 | } else { |
307 | - if ( $bot_trap_settings_form->submission_error_message() != '' ) { |
|
308 | - EE_Error::add_error( $bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
307 | + if ($bot_trap_settings_form->submission_error_message() != '') { |
|
308 | + EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | } |
312 | - } catch ( EE_Error $e ) { |
|
312 | + } catch (EE_Error $e) { |
|
313 | 313 | $e->get_error(); |
314 | 314 | } |
315 | 315 | return $EE_Registration_Config; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
69 | 69 | * @access public |
70 | 70 | */ |
71 | - public function __construct( $routing = TRUE ) { |
|
72 | - require_once( EE_MODELS . 'EEM_Question.model.php' ); |
|
73 | - require_once( EE_MODELS . 'EEM_Question_Group.model.php' ); |
|
74 | - $this->_question_model= EEM_Question::instance(); |
|
75 | - $this->_question_group_model=EEM_Question_Group::instance(); |
|
76 | - parent::__construct( $routing ); |
|
71 | + public function __construct($routing = TRUE) { |
|
72 | + require_once(EE_MODELS.'EEM_Question.model.php'); |
|
73 | + require_once(EE_MODELS.'EEM_Question_Group.model.php'); |
|
74 | + $this->_question_model = EEM_Question::instance(); |
|
75 | + $this->_question_group_model = EEM_Question_Group::instance(); |
|
76 | + parent::__construct($routing); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | *_set_page_routes |
110 | 110 | */ |
111 | 111 | protected function _set_page_routes() { |
112 | - $qst_id = ! empty( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0; |
|
112 | + $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
113 | 113 | $this->_page_routes = array( |
114 | 114 | 'default' => array( |
115 | 115 | 'func' => '_questions_overview_list_table', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | 'update_question' => array( |
132 | 132 | 'func' => '_insert_or_update_question', |
133 | - 'args' => array('new_question' => FALSE ), |
|
133 | + 'args' => array('new_question' => FALSE), |
|
134 | 134 | 'capability' => 'ee_edit_question', |
135 | 135 | 'obj_id' => $qst_id, |
136 | 136 | 'noheader' => TRUE, |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | 'filename' => 'registration_form_questions_overview_views_bulk_actions_search' |
166 | 166 | ) |
167 | 167 | ), |
168 | - 'help_tour' => array( 'Registration_Form_Questions_Overview_Help_Tour'), |
|
168 | + 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
169 | 169 | 'require_nonce' => FALSE, |
170 | 170 | 'qtips' => array( |
171 | 171 | 'EE_Registration_Form_Tips' |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'filename' => 'registration_form_question_groups' |
185 | 185 | ), |
186 | 186 | ), |
187 | - 'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'), |
|
187 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
188 | 188 | 'require_nonce' => FALSE |
189 | 189 | ), |
190 | 190 | |
@@ -193,16 +193,16 @@ discard block |
||
193 | 193 | 'label' => esc_html__('Edit Question', 'event_espresso'), |
194 | 194 | 'order' => 15, |
195 | 195 | 'persistent' => FALSE, |
196 | - 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
196 | + 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), $this->_current_page_view_url) : $this->_admin_base_url |
|
197 | 197 | ), |
198 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
198 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
199 | 199 | 'help_tabs' => array( |
200 | 200 | 'registration_form_edit_question_group_help_tab' => array( |
201 | 201 | 'title' => esc_html__('Edit Question', 'event_espresso'), |
202 | 202 | 'filename' => 'registration_form_edit_question' |
203 | 203 | ), |
204 | 204 | ), |
205 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
205 | + 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
206 | 206 | 'require_nonce' => FALSE |
207 | 207 | ), |
208 | 208 | ); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | //none of the below group are currently used for Event Categories |
231 | 231 | protected function _add_feature_pointers() {} |
232 | 232 | public function load_scripts_styles() { |
233 | - wp_register_style( 'espresso_registration', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
233 | + wp_register_style('espresso_registration', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
234 | 234 | wp_enqueue_style('espresso_registration'); |
235 | 235 | } |
236 | 236 | public function admin_init() {} |
@@ -246,20 +246,20 @@ discard block |
||
246 | 246 | |
247 | 247 | public function load_scripts_styles_add_question() { |
248 | 248 | $this->load_scripts_styles_forms(); |
249 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
250 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
249 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
250 | + wp_enqueue_script('espresso_registration_form_single'); |
|
251 | 251 | } |
252 | 252 | public function load_scripts_styles_edit_question() { |
253 | 253 | $this->load_scripts_styles_forms(); |
254 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
255 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
254 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
255 | + wp_enqueue_script('espresso_registration_form_single'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
259 | 259 | |
260 | 260 | |
261 | 261 | public function recaptcha_info_help_tab() { |
262 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
262 | + $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php'; |
|
263 | 263 | EEH_Template::display_template($template, array()); |
264 | 264 | } |
265 | 265 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ) |
292 | 292 | ); |
293 | 293 | |
294 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) { |
|
294 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) { |
|
295 | 295 | $this->_views['trash'] = array( |
296 | 296 | 'slug' => 'trash', |
297 | 297 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | */ |
310 | 310 | protected function _questions_groups_preview() { |
311 | 311 | $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
312 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__( 'Preview Question Groups Overview List Table screenshot', 'event_espresso' ) . '" />'; |
|
313 | - $this->_template_args['preview_text'] = '<strong>'.esc_html__( 'Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso' ).'</strong>'; |
|
314 | - $this->display_admin_caf_preview_page( 'question_groups_tab' ); |
|
312 | + $this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', 'event_espresso').'" />'; |
|
313 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__('Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso').'</strong>'; |
|
314 | + $this->display_admin_caf_preview_page('question_groups_tab'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -322,58 +322,58 @@ discard block |
||
322 | 322 | * @param \EEM_Base $model |
323 | 323 | * @return array where each key is the name of a model's field/db column, and each value is its value. |
324 | 324 | */ |
325 | - protected function _set_column_values_for(EEM_Base $model){ |
|
326 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
327 | - $set_column_values=array(); |
|
325 | + protected function _set_column_values_for(EEM_Base $model) { |
|
326 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
327 | + $set_column_values = array(); |
|
328 | 328 | |
329 | 329 | //some initial checks for proper values. |
330 | 330 | //if QST_admin_only, then no matter what QST_required is we disable. |
331 | - if ( !empty( $this->_req_data['QST_admin_only'] ) ) { |
|
331 | + if ( ! empty($this->_req_data['QST_admin_only'])) { |
|
332 | 332 | $this->_req_data['QST_required'] = 0; |
333 | 333 | } |
334 | - foreach($model->field_settings() as $fieldName=>$settings){ |
|
334 | + foreach ($model->field_settings() as $fieldName=>$settings) { |
|
335 | 335 | // basically if QSG_identifier is empty or not set |
336 | - if ( $fieldName === 'QSG_identifier' && ( isset( $this->_req_data['QSG_identifier'] ) && empty( $this->_req_data['QSG_identifier'] ) )) { |
|
337 | - $QSG_name = isset( $this->_req_data['QSG_name'] ) ? $this->_req_data['QSG_name'] : '' ; |
|
338 | - $set_column_values[$fieldName] = sanitize_title($QSG_name ) . '-' . uniqid( '', true ); |
|
336 | + if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
337 | + $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
338 | + $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid('', true); |
|
339 | 339 | // dd($set_column_values); |
340 | 340 | } |
341 | 341 | //if the admin label is blank, use a slug version of the question text |
342 | - else if ( $fieldName === 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] ) )) { |
|
343 | - $QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ; |
|
344 | - $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10)); |
|
342 | + else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
343 | + $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
344 | + $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
348 | - else if ( $fieldName === 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
348 | + else if ($fieldName === 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) { |
|
349 | 349 | $set_column_values[$fieldName] = 0; |
350 | 350 | } |
351 | 351 | |
352 | - else if ( $fieldName === 'QST_max' ) { |
|
352 | + else if ($fieldName === 'QST_max') { |
|
353 | 353 | $qst_system = EEM_Question::instance()->get_var( |
354 | 354 | array( |
355 | 355 | array( |
356 | - 'QST_ID' => isset( $this->_req_data[ 'QST_ID' ] ) ? $this->_req_data[ 'QST_ID' ] : 0 |
|
356 | + 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0 |
|
357 | 357 | ) |
358 | 358 | ), |
359 | 359 | 'QST_system' ); |
360 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question( $qst_system ); |
|
361 | - if( empty( $this->_req_data[ 'QST_max' ] ) || |
|
362 | - $this->_req_data[ 'QST_max' ] > $max_max ) { |
|
363 | - $set_column_values[ $fieldName ] = $max_max; |
|
360 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
361 | + if (empty($this->_req_data['QST_max']) || |
|
362 | + $this->_req_data['QST_max'] > $max_max) { |
|
363 | + $set_column_values[$fieldName] = $max_max; |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | 368 | //only add a property to the array if it's not null (otherwise the model should just use the default value) |
369 | - if( |
|
370 | - ! isset( $set_column_values[ $fieldName ] ) && |
|
371 | - isset($this->_req_data[$fieldName] ) ){ |
|
372 | - $set_column_values[$fieldName]=$this->_req_data[$fieldName]; |
|
369 | + if ( |
|
370 | + ! isset($set_column_values[$fieldName]) && |
|
371 | + isset($this->_req_data[$fieldName]) ) { |
|
372 | + $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
376 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
376 | + return $set_column_values; //validation fo this data to be performed by the model before insertion. |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -392,39 +392,39 @@ discard block |
||
392 | 392 | * _edit_question |
393 | 393 | */ |
394 | 394 | protected function _edit_question() { |
395 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
396 | - $ID=isset( $this->_req_data['QST_ID'] ) && ! empty( $this->_req_data['QST_ID'] ) ? absint( $this->_req_data['QST_ID'] ) : FALSE; |
|
395 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
396 | + $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE; |
|
397 | 397 | |
398 | - switch( $this->_req_action ) { |
|
398 | + switch ($this->_req_action) { |
|
399 | 399 | case 'add_question' : |
400 | - $this->_admin_page_title = esc_html__( 'Add Question', 'event_espresso' ); |
|
400 | + $this->_admin_page_title = esc_html__('Add Question', 'event_espresso'); |
|
401 | 401 | break; |
402 | 402 | case 'edit_question' : |
403 | - $this->_admin_page_title = esc_html__( 'Edit Question', 'event_espresso' ); |
|
403 | + $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso'); |
|
404 | 404 | break; |
405 | 405 | default : |
406 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
406 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | // add PRC_ID to title if editing |
410 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
411 | - if($ID){ |
|
412 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
413 | - $additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
410 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
411 | + if ($ID) { |
|
412 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
413 | + $additional_hidden_fields = array('QST_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
414 | 414 | $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
415 | - }else{ |
|
416 | - $question= EE_Question::new_instance(); |
|
415 | + } else { |
|
416 | + $question = EE_Question::new_instance(); |
|
417 | 417 | $question->set_order_to_latest(); |
418 | 418 | $this->_set_add_edit_form_tags('insert_question'); |
419 | 419 | } |
420 | - $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category( $question->type() ) : $this->_question_model->allowed_question_types(); |
|
421 | - $this->_template_args['QST_ID']=$ID; |
|
422 | - $this->_template_args['question']=$question; |
|
423 | - $this->_template_args['question_types']= $question_types; |
|
424 | - $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() ); |
|
420 | + $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
421 | + $this->_template_args['QST_ID'] = $ID; |
|
422 | + $this->_template_args['question'] = $question; |
|
423 | + $this->_template_args['question_types'] = $question_types; |
|
424 | + $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID()); |
|
425 | 425 | $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
426 | - $this->_set_publish_post_box_vars( 'id', $ID ); |
|
427 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
426 | + $this->_set_publish_post_box_vars('id', $ID); |
|
427 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', $this->_template_args, TRUE); |
|
428 | 428 | |
429 | 429 | // the details template wrapper |
430 | 430 | $this->display_admin_page_with_sidebar(); |
@@ -439,18 +439,18 @@ discard block |
||
439 | 439 | EE_Registry::instance()->load_helper('HTML'); |
440 | 440 | $descriptions = ''; |
441 | 441 | $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
442 | - foreach ( $question_type_descriptions as $type => $question_type_description ) { |
|
443 | - if ( $type == 'HTML_TEXTAREA' ) { |
|
442 | + foreach ($question_type_descriptions as $type => $question_type_description) { |
|
443 | + if ($type == 'HTML_TEXTAREA') { |
|
444 | 444 | $html = new EE_Simple_HTML_Validation_Strategy(); |
445 | 445 | $question_type_description .= sprintf( |
446 | - esc_html__( '%1$s(allowed tags: %2$s)', 'event_espresso' ), |
|
446 | + esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
447 | 447 | '<br/>', |
448 | 448 | $html->get_list_of_allowed_tags() |
449 | 449 | ); |
450 | 450 | } |
451 | 451 | $descriptions .= EEH_HTML::p( |
452 | 452 | $question_type_description, |
453 | - 'question_type_description-' . $type, |
|
453 | + 'question_type_description-'.$type, |
|
454 | 454 | 'question_type_description description', |
455 | 455 | 'display:none;' |
456 | 456 | ); |
@@ -464,58 +464,58 @@ discard block |
||
464 | 464 | * @param bool|true $new_question |
465 | 465 | * @throws \EE_Error |
466 | 466 | */ |
467 | - protected function _insert_or_update_question( $new_question = TRUE) { |
|
468 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
469 | - $set_column_values=$this->_set_column_values_for($this->_question_model); |
|
470 | - if($new_question){ |
|
471 | - $ID=$this->_question_model->insert($set_column_values); |
|
467 | + protected function _insert_or_update_question($new_question = TRUE) { |
|
468 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
469 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
470 | + if ($new_question) { |
|
471 | + $ID = $this->_question_model->insert($set_column_values); |
|
472 | 472 | $success = $ID ? true : false; |
473 | 473 | $action_desc = 'added'; |
474 | - }else{ |
|
475 | - $ID=absint($this->_req_data['QST_ID']); |
|
476 | - $pk=$this->_question_model->primary_key_name(); |
|
477 | - $wheres=array($pk=>$ID); |
|
474 | + } else { |
|
475 | + $ID = absint($this->_req_data['QST_ID']); |
|
476 | + $pk = $this->_question_model->primary_key_name(); |
|
477 | + $wheres = array($pk=>$ID); |
|
478 | 478 | unset($set_column_values[$pk]); |
479 | - $success= $this->_question_model->update($set_column_values,array($wheres)); |
|
480 | - $action_desc='updated'; |
|
479 | + $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
480 | + $action_desc = 'updated'; |
|
481 | 481 | } |
482 | 482 | |
483 | - if ($ID){ |
|
483 | + if ($ID) { |
|
484 | 484 | //save the related options |
485 | 485 | //trash removed options, save old ones |
486 | 486 | //get list of all options |
487 | 487 | /** @type EE_Question $question */ |
488 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
489 | - $options=$question->options(); |
|
490 | - if(! empty($options)){ |
|
491 | - foreach($options as $option_ID=>$option){ |
|
492 | - $option_req_index=$this->_get_option_req_data_index($option_ID); |
|
493 | - if($option_req_index!==FALSE){ |
|
488 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
489 | + $options = $question->options(); |
|
490 | + if ( ! empty($options)) { |
|
491 | + foreach ($options as $option_ID=>$option) { |
|
492 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
493 | + if ($option_req_index !== FALSE) { |
|
494 | 494 | $option->save($this->_req_data['question_options'][$option_req_index]); |
495 | - }else{ |
|
495 | + } else { |
|
496 | 496 | //not found, remove it |
497 | 497 | $option->delete(); |
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
501 | 501 | //save new related options |
502 | - foreach($this->_req_data['question_options'] as $index=>$option_req_data){ |
|
503 | - if( empty($option_req_data['QSO_ID'] ) && ( ( isset( $option_req_data['QSO_value'] ) && $option_req_data['QSO_value'] !== '' ) || ! empty( $option_req_data['QSO_desc'] ) ) ) {//no ID! save it! |
|
504 | - if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === '' ){ |
|
505 | - $option_req_data['QSO_value']=$option_req_data['QSO_desc']; |
|
502 | + foreach ($this->_req_data['question_options'] as $index=>$option_req_data) { |
|
503 | + if (empty($option_req_data['QSO_ID']) && ((isset($option_req_data['QSO_value']) && $option_req_data['QSO_value'] !== '') || ! empty($option_req_data['QSO_desc']))) {//no ID! save it! |
|
504 | + if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') { |
|
505 | + $option_req_data['QSO_value'] = $option_req_data['QSO_desc']; |
|
506 | 506 | } |
507 | - $new_option=EE_Question_Option::new_instance( array( 'QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
507 | + $new_option = EE_Question_Option::new_instance(array('QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
508 | 508 | $new_option->save(); |
509 | 509 | } |
510 | 510 | } |
511 | 511 | } |
512 | - $query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID ); |
|
513 | - if ( $success !== FALSE ) { |
|
514 | - $msg = $new_question ? sprintf( esc_html__('The %s has been created', 'event_espresso'), $this->_question_model->item_name() ) : sprintf( esc_html__('The %s has been updated', 'event_espresso' ), $this->_question_model->item_name() ); |
|
515 | - EE_Error::add_success( $msg ); |
|
512 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
513 | + if ($success !== FALSE) { |
|
514 | + $msg = $new_question ? sprintf(esc_html__('The %s has been created', 'event_espresso'), $this->_question_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), $this->_question_model->item_name()); |
|
515 | + EE_Error::add_success($msg); |
|
516 | 516 | } |
517 | 517 | |
518 | - $this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE); |
|
518 | + $this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | * @param int $ID of the question option to find |
529 | 529 | * @return int index in question_options array if successful, FALSE if unsuccessful |
530 | 530 | */ |
531 | - protected function _get_option_req_data_index($ID){ |
|
532 | - $req_data_for_question_options=$this->_req_data['question_options']; |
|
533 | - foreach($req_data_for_question_options as $num=>$option_data){ |
|
534 | - if( array_key_exists('QSO_ID',$option_data) && (int)$option_data['QSO_ID'] === $ID ){ |
|
531 | + protected function _get_option_req_data_index($ID) { |
|
532 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
533 | + foreach ($req_data_for_question_options as $num=>$option_data) { |
|
534 | + if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) { |
|
535 | 535 | return $num; |
536 | 536 | } |
537 | 537 | } |
@@ -553,25 +553,25 @@ discard block |
||
553 | 553 | * @param int $current_page |
554 | 554 | * @return array lik EEM_Base::get_all's $query_params parameter |
555 | 555 | */ |
556 | - protected function get_query_params($model, $per_page=10,$current_page=10){ |
|
556 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) { |
|
557 | 557 | $query_params = array(); |
558 | - $offset=($current_page-1)*$per_page; |
|
559 | - $query_params['limit']=array($offset,$per_page); |
|
560 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
558 | + $offset = ($current_page - 1) * $per_page; |
|
559 | + $query_params['limit'] = array($offset, $per_page); |
|
560 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
561 | 561 | $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
562 | 562 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
563 | - $query_params['order_by']=array( $field_to_order_by => $order ); |
|
564 | - $search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null; |
|
565 | - if(! empty($search_string)){ |
|
566 | - if($model instanceof EEM_Question_Group){ |
|
567 | - $query_params[0]=array( |
|
563 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
564 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
565 | + if ( ! empty($search_string)) { |
|
566 | + if ($model instanceof EEM_Question_Group) { |
|
567 | + $query_params[0] = array( |
|
568 | 568 | 'OR'=>array( |
569 | - 'QSG_name'=>array('LIKE',"%$search_string%"), |
|
570 | - 'QSG_desc'=>array('LIKE',"%$search_string%")) |
|
569 | + 'QSG_name'=>array('LIKE', "%$search_string%"), |
|
570 | + 'QSG_desc'=>array('LIKE', "%$search_string%")) |
|
571 | 571 | ); |
572 | - }else{ |
|
573 | - $query_params[0]=array( |
|
574 | - 'QST_display_text'=>array('LIKE',"%$search_string%") |
|
572 | + } else { |
|
573 | + $query_params[0] = array( |
|
574 | + 'QST_display_text'=>array('LIKE', "%$search_string%") |
|
575 | 575 | ); |
576 | 576 | } |
577 | 577 | } |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | * @param bool|false $count |
620 | 620 | * @return \EE_Soft_Delete_Base_Class[]|int |
621 | 621 | */ |
622 | - public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) { |
|
622 | + public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) { |
|
623 | 623 | $QST = EEM_Question::instance(); |
624 | 624 | $query_params = $this->get_query_params($QST, $per_page, $current_page); |
625 | - if ($count){ |
|
626 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
625 | + if ($count) { |
|
626 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
627 | 627 | $results = $QST->count($where); |
628 | - }else{ |
|
628 | + } else { |
|
629 | 629 | $results = $QST->get_all($query_params); |
630 | 630 | } |
631 | 631 | return $results; |
@@ -640,10 +640,10 @@ discard block |
||
640 | 640 | * @param bool|false $count |
641 | 641 | * @return \EE_Soft_Delete_Base_Class[]|int |
642 | 642 | */ |
643 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
644 | - $query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page); |
|
645 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
646 | - $questions =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
643 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
644 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
645 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
646 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
647 | 647 | return $questions; |
648 | 648 | } |
649 | 649 | |
@@ -655,12 +655,12 @@ discard block |
||
655 | 655 | * @param bool|false $count |
656 | 656 | * @return \EE_Soft_Delete_Base_Class[] |
657 | 657 | */ |
658 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
658 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
659 | 659 | /** @type EEM_Question_Group $questionGroupModel */ |
660 | 660 | $questionGroupModel = EEM_Question_Group::instance(); |
661 | 661 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
662 | 662 | return $questionGroupModel->get_all( |
663 | - $this->get_query_params( $questionGroupModel, $per_page, $current_page ) |
|
663 | + $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
664 | 664 | ); |
665 | 665 | } |
666 | 666 |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | 'persistent' => FALSE |
246 | 246 | ), |
247 | 247 | 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
248 | - 'help_tabs' => array( |
|
248 | + 'help_tabs' => array( |
|
249 | 249 | 'registration_form_add_question_help_tab' => array( |
250 | 250 | 'title' => esc_html__('Add Question', 'event_espresso'), |
251 | 251 | 'filename' => 'registration_form_add_question' |
252 | 252 | ), |
253 | 253 | ), |
254 | - 'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'), |
|
254 | + 'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'), |
|
255 | 255 | 'require_nonce' => FALSE |
256 | 256 | ), |
257 | 257 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | 'filename' => 'registration_form_add_question_group' |
269 | 269 | ), |
270 | 270 | ), |
271 | - 'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'), |
|
271 | + 'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'), |
|
272 | 272 | 'require_nonce' => FALSE |
273 | 273 | ), |
274 | 274 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | 'filename' => 'registration_form_edit_question_group' |
287 | 287 | ), |
288 | 288 | ), |
289 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'), |
|
289 | + 'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'), |
|
290 | 290 | 'require_nonce' => FALSE |
291 | 291 | ), |
292 | 292 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | 'filename' => 'registration_form_reg_form_settings' |
306 | 306 | ), |
307 | 307 | ), |
308 | - 'help_tour' => array( 'Registration_Form_Settings_Help_Tour'), |
|
308 | + 'help_tour' => array( 'Registration_Form_Settings_Help_Tour'), |
|
309 | 309 | 'require_nonce' => FALSE |
310 | 310 | ) |
311 | 311 | |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | * @return EE_Form_Section_Proper |
934 | 934 | */ |
935 | 935 | protected function _email_validation_settings_form() { |
936 | - return new EE_Form_Section_Proper( |
|
936 | + return new EE_Form_Section_Proper( |
|
937 | 937 | array( |
938 | 938 | 'name' => 'email_validation_settings', |
939 | 939 | 'html_id' => 'email_validation_settings', |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | ), |
952 | 952 | array( |
953 | 953 | 'html_label_text' => esc_html__( 'Email Validation Level', 'event_espresso' ) |
954 | - . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
954 | + . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
955 | 955 | 'html_help_text' => esc_html__( 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'), |
956 | 956 | 'default' => isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
957 | 957 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
@@ -973,8 +973,8 @@ discard block |
||
973 | 973 | * @return \EE_Registration_Config |
974 | 974 | */ |
975 | 975 | public function update_email_validation_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
976 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
977 | - try { |
|
976 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
977 | + try { |
|
978 | 978 | $email_validation_settings_form = $this->_email_validation_settings_form(); |
979 | 979 | // if not displaying a form, then check for form submission |
980 | 980 | if ( $email_validation_settings_form->was_submitted() ) { |
@@ -985,38 +985,38 @@ discard block |
||
985 | 985 | // grab validated data from form |
986 | 986 | $valid_data = $email_validation_settings_form->valid_data(); |
987 | 987 | if ( isset( $valid_data['email_validation_level'] ) ) { |
988 | - $email_validation_level = $valid_data['email_validation_level']; |
|
989 | - // now if they want to use international email addresses |
|
990 | - if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
991 | - // in case we need to reset their email validation level, |
|
992 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
993 | - if ( $prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
994 | - // if so, then reset it back to "basic" since that is the only other option that, |
|
995 | - // despite offering poor validation, supports i18n email addresses |
|
996 | - $prev_email_validation_level = 'basic'; |
|
997 | - } |
|
998 | - // confirm our i18n email validation will work on the server |
|
999 | - if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1000 | - // or reset email validation level to previous value |
|
1001 | - $email_validation_level = $prev_email_validation_level; |
|
1002 | - } |
|
1003 | - } |
|
1004 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1005 | - } else { |
|
988 | + $email_validation_level = $valid_data['email_validation_level']; |
|
989 | + // now if they want to use international email addresses |
|
990 | + if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
991 | + // in case we need to reset their email validation level, |
|
992 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
993 | + if ( $prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
994 | + // if so, then reset it back to "basic" since that is the only other option that, |
|
995 | + // despite offering poor validation, supports i18n email addresses |
|
996 | + $prev_email_validation_level = 'basic'; |
|
997 | + } |
|
998 | + // confirm our i18n email validation will work on the server |
|
999 | + if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1000 | + // or reset email validation level to previous value |
|
1001 | + $email_validation_level = $prev_email_validation_level; |
|
1002 | + } |
|
1003 | + } |
|
1004 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1005 | + } else { |
|
1006 | 1006 | EE_Error::add_error( |
1007 | 1007 | esc_html__( |
1008 | 1008 | 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
1009 | 1009 | 'event_espresso' |
1010 | 1010 | ), |
1011 | - __FILE__, __FUNCTION__, __LINE__ |
|
1012 | - ); |
|
1011 | + __FILE__, __FUNCTION__, __LINE__ |
|
1012 | + ); |
|
1013 | 1013 | } |
1014 | 1014 | } else { |
1015 | 1015 | if ( $email_validation_settings_form->submission_error_message() !== '' ) { |
1016 | 1016 | EE_Error::add_error( |
1017 | 1017 | $email_validation_settings_form->submission_error_message(), |
1018 | - __FILE__, __FUNCTION__, __LINE__ |
|
1019 | - ); |
|
1018 | + __FILE__, __FUNCTION__, __LINE__ |
|
1019 | + ); |
|
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | } |
@@ -1028,61 +1028,61 @@ discard block |
||
1028 | 1028 | |
1029 | 1029 | |
1030 | 1030 | |
1031 | - /** |
|
1032 | - * confirms that the server's PHP version has the PCRE module enabled, |
|
1033 | - * and that the PCRE version works with our i18n email validation |
|
1034 | - * |
|
1035 | - * @param \EE_Registration_Config $EE_Registration_Config |
|
1036 | - * @param string $email_validation_level |
|
1037 | - * @return bool |
|
1038 | - */ |
|
1039 | - private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1040 | - { |
|
1041 | - // first check that PCRE is enabled |
|
1042 | - if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1043 | - EE_Error::add_error( |
|
1044 | - sprintf( |
|
1045 | - esc_html__( |
|
1046 | - 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1047 | - 'event_espresso' |
|
1048 | - ), |
|
1049 | - '<br />' |
|
1050 | - ), |
|
1051 | - __FILE__, |
|
1052 | - __FUNCTION__, |
|
1053 | - __LINE__ |
|
1054 | - ); |
|
1055 | - return false; |
|
1056 | - } else { |
|
1057 | - // PCRE support is enabled, but let's still |
|
1058 | - // perform a test to see if the server will support it. |
|
1059 | - // but first, save the updated validation level to the config, |
|
1060 | - // so that the validation strategy picks it up. |
|
1061 | - // this will get bumped back down if it doesn't work |
|
1062 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1063 | - try { |
|
1064 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
1065 | - $i18n_email_address = apply_filters( |
|
1066 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1067 | - 'jägerjü[email protected]' |
|
1068 | - ); |
|
1069 | - $email_validator->validate($i18n_email_address); |
|
1070 | - } catch (Exception $e) { |
|
1071 | - EE_Error::add_error( |
|
1072 | - sprintf( |
|
1073 | - esc_html__( |
|
1074 | - 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1075 | - 'event_espresso' |
|
1076 | - ), |
|
1077 | - '<br />', |
|
1078 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1079 | - ), |
|
1080 | - __FILE__, __FUNCTION__, __LINE__ |
|
1081 | - ); |
|
1082 | - return false; |
|
1083 | - } |
|
1084 | - } |
|
1085 | - return true; |
|
1086 | - } |
|
1031 | + /** |
|
1032 | + * confirms that the server's PHP version has the PCRE module enabled, |
|
1033 | + * and that the PCRE version works with our i18n email validation |
|
1034 | + * |
|
1035 | + * @param \EE_Registration_Config $EE_Registration_Config |
|
1036 | + * @param string $email_validation_level |
|
1037 | + * @return bool |
|
1038 | + */ |
|
1039 | + private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1040 | + { |
|
1041 | + // first check that PCRE is enabled |
|
1042 | + if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1043 | + EE_Error::add_error( |
|
1044 | + sprintf( |
|
1045 | + esc_html__( |
|
1046 | + 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1047 | + 'event_espresso' |
|
1048 | + ), |
|
1049 | + '<br />' |
|
1050 | + ), |
|
1051 | + __FILE__, |
|
1052 | + __FUNCTION__, |
|
1053 | + __LINE__ |
|
1054 | + ); |
|
1055 | + return false; |
|
1056 | + } else { |
|
1057 | + // PCRE support is enabled, but let's still |
|
1058 | + // perform a test to see if the server will support it. |
|
1059 | + // but first, save the updated validation level to the config, |
|
1060 | + // so that the validation strategy picks it up. |
|
1061 | + // this will get bumped back down if it doesn't work |
|
1062 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1063 | + try { |
|
1064 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
1065 | + $i18n_email_address = apply_filters( |
|
1066 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1067 | + 'jägerjü[email protected]' |
|
1068 | + ); |
|
1069 | + $email_validator->validate($i18n_email_address); |
|
1070 | + } catch (Exception $e) { |
|
1071 | + EE_Error::add_error( |
|
1072 | + sprintf( |
|
1073 | + esc_html__( |
|
1074 | + 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1075 | + 'event_espresso' |
|
1076 | + ), |
|
1077 | + '<br />', |
|
1078 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1079 | + ), |
|
1080 | + __FILE__, __FUNCTION__, __LINE__ |
|
1081 | + ); |
|
1082 | + return false; |
|
1083 | + } |
|
1084 | + } |
|
1085 | + return true; |
|
1086 | + } |
|
1087 | 1087 | |
1088 | 1088 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ){ |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
37 | 37 | * @access public |
38 | 38 | */ |
39 | - public function __construct( $routing = TRUE ) { |
|
40 | - define( 'REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS ); |
|
41 | - define( 'REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS ); |
|
42 | - define( 'REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/' ); |
|
43 | - define( 'REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS ); |
|
44 | - define( 'REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/' ); |
|
45 | - parent::__construct( $routing ); |
|
39 | + public function __construct($routing = TRUE) { |
|
40 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS); |
|
41 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS); |
|
42 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/'); |
|
43 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS); |
|
44 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/'); |
|
45 | + parent::__construct($routing); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | |
53 | 53 | protected function _extend_page_config() { |
54 | 54 | $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
55 | - $qst_id = ! empty( $this->_req_data['QST_ID'] ) && ! is_array( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0; |
|
56 | - $qsg_id = ! empty( $this->_req_data['QSG_ID'] ) && ! is_array( $this->_req_data['QSG_ID'] ) ? $this->_req_data['QSG_ID'] : 0; |
|
55 | + $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
56 | + $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0; |
|
57 | 57 | |
58 | 58 | $new_page_routes = array( |
59 | 59 | 'question_groups' => array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'func' => '_trash_or_restore_questions', |
87 | 87 | 'capability' => 'ee_delete_question', |
88 | 88 | 'obj_id' => $qst_id, |
89 | - 'args' => array( 'trash' => FALSE ), |
|
89 | + 'args' => array('trash' => FALSE), |
|
90 | 90 | 'noheader' => TRUE |
91 | 91 | ), |
92 | 92 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | 'trash_question_group' => array( |
147 | 147 | 'func' => '_trash_or_restore_question_groups', |
148 | - 'args' => array( 'trash' => TRUE ), |
|
148 | + 'args' => array('trash' => TRUE), |
|
149 | 149 | 'capability' => 'ee_delete_question_group', |
150 | 150 | 'obj_id' => $qsg_id, |
151 | 151 | 'noheader' => TRUE |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | 'restore_question_group' => array( |
155 | 155 | 'func' => '_trash_or_restore_question_groups', |
156 | - 'args' => array( 'trash' => FALSE ), |
|
156 | + 'args' => array('trash' => FALSE), |
|
157 | 157 | 'capability' => 'ee_delete_question_group', |
158 | 158 | 'obj_id' => $qsg_id, |
159 | 159 | 'noheader' => TRUE |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | 'update_question_group' => array( |
170 | 170 | 'func' => '_insert_or_update_question_group', |
171 | - 'args' => array('new_question_group' => FALSE ), |
|
171 | + 'args' => array('new_question_group' => FALSE), |
|
172 | 172 | 'capability' => 'ee_edit_question_group', |
173 | 173 | 'obj_id' => $qsg_id, |
174 | 174 | 'noheader' => TRUE, |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | 'noheader' => TRUE |
207 | 207 | ), |
208 | 208 | ); |
209 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
209 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
210 | 210 | |
211 | 211 | $new_page_config = array( |
212 | 212 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | 'filename' => 'registration_form_question_groups_views_bulk_actions_search' |
231 | 231 | ), |
232 | 232 | ), |
233 | - 'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'), |
|
233 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
234 | 234 | 'metaboxes' => $this->_default_espresso_metaboxes, |
235 | 235 | 'require_nonce' => FALSE, |
236 | 236 | 'qtips' => array( |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | 'order' => 5, |
245 | 245 | 'persistent' => FALSE |
246 | 246 | ), |
247 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
247 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
248 | 248 | 'help_tabs' => array( |
249 | 249 | 'registration_form_add_question_help_tab' => array( |
250 | 250 | 'title' => esc_html__('Add Question', 'event_espresso'), |
251 | 251 | 'filename' => 'registration_form_add_question' |
252 | 252 | ), |
253 | 253 | ), |
254 | - 'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'), |
|
254 | + 'help_tour' => array('Registration_Form_Add_Question_Help_Tour'), |
|
255 | 255 | 'require_nonce' => FALSE |
256 | 256 | ), |
257 | 257 | |
@@ -261,14 +261,14 @@ discard block |
||
261 | 261 | 'order' => 5, |
262 | 262 | 'persistent' => FALSE |
263 | 263 | ), |
264 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
264 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
265 | 265 | 'help_tabs' => array( |
266 | 266 | 'registration_form_add_question_group_help_tab' => array( |
267 | 267 | 'title' => esc_html__('Add Question Group', 'event_espresso'), |
268 | 268 | 'filename' => 'registration_form_add_question_group' |
269 | 269 | ), |
270 | 270 | ), |
271 | - 'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'), |
|
271 | + 'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'), |
|
272 | 272 | 'require_nonce' => FALSE |
273 | 273 | ), |
274 | 274 | |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
278 | 278 | 'order' => 5, |
279 | 279 | 'persistent' => FALSE, |
280 | - 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
280 | + 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']), $this->_current_page_view_url) : $this->_admin_base_url |
|
281 | 281 | ), |
282 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
282 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
283 | 283 | 'help_tabs' => array( |
284 | 284 | 'registration_form_edit_question_group_help_tab' => array( |
285 | 285 | 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
286 | 286 | 'filename' => 'registration_form_edit_question_group' |
287 | 287 | ), |
288 | 288 | ), |
289 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'), |
|
289 | + 'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'), |
|
290 | 290 | 'require_nonce' => FALSE |
291 | 291 | ), |
292 | 292 | |
@@ -298,19 +298,19 @@ discard block |
||
298 | 298 | 'labels' => array( |
299 | 299 | 'publishbox' => esc_html__('Update Settings', 'event_espresso') |
300 | 300 | ), |
301 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
301 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
302 | 302 | 'help_tabs' => array( |
303 | 303 | 'registration_form_reg_form_settings_help_tab' => array( |
304 | 304 | 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
305 | 305 | 'filename' => 'registration_form_reg_form_settings' |
306 | 306 | ), |
307 | 307 | ), |
308 | - 'help_tour' => array( 'Registration_Form_Settings_Help_Tour'), |
|
308 | + 'help_tour' => array('Registration_Form_Settings_Help_Tour'), |
|
309 | 309 | 'require_nonce' => FALSE |
310 | 310 | ) |
311 | 311 | |
312 | 312 | ); |
313 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
313 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
314 | 314 | |
315 | 315 | //change the list table we're going to use so it's the NEW list table! |
316 | 316 | $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
325 | 325 | 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
326 | 326 | ); |
327 | - $this->_labels['buttons'] = array_merge( $this->_labels['buttons'], $new_labels ); |
|
327 | + $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
328 | 328 | |
329 | 329 | } |
330 | 330 | |
@@ -333,14 +333,14 @@ discard block |
||
333 | 333 | |
334 | 334 | |
335 | 335 | protected function _ajax_hooks() { |
336 | - add_action('wp_ajax_espresso_update_question_group_order', array( $this, 'update_question_group_order' )); |
|
336 | + add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
340 | 340 | |
341 | 341 | |
342 | 342 | public function load_scripts_styles_question_groups() { |
343 | - wp_enqueue_script( 'espresso_ajax_table_sorting' ); |
|
343 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @return void |
362 | 362 | */ |
363 | 363 | public function load_sortable_question_script() { |
364 | - wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
364 | + wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
365 | 365 | wp_enqueue_script('ee-question-sortable'); |
366 | 366 | } |
367 | 367 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | ) |
381 | 381 | ); |
382 | 382 | |
383 | - if ( EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) { |
|
383 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) { |
|
384 | 384 | $this->_views['trash'] = array( |
385 | 385 | 'slug' => 'trash', |
386 | 386 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | ) |
411 | 411 | ); |
412 | 412 | |
413 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_groups', 'espresso_registration_form_trash_question_groups' ) ) { |
|
413 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', 'espresso_registration_form_trash_question_groups')) { |
|
414 | 414 | $this->_views['trash'] = array( |
415 | 415 | 'slug' => 'trash', |
416 | 416 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -446,24 +446,24 @@ discard block |
||
446 | 446 | |
447 | 447 | |
448 | 448 | |
449 | - protected function _delete_question(){ |
|
450 | - $success = $this->_delete_items( $this->_question_model ); |
|
449 | + protected function _delete_question() { |
|
450 | + $success = $this->_delete_items($this->_question_model); |
|
451 | 451 | $this->_redirect_after_action( |
452 | 452 | $success, |
453 | - $this->_question_model->item_name( $success ), |
|
453 | + $this->_question_model->item_name($success), |
|
454 | 454 | 'deleted', |
455 | - array( 'action' => 'default', 'status' => 'all' ) |
|
455 | + array('action' => 'default', 'status' => 'all') |
|
456 | 456 | ); |
457 | 457 | } |
458 | 458 | |
459 | 459 | |
460 | 460 | protected function _delete_questions() { |
461 | - $success = $this->_delete_items( $this->_question_model ); |
|
461 | + $success = $this->_delete_items($this->_question_model); |
|
462 | 462 | $this->_redirect_after_action( |
463 | 463 | $success, |
464 | - $this->_question_model->item_name( $success ), |
|
464 | + $this->_question_model->item_name($success), |
|
465 | 465 | 'deleted permanently', |
466 | - array( 'action' => 'default', 'status' => 'trash' ) |
|
466 | + array('action' => 'default', 'status' => 'trash') |
|
467 | 467 | ); |
468 | 468 | } |
469 | 469 | |
@@ -474,26 +474,26 @@ discard block |
||
474 | 474 | * @param EEM_Soft_Delete_Base $model |
475 | 475 | * @return int number of items deleted permanently |
476 | 476 | */ |
477 | - private function _delete_items(EEM_Soft_Delete_Base $model){ |
|
477 | + private function _delete_items(EEM_Soft_Delete_Base $model) { |
|
478 | 478 | $success = 0; |
479 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
480 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
479 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
480 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
481 | 481 | // if array has more than one element than success message should be plural |
482 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
482 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
483 | 483 | // cycle thru bulk action checkboxes |
484 | - while (list( $ID, $value ) = each($this->_req_data['checkbox'])) { |
|
485 | - if ( ! $this->_delete_item( $ID, $model ) ) { |
|
484 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
485 | + if ( ! $this->_delete_item($ID, $model)) { |
|
486 | 486 | $success = 0; |
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | - }elseif( !empty($this->_req_data['QSG_ID'])){ |
|
491 | - $success = $this->_delete_item( $this->_req_data['QSG_ID'], $model ); |
|
490 | + }elseif ( ! empty($this->_req_data['QSG_ID'])) { |
|
491 | + $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
492 | 492 | |
493 | - }elseif( !empty($this->_req_data['QST_ID'])){ |
|
494 | - $success = $this->_delete_item( $this->_req_data['QST_ID'], $model ); |
|
495 | - }else{ |
|
496 | - EE_Error::add_error( sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ ); |
|
493 | + }elseif ( ! empty($this->_req_data['QST_ID'])) { |
|
494 | + $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
495 | + } else { |
|
496 | + EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__); |
|
497 | 497 | } |
498 | 498 | return $success; |
499 | 499 | } |
@@ -504,11 +504,11 @@ discard block |
||
504 | 504 | * @param EEM_Soft_Delete_Base $model |
505 | 505 | * @return boolean |
506 | 506 | */ |
507 | - protected function _delete_item( $id, $model ) { |
|
508 | - if( $model instanceof EEM_Question ) { |
|
509 | - EEM_Question_Option::instance()->delete_permanently( array( array( 'QST_ID' => absint( $id ) ) ) ); |
|
507 | + protected function _delete_item($id, $model) { |
|
508 | + if ($model instanceof EEM_Question) { |
|
509 | + EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
510 | 510 | } |
511 | - return $model->delete_permanently_by_ID( absint( $id ) ); |
|
511 | + return $model->delete_permanently_by_ID(absint($id)); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -520,41 +520,41 @@ discard block |
||
520 | 520 | |
521 | 521 | |
522 | 522 | |
523 | - protected function _edit_question_group( $type = 'add' ) { |
|
524 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
525 | - $ID=isset( $this->_req_data['QSG_ID'] ) && ! empty( $this->_req_data['QSG_ID'] ) ? absint( $this->_req_data['QSG_ID'] ) : FALSE; |
|
523 | + protected function _edit_question_group($type = 'add') { |
|
524 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
525 | + $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : FALSE; |
|
526 | 526 | |
527 | - switch( $this->_req_action ) { |
|
527 | + switch ($this->_req_action) { |
|
528 | 528 | case 'add_question_group' : |
529 | - $this->_admin_page_title = esc_html__( 'Add Question Group', 'event_espresso' ); |
|
529 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
530 | 530 | break; |
531 | 531 | case 'edit_question_group' : |
532 | - $this->_admin_page_title = esc_html__( 'Edit Question Group', 'event_espresso' ); |
|
532 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
533 | 533 | break; |
534 | 534 | default : |
535 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
535 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
536 | 536 | } |
537 | 537 | // add ID to title if editing |
538 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
539 | - if($ID){ |
|
538 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
539 | + if ($ID) { |
|
540 | 540 | /** @var EE_Question_Group $questionGroup */ |
541 | - $questionGroup=$this->_question_group_model->get_one_by_ID( $ID); |
|
542 | - $additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
541 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
542 | + $additional_hidden_fields = array('QSG_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
543 | 543 | $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
544 | - }else{ |
|
544 | + } else { |
|
545 | 545 | /** @var EE_Question_Group $questionGroup */ |
546 | 546 | $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
547 | 547 | $questionGroup->set_order_to_latest(); |
548 | 548 | $this->_set_add_edit_form_tags('insert_question_group'); |
549 | 549 | } |
550 | 550 | $this->_template_args['values'] = $this->_yes_no_values; |
551 | - $this->_template_args['all_questions']=$questionGroup->questions_in_and_not_in_group(); |
|
552 | - $this->_template_args['QSG_ID']=$ID ? $ID : TRUE; |
|
553 | - $this->_template_args['question_group']=$questionGroup; |
|
551 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
552 | + $this->_template_args['QSG_ID'] = $ID ? $ID : TRUE; |
|
553 | + $this->_template_args['question_group'] = $questionGroup; |
|
554 | 554 | |
555 | - $redirect_URL = add_query_arg( array( 'action' => 'question_groups'), $this->_admin_base_url ); |
|
556 | - $this->_set_publish_post_box_vars( 'id', $ID, FALSE, $redirect_URL ); |
|
557 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
555 | + $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
556 | + $this->_set_publish_post_box_vars('id', $ID, FALSE, $redirect_URL); |
|
557 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php', $this->_template_args, TRUE); |
|
558 | 558 | |
559 | 559 | // the details template wrapper |
560 | 560 | $this->display_admin_page_with_sidebar(); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | |
566 | 566 | protected function _delete_question_groups() { |
567 | 567 | $success = $this->_delete_items($this->_question_group_model); |
568 | - $this->_redirect_after_action( $success, $this->_question_group_model->item_name($success), 'deleted permanently', array( 'action'=>'question_groups', 'status'=>'trash' )); |
|
568 | + $this->_redirect_after_action($success, $this->_question_group_model->item_name($success), 'deleted permanently', array('action'=>'question_groups', 'status'=>'trash')); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -573,71 +573,71 @@ discard block |
||
573 | 573 | /** |
574 | 574 | * @param bool $new_question_group |
575 | 575 | */ |
576 | - protected function _insert_or_update_question_group( $new_question_group = TRUE) { |
|
577 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
578 | - $set_column_values=$this->_set_column_values_for($this->_question_group_model); |
|
579 | - if ( $new_question_group ){ |
|
576 | + protected function _insert_or_update_question_group($new_question_group = TRUE) { |
|
577 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
578 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
579 | + if ($new_question_group) { |
|
580 | 580 | $QSG_ID = $this->_question_group_model->insert($set_column_values); |
581 | 581 | $success = $QSG_ID ? 1 : 0; |
582 | 582 | } else { |
583 | 583 | $QSG_ID = absint($this->_req_data['QSG_ID']); |
584 | - unset( $set_column_values[ 'QSG_ID' ] ); |
|
585 | - $success= $this->_question_group_model->update( $set_column_values, array( array( 'QSG_ID' => $QSG_ID ))); |
|
584 | + unset($set_column_values['QSG_ID']); |
|
585 | + $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
586 | 586 | } |
587 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( EEM_Attendee::system_question_phone ); |
|
587 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone); |
|
588 | 588 | // update the existing related questions |
589 | 589 | // BUT FIRST... delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group) |
590 | - if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ] )) { |
|
590 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
591 | 591 | // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
592 | - EEM_Question_Group_Question::instance()->delete( array( array( 'QST_ID' => $phone_question_id, 'QSG_ID' => array( '!=', $QSG_ID )))); |
|
592 | + EEM_Question_Group_Question::instance()->delete(array(array('QST_ID' => $phone_question_id, 'QSG_ID' => array('!=', $QSG_ID)))); |
|
593 | 593 | } |
594 | 594 | /** @type EE_Question_Group $question_group */ |
595 | - $question_group=$this->_question_group_model->get_one_by_ID( $QSG_ID ); |
|
595 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
596 | 596 | $questions = $question_group->questions(); |
597 | 597 | // make sure system phone question is added to list of questions for this group |
598 | - if ( ! isset( $questions[$phone_question_id ] )) { |
|
599 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID( $phone_question_id ); |
|
598 | + if ( ! isset($questions[$phone_question_id])) { |
|
599 | + $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
600 | 600 | } |
601 | 601 | |
602 | - foreach( $questions as $question_ID => $question ){ |
|
602 | + foreach ($questions as $question_ID => $question) { |
|
603 | 603 | // first we always check for order. |
604 | - if ( ! empty( $this->_req_data['question_orders'][ $question_ID ] ) ){ |
|
604 | + if ( ! empty($this->_req_data['question_orders'][$question_ID])) { |
|
605 | 605 | //update question order |
606 | - $question_group->update_question_order( $question_ID, $this->_req_data['question_orders'][ $question_ID ] ); |
|
606 | + $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | // then we always check if adding or removing. |
610 | - if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ] )) { |
|
611 | - $question_group->add_question( $question_ID ); |
|
610 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
611 | + $question_group->add_question($question_ID); |
|
612 | 612 | } else { |
613 | 613 | // not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it) |
614 | 614 | if ( |
615 | 615 | in_array( |
616 | 616 | $question->system_ID(), |
617 | - EEM_Question::instance()->required_system_questions_in_system_question_group( $question_group->system_group() ) |
|
617 | + EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group()) |
|
618 | 618 | ) |
619 | 619 | ) { |
620 | 620 | continue; |
621 | 621 | } else { |
622 | - $question_group->remove_question( $question_ID ); |
|
622 | + $question_group->remove_question($question_ID); |
|
623 | 623 | } |
624 | 624 | } |
625 | 625 | } |
626 | 626 | // save new related questions |
627 | - if ( isset( $this->_req_data['questions'] )) { |
|
628 | - foreach( $this->_req_data['questions'] as $QST_ID ){ |
|
629 | - $question_group->add_question( $QST_ID ); |
|
630 | - if ( isset( $this->_req_data['question_orders'][ $QST_ID ] )) { |
|
631 | - $question_group->update_question_order( $QST_ID, $this->_req_data['question_orders'][ $QST_ID ] ); |
|
627 | + if (isset($this->_req_data['questions'])) { |
|
628 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
629 | + $question_group->add_question($QST_ID); |
|
630 | + if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
631 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | } |
635 | 635 | |
636 | - if ( $success !== FALSE ) { |
|
637 | - $msg = $new_question_group ? sprintf( esc_html__('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name() ) : sprintf( esc_html__('The %s has been updated', 'event_espresso' ), $this->_question_group_model->item_name() ); |
|
638 | - EE_Error::add_success( $msg ); |
|
636 | + if ($success !== FALSE) { |
|
637 | + $msg = $new_question_group ? sprintf(esc_html__('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), $this->_question_group_model->item_name()); |
|
638 | + EE_Error::add_success($msg); |
|
639 | 639 | } |
640 | - $this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group','QSG_ID'=>$QSG_ID), TRUE); |
|
640 | + $this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group', 'QSG_ID'=>$QSG_ID), TRUE); |
|
641 | 641 | |
642 | 642 | } |
643 | 643 | |
@@ -645,20 +645,20 @@ discard block |
||
645 | 645 | * duplicates a question and all its question options and redirects to the new question. |
646 | 646 | */ |
647 | 647 | public function _duplicate_question() { |
648 | - $question_ID = (int)$this->_req_data[ 'QST_ID' ]; |
|
649 | - $question = EEM_Question::instance()->get_one_by_ID( $question_ID ); |
|
650 | - if( $question instanceof EE_Question ) { |
|
648 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
649 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
650 | + if ($question instanceof EE_Question) { |
|
651 | 651 | $new_question = $question->duplicate(); |
652 | - if( $new_question instanceof EE_Question ) { |
|
653 | - $this->_redirect_after_action( true, esc_html__( 'Question', 'event_espresso' ), esc_html__( 'Duplicated', 'event_espresso' ), array('action'=>'edit_question', 'QST_ID' => $new_question->ID() ), TRUE); |
|
652 | + if ($new_question instanceof EE_Question) { |
|
653 | + $this->_redirect_after_action(true, esc_html__('Question', 'event_espresso'), esc_html__('Duplicated', 'event_espresso'), array('action'=>'edit_question', 'QST_ID' => $new_question->ID()), TRUE); |
|
654 | 654 | } else { |
655 | 655 | global $wpdb; |
656 | - EE_Error::add_error( sprintf( esc_html__( 'Could not duplicate question with ID %1$d because: %2$s', 'event_espresso' ), $question_ID, $wpdb->last_error ), __FILE__, __FUNCTION__, __LINE__ ); |
|
657 | - $this->_redirect_after_action(false, '', '', array('action'=>'default'), false ); |
|
656 | + EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %1$d because: %2$s', 'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__); |
|
657 | + $this->_redirect_after_action(false, '', '', array('action'=>'default'), false); |
|
658 | 658 | } |
659 | 659 | } else { |
660 | - EE_Error::add_error( sprintf( esc_html__( 'Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso' ), $question_ID ), __FILE__, __FUNCTION__, __LINE__ ); |
|
661 | - $this->_redirect_after_action( false, '', '', array( 'action' => 'default' ), false ); |
|
660 | + EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__); |
|
661 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
662 | 662 | } |
663 | 663 | } |
664 | 664 | |
@@ -667,8 +667,8 @@ discard block |
||
667 | 667 | /** |
668 | 668 | * @param bool $trash |
669 | 669 | */ |
670 | - protected function _trash_or_restore_question_groups( $trash = TRUE) { |
|
671 | - $this->_trash_or_restore_items( $this->_question_group_model, $trash ); |
|
670 | + protected function _trash_or_restore_question_groups($trash = TRUE) { |
|
671 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | |
@@ -676,9 +676,9 @@ discard block |
||
676 | 676 | /** |
677 | 677 | *_trash_question |
678 | 678 | */ |
679 | - protected function _trash_question(){ |
|
680 | - $success=$this->_question_model->delete_by_ID( (int)$this->_req_data['QST_ID'] ); |
|
681 | - $query_args=array('action'=>'default','status'=>'all'); |
|
679 | + protected function _trash_question() { |
|
680 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
681 | + $query_args = array('action'=>'default', 'status'=>'all'); |
|
682 | 682 | $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
683 | 683 | } |
684 | 684 | |
@@ -687,8 +687,8 @@ discard block |
||
687 | 687 | /** |
688 | 688 | * @param bool $trash |
689 | 689 | */ |
690 | - protected function _trash_or_restore_questions( $trash=TRUE){ |
|
691 | - $this->_trash_or_restore_items( $this->_question_model, $trash ); |
|
690 | + protected function _trash_or_restore_questions($trash = TRUE) { |
|
691 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | |
@@ -700,21 +700,21 @@ discard block |
||
700 | 700 | *@param EEM_Soft_Delete_Base $model |
701 | 701 | * @param boolean $trash whether to trash or restore |
702 | 702 | */ |
703 | - private function _trash_or_restore_items( EEM_Soft_Delete_Base $model, $trash = TRUE ) { |
|
703 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = TRUE) { |
|
704 | 704 | |
705 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
705 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
706 | 706 | |
707 | 707 | $success = 1; |
708 | 708 | //Checkboxes |
709 | 709 | //echo "trash $trash"; |
710 | 710 | //var_dump($this->_req_data['checkbox']);die; |
711 | - if ( isset( $this->_req_data['checkbox'] )) { |
|
712 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) { |
|
711 | + if (isset($this->_req_data['checkbox'])) { |
|
712 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
713 | 713 | // if array has more than one element than success message should be plural |
714 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
714 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
715 | 715 | // cycle thru bulk action checkboxes |
716 | - while (list( $ID, $value ) = each($this->_req_data['checkbox'])) { |
|
717 | - if ( ! $model->delete_or_restore_by_ID($trash,absint($ID))) { |
|
716 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
717 | + if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
718 | 718 | $success = 0; |
719 | 719 | } |
720 | 720 | } |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | } else { |
723 | 723 | // grab single id and delete |
724 | 724 | $ID = absint($this->_req_data['checkbox']); |
725 | - if ( ! $model->delete_or_restore_by_ID($trash,$ID)) { |
|
725 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
726 | 726 | $success = 0; |
727 | 727 | } |
728 | 728 | } |
@@ -730,25 +730,25 @@ discard block |
||
730 | 730 | } else { |
731 | 731 | // delete via trash link |
732 | 732 | // grab single id and delete |
733 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
734 | - if ( ! $model->delete_or_restore_by_ID($trash,$ID)) { |
|
733 | + $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
734 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
735 | 735 | $success = 0; |
736 | 736 | } |
737 | 737 | |
738 | 738 | } |
739 | 739 | |
740 | 740 | |
741 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) ); |
|
741 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) ); |
|
742 | 742 | //echo "action :$action"; |
743 | 743 | //$action = 'questions' ? 'default' : $action; |
744 | - if($trash){ |
|
744 | + if ($trash) { |
|
745 | 745 | $action_desc = 'trashed'; |
746 | 746 | $status = 'trash'; |
747 | - }else{ |
|
747 | + } else { |
|
748 | 748 | $action_desc = 'restored'; |
749 | 749 | $status = 'all'; |
750 | 750 | } |
751 | - $this->_redirect_after_action( $success, $model->item_name($success), $action_desc, array( 'action' => $action, 'status'=>$status ) ); |
|
751 | + $this->_redirect_after_action($success, $model->item_name($success), $action_desc, array('action' => $action, 'status'=>$status)); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | |
@@ -759,16 +759,16 @@ discard block |
||
759 | 759 | * @param bool|false $count |
760 | 760 | * @return \EE_Soft_Delete_Base_Class[]|int |
761 | 761 | */ |
762 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
762 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
763 | 763 | $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
764 | 764 | |
765 | - if( $count ){ |
|
765 | + if ($count) { |
|
766 | 766 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
767 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
768 | - $results=$this->_question_model->count_deleted($where); |
|
769 | - }else{ |
|
767 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
768 | + $results = $this->_question_model->count_deleted($where); |
|
769 | + } else { |
|
770 | 770 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
771 | - $results=$this->_question_model->get_all_deleted($query_params); |
|
771 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
772 | 772 | } |
773 | 773 | return $results; |
774 | 774 | } |
@@ -781,13 +781,13 @@ discard block |
||
781 | 781 | * @param bool|false $count |
782 | 782 | * @return \EE_Soft_Delete_Base_Class[] |
783 | 783 | */ |
784 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
785 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
786 | - $query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page); |
|
787 | - if ($count){ |
|
788 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
784 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
785 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
786 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
787 | + if ($count) { |
|
788 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
789 | 789 | $results = $questionGroupModel->count($where); |
790 | - }else{ |
|
790 | + } else { |
|
791 | 791 | $results = $questionGroupModel->get_all($query_params); |
792 | 792 | } |
793 | 793 | return $results; |
@@ -801,14 +801,14 @@ discard block |
||
801 | 801 | * @param bool $count |
802 | 802 | * @return \EE_Soft_Delete_Base_Class[]|int |
803 | 803 | */ |
804 | - public function get_trashed_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
805 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
806 | - $query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page); |
|
807 | - if($count){ |
|
808 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
804 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
805 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
806 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
807 | + if ($count) { |
|
808 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
809 | 809 | $query_params['limit'] = NULL; |
810 | 810 | $results = $questionGroupModel->count_deleted($where); |
811 | - }else{ |
|
811 | + } else { |
|
812 | 812 | $results = $questionGroupModel->get_all_deleted($query_params); |
813 | 813 | } |
814 | 814 | return $results; |
@@ -821,32 +821,32 @@ discard block |
||
821 | 821 | */ |
822 | 822 | public function update_question_group_order() { |
823 | 823 | |
824 | - $success = esc_html__( 'Question group order was updated successfully.', 'event_espresso' ); |
|
824 | + $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
825 | 825 | |
826 | 826 | // grab our row IDs |
827 | - $row_ids = isset( $this->_req_data['row_ids'] ) && ! empty( $this->_req_data['row_ids'] ) |
|
828 | - ? explode( ',', rtrim( $this->_req_data['row_ids'], ',' )) |
|
827 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
828 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
829 | 829 | : array(); |
830 | 830 | |
831 | - $perpage = !empty( $this->_req_data['perpage'] ) |
|
831 | + $perpage = ! empty($this->_req_data['perpage']) |
|
832 | 832 | ? (int) $this->_req_data['perpage'] |
833 | 833 | : NULL; |
834 | - $curpage = !empty( $this->_req_data['curpage'] ) |
|
834 | + $curpage = ! empty($this->_req_data['curpage']) |
|
835 | 835 | ? (int) $this->_req_data['curpage'] |
836 | 836 | : NULL; |
837 | 837 | |
838 | - if ( ! empty( $row_ids ) ) { |
|
838 | + if ( ! empty($row_ids)) { |
|
839 | 839 | //figure out where we start the row_id count at for the current page. |
840 | - $qsgcount = empty( $curpage ) ? 0 : ($curpage - 1 ) * $perpage; |
|
840 | + $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
841 | 841 | |
842 | - $row_count = count( $row_ids ); |
|
843 | - for( $i = 0; $i < $row_count; $i++ ) { |
|
842 | + $row_count = count($row_ids); |
|
843 | + for ($i = 0; $i < $row_count; $i++) { |
|
844 | 844 | //Update the questions when re-ordering |
845 | 845 | $updated = EEM_Question_Group::instance()->update( |
846 | - array( 'QSG_order' => $qsgcount ), |
|
847 | - array( array( 'QSG_ID' => $row_ids[ $i ] ) ) |
|
846 | + array('QSG_order' => $qsgcount), |
|
847 | + array(array('QSG_ID' => $row_ids[$i])) |
|
848 | 848 | ); |
849 | - if ( $updated === false ) { |
|
849 | + if ($updated === false) { |
|
850 | 850 | $success = false; |
851 | 851 | } |
852 | 852 | $qsgcount++; |
@@ -856,10 +856,10 @@ discard block |
||
856 | 856 | } |
857 | 857 | |
858 | 858 | $errors = ! $success |
859 | - ? esc_html__( 'An error occurred. The question group order was not updated.', 'event_espresso' ) |
|
859 | + ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
860 | 860 | : false; |
861 | 861 | |
862 | - echo json_encode( array( 'return_data' => false, 'success' => $success, 'errors' => $errors )); |
|
862 | + echo json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
863 | 863 | die(); |
864 | 864 | |
865 | 865 | } |
@@ -878,17 +878,17 @@ discard block |
||
878 | 878 | $this->_template_args['values'] = $this->_yes_no_values; |
879 | 879 | add_action( |
880 | 880 | 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
881 | - array( $this, 'email_validation_settings_form' ), |
|
881 | + array($this, 'email_validation_settings_form'), |
|
882 | 882 | 2 |
883 | 883 | ); |
884 | - $this->_template_args = (array)apply_filters( |
|
884 | + $this->_template_args = (array) apply_filters( |
|
885 | 885 | 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
886 | 886 | $this->_template_args |
887 | 887 | ); |
888 | - $this->_set_add_edit_form_tags( 'update_reg_form_settings' ); |
|
889 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
888 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
889 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
890 | 890 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
891 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
891 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', |
|
892 | 892 | $this->_template_args, |
893 | 893 | TRUE |
894 | 894 | ); |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | EE_Registry::instance()->CFG, |
910 | 910 | __FILE__, __FUNCTION__, __LINE__ |
911 | 911 | ); |
912 | - $this->_redirect_after_action( $success, esc_html__('Registration Form Options', 'event_espresso'), 'updated', array( 'action' => 'view_reg_form_settings' ) ); |
|
912 | + $this->_redirect_after_action($success, esc_html__('Registration Form Options', 'event_espresso'), 'updated', array('action' => 'view_reg_form_settings')); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | |
@@ -940,20 +940,20 @@ discard block |
||
940 | 940 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
941 | 941 | 'subsections' => array( |
942 | 942 | 'email_validation_hdr' => new EE_Form_Section_HTML( |
943 | - EEH_HTML::h2( esc_html__( 'Email Validation Settings', 'event_espresso' ) ) |
|
943 | + EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
944 | 944 | ), |
945 | 945 | 'email_validation_level' => new EE_Select_Input( |
946 | 946 | array( |
947 | - 'basic' => esc_html__( 'Basic', 'event_espresso' ), |
|
948 | - 'wp_default' => esc_html__( 'WordPress Default', 'event_espresso' ), |
|
949 | - 'i18n' => esc_html__( 'International', 'event_espresso' ), |
|
950 | - 'i18n_dns' => esc_html__( 'International + DNS Check', 'event_espresso' ), |
|
947 | + 'basic' => esc_html__('Basic', 'event_espresso'), |
|
948 | + 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
949 | + 'i18n' => esc_html__('International', 'event_espresso'), |
|
950 | + 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
951 | 951 | ), |
952 | 952 | array( |
953 | - 'html_label_text' => esc_html__( 'Email Validation Level', 'event_espresso' ) |
|
954 | - . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
955 | - 'html_help_text' => esc_html__( 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'), |
|
956 | - 'default' => isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
953 | + 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
954 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
955 | + 'html_help_text' => esc_html__('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'), |
|
956 | + 'default' => isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
957 | 957 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
958 | 958 | : 'wp_default', |
959 | 959 | 'required' => false |
@@ -972,25 +972,25 @@ discard block |
||
972 | 972 | * @param \EE_Registration_Config $EE_Registration_Config |
973 | 973 | * @return \EE_Registration_Config |
974 | 974 | */ |
975 | - public function update_email_validation_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
|
975 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) { |
|
976 | 976 | $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
977 | 977 | try { |
978 | 978 | $email_validation_settings_form = $this->_email_validation_settings_form(); |
979 | 979 | // if not displaying a form, then check for form submission |
980 | - if ( $email_validation_settings_form->was_submitted() ) { |
|
980 | + if ($email_validation_settings_form->was_submitted()) { |
|
981 | 981 | // capture form data |
982 | 982 | $email_validation_settings_form->receive_form_submission(); |
983 | 983 | // validate form data |
984 | - if ( $email_validation_settings_form->is_valid() ) { |
|
984 | + if ($email_validation_settings_form->is_valid()) { |
|
985 | 985 | // grab validated data from form |
986 | 986 | $valid_data = $email_validation_settings_form->valid_data(); |
987 | - if ( isset( $valid_data['email_validation_level'] ) ) { |
|
987 | + if (isset($valid_data['email_validation_level'])) { |
|
988 | 988 | $email_validation_level = $valid_data['email_validation_level']; |
989 | 989 | // now if they want to use international email addresses |
990 | - if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
990 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
991 | 991 | // in case we need to reset their email validation level, |
992 | 992 | // make sure that the previous value wasn't already set to one of the i18n options. |
993 | - if ( $prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
993 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
994 | 994 | // if so, then reset it back to "basic" since that is the only other option that, |
995 | 995 | // despite offering poor validation, supports i18n email addresses |
996 | 996 | $prev_email_validation_level = 'basic'; |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | ); |
1013 | 1013 | } |
1014 | 1014 | } else { |
1015 | - if ( $email_validation_settings_form->submission_error_message() !== '' ) { |
|
1015 | + if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1016 | 1016 | EE_Error::add_error( |
1017 | 1017 | $email_validation_settings_form->submission_error_message(), |
1018 | 1018 | __FILE__, __FUNCTION__, __LINE__ |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | } |
1023 | - } catch ( EE_Error $e ) { |
|
1023 | + } catch (EE_Error $e) { |
|
1024 | 1024 | $e->get_error(); |
1025 | 1025 | } |
1026 | 1026 | return $EE_Registration_Config; |