@@ -57,7 +57,7 @@ |
||
57 | 57 | * check whether count of tickets is approaching the potential |
58 | 58 | * limits for the server. |
59 | 59 | */ |
60 | - if (! empty($data['input_count'])) { |
|
60 | + if ( ! empty($data['input_count'])) { |
|
61 | 61 | $response['max_input_vars_check'] = $this->environment->max_input_vars_limit_check( |
62 | 62 | $data['input_count'] |
63 | 63 | ); |
@@ -15,52 +15,52 @@ |
||
15 | 15 | */ |
16 | 16 | class EventEditorHeartbeat |
17 | 17 | { |
18 | - /** |
|
19 | - * @var Domain $domain |
|
20 | - */ |
|
21 | - protected $domain; |
|
18 | + /** |
|
19 | + * @var Domain $domain |
|
20 | + */ |
|
21 | + protected $domain; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var EE_Environment_Config $environment |
|
25 | - */ |
|
26 | - protected $environment; |
|
23 | + /** |
|
24 | + * @var EE_Environment_Config $environment |
|
25 | + */ |
|
26 | + protected $environment; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * EventEditorHeartbeat constructor. |
|
31 | - * |
|
32 | - * @param Domain $domain |
|
33 | - * @param EE_Environment_Config $environment |
|
34 | - */ |
|
35 | - public function __construct(Domain $domain, EE_Environment_Config $environment) |
|
36 | - { |
|
37 | - $this->domain = $domain; |
|
38 | - $this->environment = $environment; |
|
39 | - if ($this->domain->isCaffeinated()) { |
|
40 | - add_filter('heartbeat_received', array($this, 'heartbeatResponse'), 10, 2); |
|
41 | - } |
|
42 | - } |
|
29 | + /** |
|
30 | + * EventEditorHeartbeat constructor. |
|
31 | + * |
|
32 | + * @param Domain $domain |
|
33 | + * @param EE_Environment_Config $environment |
|
34 | + */ |
|
35 | + public function __construct(Domain $domain, EE_Environment_Config $environment) |
|
36 | + { |
|
37 | + $this->domain = $domain; |
|
38 | + $this->environment = $environment; |
|
39 | + if ($this->domain->isCaffeinated()) { |
|
40 | + add_filter('heartbeat_received', array($this, 'heartbeatResponse'), 10, 2); |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
47 | - * accordingly. |
|
48 | - * |
|
49 | - * @param array $response The existing heartbeat response array. |
|
50 | - * @param array $data The incoming data package. |
|
51 | - * @return array possibly appended response. |
|
52 | - */ |
|
53 | - public function heartbeatResponse($response, $data) |
|
54 | - { |
|
55 | - /** |
|
56 | - * check whether count of tickets is approaching the potential |
|
57 | - * limits for the server. |
|
58 | - */ |
|
59 | - if (! empty($data['input_count'])) { |
|
60 | - $response['max_input_vars_check'] = $this->environment->max_input_vars_limit_check( |
|
61 | - $data['input_count'] |
|
62 | - ); |
|
63 | - } |
|
64 | - return $response; |
|
65 | - } |
|
45 | + /** |
|
46 | + * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
47 | + * accordingly. |
|
48 | + * |
|
49 | + * @param array $response The existing heartbeat response array. |
|
50 | + * @param array $data The incoming data package. |
|
51 | + * @return array possibly appended response. |
|
52 | + */ |
|
53 | + public function heartbeatResponse($response, $data) |
|
54 | + { |
|
55 | + /** |
|
56 | + * check whether count of tickets is approaching the potential |
|
57 | + * limits for the server. |
|
58 | + */ |
|
59 | + if (! empty($data['input_count'])) { |
|
60 | + $response['max_input_vars_check'] = $this->environment->max_input_vars_limit_check( |
|
61 | + $data['input_count'] |
|
62 | + ); |
|
63 | + } |
|
64 | + return $response; |
|
65 | + } |
|
66 | 66 | } |
@@ -19,53 +19,53 @@ |
||
19 | 19 | */ |
20 | 20 | class SettingsForm extends PayPalSettingsForm |
21 | 21 | { |
22 | - /** |
|
23 | - * SettingsForm constructor. |
|
24 | - * |
|
25 | - * @param array $options_array |
|
26 | - * @param string $help_tab_link |
|
27 | - * @throws InvalidDataTypeException |
|
28 | - * @throws InvalidInterfaceException |
|
29 | - * @throws InvalidArgumentException |
|
30 | - */ |
|
31 | - public function __construct(array $options_array = array(), $help_tab_link = '') |
|
32 | - { |
|
33 | - $options_array = array_replace_recursive( |
|
34 | - array( |
|
35 | - 'extra_meta_inputs' => array( |
|
36 | - 'request_shipping_addr' => new EE_Yes_No_Input( |
|
37 | - array( |
|
38 | - 'html_label_text' => sprintf( |
|
39 | - esc_html__('Request Shipping Address %s', 'event_espresso'), |
|
40 | - $help_tab_link |
|
41 | - ), |
|
42 | - 'html_help_text' => esc_html__( |
|
43 | - // @codingStandardsIgnoreStart |
|
44 | - 'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', |
|
45 | - // @codingStandardsIgnoreEnd |
|
46 | - 'event_espresso' |
|
47 | - ), |
|
48 | - 'required' => true, |
|
49 | - 'default' => false, |
|
50 | - ) |
|
51 | - ), |
|
52 | - 'image_url' => new EE_Admin_File_Uploader_Input( |
|
53 | - array( |
|
54 | - 'html_label_text' => sprintf( |
|
55 | - esc_html__('Image URL %s', 'event_espresso'), |
|
56 | - $help_tab_link |
|
57 | - ), |
|
58 | - 'html_help_text' => esc_html__( |
|
59 | - 'Used for your business/personal logo on the PayPal page', |
|
60 | - 'event_espresso' |
|
61 | - ), |
|
62 | - 'required' => false, |
|
63 | - ) |
|
64 | - ), |
|
65 | - ) |
|
66 | - ), |
|
67 | - $options_array |
|
68 | - ); |
|
69 | - parent::__construct($options_array, $help_tab_link); |
|
70 | - } |
|
22 | + /** |
|
23 | + * SettingsForm constructor. |
|
24 | + * |
|
25 | + * @param array $options_array |
|
26 | + * @param string $help_tab_link |
|
27 | + * @throws InvalidDataTypeException |
|
28 | + * @throws InvalidInterfaceException |
|
29 | + * @throws InvalidArgumentException |
|
30 | + */ |
|
31 | + public function __construct(array $options_array = array(), $help_tab_link = '') |
|
32 | + { |
|
33 | + $options_array = array_replace_recursive( |
|
34 | + array( |
|
35 | + 'extra_meta_inputs' => array( |
|
36 | + 'request_shipping_addr' => new EE_Yes_No_Input( |
|
37 | + array( |
|
38 | + 'html_label_text' => sprintf( |
|
39 | + esc_html__('Request Shipping Address %s', 'event_espresso'), |
|
40 | + $help_tab_link |
|
41 | + ), |
|
42 | + 'html_help_text' => esc_html__( |
|
43 | + // @codingStandardsIgnoreStart |
|
44 | + 'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', |
|
45 | + // @codingStandardsIgnoreEnd |
|
46 | + 'event_espresso' |
|
47 | + ), |
|
48 | + 'required' => true, |
|
49 | + 'default' => false, |
|
50 | + ) |
|
51 | + ), |
|
52 | + 'image_url' => new EE_Admin_File_Uploader_Input( |
|
53 | + array( |
|
54 | + 'html_label_text' => sprintf( |
|
55 | + esc_html__('Image URL %s', 'event_espresso'), |
|
56 | + $help_tab_link |
|
57 | + ), |
|
58 | + 'html_help_text' => esc_html__( |
|
59 | + 'Used for your business/personal logo on the PayPal page', |
|
60 | + 'event_espresso' |
|
61 | + ), |
|
62 | + 'required' => false, |
|
63 | + ) |
|
64 | + ), |
|
65 | + ) |
|
66 | + ), |
|
67 | + $options_array |
|
68 | + ); |
|
69 | + parent::__construct($options_array, $help_tab_link); |
|
70 | + } |
|
71 | 71 | } |
@@ -32,10 +32,10 @@ |
||
32 | 32 | ); |
33 | 33 | // this model is generally available for reading |
34 | 34 | $path_to_event = 'Event'; |
35 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
36 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
37 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
38 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
35 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
36 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
37 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
38 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
39 | 39 | parent::__construct($timezone); |
40 | 40 | } |
41 | 41 |
@@ -8,72 +8,72 @@ |
||
8 | 8 | */ |
9 | 9 | class EEM_Event_Question_Group extends EEM_Base |
10 | 10 | { |
11 | - /** |
|
12 | - * Name of the field indicating an event should use the question group for the primary attendee |
|
13 | - */ |
|
14 | - const PRIMARY = 'EQG_primary'; |
|
11 | + /** |
|
12 | + * Name of the field indicating an event should use the question group for the primary attendee |
|
13 | + */ |
|
14 | + const PRIMARY = 'EQG_primary'; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Name of hte field indicating an event should use the question group for additional attendees |
|
18 | - */ |
|
19 | - const ADDITIONAL = 'EQG_additional'; |
|
16 | + /** |
|
17 | + * Name of hte field indicating an event should use the question group for additional attendees |
|
18 | + */ |
|
19 | + const ADDITIONAL = 'EQG_additional'; |
|
20 | 20 | |
21 | - // private instance of the Event_Question_Group object |
|
22 | - protected static $_instance = null; |
|
21 | + // private instance of the Event_Question_Group object |
|
22 | + protected static $_instance = null; |
|
23 | 23 | |
24 | - protected function __construct($timezone = null) |
|
25 | - { |
|
26 | - $this->singular_item = esc_html__('Event to Question Group Link', 'event_espresso'); |
|
27 | - $this->plural_item = esc_html__('Event to Question Group Links', 'event_espresso'); |
|
28 | - $this->_tables = array( |
|
29 | - 'Event_Question_Group' => new EE_Primary_Table('esp_event_question_group', 'EQG_ID') |
|
30 | - ); |
|
31 | - $this->_fields = array( |
|
32 | - 'Event_Question_Group' => array( |
|
33 | - 'EQG_ID' => new EE_Primary_Key_Int_Field('EQG_ID', esc_html__('Event to Question Group Link ID', 'event_espresso')), |
|
34 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', esc_html__('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
35 | - 'QSG_ID' => new EE_Foreign_Key_Int_Field('QSG_ID', esc_html__('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'), |
|
36 | - 'EQG_primary' => new EE_Boolean_Field('EQG_primary', esc_html__('Flag indicating question is only for primary attendees', 'event_espresso'), false, false), |
|
37 | - 'EQG_additional' => new EE_Boolean_Field('EQG_additional', esc_html__('Flag indicating question is only for additional attendees', 'event_espresso'), false, false) |
|
38 | - ) |
|
39 | - ); |
|
40 | - $this->_model_relations = array( |
|
41 | - 'Event' => new EE_Belongs_To_Relation(), |
|
42 | - 'Question_Group' => new EE_Belongs_To_Relation() |
|
43 | - ); |
|
44 | - // this model is generally available for reading |
|
45 | - $path_to_event = 'Event'; |
|
46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
49 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
50 | - parent::__construct($timezone); |
|
51 | - } |
|
24 | + protected function __construct($timezone = null) |
|
25 | + { |
|
26 | + $this->singular_item = esc_html__('Event to Question Group Link', 'event_espresso'); |
|
27 | + $this->plural_item = esc_html__('Event to Question Group Links', 'event_espresso'); |
|
28 | + $this->_tables = array( |
|
29 | + 'Event_Question_Group' => new EE_Primary_Table('esp_event_question_group', 'EQG_ID') |
|
30 | + ); |
|
31 | + $this->_fields = array( |
|
32 | + 'Event_Question_Group' => array( |
|
33 | + 'EQG_ID' => new EE_Primary_Key_Int_Field('EQG_ID', esc_html__('Event to Question Group Link ID', 'event_espresso')), |
|
34 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', esc_html__('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
35 | + 'QSG_ID' => new EE_Foreign_Key_Int_Field('QSG_ID', esc_html__('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'), |
|
36 | + 'EQG_primary' => new EE_Boolean_Field('EQG_primary', esc_html__('Flag indicating question is only for primary attendees', 'event_espresso'), false, false), |
|
37 | + 'EQG_additional' => new EE_Boolean_Field('EQG_additional', esc_html__('Flag indicating question is only for additional attendees', 'event_espresso'), false, false) |
|
38 | + ) |
|
39 | + ); |
|
40 | + $this->_model_relations = array( |
|
41 | + 'Event' => new EE_Belongs_To_Relation(), |
|
42 | + 'Question_Group' => new EE_Belongs_To_Relation() |
|
43 | + ); |
|
44 | + // this model is generally available for reading |
|
45 | + $path_to_event = 'Event'; |
|
46 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
47 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
48 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
49 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
50 | + parent::__construct($timezone); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether |
|
55 | - * this is concerning primary attendees or additional attendees. |
|
56 | - * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns |
|
57 | - * EQG_additional. |
|
58 | - * @since 4.10.0.p |
|
59 | - * @param string|boolean|int $context |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function fieldNameForContext($context) |
|
63 | - { |
|
64 | - // Basically do a strict switch statement. |
|
65 | - switch (true) { |
|
66 | - case $context === 'additional': |
|
67 | - case $context === false: |
|
68 | - case $context === 0: |
|
69 | - $field_name = EEM_Event_Question_Group::ADDITIONAL; |
|
70 | - break; |
|
71 | - case $context === 'primary': |
|
72 | - case $context === true: |
|
73 | - case $context === 1: |
|
74 | - default: |
|
75 | - $field_name = EEM_Event_Question_Group::PRIMARY; |
|
76 | - } |
|
77 | - return apply_filters('FHEE__EEM_Event_Question_Group__fieldNameForContext', $field_name, $context); |
|
78 | - } |
|
53 | + /** |
|
54 | + * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether |
|
55 | + * this is concerning primary attendees or additional attendees. |
|
56 | + * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns |
|
57 | + * EQG_additional. |
|
58 | + * @since 4.10.0.p |
|
59 | + * @param string|boolean|int $context |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function fieldNameForContext($context) |
|
63 | + { |
|
64 | + // Basically do a strict switch statement. |
|
65 | + switch (true) { |
|
66 | + case $context === 'additional': |
|
67 | + case $context === false: |
|
68 | + case $context === 0: |
|
69 | + $field_name = EEM_Event_Question_Group::ADDITIONAL; |
|
70 | + break; |
|
71 | + case $context === 'primary': |
|
72 | + case $context === true: |
|
73 | + case $context === 1: |
|
74 | + default: |
|
75 | + $field_name = EEM_Event_Question_Group::PRIMARY; |
|
76 | + } |
|
77 | + return apply_filters('FHEE__EEM_Event_Question_Group__fieldNameForContext', $field_name, $context); |
|
78 | + } |
|
79 | 79 | } |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | ); |
325 | 325 | $query = $wpdb->prepare( |
326 | 326 | 'DELETE li |
327 | - FROM ' . $this->table() . ' li |
|
328 | - LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON li.TXN_ID = t.TXN_ID |
|
327 | + FROM ' . $this->table().' li |
|
328 | + LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID |
|
329 | 329 | WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s', |
330 | 330 | // use GMT time because that's what TXN_timestamps are in |
331 | 331 | date('Y-m-d H:i:s', time() - $time_to_leave_alone) |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | */ |
599 | 599 | public function getTicketLineItemsForExpiredCarts($timestamp = 0) |
600 | 600 | { |
601 | - if (! absint($timestamp)) { |
|
601 | + if ( ! absint($timestamp)) { |
|
602 | 602 | /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
603 | 603 | $session_lifespan = LoaderFactory::getLoader()->getShared( |
604 | 604 | 'EventEspresso\core\domain\values\session\SessionLifespan' |
@@ -27,598 +27,598 @@ |
||
27 | 27 | */ |
28 | 28 | class EEM_Line_Item extends EEM_Base |
29 | 29 | { |
30 | - /** |
|
31 | - * Tax sub-total is just the total of all the taxes, which should be children |
|
32 | - * of this line item. There should only ever be one tax sub-total, and it should |
|
33 | - * be a direct child of. Its quantity and LIN_unit_price = 1. |
|
34 | - */ |
|
35 | - const type_tax_sub_total = 'tax-sub-total'; |
|
36 | - |
|
37 | - /** |
|
38 | - * Tax line items indicate a tax applied to all the taxable line items. |
|
39 | - * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal |
|
40 | - * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1. |
|
41 | - */ |
|
42 | - const type_tax = 'tax'; |
|
43 | - |
|
44 | - /** |
|
45 | - * Indicating individual items purchased, or discounts or surcharges. |
|
46 | - * The sum of all the regular line items plus the tax items should equal the grand total. |
|
47 | - * Possible children are sub-line-items and cancellations. |
|
48 | - * For flat items, LIN_unit_price * LIN_quantity = LIN_total. Its LIN_total is the sum of all the children |
|
49 | - * LIN_totals. Its LIN_percent = 0. |
|
50 | - * For percent items, its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal (eg 10% = 10, not 0.1). |
|
51 | - * Its LIN_total is LIN_percent / 100 * sum of lower-priority sibling line items. Quantity = 1. |
|
52 | - */ |
|
53 | - const type_line_item = 'line-item'; |
|
54 | - |
|
55 | - /** |
|
56 | - * Line item indicating all the factors that make a single line item. |
|
57 | - * Sub-line items should have NO children line items. |
|
58 | - * For flat sub-items, their quantity should match their parent item, their LIN_unit_price should be this sub-item's |
|
59 | - * contribution towards the price of ONE of their parent items, and its LIN_total should be |
|
60 | - * = LIN_quantity * LIN_unit_price. Its LIN_percent = 0. |
|
61 | - * For percent sub-items, the quantity should be 1, LIN_unit_price should be 0, and its LIN_total should |
|
62 | - * = LIN_percent / 100 * sum of lower-priority sibling line items.. |
|
63 | - */ |
|
64 | - const type_sub_line_item = 'sub-item'; |
|
65 | - |
|
66 | - /** |
|
67 | - * Line item indicating a sub-total (eg total for an event, or pre-tax subtotal). |
|
68 | - * Direct children should be event subtotals. |
|
69 | - * Should have quantity of 1, and a LIN_total and LIN_unit_price of the sum of all its sub-items' LIN_totals. |
|
70 | - */ |
|
71 | - const type_sub_total = 'sub-total'; |
|
72 | - |
|
73 | - /** |
|
74 | - * Line item for the grand total of an order. |
|
75 | - * Its direct children should be tax subtotals and (pre-tax) subtotals, |
|
76 | - * and possibly a regular line item indicating a transaction-wide discount/surcharge. |
|
77 | - * Should have a quantity of 1, a LIN_total and LIN_unit_price of the entire order's amount. |
|
78 | - */ |
|
79 | - const type_total = 'total'; |
|
80 | - |
|
81 | - /** |
|
82 | - * When a line item is cancelled, a sub-line-item of type 'cancellation' |
|
83 | - * should be created, indicating the quantity that were cancelled |
|
84 | - * (because a line item could have a quantity of 1, and its cancellation item |
|
85 | - * could be for 3, indicating that originally 4 were purchased, but 3 have been |
|
86 | - * cancelled, and only one remains). |
|
87 | - * When items are refunded, a cancellation line item should be made, which points |
|
88 | - * to teh payment model object which actually refunded the payment. |
|
89 | - * Cancellations should NOT have any children line items; the should NOT affect |
|
90 | - * any calculations, and are only meant as a record that cancellations have occurred. |
|
91 | - * Their LIN_percent should be 0. |
|
92 | - */ |
|
93 | - const type_cancellation = 'cancellation'; |
|
94 | - |
|
95 | - // various line item object types |
|
96 | - const OBJ_TYPE_EVENT = 'Event'; |
|
97 | - |
|
98 | - const OBJ_TYPE_PRICE = 'Price'; |
|
99 | - |
|
100 | - const OBJ_TYPE_PROMOTION = 'Promotion'; |
|
101 | - |
|
102 | - const OBJ_TYPE_TICKET = 'Ticket'; |
|
103 | - |
|
104 | - const OBJ_TYPE_TRANSACTION = 'Transaction'; |
|
105 | - |
|
106 | - /** |
|
107 | - * @var EEM_Line_Item $_instance |
|
108 | - */ |
|
109 | - protected static $_instance; |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * private constructor to prevent direct creation |
|
114 | - * |
|
115 | - * @Constructor |
|
116 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings |
|
117 | - * (and any incoming timezone data that gets saved). |
|
118 | - * Note this just sends the timezone info to the date time model field objects. |
|
119 | - * Default is NULL |
|
120 | - * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
121 | - * @throws EE_Error |
|
122 | - * @throws InvalidArgumentException |
|
123 | - */ |
|
124 | - protected function __construct($timezone) |
|
125 | - { |
|
126 | - $this->singular_item = esc_html__('Line Item', 'event_espresso'); |
|
127 | - $this->plural_item = esc_html__('Line Items', 'event_espresso'); |
|
128 | - |
|
129 | - $this->_tables = array( |
|
130 | - 'Line_Item' => new EE_Primary_Table('esp_line_item', 'LIN_ID'), |
|
131 | - ); |
|
132 | - $line_items_can_be_for = apply_filters( |
|
133 | - 'FHEE__EEM_Line_Item__line_items_can_be_for', |
|
134 | - array('Ticket', 'Price', 'Event') |
|
135 | - ); |
|
136 | - $this->_fields = array( |
|
137 | - 'Line_Item' => array( |
|
138 | - 'LIN_ID' => new EE_Primary_Key_Int_Field( |
|
139 | - 'LIN_ID', |
|
140 | - esc_html__('ID', 'event_espresso') |
|
141 | - ), |
|
142 | - 'LIN_code' => new EE_Slug_Field( |
|
143 | - 'LIN_code', |
|
144 | - esc_html__('Code for index into Cart', 'event_espresso'), |
|
145 | - true |
|
146 | - ), |
|
147 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( |
|
148 | - 'TXN_ID', |
|
149 | - esc_html__('Transaction ID', 'event_espresso'), |
|
150 | - true, |
|
151 | - null, |
|
152 | - 'Transaction' |
|
153 | - ), |
|
154 | - 'LIN_name' => new EE_Full_HTML_Field( |
|
155 | - 'LIN_name', |
|
156 | - esc_html__('Line Item Name', 'event_espresso'), |
|
157 | - false, |
|
158 | - '' |
|
159 | - ), |
|
160 | - 'LIN_desc' => new EE_Full_HTML_Field( |
|
161 | - 'LIN_desc', |
|
162 | - esc_html__('Line Item Description', 'event_espresso'), |
|
163 | - true |
|
164 | - ), |
|
165 | - 'LIN_unit_price' => new EE_Money_Field( |
|
166 | - 'LIN_unit_price', |
|
167 | - esc_html__('Unit Price', 'event_espresso') |
|
168 | - ), |
|
169 | - 'LIN_percent' => new EE_Float_Field( |
|
170 | - 'LIN_percent', |
|
171 | - esc_html__('Percent', 'event_espresso'), |
|
172 | - false, |
|
173 | - 0 |
|
174 | - ), |
|
175 | - 'LIN_is_taxable' => new EE_Boolean_Field( |
|
176 | - 'LIN_is_taxable', |
|
177 | - esc_html__('Taxable', 'event_espresso'), |
|
178 | - false, |
|
179 | - false |
|
180 | - ), |
|
181 | - 'LIN_order' => new EE_Integer_Field( |
|
182 | - 'LIN_order', |
|
183 | - esc_html__('Order of Application towards total of parent', 'event_espresso'), |
|
184 | - false, |
|
185 | - 1 |
|
186 | - ), |
|
187 | - 'LIN_total' => new EE_Money_Field( |
|
188 | - 'LIN_total', |
|
189 | - esc_html__('Total (unit price x quantity)', 'event_espresso') |
|
190 | - ), |
|
191 | - 'LIN_quantity' => new EE_Integer_Field( |
|
192 | - 'LIN_quantity', |
|
193 | - esc_html__('Quantity', 'event_espresso'), |
|
194 | - true, |
|
195 | - 1 |
|
196 | - ), |
|
197 | - 'LIN_parent' => new EE_Integer_Field( |
|
198 | - 'LIN_parent', |
|
199 | - esc_html__("Parent ID (this item goes towards that Line Item's total)", 'event_espresso'), |
|
200 | - true, |
|
201 | - null |
|
202 | - ), |
|
203 | - 'LIN_type' => new EE_Enum_Text_Field( |
|
204 | - 'LIN_type', |
|
205 | - esc_html__('Type', 'event_espresso'), |
|
206 | - false, |
|
207 | - 'line-item', |
|
208 | - array( |
|
209 | - self::type_line_item => esc_html__('Line Item', 'event_espresso'), |
|
210 | - self::type_sub_line_item => esc_html__('Sub-Item', 'event_espresso'), |
|
211 | - self::type_sub_total => esc_html__('Subtotal', 'event_espresso'), |
|
212 | - self::type_tax_sub_total => esc_html__('Tax Subtotal', 'event_espresso'), |
|
213 | - self::type_tax => esc_html__('Tax', 'event_espresso'), |
|
214 | - self::type_total => esc_html__('Total', 'event_espresso'), |
|
215 | - self::type_cancellation => esc_html__('Cancellation', 'event_espresso'), |
|
216 | - ) |
|
217 | - ), |
|
218 | - 'OBJ_ID' => new EE_Foreign_Key_Int_Field( |
|
219 | - 'OBJ_ID', |
|
220 | - esc_html__('ID of Item purchased.', 'event_espresso'), |
|
221 | - true, |
|
222 | - null, |
|
223 | - $line_items_can_be_for |
|
224 | - ), |
|
225 | - 'OBJ_type' => new EE_Any_Foreign_Model_Name_Field( |
|
226 | - 'OBJ_type', |
|
227 | - esc_html__('Model Name this Line Item is for', 'event_espresso'), |
|
228 | - true, |
|
229 | - null, |
|
230 | - $line_items_can_be_for |
|
231 | - ), |
|
232 | - 'LIN_timestamp' => new EE_Datetime_Field( |
|
233 | - 'LIN_timestamp', |
|
234 | - esc_html__('When the line item was created', 'event_espresso'), |
|
235 | - false, |
|
236 | - EE_Datetime_Field::now, |
|
237 | - $timezone |
|
238 | - ), |
|
239 | - ), |
|
240 | - ); |
|
241 | - $this->_model_relations = array( |
|
242 | - 'Transaction' => new EE_Belongs_To_Relation(), |
|
243 | - 'Ticket' => new EE_Belongs_To_Any_Relation(), |
|
244 | - 'Price' => new EE_Belongs_To_Any_Relation(), |
|
245 | - 'Event' => new EE_Belongs_To_Any_Relation(), |
|
246 | - ); |
|
247 | - $this->_model_chain_to_wp_user = 'Transaction.Registration.Event'; |
|
248 | - $this->_caps_slug = 'transactions'; |
|
249 | - parent::__construct($timezone); |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * Gets all the line items for this transaction of the given type |
|
255 | - * |
|
256 | - * @param string $line_item_type like one of EEM_Line_Item::type_* |
|
257 | - * @param EE_Transaction|int $transaction |
|
258 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
259 | - * @throws EE_Error |
|
260 | - * @throws InvalidArgumentException |
|
261 | - * @throws InvalidDataTypeException |
|
262 | - * @throws InvalidInterfaceException |
|
263 | - */ |
|
264 | - public function get_all_of_type_for_transaction($line_item_type, $transaction) |
|
265 | - { |
|
266 | - $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
267 | - return $this->get_all(array( |
|
268 | - array( |
|
269 | - 'LIN_type' => $line_item_type, |
|
270 | - 'TXN_ID' => $transaction, |
|
271 | - ), |
|
272 | - )); |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * Gets all line items unrelated to tickets that are normal line items |
|
278 | - * (eg shipping, promotions, and miscellaneous other stuff should probably fit in this category) |
|
279 | - * |
|
280 | - * @param EE_Transaction|int $transaction |
|
281 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
282 | - * @throws EE_Error |
|
283 | - * @throws InvalidArgumentException |
|
284 | - * @throws InvalidDataTypeException |
|
285 | - * @throws InvalidInterfaceException |
|
286 | - */ |
|
287 | - public function get_all_non_ticket_line_items_for_transaction($transaction) |
|
288 | - { |
|
289 | - $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
290 | - return $this->get_all(array( |
|
291 | - array( |
|
292 | - 'LIN_type' => self::type_line_item, |
|
293 | - 'TXN_ID' => $transaction, |
|
294 | - 'OR' => array( |
|
295 | - 'OBJ_type*notticket' => array('!=', EEM_Line_Item::OBJ_TYPE_TICKET), |
|
296 | - 'OBJ_type*null' => array('IS_NULL'), |
|
297 | - ), |
|
298 | - ), |
|
299 | - )); |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * Deletes line items with no transaction who have passed the transaction cutoff time. |
|
305 | - * This needs to be very efficient |
|
306 | - * because if there are spam bots afoot there will be LOTS of line items. Also MySQL doesn't allow a limit when |
|
307 | - * deleting and joining tables like this. |
|
308 | - * |
|
309 | - * @return int count of how many deleted |
|
310 | - * @throws EE_Error |
|
311 | - * @throws InvalidArgumentException |
|
312 | - * @throws InvalidDataTypeException |
|
313 | - * @throws InvalidInterfaceException |
|
314 | - */ |
|
315 | - public function delete_line_items_with_no_transaction() |
|
316 | - { |
|
317 | - /** @type WPDB $wpdb */ |
|
318 | - global $wpdb; |
|
319 | - $time_to_leave_alone = apply_filters( |
|
320 | - 'FHEE__EEM_Line_Item__delete_line_items_with_no_transaction__time_to_leave_alone', |
|
321 | - WEEK_IN_SECONDS |
|
322 | - ); |
|
323 | - $query = $wpdb->prepare( |
|
324 | - 'DELETE li |
|
30 | + /** |
|
31 | + * Tax sub-total is just the total of all the taxes, which should be children |
|
32 | + * of this line item. There should only ever be one tax sub-total, and it should |
|
33 | + * be a direct child of. Its quantity and LIN_unit_price = 1. |
|
34 | + */ |
|
35 | + const type_tax_sub_total = 'tax-sub-total'; |
|
36 | + |
|
37 | + /** |
|
38 | + * Tax line items indicate a tax applied to all the taxable line items. |
|
39 | + * Should not have any children line items. Its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal |
|
40 | + * (eg 10% tax = 10, not 0.1). Its LIN_total = LIN_unit_price * pre-tax-total. Quantity = 1. |
|
41 | + */ |
|
42 | + const type_tax = 'tax'; |
|
43 | + |
|
44 | + /** |
|
45 | + * Indicating individual items purchased, or discounts or surcharges. |
|
46 | + * The sum of all the regular line items plus the tax items should equal the grand total. |
|
47 | + * Possible children are sub-line-items and cancellations. |
|
48 | + * For flat items, LIN_unit_price * LIN_quantity = LIN_total. Its LIN_total is the sum of all the children |
|
49 | + * LIN_totals. Its LIN_percent = 0. |
|
50 | + * For percent items, its LIN_unit_price = 0. Its LIN_percent is a percent, not a decimal (eg 10% = 10, not 0.1). |
|
51 | + * Its LIN_total is LIN_percent / 100 * sum of lower-priority sibling line items. Quantity = 1. |
|
52 | + */ |
|
53 | + const type_line_item = 'line-item'; |
|
54 | + |
|
55 | + /** |
|
56 | + * Line item indicating all the factors that make a single line item. |
|
57 | + * Sub-line items should have NO children line items. |
|
58 | + * For flat sub-items, their quantity should match their parent item, their LIN_unit_price should be this sub-item's |
|
59 | + * contribution towards the price of ONE of their parent items, and its LIN_total should be |
|
60 | + * = LIN_quantity * LIN_unit_price. Its LIN_percent = 0. |
|
61 | + * For percent sub-items, the quantity should be 1, LIN_unit_price should be 0, and its LIN_total should |
|
62 | + * = LIN_percent / 100 * sum of lower-priority sibling line items.. |
|
63 | + */ |
|
64 | + const type_sub_line_item = 'sub-item'; |
|
65 | + |
|
66 | + /** |
|
67 | + * Line item indicating a sub-total (eg total for an event, or pre-tax subtotal). |
|
68 | + * Direct children should be event subtotals. |
|
69 | + * Should have quantity of 1, and a LIN_total and LIN_unit_price of the sum of all its sub-items' LIN_totals. |
|
70 | + */ |
|
71 | + const type_sub_total = 'sub-total'; |
|
72 | + |
|
73 | + /** |
|
74 | + * Line item for the grand total of an order. |
|
75 | + * Its direct children should be tax subtotals and (pre-tax) subtotals, |
|
76 | + * and possibly a regular line item indicating a transaction-wide discount/surcharge. |
|
77 | + * Should have a quantity of 1, a LIN_total and LIN_unit_price of the entire order's amount. |
|
78 | + */ |
|
79 | + const type_total = 'total'; |
|
80 | + |
|
81 | + /** |
|
82 | + * When a line item is cancelled, a sub-line-item of type 'cancellation' |
|
83 | + * should be created, indicating the quantity that were cancelled |
|
84 | + * (because a line item could have a quantity of 1, and its cancellation item |
|
85 | + * could be for 3, indicating that originally 4 were purchased, but 3 have been |
|
86 | + * cancelled, and only one remains). |
|
87 | + * When items are refunded, a cancellation line item should be made, which points |
|
88 | + * to teh payment model object which actually refunded the payment. |
|
89 | + * Cancellations should NOT have any children line items; the should NOT affect |
|
90 | + * any calculations, and are only meant as a record that cancellations have occurred. |
|
91 | + * Their LIN_percent should be 0. |
|
92 | + */ |
|
93 | + const type_cancellation = 'cancellation'; |
|
94 | + |
|
95 | + // various line item object types |
|
96 | + const OBJ_TYPE_EVENT = 'Event'; |
|
97 | + |
|
98 | + const OBJ_TYPE_PRICE = 'Price'; |
|
99 | + |
|
100 | + const OBJ_TYPE_PROMOTION = 'Promotion'; |
|
101 | + |
|
102 | + const OBJ_TYPE_TICKET = 'Ticket'; |
|
103 | + |
|
104 | + const OBJ_TYPE_TRANSACTION = 'Transaction'; |
|
105 | + |
|
106 | + /** |
|
107 | + * @var EEM_Line_Item $_instance |
|
108 | + */ |
|
109 | + protected static $_instance; |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * private constructor to prevent direct creation |
|
114 | + * |
|
115 | + * @Constructor |
|
116 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings |
|
117 | + * (and any incoming timezone data that gets saved). |
|
118 | + * Note this just sends the timezone info to the date time model field objects. |
|
119 | + * Default is NULL |
|
120 | + * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
121 | + * @throws EE_Error |
|
122 | + * @throws InvalidArgumentException |
|
123 | + */ |
|
124 | + protected function __construct($timezone) |
|
125 | + { |
|
126 | + $this->singular_item = esc_html__('Line Item', 'event_espresso'); |
|
127 | + $this->plural_item = esc_html__('Line Items', 'event_espresso'); |
|
128 | + |
|
129 | + $this->_tables = array( |
|
130 | + 'Line_Item' => new EE_Primary_Table('esp_line_item', 'LIN_ID'), |
|
131 | + ); |
|
132 | + $line_items_can_be_for = apply_filters( |
|
133 | + 'FHEE__EEM_Line_Item__line_items_can_be_for', |
|
134 | + array('Ticket', 'Price', 'Event') |
|
135 | + ); |
|
136 | + $this->_fields = array( |
|
137 | + 'Line_Item' => array( |
|
138 | + 'LIN_ID' => new EE_Primary_Key_Int_Field( |
|
139 | + 'LIN_ID', |
|
140 | + esc_html__('ID', 'event_espresso') |
|
141 | + ), |
|
142 | + 'LIN_code' => new EE_Slug_Field( |
|
143 | + 'LIN_code', |
|
144 | + esc_html__('Code for index into Cart', 'event_espresso'), |
|
145 | + true |
|
146 | + ), |
|
147 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field( |
|
148 | + 'TXN_ID', |
|
149 | + esc_html__('Transaction ID', 'event_espresso'), |
|
150 | + true, |
|
151 | + null, |
|
152 | + 'Transaction' |
|
153 | + ), |
|
154 | + 'LIN_name' => new EE_Full_HTML_Field( |
|
155 | + 'LIN_name', |
|
156 | + esc_html__('Line Item Name', 'event_espresso'), |
|
157 | + false, |
|
158 | + '' |
|
159 | + ), |
|
160 | + 'LIN_desc' => new EE_Full_HTML_Field( |
|
161 | + 'LIN_desc', |
|
162 | + esc_html__('Line Item Description', 'event_espresso'), |
|
163 | + true |
|
164 | + ), |
|
165 | + 'LIN_unit_price' => new EE_Money_Field( |
|
166 | + 'LIN_unit_price', |
|
167 | + esc_html__('Unit Price', 'event_espresso') |
|
168 | + ), |
|
169 | + 'LIN_percent' => new EE_Float_Field( |
|
170 | + 'LIN_percent', |
|
171 | + esc_html__('Percent', 'event_espresso'), |
|
172 | + false, |
|
173 | + 0 |
|
174 | + ), |
|
175 | + 'LIN_is_taxable' => new EE_Boolean_Field( |
|
176 | + 'LIN_is_taxable', |
|
177 | + esc_html__('Taxable', 'event_espresso'), |
|
178 | + false, |
|
179 | + false |
|
180 | + ), |
|
181 | + 'LIN_order' => new EE_Integer_Field( |
|
182 | + 'LIN_order', |
|
183 | + esc_html__('Order of Application towards total of parent', 'event_espresso'), |
|
184 | + false, |
|
185 | + 1 |
|
186 | + ), |
|
187 | + 'LIN_total' => new EE_Money_Field( |
|
188 | + 'LIN_total', |
|
189 | + esc_html__('Total (unit price x quantity)', 'event_espresso') |
|
190 | + ), |
|
191 | + 'LIN_quantity' => new EE_Integer_Field( |
|
192 | + 'LIN_quantity', |
|
193 | + esc_html__('Quantity', 'event_espresso'), |
|
194 | + true, |
|
195 | + 1 |
|
196 | + ), |
|
197 | + 'LIN_parent' => new EE_Integer_Field( |
|
198 | + 'LIN_parent', |
|
199 | + esc_html__("Parent ID (this item goes towards that Line Item's total)", 'event_espresso'), |
|
200 | + true, |
|
201 | + null |
|
202 | + ), |
|
203 | + 'LIN_type' => new EE_Enum_Text_Field( |
|
204 | + 'LIN_type', |
|
205 | + esc_html__('Type', 'event_espresso'), |
|
206 | + false, |
|
207 | + 'line-item', |
|
208 | + array( |
|
209 | + self::type_line_item => esc_html__('Line Item', 'event_espresso'), |
|
210 | + self::type_sub_line_item => esc_html__('Sub-Item', 'event_espresso'), |
|
211 | + self::type_sub_total => esc_html__('Subtotal', 'event_espresso'), |
|
212 | + self::type_tax_sub_total => esc_html__('Tax Subtotal', 'event_espresso'), |
|
213 | + self::type_tax => esc_html__('Tax', 'event_espresso'), |
|
214 | + self::type_total => esc_html__('Total', 'event_espresso'), |
|
215 | + self::type_cancellation => esc_html__('Cancellation', 'event_espresso'), |
|
216 | + ) |
|
217 | + ), |
|
218 | + 'OBJ_ID' => new EE_Foreign_Key_Int_Field( |
|
219 | + 'OBJ_ID', |
|
220 | + esc_html__('ID of Item purchased.', 'event_espresso'), |
|
221 | + true, |
|
222 | + null, |
|
223 | + $line_items_can_be_for |
|
224 | + ), |
|
225 | + 'OBJ_type' => new EE_Any_Foreign_Model_Name_Field( |
|
226 | + 'OBJ_type', |
|
227 | + esc_html__('Model Name this Line Item is for', 'event_espresso'), |
|
228 | + true, |
|
229 | + null, |
|
230 | + $line_items_can_be_for |
|
231 | + ), |
|
232 | + 'LIN_timestamp' => new EE_Datetime_Field( |
|
233 | + 'LIN_timestamp', |
|
234 | + esc_html__('When the line item was created', 'event_espresso'), |
|
235 | + false, |
|
236 | + EE_Datetime_Field::now, |
|
237 | + $timezone |
|
238 | + ), |
|
239 | + ), |
|
240 | + ); |
|
241 | + $this->_model_relations = array( |
|
242 | + 'Transaction' => new EE_Belongs_To_Relation(), |
|
243 | + 'Ticket' => new EE_Belongs_To_Any_Relation(), |
|
244 | + 'Price' => new EE_Belongs_To_Any_Relation(), |
|
245 | + 'Event' => new EE_Belongs_To_Any_Relation(), |
|
246 | + ); |
|
247 | + $this->_model_chain_to_wp_user = 'Transaction.Registration.Event'; |
|
248 | + $this->_caps_slug = 'transactions'; |
|
249 | + parent::__construct($timezone); |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * Gets all the line items for this transaction of the given type |
|
255 | + * |
|
256 | + * @param string $line_item_type like one of EEM_Line_Item::type_* |
|
257 | + * @param EE_Transaction|int $transaction |
|
258 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
259 | + * @throws EE_Error |
|
260 | + * @throws InvalidArgumentException |
|
261 | + * @throws InvalidDataTypeException |
|
262 | + * @throws InvalidInterfaceException |
|
263 | + */ |
|
264 | + public function get_all_of_type_for_transaction($line_item_type, $transaction) |
|
265 | + { |
|
266 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
267 | + return $this->get_all(array( |
|
268 | + array( |
|
269 | + 'LIN_type' => $line_item_type, |
|
270 | + 'TXN_ID' => $transaction, |
|
271 | + ), |
|
272 | + )); |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * Gets all line items unrelated to tickets that are normal line items |
|
278 | + * (eg shipping, promotions, and miscellaneous other stuff should probably fit in this category) |
|
279 | + * |
|
280 | + * @param EE_Transaction|int $transaction |
|
281 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
282 | + * @throws EE_Error |
|
283 | + * @throws InvalidArgumentException |
|
284 | + * @throws InvalidDataTypeException |
|
285 | + * @throws InvalidInterfaceException |
|
286 | + */ |
|
287 | + public function get_all_non_ticket_line_items_for_transaction($transaction) |
|
288 | + { |
|
289 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
290 | + return $this->get_all(array( |
|
291 | + array( |
|
292 | + 'LIN_type' => self::type_line_item, |
|
293 | + 'TXN_ID' => $transaction, |
|
294 | + 'OR' => array( |
|
295 | + 'OBJ_type*notticket' => array('!=', EEM_Line_Item::OBJ_TYPE_TICKET), |
|
296 | + 'OBJ_type*null' => array('IS_NULL'), |
|
297 | + ), |
|
298 | + ), |
|
299 | + )); |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * Deletes line items with no transaction who have passed the transaction cutoff time. |
|
305 | + * This needs to be very efficient |
|
306 | + * because if there are spam bots afoot there will be LOTS of line items. Also MySQL doesn't allow a limit when |
|
307 | + * deleting and joining tables like this. |
|
308 | + * |
|
309 | + * @return int count of how many deleted |
|
310 | + * @throws EE_Error |
|
311 | + * @throws InvalidArgumentException |
|
312 | + * @throws InvalidDataTypeException |
|
313 | + * @throws InvalidInterfaceException |
|
314 | + */ |
|
315 | + public function delete_line_items_with_no_transaction() |
|
316 | + { |
|
317 | + /** @type WPDB $wpdb */ |
|
318 | + global $wpdb; |
|
319 | + $time_to_leave_alone = apply_filters( |
|
320 | + 'FHEE__EEM_Line_Item__delete_line_items_with_no_transaction__time_to_leave_alone', |
|
321 | + WEEK_IN_SECONDS |
|
322 | + ); |
|
323 | + $query = $wpdb->prepare( |
|
324 | + 'DELETE li |
|
325 | 325 | FROM ' . $this->table() . ' li |
326 | 326 | LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON li.TXN_ID = t.TXN_ID |
327 | 327 | WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s', |
328 | - // use GMT time because that's what TXN_timestamps are in |
|
329 | - date('Y-m-d H:i:s', time() - $time_to_leave_alone) |
|
330 | - ); |
|
331 | - return $wpdb->query($query); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * get_line_item_for_transaction_object |
|
337 | - * Gets a transaction's line item record for a specific object such as a EE_Event or EE_Ticket |
|
338 | - * |
|
339 | - * @param int $TXN_ID |
|
340 | - * @param EE_Base_Class $object |
|
341 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
342 | - * @throws EE_Error |
|
343 | - * @throws InvalidArgumentException |
|
344 | - * @throws InvalidDataTypeException |
|
345 | - * @throws InvalidInterfaceException |
|
346 | - * @throws ReflectionException |
|
347 | - */ |
|
348 | - public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) |
|
349 | - { |
|
350 | - return $this->get_all(array( |
|
351 | - array( |
|
352 | - 'TXN_ID' => $TXN_ID, |
|
353 | - 'OBJ_type' => str_replace('EE_', '', get_class($object)), |
|
354 | - 'OBJ_ID' => $object->ID(), |
|
355 | - ), |
|
356 | - )); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * get_object_line_items_for_transaction |
|
362 | - * Gets all of the the object line items for a transaction, based on an object type plus an array of object IDs |
|
363 | - * |
|
364 | - * @param int $TXN_ID |
|
365 | - * @param string $OBJ_type |
|
366 | - * @param array $OBJ_IDs |
|
367 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
368 | - * @throws EE_Error |
|
369 | - */ |
|
370 | - public function get_object_line_items_for_transaction( |
|
371 | - $TXN_ID, |
|
372 | - $OBJ_type = EEM_Line_Item::OBJ_TYPE_EVENT, |
|
373 | - $OBJ_IDs = array() |
|
374 | - ) { |
|
375 | - $query_params = array( |
|
376 | - 'OBJ_type' => $OBJ_type, |
|
377 | - // if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query |
|
378 | - 'OBJ_ID' => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs, |
|
379 | - ); |
|
380 | - if ($TXN_ID) { |
|
381 | - $query_params['TXN_ID'] = $TXN_ID; |
|
382 | - } |
|
383 | - return $this->get_all(array($query_params)); |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * get_all_ticket_line_items_for_transaction |
|
389 | - * |
|
390 | - * @param EE_Transaction $transaction |
|
391 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
392 | - * @throws EE_Error |
|
393 | - * @throws InvalidArgumentException |
|
394 | - * @throws InvalidDataTypeException |
|
395 | - * @throws InvalidInterfaceException |
|
396 | - * @throws ReflectionException |
|
397 | - */ |
|
398 | - public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) |
|
399 | - { |
|
400 | - return $this->get_all(array( |
|
401 | - array( |
|
402 | - 'TXN_ID' => $transaction->ID(), |
|
403 | - 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET, |
|
404 | - ), |
|
405 | - )); |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * get_ticket_line_item_for_transaction |
|
411 | - * |
|
412 | - * @param int $TXN_ID |
|
413 | - * @param int $TKT_ID |
|
414 | - * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL |
|
415 | - * @throws EE_Error |
|
416 | - * @throws InvalidArgumentException |
|
417 | - * @throws InvalidDataTypeException |
|
418 | - * @throws InvalidInterfaceException |
|
419 | - */ |
|
420 | - public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) |
|
421 | - { |
|
422 | - return $this->get_one(array( |
|
423 | - array( |
|
424 | - 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID($TXN_ID), |
|
425 | - 'OBJ_ID' => $TKT_ID, |
|
426 | - 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET, |
|
427 | - ), |
|
428 | - )); |
|
429 | - } |
|
430 | - |
|
431 | - |
|
432 | - /** |
|
433 | - * get_existing_promotion_line_item |
|
434 | - * searches the cart for existing line items for the specified promotion |
|
435 | - * |
|
436 | - * @since 1.0.0 |
|
437 | - * @param EE_Line_Item $parent_line_item |
|
438 | - * @param EE_Promotion $promotion |
|
439 | - * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL |
|
440 | - * @throws EE_Error |
|
441 | - * @throws InvalidArgumentException |
|
442 | - * @throws InvalidDataTypeException |
|
443 | - * @throws InvalidInterfaceException |
|
444 | - * @throws ReflectionException |
|
445 | - */ |
|
446 | - public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) |
|
447 | - { |
|
448 | - return $this->get_one(array( |
|
449 | - array( |
|
450 | - 'TXN_ID' => $parent_line_item->TXN_ID(), |
|
451 | - 'LIN_parent' => $parent_line_item->ID(), |
|
452 | - 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_PROMOTION, |
|
453 | - 'OBJ_ID' => $promotion->ID(), |
|
454 | - ), |
|
455 | - )); |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * get_all_promotion_line_items |
|
461 | - * searches the cart for any and all existing promotion line items |
|
462 | - * |
|
463 | - * @since 1.0.0 |
|
464 | - * @param EE_Line_Item $parent_line_item |
|
465 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
466 | - * @throws EE_Error |
|
467 | - * @throws InvalidArgumentException |
|
468 | - * @throws InvalidDataTypeException |
|
469 | - * @throws InvalidInterfaceException |
|
470 | - * @throws ReflectionException |
|
471 | - */ |
|
472 | - public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) |
|
473 | - { |
|
474 | - return $this->get_all(array( |
|
475 | - array( |
|
476 | - 'TXN_ID' => $parent_line_item->TXN_ID(), |
|
477 | - 'LIN_parent' => $parent_line_item->ID(), |
|
478 | - 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_PROMOTION, |
|
479 | - ), |
|
480 | - )); |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - /** |
|
485 | - * Gets the registration's corresponding line item. |
|
486 | - * Note: basically does NOT support having multiple line items for a single ticket, |
|
487 | - * which would happen if some of the registrations had a price modifier while others didn't. |
|
488 | - * In order to support that, we'd probably need a LIN_ID on registrations or something. |
|
489 | - * |
|
490 | - * @param EE_Registration $registration |
|
491 | - * @return EE_Base_Class|EE_Line_ITem|EE_Soft_Delete_Base_Class|NULL |
|
492 | - * @throws EE_Error |
|
493 | - */ |
|
494 | - public function get_line_item_for_registration(EE_Registration $registration) |
|
495 | - { |
|
496 | - return $this->get_one($this->line_item_for_registration_query_params($registration)); |
|
497 | - } |
|
498 | - |
|
499 | - |
|
500 | - /** |
|
501 | - * Gets the query params used to retrieve a specific line item for the given registration |
|
502 | - * |
|
503 | - * @param EE_Registration $registration |
|
504 | - * @param array $original_query_params any extra query params you'd like to be merged with |
|
505 | - * @return array @see |
|
506 | - * https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
507 | - * @throws EE_Error |
|
508 | - */ |
|
509 | - public function line_item_for_registration_query_params( |
|
510 | - EE_Registration $registration, |
|
511 | - $original_query_params = array() |
|
512 | - ) { |
|
513 | - return array_replace_recursive($original_query_params, array( |
|
514 | - array( |
|
515 | - 'OBJ_ID' => $registration->ticket_ID(), |
|
516 | - 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET, |
|
517 | - 'TXN_ID' => $registration->transaction_ID(), |
|
518 | - ), |
|
519 | - )); |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
525 | - * @throws InvalidInterfaceException |
|
526 | - * @throws InvalidDataTypeException |
|
527 | - * @throws EE_Error |
|
528 | - * @throws InvalidArgumentException |
|
529 | - */ |
|
530 | - public function get_total_line_items_with_no_transaction() |
|
531 | - { |
|
532 | - return $this->get_total_line_items_for_carts(); |
|
533 | - } |
|
534 | - |
|
535 | - |
|
536 | - /** |
|
537 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
538 | - * @throws InvalidInterfaceException |
|
539 | - * @throws InvalidDataTypeException |
|
540 | - * @throws EE_Error |
|
541 | - * @throws InvalidArgumentException |
|
542 | - */ |
|
543 | - public function get_total_line_items_for_active_carts() |
|
544 | - { |
|
545 | - return $this->get_total_line_items_for_carts(false); |
|
546 | - } |
|
547 | - |
|
548 | - |
|
549 | - /** |
|
550 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
551 | - * @throws InvalidInterfaceException |
|
552 | - * @throws InvalidDataTypeException |
|
553 | - * @throws EE_Error |
|
554 | - * @throws InvalidArgumentException |
|
555 | - */ |
|
556 | - public function get_total_line_items_for_expired_carts() |
|
557 | - { |
|
558 | - return $this->get_total_line_items_for_carts(true); |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - /** |
|
563 | - * Returns an array of grand total line items where the TXN_ID is 0. |
|
564 | - * If $expired is set to true, then only line items for expired sessions will be returned. |
|
565 | - * If $expired is set to false, then only line items for active sessions will be returned. |
|
566 | - * |
|
567 | - * @param null $expired |
|
568 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
569 | - * @throws EE_Error |
|
570 | - * @throws InvalidArgumentException |
|
571 | - * @throws InvalidDataTypeException |
|
572 | - * @throws InvalidInterfaceException |
|
573 | - */ |
|
574 | - private function get_total_line_items_for_carts($expired = null) |
|
575 | - { |
|
576 | - $where_params = array( |
|
577 | - 'TXN_ID' => 0, |
|
578 | - 'LIN_type' => 'total', |
|
579 | - ); |
|
580 | - if ($expired !== null) { |
|
581 | - /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
582 | - $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
583 | - 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
584 | - ); |
|
585 | - $where_params['LIN_timestamp'] = array( |
|
586 | - $expired ? '<=' : '>', |
|
587 | - $session_lifespan->expiration(), |
|
588 | - ); |
|
589 | - } |
|
590 | - return $this->get_all(array($where_params)); |
|
591 | - } |
|
592 | - |
|
593 | - |
|
594 | - /** |
|
595 | - * Returns an array of ticket total line items where the TXN_ID is 0 |
|
596 | - * AND the timestamp is older than the session lifespan. |
|
597 | - * |
|
598 | - * @param int $timestamp |
|
599 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
600 | - * @throws EE_Error |
|
601 | - * @throws InvalidArgumentException |
|
602 | - * @throws InvalidDataTypeException |
|
603 | - * @throws InvalidInterfaceException |
|
604 | - */ |
|
605 | - public function getTicketLineItemsForExpiredCarts($timestamp = 0) |
|
606 | - { |
|
607 | - if (! absint($timestamp)) { |
|
608 | - /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
609 | - $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
610 | - 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
611 | - ); |
|
612 | - $timestamp = $session_lifespan->expiration(); |
|
613 | - } |
|
614 | - return $this->get_all( |
|
615 | - array( |
|
616 | - array( |
|
617 | - 'TXN_ID' => 0, |
|
618 | - 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET, |
|
619 | - 'LIN_timestamp' => array('<=', $timestamp), |
|
620 | - ), |
|
621 | - ) |
|
622 | - ); |
|
623 | - } |
|
328 | + // use GMT time because that's what TXN_timestamps are in |
|
329 | + date('Y-m-d H:i:s', time() - $time_to_leave_alone) |
|
330 | + ); |
|
331 | + return $wpdb->query($query); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * get_line_item_for_transaction_object |
|
337 | + * Gets a transaction's line item record for a specific object such as a EE_Event or EE_Ticket |
|
338 | + * |
|
339 | + * @param int $TXN_ID |
|
340 | + * @param EE_Base_Class $object |
|
341 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
342 | + * @throws EE_Error |
|
343 | + * @throws InvalidArgumentException |
|
344 | + * @throws InvalidDataTypeException |
|
345 | + * @throws InvalidInterfaceException |
|
346 | + * @throws ReflectionException |
|
347 | + */ |
|
348 | + public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) |
|
349 | + { |
|
350 | + return $this->get_all(array( |
|
351 | + array( |
|
352 | + 'TXN_ID' => $TXN_ID, |
|
353 | + 'OBJ_type' => str_replace('EE_', '', get_class($object)), |
|
354 | + 'OBJ_ID' => $object->ID(), |
|
355 | + ), |
|
356 | + )); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * get_object_line_items_for_transaction |
|
362 | + * Gets all of the the object line items for a transaction, based on an object type plus an array of object IDs |
|
363 | + * |
|
364 | + * @param int $TXN_ID |
|
365 | + * @param string $OBJ_type |
|
366 | + * @param array $OBJ_IDs |
|
367 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
368 | + * @throws EE_Error |
|
369 | + */ |
|
370 | + public function get_object_line_items_for_transaction( |
|
371 | + $TXN_ID, |
|
372 | + $OBJ_type = EEM_Line_Item::OBJ_TYPE_EVENT, |
|
373 | + $OBJ_IDs = array() |
|
374 | + ) { |
|
375 | + $query_params = array( |
|
376 | + 'OBJ_type' => $OBJ_type, |
|
377 | + // if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query |
|
378 | + 'OBJ_ID' => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs, |
|
379 | + ); |
|
380 | + if ($TXN_ID) { |
|
381 | + $query_params['TXN_ID'] = $TXN_ID; |
|
382 | + } |
|
383 | + return $this->get_all(array($query_params)); |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * get_all_ticket_line_items_for_transaction |
|
389 | + * |
|
390 | + * @param EE_Transaction $transaction |
|
391 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
392 | + * @throws EE_Error |
|
393 | + * @throws InvalidArgumentException |
|
394 | + * @throws InvalidDataTypeException |
|
395 | + * @throws InvalidInterfaceException |
|
396 | + * @throws ReflectionException |
|
397 | + */ |
|
398 | + public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) |
|
399 | + { |
|
400 | + return $this->get_all(array( |
|
401 | + array( |
|
402 | + 'TXN_ID' => $transaction->ID(), |
|
403 | + 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET, |
|
404 | + ), |
|
405 | + )); |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * get_ticket_line_item_for_transaction |
|
411 | + * |
|
412 | + * @param int $TXN_ID |
|
413 | + * @param int $TKT_ID |
|
414 | + * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL |
|
415 | + * @throws EE_Error |
|
416 | + * @throws InvalidArgumentException |
|
417 | + * @throws InvalidDataTypeException |
|
418 | + * @throws InvalidInterfaceException |
|
419 | + */ |
|
420 | + public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) |
|
421 | + { |
|
422 | + return $this->get_one(array( |
|
423 | + array( |
|
424 | + 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID($TXN_ID), |
|
425 | + 'OBJ_ID' => $TKT_ID, |
|
426 | + 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET, |
|
427 | + ), |
|
428 | + )); |
|
429 | + } |
|
430 | + |
|
431 | + |
|
432 | + /** |
|
433 | + * get_existing_promotion_line_item |
|
434 | + * searches the cart for existing line items for the specified promotion |
|
435 | + * |
|
436 | + * @since 1.0.0 |
|
437 | + * @param EE_Line_Item $parent_line_item |
|
438 | + * @param EE_Promotion $promotion |
|
439 | + * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL |
|
440 | + * @throws EE_Error |
|
441 | + * @throws InvalidArgumentException |
|
442 | + * @throws InvalidDataTypeException |
|
443 | + * @throws InvalidInterfaceException |
|
444 | + * @throws ReflectionException |
|
445 | + */ |
|
446 | + public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) |
|
447 | + { |
|
448 | + return $this->get_one(array( |
|
449 | + array( |
|
450 | + 'TXN_ID' => $parent_line_item->TXN_ID(), |
|
451 | + 'LIN_parent' => $parent_line_item->ID(), |
|
452 | + 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_PROMOTION, |
|
453 | + 'OBJ_ID' => $promotion->ID(), |
|
454 | + ), |
|
455 | + )); |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * get_all_promotion_line_items |
|
461 | + * searches the cart for any and all existing promotion line items |
|
462 | + * |
|
463 | + * @since 1.0.0 |
|
464 | + * @param EE_Line_Item $parent_line_item |
|
465 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
466 | + * @throws EE_Error |
|
467 | + * @throws InvalidArgumentException |
|
468 | + * @throws InvalidDataTypeException |
|
469 | + * @throws InvalidInterfaceException |
|
470 | + * @throws ReflectionException |
|
471 | + */ |
|
472 | + public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) |
|
473 | + { |
|
474 | + return $this->get_all(array( |
|
475 | + array( |
|
476 | + 'TXN_ID' => $parent_line_item->TXN_ID(), |
|
477 | + 'LIN_parent' => $parent_line_item->ID(), |
|
478 | + 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_PROMOTION, |
|
479 | + ), |
|
480 | + )); |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + /** |
|
485 | + * Gets the registration's corresponding line item. |
|
486 | + * Note: basically does NOT support having multiple line items for a single ticket, |
|
487 | + * which would happen if some of the registrations had a price modifier while others didn't. |
|
488 | + * In order to support that, we'd probably need a LIN_ID on registrations or something. |
|
489 | + * |
|
490 | + * @param EE_Registration $registration |
|
491 | + * @return EE_Base_Class|EE_Line_ITem|EE_Soft_Delete_Base_Class|NULL |
|
492 | + * @throws EE_Error |
|
493 | + */ |
|
494 | + public function get_line_item_for_registration(EE_Registration $registration) |
|
495 | + { |
|
496 | + return $this->get_one($this->line_item_for_registration_query_params($registration)); |
|
497 | + } |
|
498 | + |
|
499 | + |
|
500 | + /** |
|
501 | + * Gets the query params used to retrieve a specific line item for the given registration |
|
502 | + * |
|
503 | + * @param EE_Registration $registration |
|
504 | + * @param array $original_query_params any extra query params you'd like to be merged with |
|
505 | + * @return array @see |
|
506 | + * https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
507 | + * @throws EE_Error |
|
508 | + */ |
|
509 | + public function line_item_for_registration_query_params( |
|
510 | + EE_Registration $registration, |
|
511 | + $original_query_params = array() |
|
512 | + ) { |
|
513 | + return array_replace_recursive($original_query_params, array( |
|
514 | + array( |
|
515 | + 'OBJ_ID' => $registration->ticket_ID(), |
|
516 | + 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET, |
|
517 | + 'TXN_ID' => $registration->transaction_ID(), |
|
518 | + ), |
|
519 | + )); |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
525 | + * @throws InvalidInterfaceException |
|
526 | + * @throws InvalidDataTypeException |
|
527 | + * @throws EE_Error |
|
528 | + * @throws InvalidArgumentException |
|
529 | + */ |
|
530 | + public function get_total_line_items_with_no_transaction() |
|
531 | + { |
|
532 | + return $this->get_total_line_items_for_carts(); |
|
533 | + } |
|
534 | + |
|
535 | + |
|
536 | + /** |
|
537 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
538 | + * @throws InvalidInterfaceException |
|
539 | + * @throws InvalidDataTypeException |
|
540 | + * @throws EE_Error |
|
541 | + * @throws InvalidArgumentException |
|
542 | + */ |
|
543 | + public function get_total_line_items_for_active_carts() |
|
544 | + { |
|
545 | + return $this->get_total_line_items_for_carts(false); |
|
546 | + } |
|
547 | + |
|
548 | + |
|
549 | + /** |
|
550 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
551 | + * @throws InvalidInterfaceException |
|
552 | + * @throws InvalidDataTypeException |
|
553 | + * @throws EE_Error |
|
554 | + * @throws InvalidArgumentException |
|
555 | + */ |
|
556 | + public function get_total_line_items_for_expired_carts() |
|
557 | + { |
|
558 | + return $this->get_total_line_items_for_carts(true); |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + /** |
|
563 | + * Returns an array of grand total line items where the TXN_ID is 0. |
|
564 | + * If $expired is set to true, then only line items for expired sessions will be returned. |
|
565 | + * If $expired is set to false, then only line items for active sessions will be returned. |
|
566 | + * |
|
567 | + * @param null $expired |
|
568 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
569 | + * @throws EE_Error |
|
570 | + * @throws InvalidArgumentException |
|
571 | + * @throws InvalidDataTypeException |
|
572 | + * @throws InvalidInterfaceException |
|
573 | + */ |
|
574 | + private function get_total_line_items_for_carts($expired = null) |
|
575 | + { |
|
576 | + $where_params = array( |
|
577 | + 'TXN_ID' => 0, |
|
578 | + 'LIN_type' => 'total', |
|
579 | + ); |
|
580 | + if ($expired !== null) { |
|
581 | + /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
582 | + $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
583 | + 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
584 | + ); |
|
585 | + $where_params['LIN_timestamp'] = array( |
|
586 | + $expired ? '<=' : '>', |
|
587 | + $session_lifespan->expiration(), |
|
588 | + ); |
|
589 | + } |
|
590 | + return $this->get_all(array($where_params)); |
|
591 | + } |
|
592 | + |
|
593 | + |
|
594 | + /** |
|
595 | + * Returns an array of ticket total line items where the TXN_ID is 0 |
|
596 | + * AND the timestamp is older than the session lifespan. |
|
597 | + * |
|
598 | + * @param int $timestamp |
|
599 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
600 | + * @throws EE_Error |
|
601 | + * @throws InvalidArgumentException |
|
602 | + * @throws InvalidDataTypeException |
|
603 | + * @throws InvalidInterfaceException |
|
604 | + */ |
|
605 | + public function getTicketLineItemsForExpiredCarts($timestamp = 0) |
|
606 | + { |
|
607 | + if (! absint($timestamp)) { |
|
608 | + /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
609 | + $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
610 | + 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
611 | + ); |
|
612 | + $timestamp = $session_lifespan->expiration(); |
|
613 | + } |
|
614 | + return $this->get_all( |
|
615 | + array( |
|
616 | + array( |
|
617 | + 'TXN_ID' => 0, |
|
618 | + 'OBJ_type' => EEM_Line_Item::OBJ_TYPE_TICKET, |
|
619 | + 'LIN_timestamp' => array('<=', $timestamp), |
|
620 | + ), |
|
621 | + ) |
|
622 | + ); |
|
623 | + } |
|
624 | 624 | } |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | public function column_id($item) |
83 | 83 | { |
84 | 84 | $content = $item->get('term_id'); |
85 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get( |
|
85 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->get_first_related('Term')->get( |
|
86 | 86 | 'name' |
87 | - ) . '</span>'; |
|
87 | + ).'</span>'; |
|
88 | 88 | return $content; |
89 | 89 | } |
90 | 90 | |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EVENTS_ADMIN_URL); |
106 | 106 | |
107 | 107 | $actions = array( |
108 | - 'edit' => '<a href="' . $edit_link . '" aria-label="' . esc_attr__( |
|
108 | + 'edit' => '<a href="'.$edit_link.'" aria-label="'.esc_attr__( |
|
109 | 109 | 'Edit Category', |
110 | 110 | 'event_espresso' |
111 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
111 | + ).'">'.esc_html__('Edit', 'event_espresso').'</a>', |
|
112 | 112 | ); |
113 | 113 | |
114 | - $actions['delete'] = '<a href="' . $delete_link . '" aria-label="' . esc_attr__( |
|
114 | + $actions['delete'] = '<a href="'.$delete_link.'" aria-label="'.esc_attr__( |
|
115 | 115 | 'Delete Category', |
116 | 116 | 'event_espresso' |
117 | - ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>'; |
|
117 | + ).'">'.esc_html__('Delete', 'event_espresso').'</a>'; |
|
118 | 118 | |
119 | 119 | $actions['view'] = sprintf( |
120 | 120 | '<a href="%s" aria-label="%s">%s</a>', |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | esc_html__('View', 'event_espresso') |
130 | 130 | ); |
131 | 131 | |
132 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get( |
|
132 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->get_first_related('Term')->get( |
|
133 | 133 | 'name' |
134 | - ) . '</a></strong>'; |
|
134 | + ).'</a></strong>'; |
|
135 | 135 | $content .= $this->row_actions($actions); |
136 | 136 | return $content; |
137 | 137 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | public function column_shortcode($item) |
141 | 141 | { |
142 | - $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
142 | + $content = '[ESPRESSO_EVENTS category_slug='.$item->get_first_related('Term')->get('slug').']'; |
|
143 | 143 | return $content; |
144 | 144 | } |
145 | 145 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | 'EVT_CAT' => $item->get_first_related('Term')->ID(), |
152 | 152 | ); |
153 | 153 | $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
154 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
154 | + $content = '<a href="'.$e_link.'">'.$item->get('term_count').'</a>'; |
|
155 | 155 | return $content; |
156 | 156 | } |
157 | 157 | } |
@@ -15,142 +15,142 @@ |
||
15 | 15 | */ |
16 | 16 | class Event_Categories_Admin_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | - public function __construct($admin_page) |
|
19 | - { |
|
20 | - parent::__construct($admin_page); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - protected function _setup_data() |
|
25 | - { |
|
26 | - $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
27 | - $this->_all_data_count = EEM_Term_Taxonomy::instance()->count( |
|
28 | - array(array('taxonomy' => 'espresso_event_categories')) |
|
29 | - ); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - protected function _set_properties() |
|
34 | - { |
|
35 | - $this->_wp_list_args = array( |
|
36 | - 'singular' => esc_html__('event category', 'event_espresso'), |
|
37 | - 'plural' => esc_html__('event categories', 'event_espresso'), |
|
38 | - 'ajax' => true, // for now, |
|
39 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
40 | - ); |
|
41 | - |
|
42 | - $this->_columns = array( |
|
43 | - 'cb' => '<input type="checkbox" />', |
|
44 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
45 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
46 | - 'shortcode' => esc_html__('Shortcode', 'event_espresso'), |
|
47 | - 'count' => esc_html__('Events', 'event_espresso'), |
|
48 | - ); |
|
49 | - |
|
50 | - $this->_sortable_columns = array( |
|
51 | - 'id' => array('Term.term_id' => true), |
|
52 | - 'name' => array('Term.slug' => false), |
|
53 | - 'count' => array('term_count' => false), |
|
54 | - ); |
|
55 | - |
|
56 | - $this->_primary_column = 'id'; |
|
57 | - |
|
58 | - $this->_hidden_columns = array(); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - // not needed |
|
63 | - protected function _get_table_filters() |
|
64 | - { |
|
65 | - return array(); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - protected function _add_view_counts() |
|
70 | - { |
|
71 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - public function column_cb($item) |
|
76 | - { |
|
77 | - return sprintf('<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - public function column_id($item) |
|
82 | - { |
|
83 | - $content = $item->get('term_id'); |
|
84 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get( |
|
85 | - 'name' |
|
86 | - ) . '</span>'; |
|
87 | - return $content; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - public function column_name($item) |
|
92 | - { |
|
93 | - $edit_query_args = array( |
|
94 | - 'action' => 'edit_category', |
|
95 | - 'EVT_CAT_ID' => $item->get('term_id'), |
|
96 | - ); |
|
97 | - |
|
98 | - $delete_query_args = array( |
|
99 | - 'action' => 'delete_category', |
|
100 | - 'EVT_CAT_ID' => $item->get('term_id'), |
|
101 | - ); |
|
102 | - |
|
103 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
104 | - $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EVENTS_ADMIN_URL); |
|
105 | - |
|
106 | - $actions = array( |
|
107 | - 'edit' => '<a href="' . $edit_link . '" aria-label="' . esc_attr__( |
|
108 | - 'Edit Category', |
|
109 | - 'event_espresso' |
|
110 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
111 | - ); |
|
112 | - |
|
113 | - $actions['delete'] = '<a href="' . $delete_link . '" aria-label="' . esc_attr__( |
|
114 | - 'Delete Category', |
|
115 | - 'event_espresso' |
|
116 | - ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>'; |
|
117 | - |
|
118 | - $actions['view'] = sprintf( |
|
119 | - '<a href="%s" aria-label="%s">%s</a>', |
|
120 | - get_term_link($item->get('term_id')), |
|
121 | - esc_attr( |
|
122 | - sprintf( |
|
123 | - /* translators: %s: event category name */ |
|
124 | - esc_html__('View “%s” archive', 'event_espresso'), |
|
125 | - $item->get_first_related('Term')->get('name') |
|
126 | - ) |
|
127 | - ), |
|
128 | - esc_html__('View', 'event_espresso') |
|
129 | - ); |
|
130 | - |
|
131 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get( |
|
132 | - 'name' |
|
133 | - ) . '</a></strong>'; |
|
134 | - $content .= $this->row_actions($actions); |
|
135 | - return $content; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - public function column_shortcode($item) |
|
140 | - { |
|
141 | - $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
142 | - return $content; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - public function column_count($item) |
|
147 | - { |
|
148 | - $e_args = array( |
|
149 | - 'action' => 'default', |
|
150 | - 'EVT_CAT' => $item->get_first_related('Term')->ID(), |
|
151 | - ); |
|
152 | - $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
|
153 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
154 | - return $content; |
|
155 | - } |
|
18 | + public function __construct($admin_page) |
|
19 | + { |
|
20 | + parent::__construct($admin_page); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + protected function _setup_data() |
|
25 | + { |
|
26 | + $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
27 | + $this->_all_data_count = EEM_Term_Taxonomy::instance()->count( |
|
28 | + array(array('taxonomy' => 'espresso_event_categories')) |
|
29 | + ); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + protected function _set_properties() |
|
34 | + { |
|
35 | + $this->_wp_list_args = array( |
|
36 | + 'singular' => esc_html__('event category', 'event_espresso'), |
|
37 | + 'plural' => esc_html__('event categories', 'event_espresso'), |
|
38 | + 'ajax' => true, // for now, |
|
39 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
40 | + ); |
|
41 | + |
|
42 | + $this->_columns = array( |
|
43 | + 'cb' => '<input type="checkbox" />', |
|
44 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
45 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
46 | + 'shortcode' => esc_html__('Shortcode', 'event_espresso'), |
|
47 | + 'count' => esc_html__('Events', 'event_espresso'), |
|
48 | + ); |
|
49 | + |
|
50 | + $this->_sortable_columns = array( |
|
51 | + 'id' => array('Term.term_id' => true), |
|
52 | + 'name' => array('Term.slug' => false), |
|
53 | + 'count' => array('term_count' => false), |
|
54 | + ); |
|
55 | + |
|
56 | + $this->_primary_column = 'id'; |
|
57 | + |
|
58 | + $this->_hidden_columns = array(); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + // not needed |
|
63 | + protected function _get_table_filters() |
|
64 | + { |
|
65 | + return array(); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + protected function _add_view_counts() |
|
70 | + { |
|
71 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + public function column_cb($item) |
|
76 | + { |
|
77 | + return sprintf('<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + public function column_id($item) |
|
82 | + { |
|
83 | + $content = $item->get('term_id'); |
|
84 | + $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get( |
|
85 | + 'name' |
|
86 | + ) . '</span>'; |
|
87 | + return $content; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + public function column_name($item) |
|
92 | + { |
|
93 | + $edit_query_args = array( |
|
94 | + 'action' => 'edit_category', |
|
95 | + 'EVT_CAT_ID' => $item->get('term_id'), |
|
96 | + ); |
|
97 | + |
|
98 | + $delete_query_args = array( |
|
99 | + 'action' => 'delete_category', |
|
100 | + 'EVT_CAT_ID' => $item->get('term_id'), |
|
101 | + ); |
|
102 | + |
|
103 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
104 | + $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EVENTS_ADMIN_URL); |
|
105 | + |
|
106 | + $actions = array( |
|
107 | + 'edit' => '<a href="' . $edit_link . '" aria-label="' . esc_attr__( |
|
108 | + 'Edit Category', |
|
109 | + 'event_espresso' |
|
110 | + ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
111 | + ); |
|
112 | + |
|
113 | + $actions['delete'] = '<a href="' . $delete_link . '" aria-label="' . esc_attr__( |
|
114 | + 'Delete Category', |
|
115 | + 'event_espresso' |
|
116 | + ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>'; |
|
117 | + |
|
118 | + $actions['view'] = sprintf( |
|
119 | + '<a href="%s" aria-label="%s">%s</a>', |
|
120 | + get_term_link($item->get('term_id')), |
|
121 | + esc_attr( |
|
122 | + sprintf( |
|
123 | + /* translators: %s: event category name */ |
|
124 | + esc_html__('View “%s” archive', 'event_espresso'), |
|
125 | + $item->get_first_related('Term')->get('name') |
|
126 | + ) |
|
127 | + ), |
|
128 | + esc_html__('View', 'event_espresso') |
|
129 | + ); |
|
130 | + |
|
131 | + $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get( |
|
132 | + 'name' |
|
133 | + ) . '</a></strong>'; |
|
134 | + $content .= $this->row_actions($actions); |
|
135 | + return $content; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + public function column_shortcode($item) |
|
140 | + { |
|
141 | + $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
142 | + return $content; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + public function column_count($item) |
|
147 | + { |
|
148 | + $e_args = array( |
|
149 | + 'action' => 'default', |
|
150 | + 'EVT_CAT' => $item->get_first_related('Term')->ID(), |
|
151 | + ); |
|
152 | + $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
|
153 | + $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
154 | + return $content; |
|
155 | + } |
|
156 | 156 | } |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <div class="padding"> |
2 | 2 | <p><?php |
3 | - printf( |
|
4 | - esc_html__('Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso'), |
|
5 | - '<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank" rel="noopener noreferrer">', |
|
6 | - '</a>' |
|
7 | - ); ?></p> |
|
3 | + printf( |
|
4 | + esc_html__('Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso'), |
|
5 | + '<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank" rel="noopener noreferrer">', |
|
6 | + '</a>' |
|
7 | + ); ?></p> |
|
8 | 8 | </div> |
9 | 9 | \ No newline at end of file |
@@ -1,93 +1,93 @@ |
||
1 | 1 | <div class="padding"> |
2 | 2 | <?php esc_html_e( |
3 | - 'If you want to integrate with Event Espresso or participate in building code, then you are in the right place. The following resources can help you get started.', |
|
4 | - 'event_espresso' |
|
5 | - ); ?> |
|
3 | + 'If you want to integrate with Event Espresso or participate in building code, then you are in the right place. The following resources can help you get started.', |
|
4 | + 'event_espresso' |
|
5 | + ); ?> |
|
6 | 6 | <h2><?php esc_html_e('Developer Resources', 'event_espresso'); ?></h2> |
7 | 7 | <ul> |
8 | 8 | <li> |
9 | 9 | <?php printf( |
10 | - esc_html__('%1$sEvent Espresso 4 Developer Documentation%2$s', 'event_espresso'), |
|
11 | - '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs#getting-started-with-the-ee-developer-docs" target="_blank" rel="noopener noreferrer">', |
|
12 | - '</a>' |
|
13 | - ); ?></li> |
|
10 | + esc_html__('%1$sEvent Espresso 4 Developer Documentation%2$s', 'event_espresso'), |
|
11 | + '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs#getting-started-with-the-ee-developer-docs" target="_blank" rel="noopener noreferrer">', |
|
12 | + '</a>' |
|
13 | + ); ?></li> |
|
14 | 14 | <li> |
15 | 15 | <?php printf( |
16 | - esc_html__('%1$sEvent Espresso 4 Developer News%2$s', 'event_espresso'), |
|
17 | - '<a href="http://developer.eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
18 | - '</a>' |
|
19 | - ); ?></li> |
|
16 | + esc_html__('%1$sEvent Espresso 4 Developer News%2$s', 'event_espresso'), |
|
17 | + '<a href="http://developer.eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
18 | + '</a>' |
|
19 | + ); ?></li> |
|
20 | 20 | <li> |
21 | 21 | <?php printf( |
22 | - esc_html__('%1$sApply%2$s to be listed as an %3$sEvent Espresso Professional%2$s', 'event_espresso'), |
|
23 | - '<a href="https://eventespresso.com/developers/event-espresso-pros-application/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
24 | - '</a>', |
|
25 | - '<a href="https://eventespresso.com/developers/event-espresso-pros/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">' |
|
26 | - ); ?></li> |
|
22 | + esc_html__('%1$sApply%2$s to be listed as an %3$sEvent Espresso Professional%2$s', 'event_espresso'), |
|
23 | + '<a href="https://eventespresso.com/developers/event-espresso-pros-application/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
24 | + '</a>', |
|
25 | + '<a href="https://eventespresso.com/developers/event-espresso-pros/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">' |
|
26 | + ); ?></li> |
|
27 | 27 | </ul> |
28 | 28 | |
29 | 29 | <h2><?php esc_html_e('Event Espresso 4 Articles for Developers', 'event_espresso'); ?></h2> |
30 | 30 | <ul> |
31 | 31 | <li> |
32 | 32 | <?php printf( |
33 | - esc_html__('%1$sCustom Post Types Usage%2$s', 'event_espresso'), |
|
34 | - '<a href="https://eventespresso.com/2014/02/epsresso-brewery-custom-post-types-event-espresso/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
35 | - '</a>' |
|
36 | - ); ?></li> |
|
33 | + esc_html__('%1$sCustom Post Types Usage%2$s', 'event_espresso'), |
|
34 | + '<a href="https://eventespresso.com/2014/02/epsresso-brewery-custom-post-types-event-espresso/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
35 | + '</a>' |
|
36 | + ); ?></li> |
|
37 | 37 | <li> |
38 | 38 | <?php printf( |
39 | - esc_html__('%1$sTheme Development%2$s', 'event_espresso'), |
|
40 | - '<a href="https://eventespresso.com/2014/02/developers-corner-theming-event-espresso-4/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
41 | - '</a>' |
|
42 | - ); ?></li> |
|
39 | + esc_html__('%1$sTheme Development%2$s', 'event_espresso'), |
|
40 | + '<a href="https://eventespresso.com/2014/02/developers-corner-theming-event-espresso-4/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
41 | + '</a>' |
|
42 | + ); ?></li> |
|
43 | 43 | <li> |
44 | 44 | <?php printf( |
45 | - esc_html__('%1$sCapability System%2$s', 'event_espresso'), |
|
46 | - '<a href="http://developer.eventespresso.com/docs/ee-capability-system-overview/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
47 | - '</a>' |
|
48 | - ); ?></li> |
|
45 | + esc_html__('%1$sCapability System%2$s', 'event_espresso'), |
|
46 | + '<a href="http://developer.eventespresso.com/docs/ee-capability-system-overview/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
47 | + '</a>' |
|
48 | + ); ?></li> |
|
49 | 49 | <li> |
50 | 50 | <?php printf( |
51 | - esc_html__('%1$sPayment Method Development%2$s', 'event_espresso'), |
|
52 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/L--Payment-Methods-and-Gateways/creating-a-payment-method.md" target="_blank" rel="noopener noreferrer">', |
|
53 | - '</a>' |
|
54 | - ); ?></li> |
|
51 | + esc_html__('%1$sPayment Method Development%2$s', 'event_espresso'), |
|
52 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/L--Payment-Methods-and-Gateways/creating-a-payment-method.md" target="_blank" rel="noopener noreferrer">', |
|
53 | + '</a>' |
|
54 | + ); ?></li> |
|
55 | 55 | <li> |
56 | 56 | <?php printf( |
57 | - esc_html__('%1$sMessages System in Event Espresso 4%2$s', 'event_espresso'), |
|
58 | - '<a href="https://eventespresso.com/2014/03/messages-systemyour-tool-getting-word/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
59 | - '</a>' |
|
60 | - ); ?></li> |
|
57 | + esc_html__('%1$sMessages System in Event Espresso 4%2$s', 'event_espresso'), |
|
58 | + '<a href="https://eventespresso.com/2014/03/messages-systemyour-tool-getting-word/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
59 | + '</a>' |
|
60 | + ); ?></li> |
|
61 | 61 | <li> |
62 | 62 | <?php printf( |
63 | - esc_html__( |
|
64 | - '%1$sDatabase Model System%2$s (used for interfacing with EE4 data via WordPress plugins and server side querying)', |
|
65 | - 'event_espresso' |
|
66 | - ), |
|
67 | - '<a href="http://developer.eventespresso.com/docs/using-ee4-model-objects/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
68 | - '</a>' |
|
69 | - ); ?></li> |
|
63 | + esc_html__( |
|
64 | + '%1$sDatabase Model System%2$s (used for interfacing with EE4 data via WordPress plugins and server side querying)', |
|
65 | + 'event_espresso' |
|
66 | + ), |
|
67 | + '<a href="http://developer.eventespresso.com/docs/using-ee4-model-objects/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
68 | + '</a>' |
|
69 | + ); ?></li> |
|
70 | 70 | </ul> |
71 | 71 | |
72 | 72 | <h2><?php esc_html_e('REST API Resources', 'event_espresso'); ?></h2> |
73 | 73 | <ul> |
74 | 74 | <li> |
75 | 75 | <?php printf( |
76 | - esc_html__('%1$sREST API: Introduction%2$s', 'event_espresso'), |
|
77 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-introduction.md" target="_blank" rel="noopener noreferrer">', |
|
78 | - '</a>' |
|
79 | - ); ?></li> |
|
76 | + esc_html__('%1$sREST API: Introduction%2$s', 'event_espresso'), |
|
77 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-introduction.md" target="_blank" rel="noopener noreferrer">', |
|
78 | + '</a>' |
|
79 | + ); ?></li> |
|
80 | 80 | <li> |
81 | 81 | <?php printf( |
82 | - esc_html__('%1$sREST API: Reading Data%2$s', 'event_espresso'), |
|
83 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-reading-data.md" target="_blank" rel="noopener noreferrer">', |
|
84 | - '</a>' |
|
85 | - ); ?></li> |
|
82 | + esc_html__('%1$sREST API: Reading Data%2$s', 'event_espresso'), |
|
83 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-reading-data.md" target="_blank" rel="noopener noreferrer">', |
|
84 | + '</a>' |
|
85 | + ); ?></li> |
|
86 | 86 | <li> |
87 | 87 | <?php printf( |
88 | - esc_html__('%1$sBuilding an EE4 Add-on Using the REST API%2$s', 'event_espresso'), |
|
89 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/T--Tutorials/building-an-ee4-addon-that-uses-angular-js-and-the-ee4-json-rest-api.md" target="_blank" rel="noopener noreferrer">', |
|
90 | - '</a>' |
|
91 | - ); ?></li> |
|
88 | + esc_html__('%1$sBuilding an EE4 Add-on Using the REST API%2$s', 'event_espresso'), |
|
89 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/T--Tutorials/building-an-ee4-addon-that-uses-angular-js-and-the-ee4-json-rest-api.md" target="_blank" rel="noopener noreferrer">', |
|
90 | + '</a>' |
|
91 | + ); ?></li> |
|
92 | 92 | </ul> |
93 | 93 | </div> |
94 | 94 | \ No newline at end of file |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getType() |
95 | 95 | { |
96 | - if (!$this->type) { |
|
96 | + if ( ! $this->type) { |
|
97 | 97 | $this->type = $this->determineType(); |
98 | 98 | } |
99 | 99 | return $this->type; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function determineType() |
107 | 107 | { |
108 | - if (!$this->getTmpFile()) { |
|
108 | + if ( ! $this->getTmpFile()) { |
|
109 | 109 | return ''; |
110 | 110 | } |
111 | 111 | $finfo = new finfo(FILEINFO_MIME_TYPE); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getExtension() |
121 | 121 | { |
122 | - if (!$this->extension) { |
|
122 | + if ( ! $this->extension) { |
|
123 | 123 | $this->extension = $this->determineExtension(); |
124 | 124 | } |
125 | 125 | return $this->extension; |
@@ -19,164 +19,164 @@ |
||
19 | 19 | */ |
20 | 20 | class FileSubmission implements FileSubmissionInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string original name on the client machine |
|
24 | - */ |
|
25 | - protected $name; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string mime type |
|
29 | - */ |
|
30 | - protected $type; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string file extension |
|
34 | - */ |
|
35 | - protected $extension; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var int in bytes |
|
39 | - */ |
|
40 | - protected $size; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string local filepath to the temporary file |
|
44 | - */ |
|
45 | - protected $tmp_file; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values |
|
49 | - * although those aren't expected. |
|
50 | - */ |
|
51 | - protected $error_code; |
|
52 | - |
|
53 | - /** |
|
54 | - * FileSubmission constructor. |
|
55 | - * @param $name |
|
56 | - * @param $tmp_file |
|
57 | - * @param $size |
|
58 | - * @param null $error_code |
|
59 | - * @throws InvalidArgumentException |
|
60 | - */ |
|
61 | - public function __construct($name, $tmp_file, $size, $error_code = null) |
|
62 | - { |
|
63 | - $this->name = basename($name); |
|
64 | - $scheme = parse_url($tmp_file, PHP_URL_SCHEME); |
|
65 | - if (in_array($scheme, ['http', 'https'])) { |
|
66 | - // Wait a minute- just local filepaths please, no URL schemes allowed! |
|
67 | - throw new InvalidArgumentException( |
|
68 | - sprintf( |
|
69 | - // @codingStandardsIgnoreStart |
|
70 | - esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'), |
|
71 | - // @codingStandardsIgnoreEnd |
|
72 | - $scheme, |
|
73 | - $tmp_file |
|
74 | - ) |
|
75 | - ); |
|
76 | - } |
|
77 | - $this->tmp_file = (string) $tmp_file; |
|
78 | - $this->size = (int) $size; |
|
79 | - $this->error_code = (int) $error_code; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function getName() |
|
86 | - { |
|
87 | - return $this->name; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Gets the file's mime type |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function getType() |
|
95 | - { |
|
96 | - if (!$this->type) { |
|
97 | - $this->type = $this->determineType(); |
|
98 | - } |
|
99 | - return $this->type; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @since 4.9.80.p |
|
104 | - * @return string |
|
105 | - */ |
|
106 | - protected function determineType() |
|
107 | - { |
|
108 | - if (!$this->getTmpFile()) { |
|
109 | - return ''; |
|
110 | - } |
|
111 | - $finfo = new finfo(FILEINFO_MIME_TYPE); |
|
112 | - return $finfo->file($this->getTmpFile()); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Gets the file's extension. |
|
117 | - * @since 4.9.80.p |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function getExtension() |
|
121 | - { |
|
122 | - if (!$this->extension) { |
|
123 | - $this->extension = $this->determineExtension(); |
|
124 | - } |
|
125 | - return $this->extension; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Determine's the file's extension given the temporary file. |
|
130 | - * @since 4.9.80.p |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - protected function determineExtension() |
|
134 | - { |
|
135 | - $position_of_period = strrpos($this->getName(), '.'); |
|
136 | - if ($position_of_period === false) { |
|
137 | - return ''; |
|
138 | - } |
|
139 | - return mb_substr( |
|
140 | - $this->getName(), |
|
141 | - $position_of_period + 1 |
|
142 | - ); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Gets the size of the file |
|
147 | - * @return int |
|
148 | - */ |
|
149 | - public function getSize() |
|
150 | - { |
|
151 | - return $this->size; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Gets the path to the temporary file which was uploaded. |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function getTmpFile() |
|
159 | - { |
|
160 | - return $this->tmp_file; |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * @since 4.9.80.p |
|
165 | - * @return string |
|
166 | - */ |
|
167 | - public function __toString() |
|
168 | - { |
|
169 | - return $this->getName(); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Gets the error code PHP reported for the file upload. |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - public function getErrorCode() |
|
177 | - { |
|
178 | - return $this->error_code; |
|
179 | - } |
|
22 | + /** |
|
23 | + * @var string original name on the client machine |
|
24 | + */ |
|
25 | + protected $name; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string mime type |
|
29 | + */ |
|
30 | + protected $type; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string file extension |
|
34 | + */ |
|
35 | + protected $extension; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var int in bytes |
|
39 | + */ |
|
40 | + protected $size; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string local filepath to the temporary file |
|
44 | + */ |
|
45 | + protected $tmp_file; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values |
|
49 | + * although those aren't expected. |
|
50 | + */ |
|
51 | + protected $error_code; |
|
52 | + |
|
53 | + /** |
|
54 | + * FileSubmission constructor. |
|
55 | + * @param $name |
|
56 | + * @param $tmp_file |
|
57 | + * @param $size |
|
58 | + * @param null $error_code |
|
59 | + * @throws InvalidArgumentException |
|
60 | + */ |
|
61 | + public function __construct($name, $tmp_file, $size, $error_code = null) |
|
62 | + { |
|
63 | + $this->name = basename($name); |
|
64 | + $scheme = parse_url($tmp_file, PHP_URL_SCHEME); |
|
65 | + if (in_array($scheme, ['http', 'https'])) { |
|
66 | + // Wait a minute- just local filepaths please, no URL schemes allowed! |
|
67 | + throw new InvalidArgumentException( |
|
68 | + sprintf( |
|
69 | + // @codingStandardsIgnoreStart |
|
70 | + esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'), |
|
71 | + // @codingStandardsIgnoreEnd |
|
72 | + $scheme, |
|
73 | + $tmp_file |
|
74 | + ) |
|
75 | + ); |
|
76 | + } |
|
77 | + $this->tmp_file = (string) $tmp_file; |
|
78 | + $this->size = (int) $size; |
|
79 | + $this->error_code = (int) $error_code; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function getName() |
|
86 | + { |
|
87 | + return $this->name; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Gets the file's mime type |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function getType() |
|
95 | + { |
|
96 | + if (!$this->type) { |
|
97 | + $this->type = $this->determineType(); |
|
98 | + } |
|
99 | + return $this->type; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @since 4.9.80.p |
|
104 | + * @return string |
|
105 | + */ |
|
106 | + protected function determineType() |
|
107 | + { |
|
108 | + if (!$this->getTmpFile()) { |
|
109 | + return ''; |
|
110 | + } |
|
111 | + $finfo = new finfo(FILEINFO_MIME_TYPE); |
|
112 | + return $finfo->file($this->getTmpFile()); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Gets the file's extension. |
|
117 | + * @since 4.9.80.p |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function getExtension() |
|
121 | + { |
|
122 | + if (!$this->extension) { |
|
123 | + $this->extension = $this->determineExtension(); |
|
124 | + } |
|
125 | + return $this->extension; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Determine's the file's extension given the temporary file. |
|
130 | + * @since 4.9.80.p |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + protected function determineExtension() |
|
134 | + { |
|
135 | + $position_of_period = strrpos($this->getName(), '.'); |
|
136 | + if ($position_of_period === false) { |
|
137 | + return ''; |
|
138 | + } |
|
139 | + return mb_substr( |
|
140 | + $this->getName(), |
|
141 | + $position_of_period + 1 |
|
142 | + ); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Gets the size of the file |
|
147 | + * @return int |
|
148 | + */ |
|
149 | + public function getSize() |
|
150 | + { |
|
151 | + return $this->size; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Gets the path to the temporary file which was uploaded. |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function getTmpFile() |
|
159 | + { |
|
160 | + return $this->tmp_file; |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * @since 4.9.80.p |
|
165 | + * @return string |
|
166 | + */ |
|
167 | + public function __toString() |
|
168 | + { |
|
169 | + return $this->getName(); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Gets the error code PHP reported for the file upload. |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + public function getErrorCode() |
|
177 | + { |
|
178 | + return $this->error_code; |
|
179 | + } |
|
180 | 180 | } |
181 | 181 | // End of file FileSubmission.php |
182 | 182 | // Location: EventEspresso\core\services\request\files/FileSubmission.php |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
43 | 43 | wp_deregister_script('select2'); |
44 | 44 | wp_deregister_style('select2'); |
45 | - wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | - wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | - wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true); |
|
48 | - wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
45 | + wp_register_script('select2', EE_GLOBAL_ASSETS_URL.'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | + wp_register_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | + wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL.'scripts/form_section_select2_init.js', array('select2'), '1.0.0', true); |
|
48 | + wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | public function get_other_js_data($other_js_data = array()) |
75 | 75 | { |
76 | 76 | $other_js_data = parent::get_other_js_data($other_js_data); |
77 | - if (! isset($other_js_data['select2s'])) { |
|
77 | + if ( ! isset($other_js_data['select2s'])) { |
|
78 | 78 | $other_js_data['select2s'] = array(); |
79 | 79 | } |
80 | - $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args(); |
|
80 | + $other_js_data['select2s'][$this->_input->html_id()] = $this->get_js_args(); |
|
81 | 81 | return $other_js_data; |
82 | 82 | } |
83 | 83 |
@@ -15,80 +15,80 @@ |
||
15 | 15 | */ |
16 | 16 | class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy |
17 | 17 | { |
18 | - /** |
|
19 | - * Arguments that will be passed into the select2 javascript constructor |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $_select2_js_args = array(); |
|
18 | + /** |
|
19 | + * Arguments that will be passed into the select2 javascript constructor |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $_select2_js_args = array(); |
|
23 | 23 | |
24 | - /** |
|
25 | - * |
|
26 | - * @param array $select2_js_args pass in the EXACT array of JS arguments you want |
|
27 | - * to pass into the select2 js/html input. See https://select2.github.io |
|
28 | - */ |
|
29 | - public function __construct($select2_js_args = array()) |
|
30 | - { |
|
31 | - $this->_select2_js_args = $select2_js_args; |
|
32 | - parent::__construct(); |
|
33 | - } |
|
24 | + /** |
|
25 | + * |
|
26 | + * @param array $select2_js_args pass in the EXACT array of JS arguments you want |
|
27 | + * to pass into the select2 js/html input. See https://select2.github.io |
|
28 | + */ |
|
29 | + public function __construct($select2_js_args = array()) |
|
30 | + { |
|
31 | + $this->_select2_js_args = $select2_js_args; |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * enqueues the select2 initializing js (which depends on the select2 js) and |
|
37 | - * the select2 css |
|
38 | - */ |
|
39 | - public function enqueue_js() |
|
40 | - { |
|
41 | - // need to first deregister the select2 script in case some other plugin **cough cough Toolset Types cough** |
|
42 | - // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
|
43 | - wp_deregister_script('select2'); |
|
44 | - wp_deregister_style('select2'); |
|
45 | - wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | - wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | - wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true); |
|
48 | - wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
49 | - } |
|
35 | + /** |
|
36 | + * enqueues the select2 initializing js (which depends on the select2 js) and |
|
37 | + * the select2 css |
|
38 | + */ |
|
39 | + public function enqueue_js() |
|
40 | + { |
|
41 | + // need to first deregister the select2 script in case some other plugin **cough cough Toolset Types cough** |
|
42 | + // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
|
43 | + wp_deregister_script('select2'); |
|
44 | + wp_deregister_style('select2'); |
|
45 | + wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | + wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | + wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true); |
|
48 | + wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Gets the javascript args which will be localized and passed into the select2 js/html input |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - public function get_js_args() |
|
56 | - { |
|
57 | - return $this->_select2_js_args; |
|
58 | - } |
|
51 | + /** |
|
52 | + * Gets the javascript args which will be localized and passed into the select2 js/html input |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + public function get_js_args() |
|
56 | + { |
|
57 | + return $this->_select2_js_args; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Sets the exact js args which will be passed into the select2 js/html input |
|
62 | - * @param array $js_args |
|
63 | - */ |
|
64 | - public function set_js_args($js_args) |
|
65 | - { |
|
66 | - $this->_select2_js_args = $js_args; |
|
67 | - } |
|
60 | + /** |
|
61 | + * Sets the exact js args which will be passed into the select2 js/html input |
|
62 | + * @param array $js_args |
|
63 | + */ |
|
64 | + public function set_js_args($js_args) |
|
65 | + { |
|
66 | + $this->_select2_js_args = $js_args; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Adds select2 data for localization |
|
71 | - * @param array $other_js_data |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function get_other_js_data($other_js_data = array()) |
|
75 | - { |
|
76 | - $other_js_data = parent::get_other_js_data($other_js_data); |
|
77 | - if (! isset($other_js_data['select2s'])) { |
|
78 | - $other_js_data['select2s'] = array(); |
|
79 | - } |
|
80 | - $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args(); |
|
81 | - return $other_js_data; |
|
82 | - } |
|
69 | + /** |
|
70 | + * Adds select2 data for localization |
|
71 | + * @param array $other_js_data |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function get_other_js_data($other_js_data = array()) |
|
75 | + { |
|
76 | + $other_js_data = parent::get_other_js_data($other_js_data); |
|
77 | + if (! isset($other_js_data['select2s'])) { |
|
78 | + $other_js_data['select2s'] = array(); |
|
79 | + } |
|
80 | + $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args(); |
|
81 | + return $other_js_data; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Overrides standard attributes array to add the CSS class "ee-select2" |
|
86 | - * @return array |
|
87 | - */ |
|
88 | - protected function _standard_attributes_array() |
|
89 | - { |
|
90 | - $standard_attributes = parent::_standard_attributes_array(); |
|
91 | - $standard_attributes['class'] .= ' ee-select2'; |
|
92 | - return $standard_attributes; |
|
93 | - } |
|
84 | + /** |
|
85 | + * Overrides standard attributes array to add the CSS class "ee-select2" |
|
86 | + * @return array |
|
87 | + */ |
|
88 | + protected function _standard_attributes_array() |
|
89 | + { |
|
90 | + $standard_attributes = parent::_standard_attributes_array(); |
|
91 | + $standard_attributes['class'] .= ' ee-select2'; |
|
92 | + return $standard_attributes; |
|
93 | + } |
|
94 | 94 | } |