@@ -112,10 +112,10 @@ |
||
112 | 112 | ]; |
113 | 113 | $this->_wp_core_model = true; |
114 | 114 | $this->_caps_slug = 'users'; |
115 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
116 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
115 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read] = 'list'; |
|
116 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read_admin] = 'list'; |
|
117 | 117 | foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
118 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
118 | + $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_WP_User(); |
|
119 | 119 | } |
120 | 120 | // @todo: account for create_users controls whether they can create users at all |
121 | 121 | parent::__construct($timezone); |
@@ -12,133 +12,133 @@ |
||
12 | 12 | */ |
13 | 13 | class EEM_WP_User extends EEM_Base |
14 | 14 | { |
15 | - /** |
|
16 | - * private instance of the EEM_WP_User object |
|
17 | - * |
|
18 | - * @type EEM_WP_User |
|
19 | - */ |
|
20 | - protected static $_instance; |
|
15 | + /** |
|
16 | + * private instance of the EEM_WP_User object |
|
17 | + * |
|
18 | + * @type EEM_WP_User |
|
19 | + */ |
|
20 | + protected static $_instance; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * constructor |
|
25 | - * |
|
26 | - * @param null $timezone |
|
27 | - * @param ModelFieldFactory $model_field_factory |
|
28 | - * @throws EE_Error |
|
29 | - * @throws InvalidArgumentException |
|
30 | - */ |
|
31 | - protected function __construct($timezone, ModelFieldFactory $model_field_factory) |
|
32 | - { |
|
33 | - $this->singular_item = esc_html__('WP_User', 'event_espresso'); |
|
34 | - $this->plural_item = esc_html__('WP_Users', 'event_espresso'); |
|
35 | - global $wpdb; |
|
36 | - $this->_tables = array( |
|
37 | - 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
38 | - ); |
|
39 | - $this->_fields = array( |
|
40 | - 'WP_User' => array( |
|
41 | - 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
42 | - 'ID', |
|
43 | - esc_html__('WP_User ID', 'event_espresso') |
|
44 | - ), |
|
45 | - 'user_login' => $model_field_factory->createPlainTextField( |
|
46 | - 'user_login', |
|
47 | - esc_html__('User Login', 'event_espresso'), |
|
48 | - false |
|
49 | - ), |
|
50 | - 'user_pass' => $model_field_factory->createPlainTextField( |
|
51 | - 'user_pass', |
|
52 | - esc_html__('User Password', 'event_espresso'), |
|
53 | - false |
|
54 | - ), |
|
55 | - 'user_nicename' => $model_field_factory->createPlainTextField( |
|
56 | - 'user_nicename', |
|
57 | - esc_html__(' User Nice Name', 'event_espresso'), |
|
58 | - false |
|
59 | - ), |
|
60 | - 'user_email' => $model_field_factory->createEmailField( |
|
61 | - 'user_email', |
|
62 | - esc_html__('User Email', 'event_espresso'), |
|
63 | - false, |
|
64 | - null |
|
65 | - ), |
|
66 | - 'user_registered' => $model_field_factory->createDatetimeField( |
|
67 | - 'user_registered', |
|
68 | - esc_html__('Date User Registered', 'event_espresso'), |
|
69 | - $timezone |
|
70 | - ), |
|
71 | - 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
72 | - 'user_activation_key', |
|
73 | - esc_html__('User Activation Key', 'event_espresso'), |
|
74 | - false |
|
75 | - ), |
|
76 | - 'user_status' => $model_field_factory->createIntegerField( |
|
77 | - 'user_status', |
|
78 | - esc_html__('User Status', 'event_espresso') |
|
79 | - ), |
|
80 | - 'display_name' => $model_field_factory->createPlainTextField( |
|
81 | - 'display_name', |
|
82 | - esc_html__('Display Name', 'event_espresso'), |
|
83 | - false |
|
84 | - ), |
|
85 | - ), |
|
86 | - ); |
|
87 | - $this->_model_relations = array( |
|
88 | - 'Attendee' => new EE_Has_Many_Relation(), |
|
89 | - // all models are related to the change log |
|
90 | - // 'Change_Log' => new EE_Has_Many_Relation(), |
|
91 | - 'Event' => new EE_Has_Many_Relation(), |
|
92 | - 'Message' => new EE_Has_Many_Relation(), |
|
93 | - 'Payment_Method' => new EE_Has_Many_Relation(), |
|
94 | - 'Price' => new EE_Has_Many_Relation(), |
|
95 | - 'Price_Type' => new EE_Has_Many_Relation(), |
|
96 | - 'Question' => new EE_Has_Many_Relation(), |
|
97 | - 'Question_Group' => new EE_Has_Many_Relation(), |
|
98 | - 'Ticket' => new EE_Has_Many_Relation(), |
|
99 | - 'Venue' => new EE_Has_Many_Relation(), |
|
100 | - ); |
|
101 | - $this->foreign_key_aliases = [ |
|
102 | - 'Event.EVT_wp_user' => 'WP_User.ID', |
|
103 | - 'Payment_Method.PMD_wp_user' => 'WP_User.ID', |
|
104 | - 'Price.PRC_wp_user' => 'WP_User.ID', |
|
105 | - 'Price_Type.PRT_wp_user' => 'WP_User.ID', |
|
106 | - 'Question.QST_wp_user' => 'WP_User.ID', |
|
107 | - 'Question_Group.QSG_wp_user' => 'WP_User.ID', |
|
108 | - 'Ticket.VNU_wp_user' => 'WP_User.ID', |
|
109 | - 'Venue.TKT_wp_user' => 'WP_User.ID', |
|
110 | - ]; |
|
111 | - $this->_wp_core_model = true; |
|
112 | - $this->_caps_slug = 'users'; |
|
113 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
114 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
115 | - foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
116 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
117 | - } |
|
118 | - // @todo: account for create_users controls whether they can create users at all |
|
119 | - parent::__construct($timezone); |
|
120 | - } |
|
23 | + /** |
|
24 | + * constructor |
|
25 | + * |
|
26 | + * @param null $timezone |
|
27 | + * @param ModelFieldFactory $model_field_factory |
|
28 | + * @throws EE_Error |
|
29 | + * @throws InvalidArgumentException |
|
30 | + */ |
|
31 | + protected function __construct($timezone, ModelFieldFactory $model_field_factory) |
|
32 | + { |
|
33 | + $this->singular_item = esc_html__('WP_User', 'event_espresso'); |
|
34 | + $this->plural_item = esc_html__('WP_Users', 'event_espresso'); |
|
35 | + global $wpdb; |
|
36 | + $this->_tables = array( |
|
37 | + 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
38 | + ); |
|
39 | + $this->_fields = array( |
|
40 | + 'WP_User' => array( |
|
41 | + 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
42 | + 'ID', |
|
43 | + esc_html__('WP_User ID', 'event_espresso') |
|
44 | + ), |
|
45 | + 'user_login' => $model_field_factory->createPlainTextField( |
|
46 | + 'user_login', |
|
47 | + esc_html__('User Login', 'event_espresso'), |
|
48 | + false |
|
49 | + ), |
|
50 | + 'user_pass' => $model_field_factory->createPlainTextField( |
|
51 | + 'user_pass', |
|
52 | + esc_html__('User Password', 'event_espresso'), |
|
53 | + false |
|
54 | + ), |
|
55 | + 'user_nicename' => $model_field_factory->createPlainTextField( |
|
56 | + 'user_nicename', |
|
57 | + esc_html__(' User Nice Name', 'event_espresso'), |
|
58 | + false |
|
59 | + ), |
|
60 | + 'user_email' => $model_field_factory->createEmailField( |
|
61 | + 'user_email', |
|
62 | + esc_html__('User Email', 'event_espresso'), |
|
63 | + false, |
|
64 | + null |
|
65 | + ), |
|
66 | + 'user_registered' => $model_field_factory->createDatetimeField( |
|
67 | + 'user_registered', |
|
68 | + esc_html__('Date User Registered', 'event_espresso'), |
|
69 | + $timezone |
|
70 | + ), |
|
71 | + 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
72 | + 'user_activation_key', |
|
73 | + esc_html__('User Activation Key', 'event_espresso'), |
|
74 | + false |
|
75 | + ), |
|
76 | + 'user_status' => $model_field_factory->createIntegerField( |
|
77 | + 'user_status', |
|
78 | + esc_html__('User Status', 'event_espresso') |
|
79 | + ), |
|
80 | + 'display_name' => $model_field_factory->createPlainTextField( |
|
81 | + 'display_name', |
|
82 | + esc_html__('Display Name', 'event_espresso'), |
|
83 | + false |
|
84 | + ), |
|
85 | + ), |
|
86 | + ); |
|
87 | + $this->_model_relations = array( |
|
88 | + 'Attendee' => new EE_Has_Many_Relation(), |
|
89 | + // all models are related to the change log |
|
90 | + // 'Change_Log' => new EE_Has_Many_Relation(), |
|
91 | + 'Event' => new EE_Has_Many_Relation(), |
|
92 | + 'Message' => new EE_Has_Many_Relation(), |
|
93 | + 'Payment_Method' => new EE_Has_Many_Relation(), |
|
94 | + 'Price' => new EE_Has_Many_Relation(), |
|
95 | + 'Price_Type' => new EE_Has_Many_Relation(), |
|
96 | + 'Question' => new EE_Has_Many_Relation(), |
|
97 | + 'Question_Group' => new EE_Has_Many_Relation(), |
|
98 | + 'Ticket' => new EE_Has_Many_Relation(), |
|
99 | + 'Venue' => new EE_Has_Many_Relation(), |
|
100 | + ); |
|
101 | + $this->foreign_key_aliases = [ |
|
102 | + 'Event.EVT_wp_user' => 'WP_User.ID', |
|
103 | + 'Payment_Method.PMD_wp_user' => 'WP_User.ID', |
|
104 | + 'Price.PRC_wp_user' => 'WP_User.ID', |
|
105 | + 'Price_Type.PRT_wp_user' => 'WP_User.ID', |
|
106 | + 'Question.QST_wp_user' => 'WP_User.ID', |
|
107 | + 'Question_Group.QSG_wp_user' => 'WP_User.ID', |
|
108 | + 'Ticket.VNU_wp_user' => 'WP_User.ID', |
|
109 | + 'Venue.TKT_wp_user' => 'WP_User.ID', |
|
110 | + ]; |
|
111 | + $this->_wp_core_model = true; |
|
112 | + $this->_caps_slug = 'users'; |
|
113 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
114 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
115 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
116 | + $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
117 | + } |
|
118 | + // @todo: account for create_users controls whether they can create users at all |
|
119 | + parent::__construct($timezone); |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * We don't need a foreign key to the WP_User model, we just need its primary key |
|
125 | - * |
|
126 | - * @return string |
|
127 | - * @throws EE_Error |
|
128 | - */ |
|
129 | - public function wp_user_field_name() |
|
130 | - { |
|
131 | - return $this->primary_key_name(); |
|
132 | - } |
|
123 | + /** |
|
124 | + * We don't need a foreign key to the WP_User model, we just need its primary key |
|
125 | + * |
|
126 | + * @return string |
|
127 | + * @throws EE_Error |
|
128 | + */ |
|
129 | + public function wp_user_field_name() |
|
130 | + { |
|
131 | + return $this->primary_key_name(); |
|
132 | + } |
|
133 | 133 | |
134 | 134 | |
135 | - /** |
|
136 | - * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
137 | - * |
|
138 | - * @return boolean |
|
139 | - */ |
|
140 | - public function is_owned() |
|
141 | - { |
|
142 | - return true; |
|
143 | - } |
|
135 | + /** |
|
136 | + * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
137 | + * |
|
138 | + * @return boolean |
|
139 | + */ |
|
140 | + public function is_owned() |
|
141 | + { |
|
142 | + return true; |
|
143 | + } |
|
144 | 144 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | public function is_valid_scope($scope) |
171 | 171 | { |
172 | 172 | $scopes = $this->scopes(); |
173 | - if (isset($scopes[ $scope ])) { |
|
173 | + if (isset($scopes[$scope])) { |
|
174 | 174 | return true; |
175 | 175 | } |
176 | 176 | return false; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function get_all_active($scope = null, $query_params = []) |
189 | 189 | { |
190 | - if (! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
190 | + if ( ! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
191 | 191 | $query_params['order_by'] = ['PMD_order' => 'ASC', 'PMD_ID' => 'ASC']; |
192 | 192 | } |
193 | 193 | return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $count = 0; |
236 | 236 | foreach ($this->scopes() as $scope_name => $desc) { |
237 | 237 | $count++; |
238 | - $acceptable_scopes[ 'PMD_scope*' . $count ] = ['LIKE', '%' . $scope_name . '%']; |
|
238 | + $acceptable_scopes['PMD_scope*'.$count] = ['LIKE', '%'.$scope_name.'%']; |
|
239 | 239 | } |
240 | 240 | return array_replace_recursive([['OR*active_scope' => $acceptable_scopes]], $query_params); |
241 | 241 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $usable_payment_methods = []; |
392 | 392 | foreach ($payment_methods as $key => $payment_method) { |
393 | 393 | if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
394 | - $usable_payment_methods[ $key ] = $payment_method; |
|
394 | + $usable_payment_methods[$key] = $payment_method; |
|
395 | 395 | // some payment methods enqueue their scripts in EE_PMT_*::__construct |
396 | 396 | // which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
397 | 397 | // its scripts). but for backwards-compat we should continue to do that |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $payment_method |
406 | 406 | ); |
407 | 407 | new PersistentAdminNotice( |
408 | - 'auto-deactivated-' . $payment_method->type(), |
|
408 | + 'auto-deactivated-'.$payment_method->type(), |
|
409 | 409 | sprintf( |
410 | 410 | esc_html__( |
411 | 411 | 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | ), |
414 | 414 | $payment_method->admin_name(), |
415 | 415 | '<br />', |
416 | - '<a href="' . admin_url('plugins.php') . '">', |
|
416 | + '<a href="'.admin_url('plugins.php').'">', |
|
417 | 417 | '</a>' |
418 | 418 | ), |
419 | 419 | true |
@@ -16,456 +16,456 @@ |
||
16 | 16 | */ |
17 | 17 | class EEM_Payment_Method extends EEM_Base |
18 | 18 | { |
19 | - const scope_cart = 'CART'; |
|
20 | - |
|
21 | - const scope_admin = 'ADMIN'; |
|
22 | - |
|
23 | - const scope_api = 'API'; |
|
24 | - |
|
25 | - /** |
|
26 | - * @type EEM_Payment_Method |
|
27 | - */ |
|
28 | - protected static $_instance = null; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * private constructor to prevent direct creation |
|
33 | - * |
|
34 | - * @param null $timezone |
|
35 | - * @throws EE_Error |
|
36 | - */ |
|
37 | - protected function __construct($timezone = null) |
|
38 | - { |
|
39 | - $this->singular_item = esc_html__('Payment Method', 'event_espresso'); |
|
40 | - $this->plural_item = esc_html__('Payment Methods', 'event_espresso'); |
|
41 | - $this->_tables = [ |
|
42 | - 'Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID'), |
|
43 | - ]; |
|
44 | - $this->_fields = [ |
|
45 | - 'Payment_Method' => [ |
|
46 | - 'PMD_ID' => new EE_Primary_Key_Int_Field( |
|
47 | - 'PMD_ID', |
|
48 | - esc_html__('ID', 'event_espresso') |
|
49 | - ), |
|
50 | - 'PMD_type' => new EE_Plain_Text_Field( |
|
51 | - 'PMD_type', |
|
52 | - esc_html__('Payment Method Type', 'event_espresso'), |
|
53 | - false, |
|
54 | - 'Admin_Only' |
|
55 | - ), |
|
56 | - 'PMD_name' => new EE_Plain_Text_Field( |
|
57 | - 'PMD_name', |
|
58 | - esc_html__('Name', 'event_espresso'), |
|
59 | - false |
|
60 | - ), |
|
61 | - 'PMD_desc' => new EE_Post_Content_Field( |
|
62 | - 'PMD_desc', |
|
63 | - esc_html__('Description', 'event_espresso'), |
|
64 | - false, |
|
65 | - '' |
|
66 | - ), |
|
67 | - 'PMD_admin_name' => new EE_Plain_Text_Field( |
|
68 | - 'PMD_admin_name', |
|
69 | - esc_html__('Admin-Only Name', 'event_espresso'), |
|
70 | - true |
|
71 | - ), |
|
72 | - 'PMD_admin_desc' => new EE_Post_Content_Field( |
|
73 | - 'PMD_admin_desc', |
|
74 | - esc_html__('Admin-Only Description', 'event_espresso'), |
|
75 | - true |
|
76 | - ), |
|
77 | - 'PMD_slug' => new EE_Slug_Field( |
|
78 | - 'PMD_slug', |
|
79 | - esc_html__('Slug', 'event_espresso'), |
|
80 | - false |
|
81 | - ), |
|
82 | - 'PMD_order' => new EE_Integer_Field( |
|
83 | - 'PMD_order', |
|
84 | - esc_html__('Order', 'event_espresso'), |
|
85 | - false, |
|
86 | - 0 |
|
87 | - ), |
|
88 | - 'PMD_debug_mode' => new EE_Boolean_Field( |
|
89 | - 'PMD_debug_mode', |
|
90 | - esc_html__('Debug Mode On?', 'event_espresso'), |
|
91 | - false, |
|
92 | - false |
|
93 | - ), |
|
94 | - 'PMD_wp_user' => new EE_WP_User_Field( |
|
95 | - 'PMD_wp_user', |
|
96 | - esc_html__('Payment Method Creator ID', 'event_espresso'), |
|
97 | - false |
|
98 | - ), |
|
99 | - 'PMD_open_by_default' => new EE_Boolean_Field( |
|
100 | - 'PMD_open_by_default', |
|
101 | - esc_html__('Open by Default?', 'event_espresso'), |
|
102 | - false, |
|
103 | - false |
|
104 | - ), |
|
105 | - 'PMD_button_url' => new EE_Plain_Text_Field( |
|
106 | - 'PMD_button_url', |
|
107 | - esc_html__('Button URL', 'event_espresso'), |
|
108 | - true, |
|
109 | - '' |
|
110 | - ), |
|
111 | - 'PMD_scope' => new EE_Serialized_Text_Field( |
|
112 | - 'PMD_scope', |
|
113 | - esc_html__('Usable From?', 'event_espresso'), |
|
114 | - false, |
|
115 | - []// possible values currently are 'CART','ADMIN','API' |
|
116 | - ), |
|
117 | - ], |
|
118 | - ]; |
|
119 | - $this->_model_relations = [ |
|
120 | - 'Payment' => new EE_Has_Many_Relation(), |
|
121 | - 'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'), |
|
122 | - 'Transaction' => new EE_Has_Many_Relation(), |
|
123 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
124 | - ]; |
|
125 | - parent::__construct($timezone); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * Gets one by the slug provided |
|
131 | - * |
|
132 | - * @param string $slug |
|
133 | - * @return EE_Base_Class|EE_Payment_Method|EE_Soft_Delete_Base_Class|NULL |
|
134 | - * @throws EE_Error |
|
135 | - */ |
|
136 | - public function get_one_by_slug($slug) |
|
137 | - { |
|
138 | - return $this->get_one([['PMD_slug' => $slug]]); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * Gets all the acceptable scopes for payment methods. |
|
144 | - * Keys are their names as store din the DB, and values are nice names for displaying them |
|
145 | - * |
|
146 | - * @return array |
|
147 | - */ |
|
148 | - public function scopes() |
|
149 | - { |
|
150 | - return apply_filters( |
|
151 | - 'FHEE__EEM_Payment_Method__scopes', |
|
152 | - [ |
|
153 | - EEM_Payment_Method::scope_cart => esc_html__('Front-end Registration Page', 'event_espresso'), |
|
154 | - EEM_Payment_Method::scope_admin => esc_html__( |
|
155 | - 'Admin Registration Page (no online processing)', |
|
156 | - 'event_espresso' |
|
157 | - ), |
|
158 | - ] |
|
159 | - ); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * Determines if this is an valid scope |
|
165 | - * |
|
166 | - * @param string $scope like one of EEM_Payment_Method::instance()->scopes() |
|
167 | - * @return boolean |
|
168 | - */ |
|
169 | - public function is_valid_scope($scope) |
|
170 | - { |
|
171 | - $scopes = $this->scopes(); |
|
172 | - if (isset($scopes[ $scope ])) { |
|
173 | - return true; |
|
174 | - } |
|
175 | - return false; |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * Gets all active payment methods |
|
181 | - * |
|
182 | - * @param string $scope one of |
|
183 | - * @param array $query_params |
|
184 | - * @return EE_Base_Class[]|EE_Payment_Method[] |
|
185 | - * @throws EE_Error |
|
186 | - */ |
|
187 | - public function get_all_active($scope = null, $query_params = []) |
|
188 | - { |
|
189 | - if (! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
190 | - $query_params['order_by'] = ['PMD_order' => 'ASC', 'PMD_ID' => 'ASC']; |
|
191 | - } |
|
192 | - return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * Counts all active gateways in the specified scope |
|
198 | - * |
|
199 | - * @param string $scope one of EEM_Payment_Method::scope_* |
|
200 | - * @param array $query_params |
|
201 | - * @return int |
|
202 | - * @throws EE_Error |
|
203 | - */ |
|
204 | - public function count_active($scope = null, $query_params = []) |
|
205 | - { |
|
206 | - return $this->count($this->_get_query_params_for_all_active($scope, $query_params)); |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * Creates the $query_params that can be passed into any EEM_Payment_Method as their $query_params |
|
212 | - * argument to get all active for a given scope |
|
213 | - * |
|
214 | - * @param string $scope one of the constants EEM_Payment_Method::scope_* |
|
215 | - * @param array $query_params |
|
216 | - * @return array |
|
217 | - * @throws EE_Error |
|
218 | - * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
219 | - */ |
|
220 | - protected function _get_query_params_for_all_active($scope = null, $query_params = []) |
|
221 | - { |
|
222 | - if ($scope) { |
|
223 | - if ($this->is_valid_scope($scope)) { |
|
224 | - return array_replace_recursive([['PMD_scope' => ['LIKE', "%$scope%"]]], $query_params); |
|
225 | - } |
|
226 | - throw new EE_Error( |
|
227 | - sprintf( |
|
228 | - esc_html__("'%s' is not a valid scope for a payment method", 'event_espresso'), |
|
229 | - $scope |
|
230 | - ) |
|
231 | - ); |
|
232 | - } |
|
233 | - $acceptable_scopes = []; |
|
234 | - $count = 0; |
|
235 | - foreach ($this->scopes() as $scope_name => $desc) { |
|
236 | - $count++; |
|
237 | - $acceptable_scopes[ 'PMD_scope*' . $count ] = ['LIKE', '%' . $scope_name . '%']; |
|
238 | - } |
|
239 | - return array_replace_recursive([['OR*active_scope' => $acceptable_scopes]], $query_params); |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * Creates the $query_params that can be passed into any EEM_Payment_Method as their $query_params |
|
245 | - * argument to get all active for a given scope |
|
246 | - * |
|
247 | - * @param string $scope one of the constants EEM_Payment_Method::scope_* |
|
248 | - * @param array $query_params |
|
249 | - * @return array |
|
250 | - * @throws EE_Error |
|
251 | - * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
252 | - */ |
|
253 | - public function get_query_params_for_all_active($scope = null, $query_params = []) |
|
254 | - { |
|
255 | - return $this->_get_query_params_for_all_active($scope, $query_params); |
|
256 | - } |
|
257 | - |
|
258 | - |
|
259 | - /** |
|
260 | - * Gets one active payment method. see @get_all_active for documentation |
|
261 | - * |
|
262 | - * @param string $scope |
|
263 | - * @param array $query_params |
|
264 | - * @return EE_Base_Class|EE_Payment_Method|EE_Soft_Delete_Base_Class|NULL |
|
265 | - * @throws EE_Error |
|
266 | - */ |
|
267 | - public function get_one_active($scope = null, $query_params = []) |
|
268 | - { |
|
269 | - return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params)); |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * Gets one payment method of that type, regardless of whether its active or not |
|
275 | - * |
|
276 | - * @param string $type |
|
277 | - * @return EE_Base_Class|EE_Payment_Method|EE_Soft_Delete_Base_Class|NULL |
|
278 | - * @throws EE_Error |
|
279 | - */ |
|
280 | - public function get_one_of_type($type) |
|
281 | - { |
|
282 | - return $this->get_one([['PMD_type' => $type]]); |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * Overrides parent ot also check by the slug |
|
288 | - * |
|
289 | - * @param string|int|EE_Payment_Method $base_class_obj_or_id |
|
290 | - * @param boolean $ensure_is_in_db |
|
291 | - * @return EE_Base_Class|EE_Payment_Method|EE_Soft_Delete_Base_Class|int|string |
|
292 | - * @throws EE_Error |
|
293 | - * @see EEM_Base::ensure_is_obj() |
|
294 | - */ |
|
295 | - public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = false) |
|
296 | - { |
|
297 | - // first: check if it's a slug |
|
298 | - if (is_string($base_class_obj_or_id)) { |
|
299 | - $obj = $this->get_one_by_slug($base_class_obj_or_id); |
|
300 | - if ($obj) { |
|
301 | - return $obj; |
|
302 | - } |
|
303 | - } |
|
304 | - // ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID) |
|
305 | - try { |
|
306 | - return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db); |
|
307 | - } catch (EE_Error $e) { |
|
308 | - // handle it outside the catch |
|
309 | - } |
|
310 | - throw new EE_Error( |
|
311 | - sprintf( |
|
312 | - esc_html__("'%s' is neither a Payment Method ID, slug, nor object.", 'event_espresso'), |
|
313 | - $base_class_obj_or_id |
|
314 | - ) |
|
315 | - ); |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - /** |
|
320 | - * Gets the ID of this object, or if its a string finds the object's id |
|
321 | - * associated with that slug |
|
322 | - * |
|
323 | - * @param mixed $base_obj_or_id_or_slug |
|
324 | - * @return int |
|
325 | - * @throws EE_Error |
|
326 | - */ |
|
327 | - public function ensure_is_ID($base_obj_or_id_or_slug) |
|
328 | - { |
|
329 | - if (is_string($base_obj_or_id_or_slug)) { |
|
330 | - // assume it's a slug |
|
331 | - $base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug); |
|
332 | - } |
|
333 | - return parent::ensure_is_ID($base_obj_or_id_or_slug); |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * Verifies the button urls on all the passed payment methods have a valid button url. |
|
339 | - * If not, resets them to their default. |
|
340 | - * |
|
341 | - * @param EE_Payment_Method[] $payment_methods if NULL, defaults to all payment methods active in the cart |
|
342 | - * @throws EE_Error |
|
343 | - * @throws ReflectionException |
|
344 | - */ |
|
345 | - public function verify_button_urls($payment_methods = null) |
|
346 | - { |
|
347 | - $payment_methods = is_array($payment_methods) |
|
348 | - ? $payment_methods |
|
349 | - : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
350 | - foreach ($payment_methods as $payment_method) { |
|
351 | - try { |
|
352 | - // If there is really no button URL at all, or if the button URLs still point to decaf folder even |
|
353 | - // though this is a caffeinated install, reset it to the default. |
|
354 | - $current_button_url = $payment_method->button_url(); |
|
355 | - if ( |
|
356 | - empty($current_button_url) |
|
357 | - || ( |
|
358 | - strpos($current_button_url, 'decaf') !== false |
|
359 | - && strpos($payment_method->type_obj()->default_button_url(), 'decaf') === false |
|
360 | - ) |
|
361 | - ) { |
|
362 | - $payment_method->save( |
|
363 | - [ |
|
364 | - 'PMD_button_url' => $payment_method->type_obj()->default_button_url(), |
|
365 | - ] |
|
366 | - ); |
|
367 | - } |
|
368 | - } catch (EE_Error $e) { |
|
369 | - $payment_method->deactivate(); |
|
370 | - } |
|
371 | - } |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * Overrides parent to not only turn wpdb results into EE_Payment_Method objects, |
|
377 | - * but also verifies the payment method type of each is a usable object. If not, |
|
378 | - * deactivate it, sets a notification, and deactivates it |
|
379 | - * |
|
380 | - * @param array $rows |
|
381 | - * @return EE_Payment_Method[] |
|
382 | - * @throws EE_Error |
|
383 | - * @throws InvalidDataTypeException |
|
384 | - * @throws ReflectionException |
|
385 | - */ |
|
386 | - protected function _create_objects($rows = []) |
|
387 | - { |
|
388 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
389 | - $payment_methods = parent::_create_objects($rows); |
|
390 | - /* @var $payment_methods EE_Payment_Method[] */ |
|
391 | - $usable_payment_methods = []; |
|
392 | - foreach ($payment_methods as $key => $payment_method) { |
|
393 | - if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
|
394 | - $usable_payment_methods[ $key ] = $payment_method; |
|
395 | - // some payment methods enqueue their scripts in EE_PMT_*::__construct |
|
396 | - // which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
|
397 | - // its scripts). but for backwards-compat we should continue to do that |
|
398 | - $payment_method->type_obj(); |
|
399 | - } elseif ($payment_method->active()) { |
|
400 | - // only deactivate and notify the admin if the payment is active somewhere |
|
401 | - $payment_method->deactivate(); |
|
402 | - $payment_method->save(); |
|
403 | - do_action( |
|
404 | - 'AHEE__EEM_Payment_Method___create_objects_auto_deactivated_payment_method', |
|
405 | - $payment_method |
|
406 | - ); |
|
407 | - new PersistentAdminNotice( |
|
408 | - 'auto-deactivated-' . $payment_method->type(), |
|
409 | - sprintf( |
|
410 | - esc_html__( |
|
411 | - 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', |
|
412 | - 'event_espresso' |
|
413 | - ), |
|
414 | - $payment_method->admin_name(), |
|
415 | - '<br />', |
|
416 | - '<a href="' . admin_url('plugins.php') . '">', |
|
417 | - '</a>' |
|
418 | - ), |
|
419 | - true |
|
420 | - ); |
|
421 | - } |
|
422 | - } |
|
423 | - return $usable_payment_methods; |
|
424 | - } |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * Gets all the payment methods which can be used for transaction |
|
429 | - * (according to the relations between payment methods and events, and |
|
430 | - * the currencies used for the transaction and their relation to payment methods) |
|
431 | - * |
|
432 | - * @param EE_Transaction $transaction |
|
433 | - * @param string $scope @see EEM_Payment_Method::get_all_for_events |
|
434 | - * @return EE_Payment_Method[] |
|
435 | - * @throws EE_Error |
|
436 | - */ |
|
437 | - public function get_all_for_transaction($transaction, $scope) |
|
438 | - { |
|
439 | - // give addons a chance to override what payment methods are chosen based on the transaction |
|
440 | - return apply_filters( |
|
441 | - 'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', |
|
442 | - $this->get_all_active($scope, ['group_by' => 'PMD_type']), |
|
443 | - $transaction, |
|
444 | - $scope |
|
445 | - ); |
|
446 | - } |
|
447 | - |
|
448 | - |
|
449 | - /** |
|
450 | - * Returns the payment method used for the last payment made for a registration. |
|
451 | - * Note: if an offline payment method was selected on the related transaction then this will have no payment |
|
452 | - * methods returned. It will ONLY return a payment method for a PAYMENT recorded against the registration. |
|
453 | - * |
|
454 | - * @param EE_Registration|int $registration_or_reg_id Either the EE_Registration object or the id for the |
|
455 | - * registration. |
|
456 | - * @return EE_Payment|null |
|
457 | - * @throws EE_Error |
|
458 | - */ |
|
459 | - public function get_last_used_for_registration($registration_or_reg_id) |
|
460 | - { |
|
461 | - $registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id); |
|
462 | - |
|
463 | - $query_params = [ |
|
464 | - 0 => [ |
|
465 | - 'Payment.Registration.REG_ID' => $registration_id, |
|
466 | - ], |
|
467 | - 'order_by' => ['Payment.PAY_ID' => 'DESC'], |
|
468 | - ]; |
|
469 | - return $this->get_one($query_params); |
|
470 | - } |
|
19 | + const scope_cart = 'CART'; |
|
20 | + |
|
21 | + const scope_admin = 'ADMIN'; |
|
22 | + |
|
23 | + const scope_api = 'API'; |
|
24 | + |
|
25 | + /** |
|
26 | + * @type EEM_Payment_Method |
|
27 | + */ |
|
28 | + protected static $_instance = null; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * private constructor to prevent direct creation |
|
33 | + * |
|
34 | + * @param null $timezone |
|
35 | + * @throws EE_Error |
|
36 | + */ |
|
37 | + protected function __construct($timezone = null) |
|
38 | + { |
|
39 | + $this->singular_item = esc_html__('Payment Method', 'event_espresso'); |
|
40 | + $this->plural_item = esc_html__('Payment Methods', 'event_espresso'); |
|
41 | + $this->_tables = [ |
|
42 | + 'Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID'), |
|
43 | + ]; |
|
44 | + $this->_fields = [ |
|
45 | + 'Payment_Method' => [ |
|
46 | + 'PMD_ID' => new EE_Primary_Key_Int_Field( |
|
47 | + 'PMD_ID', |
|
48 | + esc_html__('ID', 'event_espresso') |
|
49 | + ), |
|
50 | + 'PMD_type' => new EE_Plain_Text_Field( |
|
51 | + 'PMD_type', |
|
52 | + esc_html__('Payment Method Type', 'event_espresso'), |
|
53 | + false, |
|
54 | + 'Admin_Only' |
|
55 | + ), |
|
56 | + 'PMD_name' => new EE_Plain_Text_Field( |
|
57 | + 'PMD_name', |
|
58 | + esc_html__('Name', 'event_espresso'), |
|
59 | + false |
|
60 | + ), |
|
61 | + 'PMD_desc' => new EE_Post_Content_Field( |
|
62 | + 'PMD_desc', |
|
63 | + esc_html__('Description', 'event_espresso'), |
|
64 | + false, |
|
65 | + '' |
|
66 | + ), |
|
67 | + 'PMD_admin_name' => new EE_Plain_Text_Field( |
|
68 | + 'PMD_admin_name', |
|
69 | + esc_html__('Admin-Only Name', 'event_espresso'), |
|
70 | + true |
|
71 | + ), |
|
72 | + 'PMD_admin_desc' => new EE_Post_Content_Field( |
|
73 | + 'PMD_admin_desc', |
|
74 | + esc_html__('Admin-Only Description', 'event_espresso'), |
|
75 | + true |
|
76 | + ), |
|
77 | + 'PMD_slug' => new EE_Slug_Field( |
|
78 | + 'PMD_slug', |
|
79 | + esc_html__('Slug', 'event_espresso'), |
|
80 | + false |
|
81 | + ), |
|
82 | + 'PMD_order' => new EE_Integer_Field( |
|
83 | + 'PMD_order', |
|
84 | + esc_html__('Order', 'event_espresso'), |
|
85 | + false, |
|
86 | + 0 |
|
87 | + ), |
|
88 | + 'PMD_debug_mode' => new EE_Boolean_Field( |
|
89 | + 'PMD_debug_mode', |
|
90 | + esc_html__('Debug Mode On?', 'event_espresso'), |
|
91 | + false, |
|
92 | + false |
|
93 | + ), |
|
94 | + 'PMD_wp_user' => new EE_WP_User_Field( |
|
95 | + 'PMD_wp_user', |
|
96 | + esc_html__('Payment Method Creator ID', 'event_espresso'), |
|
97 | + false |
|
98 | + ), |
|
99 | + 'PMD_open_by_default' => new EE_Boolean_Field( |
|
100 | + 'PMD_open_by_default', |
|
101 | + esc_html__('Open by Default?', 'event_espresso'), |
|
102 | + false, |
|
103 | + false |
|
104 | + ), |
|
105 | + 'PMD_button_url' => new EE_Plain_Text_Field( |
|
106 | + 'PMD_button_url', |
|
107 | + esc_html__('Button URL', 'event_espresso'), |
|
108 | + true, |
|
109 | + '' |
|
110 | + ), |
|
111 | + 'PMD_scope' => new EE_Serialized_Text_Field( |
|
112 | + 'PMD_scope', |
|
113 | + esc_html__('Usable From?', 'event_espresso'), |
|
114 | + false, |
|
115 | + []// possible values currently are 'CART','ADMIN','API' |
|
116 | + ), |
|
117 | + ], |
|
118 | + ]; |
|
119 | + $this->_model_relations = [ |
|
120 | + 'Payment' => new EE_Has_Many_Relation(), |
|
121 | + 'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'), |
|
122 | + 'Transaction' => new EE_Has_Many_Relation(), |
|
123 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
124 | + ]; |
|
125 | + parent::__construct($timezone); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * Gets one by the slug provided |
|
131 | + * |
|
132 | + * @param string $slug |
|
133 | + * @return EE_Base_Class|EE_Payment_Method|EE_Soft_Delete_Base_Class|NULL |
|
134 | + * @throws EE_Error |
|
135 | + */ |
|
136 | + public function get_one_by_slug($slug) |
|
137 | + { |
|
138 | + return $this->get_one([['PMD_slug' => $slug]]); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * Gets all the acceptable scopes for payment methods. |
|
144 | + * Keys are their names as store din the DB, and values are nice names for displaying them |
|
145 | + * |
|
146 | + * @return array |
|
147 | + */ |
|
148 | + public function scopes() |
|
149 | + { |
|
150 | + return apply_filters( |
|
151 | + 'FHEE__EEM_Payment_Method__scopes', |
|
152 | + [ |
|
153 | + EEM_Payment_Method::scope_cart => esc_html__('Front-end Registration Page', 'event_espresso'), |
|
154 | + EEM_Payment_Method::scope_admin => esc_html__( |
|
155 | + 'Admin Registration Page (no online processing)', |
|
156 | + 'event_espresso' |
|
157 | + ), |
|
158 | + ] |
|
159 | + ); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * Determines if this is an valid scope |
|
165 | + * |
|
166 | + * @param string $scope like one of EEM_Payment_Method::instance()->scopes() |
|
167 | + * @return boolean |
|
168 | + */ |
|
169 | + public function is_valid_scope($scope) |
|
170 | + { |
|
171 | + $scopes = $this->scopes(); |
|
172 | + if (isset($scopes[ $scope ])) { |
|
173 | + return true; |
|
174 | + } |
|
175 | + return false; |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * Gets all active payment methods |
|
181 | + * |
|
182 | + * @param string $scope one of |
|
183 | + * @param array $query_params |
|
184 | + * @return EE_Base_Class[]|EE_Payment_Method[] |
|
185 | + * @throws EE_Error |
|
186 | + */ |
|
187 | + public function get_all_active($scope = null, $query_params = []) |
|
188 | + { |
|
189 | + if (! isset($query_params['order_by']) && ! isset($query_params['order'])) { |
|
190 | + $query_params['order_by'] = ['PMD_order' => 'ASC', 'PMD_ID' => 'ASC']; |
|
191 | + } |
|
192 | + return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params)); |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * Counts all active gateways in the specified scope |
|
198 | + * |
|
199 | + * @param string $scope one of EEM_Payment_Method::scope_* |
|
200 | + * @param array $query_params |
|
201 | + * @return int |
|
202 | + * @throws EE_Error |
|
203 | + */ |
|
204 | + public function count_active($scope = null, $query_params = []) |
|
205 | + { |
|
206 | + return $this->count($this->_get_query_params_for_all_active($scope, $query_params)); |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * Creates the $query_params that can be passed into any EEM_Payment_Method as their $query_params |
|
212 | + * argument to get all active for a given scope |
|
213 | + * |
|
214 | + * @param string $scope one of the constants EEM_Payment_Method::scope_* |
|
215 | + * @param array $query_params |
|
216 | + * @return array |
|
217 | + * @throws EE_Error |
|
218 | + * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
219 | + */ |
|
220 | + protected function _get_query_params_for_all_active($scope = null, $query_params = []) |
|
221 | + { |
|
222 | + if ($scope) { |
|
223 | + if ($this->is_valid_scope($scope)) { |
|
224 | + return array_replace_recursive([['PMD_scope' => ['LIKE', "%$scope%"]]], $query_params); |
|
225 | + } |
|
226 | + throw new EE_Error( |
|
227 | + sprintf( |
|
228 | + esc_html__("'%s' is not a valid scope for a payment method", 'event_espresso'), |
|
229 | + $scope |
|
230 | + ) |
|
231 | + ); |
|
232 | + } |
|
233 | + $acceptable_scopes = []; |
|
234 | + $count = 0; |
|
235 | + foreach ($this->scopes() as $scope_name => $desc) { |
|
236 | + $count++; |
|
237 | + $acceptable_scopes[ 'PMD_scope*' . $count ] = ['LIKE', '%' . $scope_name . '%']; |
|
238 | + } |
|
239 | + return array_replace_recursive([['OR*active_scope' => $acceptable_scopes]], $query_params); |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * Creates the $query_params that can be passed into any EEM_Payment_Method as their $query_params |
|
245 | + * argument to get all active for a given scope |
|
246 | + * |
|
247 | + * @param string $scope one of the constants EEM_Payment_Method::scope_* |
|
248 | + * @param array $query_params |
|
249 | + * @return array |
|
250 | + * @throws EE_Error |
|
251 | + * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
252 | + */ |
|
253 | + public function get_query_params_for_all_active($scope = null, $query_params = []) |
|
254 | + { |
|
255 | + return $this->_get_query_params_for_all_active($scope, $query_params); |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + /** |
|
260 | + * Gets one active payment method. see @get_all_active for documentation |
|
261 | + * |
|
262 | + * @param string $scope |
|
263 | + * @param array $query_params |
|
264 | + * @return EE_Base_Class|EE_Payment_Method|EE_Soft_Delete_Base_Class|NULL |
|
265 | + * @throws EE_Error |
|
266 | + */ |
|
267 | + public function get_one_active($scope = null, $query_params = []) |
|
268 | + { |
|
269 | + return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params)); |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * Gets one payment method of that type, regardless of whether its active or not |
|
275 | + * |
|
276 | + * @param string $type |
|
277 | + * @return EE_Base_Class|EE_Payment_Method|EE_Soft_Delete_Base_Class|NULL |
|
278 | + * @throws EE_Error |
|
279 | + */ |
|
280 | + public function get_one_of_type($type) |
|
281 | + { |
|
282 | + return $this->get_one([['PMD_type' => $type]]); |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * Overrides parent ot also check by the slug |
|
288 | + * |
|
289 | + * @param string|int|EE_Payment_Method $base_class_obj_or_id |
|
290 | + * @param boolean $ensure_is_in_db |
|
291 | + * @return EE_Base_Class|EE_Payment_Method|EE_Soft_Delete_Base_Class|int|string |
|
292 | + * @throws EE_Error |
|
293 | + * @see EEM_Base::ensure_is_obj() |
|
294 | + */ |
|
295 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = false) |
|
296 | + { |
|
297 | + // first: check if it's a slug |
|
298 | + if (is_string($base_class_obj_or_id)) { |
|
299 | + $obj = $this->get_one_by_slug($base_class_obj_or_id); |
|
300 | + if ($obj) { |
|
301 | + return $obj; |
|
302 | + } |
|
303 | + } |
|
304 | + // ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID) |
|
305 | + try { |
|
306 | + return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db); |
|
307 | + } catch (EE_Error $e) { |
|
308 | + // handle it outside the catch |
|
309 | + } |
|
310 | + throw new EE_Error( |
|
311 | + sprintf( |
|
312 | + esc_html__("'%s' is neither a Payment Method ID, slug, nor object.", 'event_espresso'), |
|
313 | + $base_class_obj_or_id |
|
314 | + ) |
|
315 | + ); |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + /** |
|
320 | + * Gets the ID of this object, or if its a string finds the object's id |
|
321 | + * associated with that slug |
|
322 | + * |
|
323 | + * @param mixed $base_obj_or_id_or_slug |
|
324 | + * @return int |
|
325 | + * @throws EE_Error |
|
326 | + */ |
|
327 | + public function ensure_is_ID($base_obj_or_id_or_slug) |
|
328 | + { |
|
329 | + if (is_string($base_obj_or_id_or_slug)) { |
|
330 | + // assume it's a slug |
|
331 | + $base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug); |
|
332 | + } |
|
333 | + return parent::ensure_is_ID($base_obj_or_id_or_slug); |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * Verifies the button urls on all the passed payment methods have a valid button url. |
|
339 | + * If not, resets them to their default. |
|
340 | + * |
|
341 | + * @param EE_Payment_Method[] $payment_methods if NULL, defaults to all payment methods active in the cart |
|
342 | + * @throws EE_Error |
|
343 | + * @throws ReflectionException |
|
344 | + */ |
|
345 | + public function verify_button_urls($payment_methods = null) |
|
346 | + { |
|
347 | + $payment_methods = is_array($payment_methods) |
|
348 | + ? $payment_methods |
|
349 | + : $this->get_all_active(EEM_Payment_Method::scope_cart); |
|
350 | + foreach ($payment_methods as $payment_method) { |
|
351 | + try { |
|
352 | + // If there is really no button URL at all, or if the button URLs still point to decaf folder even |
|
353 | + // though this is a caffeinated install, reset it to the default. |
|
354 | + $current_button_url = $payment_method->button_url(); |
|
355 | + if ( |
|
356 | + empty($current_button_url) |
|
357 | + || ( |
|
358 | + strpos($current_button_url, 'decaf') !== false |
|
359 | + && strpos($payment_method->type_obj()->default_button_url(), 'decaf') === false |
|
360 | + ) |
|
361 | + ) { |
|
362 | + $payment_method->save( |
|
363 | + [ |
|
364 | + 'PMD_button_url' => $payment_method->type_obj()->default_button_url(), |
|
365 | + ] |
|
366 | + ); |
|
367 | + } |
|
368 | + } catch (EE_Error $e) { |
|
369 | + $payment_method->deactivate(); |
|
370 | + } |
|
371 | + } |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * Overrides parent to not only turn wpdb results into EE_Payment_Method objects, |
|
377 | + * but also verifies the payment method type of each is a usable object. If not, |
|
378 | + * deactivate it, sets a notification, and deactivates it |
|
379 | + * |
|
380 | + * @param array $rows |
|
381 | + * @return EE_Payment_Method[] |
|
382 | + * @throws EE_Error |
|
383 | + * @throws InvalidDataTypeException |
|
384 | + * @throws ReflectionException |
|
385 | + */ |
|
386 | + protected function _create_objects($rows = []) |
|
387 | + { |
|
388 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
389 | + $payment_methods = parent::_create_objects($rows); |
|
390 | + /* @var $payment_methods EE_Payment_Method[] */ |
|
391 | + $usable_payment_methods = []; |
|
392 | + foreach ($payment_methods as $key => $payment_method) { |
|
393 | + if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) { |
|
394 | + $usable_payment_methods[ $key ] = $payment_method; |
|
395 | + // some payment methods enqueue their scripts in EE_PMT_*::__construct |
|
396 | + // which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue |
|
397 | + // its scripts). but for backwards-compat we should continue to do that |
|
398 | + $payment_method->type_obj(); |
|
399 | + } elseif ($payment_method->active()) { |
|
400 | + // only deactivate and notify the admin if the payment is active somewhere |
|
401 | + $payment_method->deactivate(); |
|
402 | + $payment_method->save(); |
|
403 | + do_action( |
|
404 | + 'AHEE__EEM_Payment_Method___create_objects_auto_deactivated_payment_method', |
|
405 | + $payment_method |
|
406 | + ); |
|
407 | + new PersistentAdminNotice( |
|
408 | + 'auto-deactivated-' . $payment_method->type(), |
|
409 | + sprintf( |
|
410 | + esc_html__( |
|
411 | + 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', |
|
412 | + 'event_espresso' |
|
413 | + ), |
|
414 | + $payment_method->admin_name(), |
|
415 | + '<br />', |
|
416 | + '<a href="' . admin_url('plugins.php') . '">', |
|
417 | + '</a>' |
|
418 | + ), |
|
419 | + true |
|
420 | + ); |
|
421 | + } |
|
422 | + } |
|
423 | + return $usable_payment_methods; |
|
424 | + } |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * Gets all the payment methods which can be used for transaction |
|
429 | + * (according to the relations between payment methods and events, and |
|
430 | + * the currencies used for the transaction and their relation to payment methods) |
|
431 | + * |
|
432 | + * @param EE_Transaction $transaction |
|
433 | + * @param string $scope @see EEM_Payment_Method::get_all_for_events |
|
434 | + * @return EE_Payment_Method[] |
|
435 | + * @throws EE_Error |
|
436 | + */ |
|
437 | + public function get_all_for_transaction($transaction, $scope) |
|
438 | + { |
|
439 | + // give addons a chance to override what payment methods are chosen based on the transaction |
|
440 | + return apply_filters( |
|
441 | + 'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', |
|
442 | + $this->get_all_active($scope, ['group_by' => 'PMD_type']), |
|
443 | + $transaction, |
|
444 | + $scope |
|
445 | + ); |
|
446 | + } |
|
447 | + |
|
448 | + |
|
449 | + /** |
|
450 | + * Returns the payment method used for the last payment made for a registration. |
|
451 | + * Note: if an offline payment method was selected on the related transaction then this will have no payment |
|
452 | + * methods returned. It will ONLY return a payment method for a PAYMENT recorded against the registration. |
|
453 | + * |
|
454 | + * @param EE_Registration|int $registration_or_reg_id Either the EE_Registration object or the id for the |
|
455 | + * registration. |
|
456 | + * @return EE_Payment|null |
|
457 | + * @throws EE_Error |
|
458 | + */ |
|
459 | + public function get_last_used_for_registration($registration_or_reg_id) |
|
460 | + { |
|
461 | + $registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id); |
|
462 | + |
|
463 | + $query_params = [ |
|
464 | + 0 => [ |
|
465 | + 'Payment.Registration.REG_ID' => $registration_id, |
|
466 | + ], |
|
467 | + 'order_by' => ['Payment.PAY_ID' => 'DESC'], |
|
468 | + ]; |
|
469 | + return $this->get_one($query_params); |
|
470 | + } |
|
471 | 471 | } |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
58 | 58 | ]; |
59 | 59 | $path_to_event = 'Event'; |
60 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
60 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public( |
|
61 | 61 | $path_to_event |
62 | 62 | ); |
63 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
63 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected( |
|
64 | 64 | $path_to_event |
65 | 65 | ); |
66 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
66 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected( |
|
67 | 67 | $path_to_event |
68 | 68 | ); |
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected( |
|
70 | 70 | $path_to_event, |
71 | 71 | EEM_Base::caps_edit |
72 | 72 | ); |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | $where = []; |
118 | - if (! empty($GRP_IDs)) { |
|
118 | + if ( ! empty($GRP_IDs)) { |
|
119 | 119 | $where['GRP_ID'] = ['IN', (array) $GRP_IDs]; |
120 | 120 | } |
121 | - if (! empty($EVT_IDs)) { |
|
121 | + if ( ! empty($EVT_IDs)) { |
|
122 | 122 | $where['EVT_ID'] = ['IN', (array) $EVT_IDs]; |
123 | 123 | } |
124 | 124 |
@@ -11,116 +11,116 @@ |
||
11 | 11 | */ |
12 | 12 | class EEM_Event_Message_Template extends EEM_Base |
13 | 13 | { |
14 | - // private instance of the EEM_Event_Message_Template object |
|
15 | - protected static $_instance = null; |
|
14 | + // private instance of the EEM_Event_Message_Template object |
|
15 | + protected static $_instance = null; |
|
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * protected constructor to prevent direct creation |
|
20 | - * |
|
21 | - * @param null $timezone |
|
22 | - * @throws EE_Error |
|
23 | - */ |
|
24 | - protected function __construct($timezone = null) |
|
25 | - { |
|
26 | - $this->singular_item = esc_html__('Event Message Template', 'event_espresso'); |
|
27 | - $this->plural_item = esc_html__('Event Message Templates', 'event_espresso'); |
|
18 | + /** |
|
19 | + * protected constructor to prevent direct creation |
|
20 | + * |
|
21 | + * @param null $timezone |
|
22 | + * @throws EE_Error |
|
23 | + */ |
|
24 | + protected function __construct($timezone = null) |
|
25 | + { |
|
26 | + $this->singular_item = esc_html__('Event Message Template', 'event_espresso'); |
|
27 | + $this->plural_item = esc_html__('Event Message Templates', 'event_espresso'); |
|
28 | 28 | |
29 | - $this->_tables = [ |
|
30 | - 'Event_Message_Template' => new EE_Primary_Table('esp_event_message_template', 'EMT_ID'), |
|
31 | - ]; |
|
32 | - $this->_fields = [ |
|
33 | - 'Event_Message_Template' => [ |
|
34 | - 'EMT_ID' => new EE_Primary_Key_Int_Field( |
|
35 | - 'EMT_ID', |
|
36 | - esc_html__('Event Message Template ID', 'event_espresso') |
|
37 | - ), |
|
38 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
39 | - 'EVT_ID', |
|
40 | - esc_html__('The ID to the Event', 'event_espresso'), |
|
41 | - false, |
|
42 | - 0, |
|
43 | - 'Event' |
|
44 | - ), |
|
45 | - 'GRP_ID' => new EE_Foreign_Key_Int_Field( |
|
46 | - 'GRP_ID', |
|
47 | - esc_html__('The ID to the Message Template Group', 'event_espresso'), |
|
48 | - false, |
|
49 | - 0, |
|
50 | - 'Message_Template_Group' |
|
51 | - ), |
|
52 | - ], |
|
53 | - ]; |
|
54 | - $this->_model_relations = [ |
|
55 | - 'Event' => new EE_Belongs_To_Relation(), |
|
56 | - 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
|
57 | - ]; |
|
58 | - $path_to_event = 'Event'; |
|
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
60 | - $path_to_event |
|
61 | - ); |
|
62 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
63 | - $path_to_event |
|
64 | - ); |
|
65 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
66 | - $path_to_event |
|
67 | - ); |
|
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
69 | - $path_to_event, |
|
70 | - EEM_Base::caps_edit |
|
71 | - ); |
|
72 | - parent::__construct($timezone); |
|
73 | - } |
|
29 | + $this->_tables = [ |
|
30 | + 'Event_Message_Template' => new EE_Primary_Table('esp_event_message_template', 'EMT_ID'), |
|
31 | + ]; |
|
32 | + $this->_fields = [ |
|
33 | + 'Event_Message_Template' => [ |
|
34 | + 'EMT_ID' => new EE_Primary_Key_Int_Field( |
|
35 | + 'EMT_ID', |
|
36 | + esc_html__('Event Message Template ID', 'event_espresso') |
|
37 | + ), |
|
38 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
39 | + 'EVT_ID', |
|
40 | + esc_html__('The ID to the Event', 'event_espresso'), |
|
41 | + false, |
|
42 | + 0, |
|
43 | + 'Event' |
|
44 | + ), |
|
45 | + 'GRP_ID' => new EE_Foreign_Key_Int_Field( |
|
46 | + 'GRP_ID', |
|
47 | + esc_html__('The ID to the Message Template Group', 'event_espresso'), |
|
48 | + false, |
|
49 | + 0, |
|
50 | + 'Message_Template_Group' |
|
51 | + ), |
|
52 | + ], |
|
53 | + ]; |
|
54 | + $this->_model_relations = [ |
|
55 | + 'Event' => new EE_Belongs_To_Relation(), |
|
56 | + 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
|
57 | + ]; |
|
58 | + $path_to_event = 'Event'; |
|
59 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
60 | + $path_to_event |
|
61 | + ); |
|
62 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
63 | + $path_to_event |
|
64 | + ); |
|
65 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
66 | + $path_to_event |
|
67 | + ); |
|
68 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
69 | + $path_to_event, |
|
70 | + EEM_Base::caps_edit |
|
71 | + ); |
|
72 | + parent::__construct($timezone); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * helper method to simply return an array of event ids for events attached to the given |
|
78 | - * message template group. |
|
79 | - * |
|
80 | - * @param int $GRP_ID The MTP group we want attached events for. |
|
81 | - * @return array An array of event ids. |
|
82 | - * @throws EE_Error |
|
83 | - * @since 4.3.0 |
|
84 | - */ |
|
85 | - public function get_attached_event_ids($GRP_ID) |
|
86 | - { |
|
87 | - $event_ids = $this->_get_all_wpdb_results([['GRP_ID' => $GRP_ID]], ARRAY_N, 'EVT_ID'); |
|
88 | - $event_ids = call_user_func_array('array_merge', $event_ids); |
|
89 | - return $event_ids; |
|
90 | - } |
|
76 | + /** |
|
77 | + * helper method to simply return an array of event ids for events attached to the given |
|
78 | + * message template group. |
|
79 | + * |
|
80 | + * @param int $GRP_ID The MTP group we want attached events for. |
|
81 | + * @return array An array of event ids. |
|
82 | + * @throws EE_Error |
|
83 | + * @since 4.3.0 |
|
84 | + */ |
|
85 | + public function get_attached_event_ids($GRP_ID) |
|
86 | + { |
|
87 | + $event_ids = $this->_get_all_wpdb_results([['GRP_ID' => $GRP_ID]], ARRAY_N, 'EVT_ID'); |
|
88 | + $event_ids = call_user_func_array('array_merge', $event_ids); |
|
89 | + return $event_ids; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * helper method for clearing event/group relations for the given event ids and grp ids. |
|
95 | - * |
|
96 | - * @param array $GRP_IDs An array of GRP_IDs. Optional. If empty then there must be EVT IDs. |
|
97 | - * @param array $EVT_IDs An array of EVT_IDs. Optional. If empty then there must be GRP IDs. |
|
98 | - * @return int How many rows were deleted. |
|
99 | - * @throws EE_Error |
|
100 | - * @throws EE_Error |
|
101 | - */ |
|
102 | - public function delete_event_group_relations($GRP_IDs = [], $EVT_IDs = []) |
|
103 | - { |
|
104 | - if (empty($GRP_IDs) && empty($EVT_IDs)) { |
|
105 | - throw new EE_Error( |
|
106 | - sprintf( |
|
107 | - esc_html__( |
|
108 | - '%s requires either an array of GRP_IDs or EVT_IDs or both, but both cannot be empty.', |
|
109 | - 'event_espresso' |
|
110 | - ), |
|
111 | - __METHOD__ |
|
112 | - ) |
|
113 | - ); |
|
114 | - } |
|
93 | + /** |
|
94 | + * helper method for clearing event/group relations for the given event ids and grp ids. |
|
95 | + * |
|
96 | + * @param array $GRP_IDs An array of GRP_IDs. Optional. If empty then there must be EVT IDs. |
|
97 | + * @param array $EVT_IDs An array of EVT_IDs. Optional. If empty then there must be GRP IDs. |
|
98 | + * @return int How many rows were deleted. |
|
99 | + * @throws EE_Error |
|
100 | + * @throws EE_Error |
|
101 | + */ |
|
102 | + public function delete_event_group_relations($GRP_IDs = [], $EVT_IDs = []) |
|
103 | + { |
|
104 | + if (empty($GRP_IDs) && empty($EVT_IDs)) { |
|
105 | + throw new EE_Error( |
|
106 | + sprintf( |
|
107 | + esc_html__( |
|
108 | + '%s requires either an array of GRP_IDs or EVT_IDs or both, but both cannot be empty.', |
|
109 | + 'event_espresso' |
|
110 | + ), |
|
111 | + __METHOD__ |
|
112 | + ) |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | |
116 | - $where = []; |
|
117 | - if (! empty($GRP_IDs)) { |
|
118 | - $where['GRP_ID'] = ['IN', (array) $GRP_IDs]; |
|
119 | - } |
|
120 | - if (! empty($EVT_IDs)) { |
|
121 | - $where['EVT_ID'] = ['IN', (array) $EVT_IDs]; |
|
122 | - } |
|
116 | + $where = []; |
|
117 | + if (! empty($GRP_IDs)) { |
|
118 | + $where['GRP_ID'] = ['IN', (array) $GRP_IDs]; |
|
119 | + } |
|
120 | + if (! empty($EVT_IDs)) { |
|
121 | + $where['EVT_ID'] = ['IN', (array) $EVT_IDs]; |
|
122 | + } |
|
123 | 123 | |
124 | - return $this->delete([$where], false); |
|
125 | - } |
|
124 | + return $this->delete([$where], false); |
|
125 | + } |
|
126 | 126 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
41 | + if ( ! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | 42 | /** |
43 | 43 | * espresso_duplicate_plugin_error |
44 | 44 | * displays if more than one version of EE is activated at the same time |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
63 | 63 | } else { |
64 | 64 | define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | 66 | /** |
67 | 67 | * espresso_minimum_php_version_error |
68 | 68 | * |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | |
117 | 117 | register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
119 | + require_once __DIR__.'/core/bootstrap_espresso.php'; |
|
120 | 120 | bootstrap_espresso(); |
121 | 121 | } |
122 | 122 | } |
123 | -if (! function_exists('espresso_deactivate_plugin')) { |
|
123 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
124 | 124 | /** |
125 | 125 | * deactivate_plugin |
126 | 126 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function espresso_deactivate_plugin($plugin_basename = '') |
133 | 133 | { |
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
134 | + if ( ! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
136 | 136 | } |
137 | 137 | unset($_GET['activate'], $_REQUEST['activate']); |
138 | 138 | deactivate_plugins($plugin_basename); |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.39.rc.007'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.39.rc.007'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | \ No newline at end of file |
@@ -4,45 +4,45 @@ |
||
4 | 4 | interface EnqueueAssetsInterface |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * a place to register scripts and stylesheets with WordPress core |
|
9 | - * IMPORTANT !!! |
|
10 | - * ALL JavaScript files need to be registered for loading in the footer |
|
11 | - * by setting the 5th parameter of wp_register_script() to ` true ` |
|
12 | - * |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function registerScriptsAndStylesheets(); |
|
7 | + /** |
|
8 | + * a place to register scripts and stylesheets with WordPress core |
|
9 | + * IMPORTANT !!! |
|
10 | + * ALL JavaScript files need to be registered for loading in the footer |
|
11 | + * by setting the 5th parameter of wp_register_script() to ` true ` |
|
12 | + * |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function registerScriptsAndStylesheets(); |
|
16 | 16 | |
17 | - /** |
|
18 | - * a place to enqueue previously registered stylesheets |
|
19 | - * this will be called during the wp_enqueue_scripts hook for frontend requests |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function enqueueStylesheets(); |
|
17 | + /** |
|
18 | + * a place to enqueue previously registered stylesheets |
|
19 | + * this will be called during the wp_enqueue_scripts hook for frontend requests |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function enqueueStylesheets(); |
|
24 | 24 | |
25 | - /** |
|
26 | - * a place to enqueue previously registered stylesheets |
|
27 | - * this will be called during the admin_enqueue_scripts hook for admin requests |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function enqueueAdminStylesheets(); |
|
25 | + /** |
|
26 | + * a place to enqueue previously registered stylesheets |
|
27 | + * this will be called during the admin_enqueue_scripts hook for admin requests |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function enqueueAdminStylesheets(); |
|
32 | 32 | |
33 | - /** |
|
34 | - * a place to enqueue previously registered scripts for frontend requests |
|
35 | - * |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - public function enqueueScripts(); |
|
33 | + /** |
|
34 | + * a place to enqueue previously registered scripts for frontend requests |
|
35 | + * |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + public function enqueueScripts(); |
|
39 | 39 | |
40 | - /** |
|
41 | - * a place to enqueue previously registered scripts for admin requests |
|
42 | - * |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public function enqueueAdminScripts(); |
|
40 | + /** |
|
41 | + * a place to enqueue previously registered scripts for admin requests |
|
42 | + * |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public function enqueueAdminScripts(); |
|
46 | 46 | } |
47 | 47 | // End of file EnqueueAssetsInterface.php |
48 | 48 | // Location: EventEspresso\core\domain/EnqueueAssetsInterface.php |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <p><strong><?php esc_html_e('Message Types', 'event_espresso'); ?></strong></p> |
2 | 2 | <p> |
3 | 3 | <?php |
4 | - printf( |
|
5 | - esc_html__( |
|
6 | - 'Messages are email notifications that are sent out by Event Espresso. Message Types are the %1$skinds%2$s of messages that get delivered. They can be thought of as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email Messenger:', |
|
7 | - 'event_espresso' |
|
8 | - ), |
|
9 | - '<em>', |
|
10 | - '</em>' |
|
11 | - ); |
|
12 | - ?> |
|
4 | + printf( |
|
5 | + esc_html__( |
|
6 | + 'Messages are email notifications that are sent out by Event Espresso. Message Types are the %1$skinds%2$s of messages that get delivered. They can be thought of as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email Messenger:', |
|
7 | + 'event_espresso' |
|
8 | + ), |
|
9 | + '<em>', |
|
10 | + '</em>' |
|
11 | + ); |
|
12 | + ?> |
|
13 | 13 | </p> |
14 | 14 | <ul> |
15 | 15 | <li> |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | <p><strong><?php esc_html_e('Contexts', 'event_espresso'); ?></strong></p> |
25 | 25 | <p> |
26 | 26 | <?php esc_html_e( |
27 | - 'Each Message Type (kind of message) has different contexts. Contexts are dynamic and typically represent recipients (individuals receiving email notifications). For example, when the Registration Confirmation message type is triggered, it will send out a message to the following recipients: Event Administrator, Primary Registrant, and Additional Registrants. On the other hand, the Payment Message Type has only two recipients: Event Administrator and Primary Registrant.', |
|
28 | - 'event_espresso' |
|
29 | - ); ?> |
|
27 | + 'Each Message Type (kind of message) has different contexts. Contexts are dynamic and typically represent recipients (individuals receiving email notifications). For example, when the Registration Confirmation message type is triggered, it will send out a message to the following recipients: Event Administrator, Primary Registrant, and Additional Registrants. On the other hand, the Payment Message Type has only two recipients: Event Administrator and Primary Registrant.', |
|
28 | + 'event_espresso' |
|
29 | + ); ?> |
|
30 | 30 | </p> |
31 | 31 | <p> |
32 | 32 | <?php esc_html_e( |
33 | - 'A message context can be deactivated by removing a recipient from the "TO" field. This will set the field to blank and you can save changes. Deactivated message contexts will appear in grey when viewed in the Messages Overview tab. To re-activate a message context, go to that message context and setup a recipient (using one of the available shortcodes) and save changes. This will reactivate the message context and it will appear as blue in the Messages Overview tab.', |
|
34 | - 'event_espresso' |
|
35 | - ); ?> |
|
33 | + 'A message context can be deactivated by removing a recipient from the "TO" field. This will set the field to blank and you can save changes. Deactivated message contexts will appear in grey when viewed in the Messages Overview tab. To re-activate a message context, go to that message context and setup a recipient (using one of the available shortcodes) and save changes. This will reactivate the message context and it will appear as blue in the Messages Overview tab.', |
|
34 | + 'event_espresso' |
|
35 | + ); ?> |
|
36 | 36 | </p> |
37 | 37 | <p><strong><?php esc_html_e('Activation / Deactivation of Message Types', 'event_espresso'); ?></strong></p> |
38 | 38 | <p> |
39 | 39 | <?php esc_html_e( |
40 | - 'When a new install of Event Espresso is activated, all message types will be activated except for those for Cancelled and Declined registrations. The message types for Cancelled and Declined registrations can be easily activated through the Settings tab for Messages. Deactivating and re-activating Event Espresso will keep the current settings saved.', |
|
41 | - 'event_espresso' |
|
42 | - ); ?> |
|
40 | + 'When a new install of Event Espresso is activated, all message types will be activated except for those for Cancelled and Declined registrations. The message types for Cancelled and Declined registrations can be easily activated through the Settings tab for Messages. Deactivating and re-activating Event Espresso will keep the current settings saved.', |
|
41 | + 'event_espresso' |
|
42 | + ); ?> |
|
43 | 43 | </p> |
@@ -53,7 +53,7 @@ |
||
53 | 53 | 'The URL of the button image for this payment method in the registration process. You may use any uploaded image on your website (click %s next to the field to select). If left blank, the default button image will be used.', |
54 | 54 | 'event_espresso' |
55 | 55 | ), |
56 | - '<img src="' . admin_url('images/media-button-image.gif') . '">' |
|
56 | + '<img src="'.admin_url('images/media-button-image.gif').'">' |
|
57 | 57 | ); |
58 | 58 | ?> |
59 | 59 | </li> |
@@ -12,62 +12,62 @@ discard block |
||
12 | 12 | <strong><?php esc_html_e('Name', 'event_espresso'); ?></strong> |
13 | 13 | <br> |
14 | 14 | <?php esc_html_e( |
15 | - 'The name of the payment method as customers see it in the registration form, in emails, in receipts, etc.', |
|
16 | - 'event_espresso' |
|
17 | - ); ?> |
|
15 | + 'The name of the payment method as customers see it in the registration form, in emails, in receipts, etc.', |
|
16 | + 'event_espresso' |
|
17 | + ); ?> |
|
18 | 18 | </li> |
19 | 19 | <li> |
20 | 20 | <strong><?php esc_html_e('Description', 'event_espresso'); ?></strong> |
21 | 21 | <br /> |
22 | 22 | <?php esc_html_e( |
23 | - 'The description of how to use the payment method as customers will see it. This is mostly only seen during registration.', |
|
24 | - 'event_espresso' |
|
25 | - ); ?> |
|
23 | + 'The description of how to use the payment method as customers will see it. This is mostly only seen during registration.', |
|
24 | + 'event_espresso' |
|
25 | + ); ?> |
|
26 | 26 | </li> |
27 | 27 | <li> |
28 | 28 | <strong><?php esc_html_e('Admin-Only Name', 'event_espresso'); ?></strong> |
29 | 29 | <br /> |
30 | 30 | <?php esc_html_e( |
31 | - 'The name of the payment method as seen internally by site administrators and staff.', |
|
32 | - 'event_espresso' |
|
33 | - ); ?> |
|
31 | + 'The name of the payment method as seen internally by site administrators and staff.', |
|
32 | + 'event_espresso' |
|
33 | + ); ?> |
|
34 | 34 | </li> |
35 | 35 | <li> |
36 | 36 | <strong><?php esc_html_e('Admin-Only Description', 'event_espresso'); ?></strong> |
37 | 37 | <br /> |
38 | 38 | <?php esc_html_e( |
39 | - 'The description of the payment method as seen internally by site administrators and staff.', |
|
40 | - 'event_espresso' |
|
41 | - ); ?> |
|
39 | + 'The description of the payment method as seen internally by site administrators and staff.', |
|
40 | + 'event_espresso' |
|
41 | + ); ?> |
|
42 | 42 | </li> |
43 | 43 | <li> |
44 | 44 | <strong><?php esc_html_e('Debug (sandbox) Mode', 'event_espresso'); ?></strong> |
45 | 45 | <br /> |
46 | 46 | <?php esc_html_e( |
47 | - 'Many payment methods have a debug/sandbox mode where payments are not processed but are only simulated. This is helpful when setup and debugging.', |
|
48 | - 'event_espresso' |
|
49 | - ); ?> |
|
47 | + 'Many payment methods have a debug/sandbox mode where payments are not processed but are only simulated. This is helpful when setup and debugging.', |
|
48 | + 'event_espresso' |
|
49 | + ); ?> |
|
50 | 50 | </li> |
51 | 51 | <li> |
52 | 52 | <strong><?php esc_html_e('Open by Default', 'event_espresso'); ?></strong> |
53 | 53 | <br /> |
54 | 54 | <?php esc_html_e( |
55 | - 'If checked, this payment method will be selected by default (assuming no other valid payment methods are also marked as open by default.)', |
|
56 | - 'event_espresso' |
|
57 | - ); ?> |
|
55 | + 'If checked, this payment method will be selected by default (assuming no other valid payment methods are also marked as open by default.)', |
|
56 | + 'event_espresso' |
|
57 | + ); ?> |
|
58 | 58 | </li> |
59 | 59 | <li> |
60 | 60 | <strong><?php esc_html_e('Button URL', 'event_espresso'); ?></strong> |
61 | 61 | <br /> |
62 | 62 | <?php |
63 | - printf( |
|
64 | - esc_html__( |
|
65 | - 'The URL of the button image for this payment method in the registration process. You may use any uploaded image on your website (click %s next to the field to select). If left blank, the default button image will be used.', |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - '<img src="' . admin_url('images/media-button-image.gif') . '">' |
|
69 | - ); |
|
70 | - ?> |
|
63 | + printf( |
|
64 | + esc_html__( |
|
65 | + 'The URL of the button image for this payment method in the registration process. You may use any uploaded image on your website (click %s next to the field to select). If left blank, the default button image will be used.', |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + '<img src="' . admin_url('images/media-button-image.gif') . '">' |
|
69 | + ); |
|
70 | + ?> |
|
71 | 71 | </li> |
72 | 72 | <li><strong><?php esc_html_e('Usable From', 'event_espresso'); ?></strong> |
73 | 73 | <br /> |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | <ul> |
76 | 76 | <li> |
77 | 77 | <?php esc_html_e( |
78 | - 'Front-end Registration Page: the payment method will appear as an option during the normal registration process to customers and they can use it to process payments.', |
|
79 | - 'event_espresso' |
|
80 | - ); ?> |
|
78 | + 'Front-end Registration Page: the payment method will appear as an option during the normal registration process to customers and they can use it to process payments.', |
|
79 | + 'event_espresso' |
|
80 | + ); ?> |
|
81 | 81 | </li> |
82 | 82 | <li> |
83 | 83 | <?php esc_html_e( |
84 | - 'Admin Registration Page: when recording payments made from the transaction admin page, the payment method will appear as an option. Note: currently payments can only be RECORDED from the admin, they cannot be PROCESSED.', |
|
85 | - 'event_espresso' |
|
86 | - ); ?> |
|
84 | + 'Admin Registration Page: when recording payments made from the transaction admin page, the payment method will appear as an option. Note: currently payments can only be RECORDED from the admin, they cannot be PROCESSED.', |
|
85 | + 'event_espresso' |
|
86 | + ); ?> |
|
87 | 87 | </li> |
88 | 88 | </ul> |
89 | 89 | </li> |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
92 | 92 | <br /> |
93 | 93 | <?php esc_html_e( |
94 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
95 | - 'event_espresso' |
|
94 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
95 | + 'event_espresso' |
|
96 | 96 | ); ?> |
97 | 97 | <p> |
98 | 98 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
99 | 99 | <br /> |
100 | 100 | <?php esc_html_e( |
101 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
102 | - 'event_espresso' |
|
103 | - ); ?> |
|
101 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
102 | + 'event_espresso' |
|
103 | + ); ?> |
|
104 | 104 | </p> |
105 | 105 | \ No newline at end of file |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | private function _get_datetimes_from_event(EE_Event $event) |
169 | 169 | { |
170 | 170 | return isset($this->_extra_data['data']->events) |
171 | - ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
171 | + ? $this->_extra_data['data']->events[$event->ID()]['dtt_objs'] |
|
172 | 172 | : []; |
173 | 173 | } |
174 | 174 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
183 | 183 | { |
184 | 184 | return isset($this->_extra_data['data']->tickets) |
185 | - ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
185 | + ? $this->_extra_data['data']->tickets[$ticket->ID()]['dtt_objs'] |
|
186 | 186 | : []; |
187 | 187 | } |
188 | 188 | } |
@@ -18,168 +18,168 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Datetime_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - protected function _init_props() |
|
22 | - { |
|
23 | - $this->label = esc_html__('Datetime List Shortcodes', 'event_espresso'); |
|
24 | - $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso'); |
|
25 | - $this->_shortcodes = [ |
|
26 | - '[DATETIME_LIST]' => esc_html__( |
|
27 | - 'Will output a list of datetimes according to the layout specified in the datetime list field.', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - ]; |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @throws EE_Error |
|
36 | - * @throws ReflectionException |
|
37 | - */ |
|
38 | - protected function _parser($shortcode) |
|
39 | - { |
|
40 | - switch ($shortcode) { |
|
41 | - case '[DATETIME_LIST]': |
|
42 | - return $this->_get_datetime_list(); |
|
43 | - } |
|
44 | - return ''; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
50 | - * |
|
51 | - * @return string |
|
52 | - * @throws EE_Error |
|
53 | - * @throws EE_Error |
|
54 | - * @throws ReflectionException |
|
55 | - */ |
|
56 | - private function _get_datetime_list() |
|
57 | - { |
|
58 | - $this->_validate_list_requirements(); |
|
59 | - |
|
60 | - if ($this->_data['data'] instanceof EE_Ticket) { |
|
61 | - return $this->_get_datetime_list_for_ticket(); |
|
62 | - } |
|
63 | - if ($this->_data['data'] instanceof EE_Event) { |
|
64 | - return $this->_get_datetime_list_for_event(); |
|
65 | - } |
|
66 | - if ( |
|
67 | - $this->_data['data'] instanceof EE_Messages_Addressee |
|
68 | - && $this->_data['data']->reg_obj instanceof EE_Registration |
|
69 | - ) { |
|
70 | - return $this->_get_datetime_list_for_registration(); |
|
71 | - } |
|
72 | - // prevent recursive loop |
|
73 | - return ''; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * return parsed list of datetimes for an event |
|
79 | - * |
|
80 | - * @return string |
|
81 | - * @throws EE_Error |
|
82 | - * @throws ReflectionException |
|
83 | - */ |
|
84 | - private function _get_datetime_list_for_event() |
|
85 | - { |
|
86 | - $event = $this->_data['data']; |
|
87 | - $valid_shortcodes = ['datetime', 'attendee']; |
|
88 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
89 | - ? $this->_data['template']['datetime_list'] |
|
90 | - : $this->_extra_data['template']['datetime_list']; |
|
91 | - |
|
92 | - // here we're setting up the datetimes for the datetime list template for THIS event. |
|
93 | - $dtt_parsed = ''; |
|
94 | - $datetimes = $this->_get_datetimes_from_event($event); |
|
95 | - |
|
96 | - // each datetime in this case should be an datetime object. |
|
97 | - foreach ($datetimes as $datetime) { |
|
98 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
99 | - $template, |
|
100 | - $datetime, |
|
101 | - $valid_shortcodes, |
|
102 | - $this->_extra_data |
|
103 | - ); |
|
104 | - } |
|
105 | - |
|
106 | - return $dtt_parsed; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * return parsed list of datetimes for an ticket |
|
112 | - * |
|
113 | - * @return string |
|
114 | - * @throws EE_Error |
|
115 | - */ |
|
116 | - private function _get_datetime_list_for_ticket() |
|
117 | - { |
|
118 | - $valid_shortcodes = ['datetime', 'attendee']; |
|
119 | - |
|
120 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
121 | - ? $this->_data['template']['datetime_list'] |
|
122 | - : $this->_extra_data['template']['datetime_list']; |
|
123 | - $ticket = $this->_data['data']; |
|
124 | - |
|
125 | - // here we're setting up the datetimes for the datetime list template for THIS ticket. |
|
126 | - $dtt_parsed = ''; |
|
127 | - $datetimes = $this->_get_datetimes_from_ticket($ticket); |
|
128 | - |
|
129 | - // each datetime in this case should be an datetime object. |
|
130 | - foreach ($datetimes as $datetime) { |
|
131 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
132 | - $template, |
|
133 | - $datetime, |
|
134 | - $valid_shortcodes, |
|
135 | - $this->_extra_data |
|
136 | - ); |
|
137 | - } |
|
138 | - |
|
139 | - return $dtt_parsed; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * return parsed list of datetimes from a given registration. |
|
145 | - * |
|
146 | - * @return string |
|
147 | - * @throws EE_Error |
|
148 | - * @throws EE_Error |
|
149 | - */ |
|
150 | - private function _get_datetime_list_for_registration() |
|
151 | - { |
|
152 | - $registration = $this->_data['data']->reg_obj; |
|
153 | - |
|
154 | - // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket(); |
|
155 | - $this->_data['data'] = $registration->ticket(); |
|
156 | - return $this->_get_datetime_list_for_ticket(); |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * @param EE_Event $event |
|
162 | - * @return array|mixed |
|
163 | - * @throws EE_Error |
|
164 | - * @throws ReflectionException |
|
165 | - */ |
|
166 | - private function _get_datetimes_from_event(EE_Event $event) |
|
167 | - { |
|
168 | - return isset($this->_extra_data['data']->events) |
|
169 | - ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
170 | - : []; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * @param EE_Ticket $ticket |
|
176 | - * @return array|mixed |
|
177 | - * @throws EE_Error |
|
178 | - */ |
|
179 | - private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
|
180 | - { |
|
181 | - return isset($this->_extra_data['data']->tickets) |
|
182 | - ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
183 | - : []; |
|
184 | - } |
|
21 | + protected function _init_props() |
|
22 | + { |
|
23 | + $this->label = esc_html__('Datetime List Shortcodes', 'event_espresso'); |
|
24 | + $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso'); |
|
25 | + $this->_shortcodes = [ |
|
26 | + '[DATETIME_LIST]' => esc_html__( |
|
27 | + 'Will output a list of datetimes according to the layout specified in the datetime list field.', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + ]; |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @throws EE_Error |
|
36 | + * @throws ReflectionException |
|
37 | + */ |
|
38 | + protected function _parser($shortcode) |
|
39 | + { |
|
40 | + switch ($shortcode) { |
|
41 | + case '[DATETIME_LIST]': |
|
42 | + return $this->_get_datetime_list(); |
|
43 | + } |
|
44 | + return ''; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
50 | + * |
|
51 | + * @return string |
|
52 | + * @throws EE_Error |
|
53 | + * @throws EE_Error |
|
54 | + * @throws ReflectionException |
|
55 | + */ |
|
56 | + private function _get_datetime_list() |
|
57 | + { |
|
58 | + $this->_validate_list_requirements(); |
|
59 | + |
|
60 | + if ($this->_data['data'] instanceof EE_Ticket) { |
|
61 | + return $this->_get_datetime_list_for_ticket(); |
|
62 | + } |
|
63 | + if ($this->_data['data'] instanceof EE_Event) { |
|
64 | + return $this->_get_datetime_list_for_event(); |
|
65 | + } |
|
66 | + if ( |
|
67 | + $this->_data['data'] instanceof EE_Messages_Addressee |
|
68 | + && $this->_data['data']->reg_obj instanceof EE_Registration |
|
69 | + ) { |
|
70 | + return $this->_get_datetime_list_for_registration(); |
|
71 | + } |
|
72 | + // prevent recursive loop |
|
73 | + return ''; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * return parsed list of datetimes for an event |
|
79 | + * |
|
80 | + * @return string |
|
81 | + * @throws EE_Error |
|
82 | + * @throws ReflectionException |
|
83 | + */ |
|
84 | + private function _get_datetime_list_for_event() |
|
85 | + { |
|
86 | + $event = $this->_data['data']; |
|
87 | + $valid_shortcodes = ['datetime', 'attendee']; |
|
88 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
89 | + ? $this->_data['template']['datetime_list'] |
|
90 | + : $this->_extra_data['template']['datetime_list']; |
|
91 | + |
|
92 | + // here we're setting up the datetimes for the datetime list template for THIS event. |
|
93 | + $dtt_parsed = ''; |
|
94 | + $datetimes = $this->_get_datetimes_from_event($event); |
|
95 | + |
|
96 | + // each datetime in this case should be an datetime object. |
|
97 | + foreach ($datetimes as $datetime) { |
|
98 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
99 | + $template, |
|
100 | + $datetime, |
|
101 | + $valid_shortcodes, |
|
102 | + $this->_extra_data |
|
103 | + ); |
|
104 | + } |
|
105 | + |
|
106 | + return $dtt_parsed; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * return parsed list of datetimes for an ticket |
|
112 | + * |
|
113 | + * @return string |
|
114 | + * @throws EE_Error |
|
115 | + */ |
|
116 | + private function _get_datetime_list_for_ticket() |
|
117 | + { |
|
118 | + $valid_shortcodes = ['datetime', 'attendee']; |
|
119 | + |
|
120 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
121 | + ? $this->_data['template']['datetime_list'] |
|
122 | + : $this->_extra_data['template']['datetime_list']; |
|
123 | + $ticket = $this->_data['data']; |
|
124 | + |
|
125 | + // here we're setting up the datetimes for the datetime list template for THIS ticket. |
|
126 | + $dtt_parsed = ''; |
|
127 | + $datetimes = $this->_get_datetimes_from_ticket($ticket); |
|
128 | + |
|
129 | + // each datetime in this case should be an datetime object. |
|
130 | + foreach ($datetimes as $datetime) { |
|
131 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
132 | + $template, |
|
133 | + $datetime, |
|
134 | + $valid_shortcodes, |
|
135 | + $this->_extra_data |
|
136 | + ); |
|
137 | + } |
|
138 | + |
|
139 | + return $dtt_parsed; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * return parsed list of datetimes from a given registration. |
|
145 | + * |
|
146 | + * @return string |
|
147 | + * @throws EE_Error |
|
148 | + * @throws EE_Error |
|
149 | + */ |
|
150 | + private function _get_datetime_list_for_registration() |
|
151 | + { |
|
152 | + $registration = $this->_data['data']->reg_obj; |
|
153 | + |
|
154 | + // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket(); |
|
155 | + $this->_data['data'] = $registration->ticket(); |
|
156 | + return $this->_get_datetime_list_for_ticket(); |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * @param EE_Event $event |
|
162 | + * @return array|mixed |
|
163 | + * @throws EE_Error |
|
164 | + * @throws ReflectionException |
|
165 | + */ |
|
166 | + private function _get_datetimes_from_event(EE_Event $event) |
|
167 | + { |
|
168 | + return isset($this->_extra_data['data']->events) |
|
169 | + ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
170 | + : []; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * @param EE_Ticket $ticket |
|
176 | + * @return array|mixed |
|
177 | + * @throws EE_Error |
|
178 | + */ |
|
179 | + private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
|
180 | + { |
|
181 | + return isset($this->_extra_data['data']->tickets) |
|
182 | + ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
183 | + : []; |
|
184 | + } |
|
185 | 185 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | private function _get_tickets_from_event(EE_Event $event) |
203 | 203 | { |
204 | 204 | return isset($this->_extra_data['data']->events) |
205 | - ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs'] |
|
205 | + ? $this->_extra_data['data']->events[$event->ID()]['tkt_objs'] |
|
206 | 206 | : []; |
207 | 207 | } |
208 | 208 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | private function _get_ticket_list_from_registration(EE_Registration $registration) |
217 | 217 | { |
218 | 218 | return isset($this->_extra_data['data']->registrations) |
219 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']] |
|
219 | + ? [$this->_extra_data['data']->registrations[$registration->ID()]['tkt_obj']] |
|
220 | 220 | : []; |
221 | 221 | } |
222 | 222 | } |
@@ -18,208 +18,208 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Ticket_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct(); |
|
24 | - } |
|
25 | - |
|
26 | - |
|
27 | - protected function _init_props() |
|
28 | - { |
|
29 | - $this->label = esc_html__('Ticket List Shortcodes', 'event_espresso'); |
|
30 | - $this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso'); |
|
31 | - $this->_shortcodes = [ |
|
32 | - '[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'), |
|
33 | - ]; |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @param string $shortcode |
|
39 | - * @return string |
|
40 | - * @throws EE_Error |
|
41 | - * @throws ReflectionException |
|
42 | - */ |
|
43 | - protected function _parser($shortcode) |
|
44 | - { |
|
45 | - switch ($shortcode) { |
|
46 | - case '[TICKET_LIST]': |
|
47 | - return $this->_get_ticket_list(); |
|
48 | - } |
|
49 | - return ''; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
55 | - * |
|
56 | - * @return string |
|
57 | - * @throws EE_Error |
|
58 | - * @throws ReflectionException |
|
59 | - */ |
|
60 | - private function _get_ticket_list() |
|
61 | - { |
|
62 | - $this->_validate_list_requirements(); |
|
63 | - |
|
64 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
65 | - return $this->_get_ticket_list_for_main(); |
|
66 | - } |
|
67 | - if ($this->_data['data'] instanceof EE_Registration) { |
|
68 | - return $this->_get_ticket_list_for_attendee(); |
|
69 | - } |
|
70 | - if ($this->_data['data'] instanceof EE_Event) { |
|
71 | - return $this->_get_ticket_list_for_event(); |
|
72 | - } |
|
73 | - // prevent recursive loop |
|
74 | - return ''; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * This returns the parsed ticket list for main template; |
|
80 | - */ |
|
81 | - private function _get_ticket_list_for_main() |
|
82 | - { |
|
83 | - $valid_shortcodes = [ |
|
84 | - 'ticket', |
|
85 | - 'event_list', |
|
86 | - 'attendee_list', |
|
87 | - 'datetime_list', |
|
88 | - 'attendee', |
|
89 | - 'line_item_list', |
|
90 | - 'primary_registration_details', |
|
91 | - 'recipient_details', |
|
92 | - ]; |
|
93 | - $template = $this->_data['template']; |
|
94 | - $data = $this->_data['data']; |
|
95 | - $ticket_list = ''; |
|
96 | - |
|
97 | - |
|
98 | - // now we need to loop through the ticket list and send data to the EE_Parser helper. |
|
99 | - foreach ($data->tickets as $ticket) { |
|
100 | - $ticket_list .= $this->_shortcode_helper->parse_ticket_list_template( |
|
101 | - $template, |
|
102 | - $ticket['ticket'], |
|
103 | - $valid_shortcodes, |
|
104 | - $this->_extra_data |
|
105 | - ); |
|
106 | - } |
|
107 | - |
|
108 | - return $ticket_list; |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * return parsed list of tickets for an event |
|
114 | - * |
|
115 | - * @return string |
|
116 | - * @throws EE_Error |
|
117 | - * @throws ReflectionException |
|
118 | - */ |
|
119 | - private function _get_ticket_list_for_event() |
|
120 | - { |
|
121 | - $valid_shortcodes = [ |
|
122 | - 'ticket', |
|
123 | - 'attendee_list', |
|
124 | - 'datetime_list', |
|
125 | - 'attendee', |
|
126 | - 'venue', |
|
127 | - 'line_item_list', |
|
128 | - 'primary_registration_details', |
|
129 | - 'recipient_details', |
|
130 | - ]; |
|
131 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
132 | - ? $this->_data['template']['ticket_list'] |
|
133 | - : $this->_extra_data['template']['ticket_list']; |
|
134 | - $event = $this->_data['data']; |
|
135 | - |
|
136 | - // let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion. |
|
137 | - $template = str_replace('[EVENT_LIST]', '', $template); |
|
138 | - |
|
139 | - // here we're setting up the tickets for the ticket list template for THIS event. |
|
140 | - $tkt_parsed = ''; |
|
141 | - $tickets = $this->_get_tickets_from_event($event); |
|
142 | - |
|
143 | - // each ticket in this case should be an ticket object. |
|
144 | - foreach ($tickets as $ticket) { |
|
145 | - $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
146 | - $template, |
|
147 | - $ticket, |
|
148 | - $valid_shortcodes, |
|
149 | - $this->_extra_data |
|
150 | - ); |
|
151 | - } |
|
152 | - |
|
153 | - return $tkt_parsed; |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * return parsed list of tickets for an attendee |
|
159 | - * |
|
160 | - * @return string |
|
161 | - * @throws EE_Error |
|
162 | - * @throws ReflectionException |
|
163 | - */ |
|
164 | - private function _get_ticket_list_for_attendee() |
|
165 | - { |
|
166 | - $valid_shortcodes = [ |
|
167 | - 'ticket', |
|
168 | - 'event_list', |
|
169 | - 'datetime_list', |
|
170 | - 'attendee', |
|
171 | - 'primary_registration_details', |
|
172 | - 'recipient_details', |
|
173 | - ]; |
|
174 | - |
|
175 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
176 | - ? $this->_data['template']['ticket_list'] |
|
177 | - : $this->_extra_data['template']['ticket_list']; |
|
178 | - $registration = $this->_data['data']; |
|
179 | - |
|
180 | - // let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
181 | - $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
182 | - |
|
183 | - // here we're setting up the tickets for the ticket list template for THIS attendee. |
|
184 | - $tkt_parsed = ''; |
|
185 | - $tickets = $this->_get_ticket_list_from_registration($registration); |
|
186 | - |
|
187 | - // each ticket in this case should be an ticket object. |
|
188 | - foreach ($tickets as $ticket) { |
|
189 | - $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
190 | - $template, |
|
191 | - $ticket, |
|
192 | - $valid_shortcodes, |
|
193 | - $this->_extra_data |
|
194 | - ); |
|
195 | - } |
|
196 | - |
|
197 | - return $tkt_parsed; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * @throws EE_Error |
|
203 | - * @throws ReflectionException |
|
204 | - */ |
|
205 | - private function _get_tickets_from_event(EE_Event $event) |
|
206 | - { |
|
207 | - return isset($this->_extra_data['data']->events) |
|
208 | - ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs'] |
|
209 | - : []; |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * @param EE_Registration $registration |
|
215 | - * @return array |
|
216 | - * @throws EE_Error |
|
217 | - * @throws ReflectionException |
|
218 | - */ |
|
219 | - private function _get_ticket_list_from_registration(EE_Registration $registration) |
|
220 | - { |
|
221 | - return isset($this->_extra_data['data']->registrations) |
|
222 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']] |
|
223 | - : []; |
|
224 | - } |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct(); |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + protected function _init_props() |
|
28 | + { |
|
29 | + $this->label = esc_html__('Ticket List Shortcodes', 'event_espresso'); |
|
30 | + $this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso'); |
|
31 | + $this->_shortcodes = [ |
|
32 | + '[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'), |
|
33 | + ]; |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @param string $shortcode |
|
39 | + * @return string |
|
40 | + * @throws EE_Error |
|
41 | + * @throws ReflectionException |
|
42 | + */ |
|
43 | + protected function _parser($shortcode) |
|
44 | + { |
|
45 | + switch ($shortcode) { |
|
46 | + case '[TICKET_LIST]': |
|
47 | + return $this->_get_ticket_list(); |
|
48 | + } |
|
49 | + return ''; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
55 | + * |
|
56 | + * @return string |
|
57 | + * @throws EE_Error |
|
58 | + * @throws ReflectionException |
|
59 | + */ |
|
60 | + private function _get_ticket_list() |
|
61 | + { |
|
62 | + $this->_validate_list_requirements(); |
|
63 | + |
|
64 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
65 | + return $this->_get_ticket_list_for_main(); |
|
66 | + } |
|
67 | + if ($this->_data['data'] instanceof EE_Registration) { |
|
68 | + return $this->_get_ticket_list_for_attendee(); |
|
69 | + } |
|
70 | + if ($this->_data['data'] instanceof EE_Event) { |
|
71 | + return $this->_get_ticket_list_for_event(); |
|
72 | + } |
|
73 | + // prevent recursive loop |
|
74 | + return ''; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * This returns the parsed ticket list for main template; |
|
80 | + */ |
|
81 | + private function _get_ticket_list_for_main() |
|
82 | + { |
|
83 | + $valid_shortcodes = [ |
|
84 | + 'ticket', |
|
85 | + 'event_list', |
|
86 | + 'attendee_list', |
|
87 | + 'datetime_list', |
|
88 | + 'attendee', |
|
89 | + 'line_item_list', |
|
90 | + 'primary_registration_details', |
|
91 | + 'recipient_details', |
|
92 | + ]; |
|
93 | + $template = $this->_data['template']; |
|
94 | + $data = $this->_data['data']; |
|
95 | + $ticket_list = ''; |
|
96 | + |
|
97 | + |
|
98 | + // now we need to loop through the ticket list and send data to the EE_Parser helper. |
|
99 | + foreach ($data->tickets as $ticket) { |
|
100 | + $ticket_list .= $this->_shortcode_helper->parse_ticket_list_template( |
|
101 | + $template, |
|
102 | + $ticket['ticket'], |
|
103 | + $valid_shortcodes, |
|
104 | + $this->_extra_data |
|
105 | + ); |
|
106 | + } |
|
107 | + |
|
108 | + return $ticket_list; |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * return parsed list of tickets for an event |
|
114 | + * |
|
115 | + * @return string |
|
116 | + * @throws EE_Error |
|
117 | + * @throws ReflectionException |
|
118 | + */ |
|
119 | + private function _get_ticket_list_for_event() |
|
120 | + { |
|
121 | + $valid_shortcodes = [ |
|
122 | + 'ticket', |
|
123 | + 'attendee_list', |
|
124 | + 'datetime_list', |
|
125 | + 'attendee', |
|
126 | + 'venue', |
|
127 | + 'line_item_list', |
|
128 | + 'primary_registration_details', |
|
129 | + 'recipient_details', |
|
130 | + ]; |
|
131 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
132 | + ? $this->_data['template']['ticket_list'] |
|
133 | + : $this->_extra_data['template']['ticket_list']; |
|
134 | + $event = $this->_data['data']; |
|
135 | + |
|
136 | + // let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion. |
|
137 | + $template = str_replace('[EVENT_LIST]', '', $template); |
|
138 | + |
|
139 | + // here we're setting up the tickets for the ticket list template for THIS event. |
|
140 | + $tkt_parsed = ''; |
|
141 | + $tickets = $this->_get_tickets_from_event($event); |
|
142 | + |
|
143 | + // each ticket in this case should be an ticket object. |
|
144 | + foreach ($tickets as $ticket) { |
|
145 | + $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
146 | + $template, |
|
147 | + $ticket, |
|
148 | + $valid_shortcodes, |
|
149 | + $this->_extra_data |
|
150 | + ); |
|
151 | + } |
|
152 | + |
|
153 | + return $tkt_parsed; |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * return parsed list of tickets for an attendee |
|
159 | + * |
|
160 | + * @return string |
|
161 | + * @throws EE_Error |
|
162 | + * @throws ReflectionException |
|
163 | + */ |
|
164 | + private function _get_ticket_list_for_attendee() |
|
165 | + { |
|
166 | + $valid_shortcodes = [ |
|
167 | + 'ticket', |
|
168 | + 'event_list', |
|
169 | + 'datetime_list', |
|
170 | + 'attendee', |
|
171 | + 'primary_registration_details', |
|
172 | + 'recipient_details', |
|
173 | + ]; |
|
174 | + |
|
175 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
176 | + ? $this->_data['template']['ticket_list'] |
|
177 | + : $this->_extra_data['template']['ticket_list']; |
|
178 | + $registration = $this->_data['data']; |
|
179 | + |
|
180 | + // let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
181 | + $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
182 | + |
|
183 | + // here we're setting up the tickets for the ticket list template for THIS attendee. |
|
184 | + $tkt_parsed = ''; |
|
185 | + $tickets = $this->_get_ticket_list_from_registration($registration); |
|
186 | + |
|
187 | + // each ticket in this case should be an ticket object. |
|
188 | + foreach ($tickets as $ticket) { |
|
189 | + $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
190 | + $template, |
|
191 | + $ticket, |
|
192 | + $valid_shortcodes, |
|
193 | + $this->_extra_data |
|
194 | + ); |
|
195 | + } |
|
196 | + |
|
197 | + return $tkt_parsed; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * @throws EE_Error |
|
203 | + * @throws ReflectionException |
|
204 | + */ |
|
205 | + private function _get_tickets_from_event(EE_Event $event) |
|
206 | + { |
|
207 | + return isset($this->_extra_data['data']->events) |
|
208 | + ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs'] |
|
209 | + : []; |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * @param EE_Registration $registration |
|
215 | + * @return array |
|
216 | + * @throws EE_Error |
|
217 | + * @throws ReflectionException |
|
218 | + */ |
|
219 | + private function _get_ticket_list_from_registration(EE_Registration $registration) |
|
220 | + { |
|
221 | + return isset($this->_extra_data['data']->registrations) |
|
222 | + ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']] |
|
223 | + : []; |
|
224 | + } |
|
225 | 225 | } |