@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | $transaction = $registration->transaction(); |
55 | 55 | |
56 | 56 | // bail early if no transaction |
57 | - if (! $transaction instanceof EE_Transaction) { |
|
57 | + if ( ! $transaction instanceof EE_Transaction) { |
|
58 | 58 | throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso')); |
59 | 59 | } |
60 | 60 | |
61 | - $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0; |
|
61 | + $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array(array('PAY_ID' => $id, 'TXN_ID' => $transaction->ID()))) : 0; |
|
62 | 62 | |
63 | - return array( $transaction, $payment ); |
|
63 | + return array($transaction, $payment); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger) |
69 | 69 | { |
70 | 70 | // this is just a test |
71 | - return $this->name . ' Message Type for ' . $messenger->name . ' Messenger '; |
|
71 | + return $this->name.' Message Type for '.$messenger->name.' Messenger '; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -12,67 +12,67 @@ |
||
12 | 12 | */ |
13 | 13 | abstract class EE_Payment_Base_message_type extends EE_message_type |
14 | 14 | { |
15 | - /** |
|
16 | - * @see parent::get_priority() for documentation. |
|
17 | - * @return int |
|
18 | - */ |
|
19 | - public function get_priority() |
|
20 | - { |
|
21 | - return EEM_Message::priority_high; |
|
22 | - } |
|
15 | + /** |
|
16 | + * @see parent::get_priority() for documentation. |
|
17 | + * @return int |
|
18 | + */ |
|
19 | + public function get_priority() |
|
20 | + { |
|
21 | + return EEM_Message::priority_high; |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * see abstract declaration in parent class for details. |
|
29 | - */ |
|
30 | - protected function _set_admin_pages() |
|
31 | - { |
|
32 | - $this->admin_registered_pages = array( |
|
33 | - 'events_edit' => true |
|
34 | - ); |
|
35 | - } |
|
27 | + /** |
|
28 | + * see abstract declaration in parent class for details. |
|
29 | + */ |
|
30 | + protected function _set_admin_pages() |
|
31 | + { |
|
32 | + $this->admin_registered_pages = array( |
|
33 | + 'events_edit' => true |
|
34 | + ); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - protected function _set_data_handler() |
|
40 | - { |
|
41 | - $this->_data_handler = 'Gateways'; |
|
42 | - } |
|
39 | + protected function _set_data_handler() |
|
40 | + { |
|
41 | + $this->_data_handler = 'Gateways'; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | 46 | |
47 | - protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
48 | - { |
|
47 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
48 | + { |
|
49 | 49 | |
50 | - // use the registration to get the transaction. |
|
51 | - $transaction = $registration->transaction(); |
|
50 | + // use the registration to get the transaction. |
|
51 | + $transaction = $registration->transaction(); |
|
52 | 52 | |
53 | - // bail early if no transaction |
|
54 | - if (! $transaction instanceof EE_Transaction) { |
|
55 | - throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso')); |
|
56 | - } |
|
53 | + // bail early if no transaction |
|
54 | + if (! $transaction instanceof EE_Transaction) { |
|
55 | + throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso')); |
|
56 | + } |
|
57 | 57 | |
58 | - $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0; |
|
58 | + $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0; |
|
59 | 59 | |
60 | - return array( $transaction, $payment ); |
|
61 | - } |
|
60 | + return array( $transaction, $payment ); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger) |
|
66 | - { |
|
67 | - // this is just a test |
|
68 | - return $this->name . ' Message Type for ' . $messenger->name . ' Messenger '; |
|
69 | - } |
|
65 | + protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger) |
|
66 | + { |
|
67 | + // this is just a test |
|
68 | + return $this->name . ' Message Type for ' . $messenger->name . ' Messenger '; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * This message type doesn't need any settings so we are just setting to empty array. |
|
73 | - */ |
|
74 | - protected function _set_admin_settings_fields() |
|
75 | - { |
|
76 | - $this->_admin_settings_fields = array(); |
|
77 | - } |
|
71 | + /** |
|
72 | + * This message type doesn't need any settings so we are just setting to empty array. |
|
73 | + */ |
|
74 | + protected function _set_admin_settings_fields() |
|
75 | + { |
|
76 | + $this->_admin_settings_fields = array(); |
|
77 | + } |
|
78 | 78 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | return $this->_message; |
94 | 94 | } |
95 | 95 | $message = EEM_Message::instance()->get_one_by_token($this->token); |
96 | - if (! $message instanceof EE_Message) { |
|
96 | + if ( ! $message instanceof EE_Message) { |
|
97 | 97 | throw new EE_Error( |
98 | 98 | sprintf( |
99 | 99 | esc_html__('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'), |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | $message->set_STS_ID(EEM_Message::status_idle); |
105 | 105 | |
106 | - if (! $this->_sending_messenger instanceof EE_messenger) { |
|
106 | + if ( ! $this->_sending_messenger instanceof EE_messenger) { |
|
107 | 107 | $message->set_STS_ID(EEM_Message::status_failed); |
108 | 108 | $message->set_error_message( |
109 | 109 | sprintf( |
@@ -11,111 +11,111 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Message_Generated_From_Token extends EE_Message_To_Generate implements EEI_Has_Sending_Messenger |
13 | 13 | { |
14 | - /** |
|
15 | - * Sending messenger |
|
16 | - * |
|
17 | - * @type EE_messenger | string |
|
18 | - */ |
|
19 | - protected $_sending_messenger = ''; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * Holds the incoming token; |
|
24 | - * @type string |
|
25 | - */ |
|
26 | - public $token = ''; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * Constructor |
|
31 | - * |
|
32 | - * @param string $sending_messenger_slug This is used to set what messenger is used to "send" |
|
33 | - * the EE_Message retrieved from the DB via the given token. |
|
34 | - * @param string $token This is a token for a Message that should already exist int the db. |
|
35 | - * This is then used to populate the properties in here. |
|
36 | - * @param EE_Message_Resource_Manager $message_resource_manager |
|
37 | - */ |
|
38 | - public function __construct($token, $sending_messenger_slug, EE_Message_Resource_Manager $message_resource_manager) |
|
39 | - { |
|
40 | - $this->token = $token; |
|
41 | - $this->_sending_messenger = $this->_set_sending_messenger($sending_messenger_slug, $message_resource_manager); |
|
42 | - $this->_message = $this->_generate_message(); |
|
43 | - // set params for parent from the message object |
|
44 | - parent::__construct( |
|
45 | - $this->_message->messenger(), |
|
46 | - $this->_message->message_type(), |
|
47 | - array(), |
|
48 | - $this->_message->context(), |
|
49 | - false |
|
50 | - ); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @param string $sending_messenger_slug |
|
57 | - * @param \EE_Message_Resource_Manager $message_resource_manager |
|
58 | - * @return \EE_messenger | string |
|
59 | - */ |
|
60 | - protected function _set_sending_messenger( |
|
61 | - $sending_messenger_slug, |
|
62 | - EE_Message_Resource_Manager $message_resource_manager |
|
63 | - ) { |
|
64 | - $sending_messenger = $message_resource_manager->get_active_messenger($sending_messenger_slug); |
|
65 | - return $sending_messenger instanceof EE_messenger ? $sending_messenger : $sending_messenger_slug; |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @return EE_messenger |
|
72 | - */ |
|
73 | - public function sending_messenger() |
|
74 | - { |
|
75 | - return $this->_sending_messenger; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * generates an EE_Message using the supplied arguments and some defaults |
|
82 | - * |
|
83 | - * @param array $properties |
|
84 | - * @return EE_Message |
|
85 | - * @throws \EE_Error |
|
86 | - */ |
|
87 | - protected function _generate_message($properties = array()) |
|
88 | - { |
|
89 | - // a message was generated immediately but the parent class will call this again |
|
90 | - if ($this->_message instanceof EE_Message) { |
|
91 | - return $this->_message; |
|
92 | - } |
|
93 | - $message = EEM_Message::instance()->get_one_by_token($this->token); |
|
94 | - if (! $message instanceof EE_Message) { |
|
95 | - throw new EE_Error( |
|
96 | - sprintf( |
|
97 | - esc_html__('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'), |
|
98 | - $this->token |
|
99 | - ) |
|
100 | - ); |
|
101 | - } |
|
102 | - $message->set_STS_ID(EEM_Message::status_idle); |
|
103 | - |
|
104 | - if (! $this->_sending_messenger instanceof EE_messenger) { |
|
105 | - $message->set_STS_ID(EEM_Message::status_failed); |
|
106 | - $message->set_error_message( |
|
107 | - sprintf( |
|
108 | - esc_html__('Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso'), |
|
109 | - $this->_sending_messenger |
|
110 | - ) |
|
111 | - ); |
|
112 | - } |
|
113 | - |
|
114 | - // set properties |
|
115 | - $this->_valid = true; |
|
116 | - $this->_messenger = $message->messenger_object(); |
|
117 | - $this->_message_type = $message->message_type_object(); |
|
118 | - $this->_send_now = $message->send_now(); |
|
119 | - return $message; |
|
120 | - } |
|
14 | + /** |
|
15 | + * Sending messenger |
|
16 | + * |
|
17 | + * @type EE_messenger | string |
|
18 | + */ |
|
19 | + protected $_sending_messenger = ''; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * Holds the incoming token; |
|
24 | + * @type string |
|
25 | + */ |
|
26 | + public $token = ''; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * Constructor |
|
31 | + * |
|
32 | + * @param string $sending_messenger_slug This is used to set what messenger is used to "send" |
|
33 | + * the EE_Message retrieved from the DB via the given token. |
|
34 | + * @param string $token This is a token for a Message that should already exist int the db. |
|
35 | + * This is then used to populate the properties in here. |
|
36 | + * @param EE_Message_Resource_Manager $message_resource_manager |
|
37 | + */ |
|
38 | + public function __construct($token, $sending_messenger_slug, EE_Message_Resource_Manager $message_resource_manager) |
|
39 | + { |
|
40 | + $this->token = $token; |
|
41 | + $this->_sending_messenger = $this->_set_sending_messenger($sending_messenger_slug, $message_resource_manager); |
|
42 | + $this->_message = $this->_generate_message(); |
|
43 | + // set params for parent from the message object |
|
44 | + parent::__construct( |
|
45 | + $this->_message->messenger(), |
|
46 | + $this->_message->message_type(), |
|
47 | + array(), |
|
48 | + $this->_message->context(), |
|
49 | + false |
|
50 | + ); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @param string $sending_messenger_slug |
|
57 | + * @param \EE_Message_Resource_Manager $message_resource_manager |
|
58 | + * @return \EE_messenger | string |
|
59 | + */ |
|
60 | + protected function _set_sending_messenger( |
|
61 | + $sending_messenger_slug, |
|
62 | + EE_Message_Resource_Manager $message_resource_manager |
|
63 | + ) { |
|
64 | + $sending_messenger = $message_resource_manager->get_active_messenger($sending_messenger_slug); |
|
65 | + return $sending_messenger instanceof EE_messenger ? $sending_messenger : $sending_messenger_slug; |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @return EE_messenger |
|
72 | + */ |
|
73 | + public function sending_messenger() |
|
74 | + { |
|
75 | + return $this->_sending_messenger; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * generates an EE_Message using the supplied arguments and some defaults |
|
82 | + * |
|
83 | + * @param array $properties |
|
84 | + * @return EE_Message |
|
85 | + * @throws \EE_Error |
|
86 | + */ |
|
87 | + protected function _generate_message($properties = array()) |
|
88 | + { |
|
89 | + // a message was generated immediately but the parent class will call this again |
|
90 | + if ($this->_message instanceof EE_Message) { |
|
91 | + return $this->_message; |
|
92 | + } |
|
93 | + $message = EEM_Message::instance()->get_one_by_token($this->token); |
|
94 | + if (! $message instanceof EE_Message) { |
|
95 | + throw new EE_Error( |
|
96 | + sprintf( |
|
97 | + esc_html__('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'), |
|
98 | + $this->token |
|
99 | + ) |
|
100 | + ); |
|
101 | + } |
|
102 | + $message->set_STS_ID(EEM_Message::status_idle); |
|
103 | + |
|
104 | + if (! $this->_sending_messenger instanceof EE_messenger) { |
|
105 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
106 | + $message->set_error_message( |
|
107 | + sprintf( |
|
108 | + esc_html__('Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso'), |
|
109 | + $this->_sending_messenger |
|
110 | + ) |
|
111 | + ); |
|
112 | + } |
|
113 | + |
|
114 | + // set properties |
|
115 | + $this->_valid = true; |
|
116 | + $this->_messenger = $message->messenger_object(); |
|
117 | + $this->_message_type = $message->message_type_object(); |
|
118 | + $this->_send_now = $message->send_now(); |
|
119 | + return $message; |
|
120 | + } |
|
121 | 121 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger) |
37 | 37 | { |
38 | 38 | // this is just a test |
39 | - return $this->name . ' Message Type for ' . $messenger->name . ' Messenger '; |
|
39 | + return $this->name.' Message Type for '.$messenger->name.' Messenger '; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | if (isset($data_type[1]) && $data_type[1] instanceof EE_Registration) { |
56 | 56 | $regs = $data_type; |
57 | 57 | } else { |
58 | - $regs = is_array($data_type[0]) ? $data_type[0] : array( $maybe_reg ); |
|
58 | + $regs = is_array($data_type[0]) ? $data_type[0] : array($maybe_reg); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | foreach ($regs as $reg) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->_regs_for_sending[] = $reg->ID(); |
64 | 64 | } |
65 | 65 | } |
66 | - $this->_data = isset($this->_data[1]) ? array( $maybe_reg->transaction(), null, $this->_data[1] ) : array( $maybe_reg->transaction() ); |
|
66 | + $this->_data = isset($this->_data[1]) ? array($maybe_reg->transaction(), null, $this->_data[1]) : array($maybe_reg->transaction()); |
|
67 | 67 | $this->_data_handler = 'Gateways'; |
68 | 68 | } else { |
69 | 69 | $this->_data_handler = 'Gateways'; |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | |
83 | 83 | protected function _get_data_for_context($context, EE_Registration $registration, $id) |
84 | 84 | { |
85 | - if ($context == 'admin') { |
|
85 | + if ($context == 'admin') { |
|
86 | 86 | // use the registration to get the transaction. |
87 | 87 | $transaction = $registration->transaction(); |
88 | 88 | |
89 | 89 | // bail early if no transaction |
90 | - if (! $transaction instanceof EE_Transaction) { |
|
90 | + if ( ! $transaction instanceof EE_Transaction) { |
|
91 | 91 | throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso')); |
92 | 92 | } |
93 | 93 | |
94 | - $payment = !empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0; |
|
95 | - return array( $transaction, $payment ); |
|
94 | + $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array(array('PAY_ID' => $id, 'TXN_ID' => $transaction->ID()))) : 0; |
|
95 | + return array($transaction, $payment); |
|
96 | 96 | } else { |
97 | 97 | return $registration; |
98 | 98 | } |
@@ -12,126 +12,126 @@ |
||
12 | 12 | */ |
13 | 13 | abstract class EE_Registration_Base_message_type extends EE_message_type |
14 | 14 | { |
15 | - /** |
|
16 | - * @see parent::get_priority() for documentation. |
|
17 | - * @return int |
|
18 | - */ |
|
19 | - public function get_priority() |
|
20 | - { |
|
21 | - return EEM_Message::priority_medium; |
|
22 | - } |
|
23 | - |
|
24 | - |
|
25 | - |
|
26 | - protected function _set_admin_pages() |
|
27 | - { |
|
28 | - $this->admin_registered_pages = array( |
|
29 | - 'events_edit' => true |
|
30 | - ); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger) |
|
35 | - { |
|
36 | - // this is just a test |
|
37 | - return $this->name . ' Message Type for ' . $messenger->name . ' Messenger '; |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - |
|
43 | - protected function _set_data_handler() |
|
44 | - { |
|
45 | - if (is_array($this->_data)) { |
|
46 | - $data_type = reset($this->_data); |
|
47 | - |
|
48 | - if (is_array($data_type)) { |
|
49 | - // grab the first item and see if its a registration. |
|
50 | - $maybe_reg = isset($data_type[0]) && is_array($data_type[0]) ? reset($data_type[0]) : reset($data_type); |
|
51 | - if ($maybe_reg instanceof EE_Registration) { |
|
52 | - // is $data_type itself just an array of registrations? |
|
53 | - if (isset($data_type[1]) && $data_type[1] instanceof EE_Registration) { |
|
54 | - $regs = $data_type; |
|
55 | - } else { |
|
56 | - $regs = is_array($data_type[0]) ? $data_type[0] : array( $maybe_reg ); |
|
57 | - } |
|
58 | - |
|
59 | - foreach ($regs as $reg) { |
|
60 | - if ($reg instanceof EE_Registration) { |
|
61 | - $this->_regs_for_sending[] = $reg->ID(); |
|
62 | - } |
|
63 | - } |
|
64 | - $this->_data = isset($this->_data[1]) ? array( $maybe_reg->transaction(), null, $this->_data[1] ) : array( $maybe_reg->transaction() ); |
|
65 | - $this->_data_handler = 'Gateways'; |
|
66 | - } else { |
|
67 | - $this->_data_handler = 'Gateways'; |
|
68 | - } |
|
69 | - } else { |
|
70 | - $this->_data_handler = $data_type instanceof EE_Registration ? 'REG' : 'Gateways'; |
|
71 | - } |
|
72 | - } else { |
|
73 | - $this->_data_handler = $this->_data instanceof EE_Registration ? 'REG' : 'Gateways'; |
|
74 | - } |
|
75 | - |
|
76 | - $this->_single_message = $this->_data_handler == 'REG' ? true : false; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
82 | - { |
|
83 | - if ($context == 'admin') { |
|
84 | - // use the registration to get the transaction. |
|
85 | - $transaction = $registration->transaction(); |
|
86 | - |
|
87 | - // bail early if no transaction |
|
88 | - if (! $transaction instanceof EE_Transaction) { |
|
89 | - throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso')); |
|
90 | - } |
|
91 | - |
|
92 | - $payment = !empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0; |
|
93 | - return array( $transaction, $payment ); |
|
94 | - } else { |
|
95 | - return $registration; |
|
96 | - } |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * Setup admin settings for this message type. |
|
103 | - */ |
|
104 | - protected function _set_admin_settings_fields() |
|
105 | - { |
|
106 | - $this->_admin_settings_fields = array(); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * returns an array of addressee objects for event_admins |
|
115 | - * |
|
116 | - * @access protected |
|
117 | - * @return array array of EE_Messages_Addressee objects |
|
118 | - */ |
|
119 | - protected function _admin_addressees() |
|
120 | - { |
|
121 | - if ($this->_single_message) { |
|
122 | - return array(); |
|
123 | - } |
|
124 | - return parent::_admin_addressees(); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - protected function _primary_attendee_addressees() |
|
130 | - { |
|
131 | - if ($this->_single_message) { |
|
132 | - return array(); |
|
133 | - } |
|
134 | - |
|
135 | - return parent::_primary_attendee_addressees(); |
|
136 | - } |
|
15 | + /** |
|
16 | + * @see parent::get_priority() for documentation. |
|
17 | + * @return int |
|
18 | + */ |
|
19 | + public function get_priority() |
|
20 | + { |
|
21 | + return EEM_Message::priority_medium; |
|
22 | + } |
|
23 | + |
|
24 | + |
|
25 | + |
|
26 | + protected function _set_admin_pages() |
|
27 | + { |
|
28 | + $this->admin_registered_pages = array( |
|
29 | + 'events_edit' => true |
|
30 | + ); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger) |
|
35 | + { |
|
36 | + // this is just a test |
|
37 | + return $this->name . ' Message Type for ' . $messenger->name . ' Messenger '; |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + |
|
43 | + protected function _set_data_handler() |
|
44 | + { |
|
45 | + if (is_array($this->_data)) { |
|
46 | + $data_type = reset($this->_data); |
|
47 | + |
|
48 | + if (is_array($data_type)) { |
|
49 | + // grab the first item and see if its a registration. |
|
50 | + $maybe_reg = isset($data_type[0]) && is_array($data_type[0]) ? reset($data_type[0]) : reset($data_type); |
|
51 | + if ($maybe_reg instanceof EE_Registration) { |
|
52 | + // is $data_type itself just an array of registrations? |
|
53 | + if (isset($data_type[1]) && $data_type[1] instanceof EE_Registration) { |
|
54 | + $regs = $data_type; |
|
55 | + } else { |
|
56 | + $regs = is_array($data_type[0]) ? $data_type[0] : array( $maybe_reg ); |
|
57 | + } |
|
58 | + |
|
59 | + foreach ($regs as $reg) { |
|
60 | + if ($reg instanceof EE_Registration) { |
|
61 | + $this->_regs_for_sending[] = $reg->ID(); |
|
62 | + } |
|
63 | + } |
|
64 | + $this->_data = isset($this->_data[1]) ? array( $maybe_reg->transaction(), null, $this->_data[1] ) : array( $maybe_reg->transaction() ); |
|
65 | + $this->_data_handler = 'Gateways'; |
|
66 | + } else { |
|
67 | + $this->_data_handler = 'Gateways'; |
|
68 | + } |
|
69 | + } else { |
|
70 | + $this->_data_handler = $data_type instanceof EE_Registration ? 'REG' : 'Gateways'; |
|
71 | + } |
|
72 | + } else { |
|
73 | + $this->_data_handler = $this->_data instanceof EE_Registration ? 'REG' : 'Gateways'; |
|
74 | + } |
|
75 | + |
|
76 | + $this->_single_message = $this->_data_handler == 'REG' ? true : false; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
82 | + { |
|
83 | + if ($context == 'admin') { |
|
84 | + // use the registration to get the transaction. |
|
85 | + $transaction = $registration->transaction(); |
|
86 | + |
|
87 | + // bail early if no transaction |
|
88 | + if (! $transaction instanceof EE_Transaction) { |
|
89 | + throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso')); |
|
90 | + } |
|
91 | + |
|
92 | + $payment = !empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0; |
|
93 | + return array( $transaction, $payment ); |
|
94 | + } else { |
|
95 | + return $registration; |
|
96 | + } |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * Setup admin settings for this message type. |
|
103 | + */ |
|
104 | + protected function _set_admin_settings_fields() |
|
105 | + { |
|
106 | + $this->_admin_settings_fields = array(); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * returns an array of addressee objects for event_admins |
|
115 | + * |
|
116 | + * @access protected |
|
117 | + * @return array array of EE_Messages_Addressee objects |
|
118 | + */ |
|
119 | + protected function _admin_addressees() |
|
120 | + { |
|
121 | + if ($this->_single_message) { |
|
122 | + return array(); |
|
123 | + } |
|
124 | + return parent::_admin_addressees(); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + protected function _primary_attendee_addressees() |
|
130 | + { |
|
131 | + if ($this->_single_message) { |
|
132 | + return array(); |
|
133 | + } |
|
134 | + |
|
135 | + return parent::_primary_attendee_addressees(); |
|
136 | + } |
|
137 | 137 | } |
@@ -207,7 +207,7 @@ |
||
207 | 207 | { |
208 | 208 | foreach ($this->_qtipsa as $qt) { |
209 | 209 | // make sure we have what we need. |
210 | - if (! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) { |
|
210 | + if ( ! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) { |
|
211 | 211 | throw new EE_Error( |
212 | 212 | sprintf( |
213 | 213 | esc_html__( |
@@ -14,235 +14,235 @@ discard block |
||
14 | 14 | */ |
15 | 15 | abstract class EE_Qtip_Config extends EE_Base |
16 | 16 | { |
17 | - /** |
|
18 | - * This will hold the qtips setup array (setup by children) |
|
19 | - * |
|
20 | - * @access protected |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - protected $_qtipsa; |
|
17 | + /** |
|
18 | + * This will hold the qtips setup array (setup by children) |
|
19 | + * |
|
20 | + * @access protected |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + protected $_qtipsa; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * This holds the constructed EE_Qtip objects |
|
28 | - * |
|
29 | - * @access protected |
|
30 | - * @var EE_Qtip |
|
31 | - */ |
|
32 | - protected $_qtips; |
|
26 | + /** |
|
27 | + * This holds the constructed EE_Qtip objects |
|
28 | + * |
|
29 | + * @access protected |
|
30 | + * @var EE_Qtip |
|
31 | + */ |
|
32 | + protected $_qtips; |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * an array of default options for instantiated qtip js objects |
|
37 | - * |
|
38 | - * @access protected |
|
39 | - * @var array |
|
40 | - */ |
|
41 | - protected $_default_options; |
|
35 | + /** |
|
36 | + * an array of default options for instantiated qtip js objects |
|
37 | + * |
|
38 | + * @access protected |
|
39 | + * @var array |
|
40 | + */ |
|
41 | + protected $_default_options; |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * constructor |
|
46 | - * |
|
47 | - * @access public |
|
48 | - */ |
|
49 | - public function __construct() |
|
50 | - { |
|
51 | - $this->_qtipsa = $this->_qtips = array(); |
|
52 | - $this->_set_default_options(); |
|
53 | - $this->_set_tips_array(); |
|
54 | - $this->_construct_tips(); |
|
55 | - } |
|
44 | + /** |
|
45 | + * constructor |
|
46 | + * |
|
47 | + * @access public |
|
48 | + */ |
|
49 | + public function __construct() |
|
50 | + { |
|
51 | + $this->_qtipsa = $this->_qtips = array(); |
|
52 | + $this->_set_default_options(); |
|
53 | + $this->_set_tips_array(); |
|
54 | + $this->_construct_tips(); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Children define this method and its purpose is to setup the $_qtipsa property. The format of this property is: |
|
60 | - * |
|
61 | - * $qtipsa = array( |
|
62 | - * 0 => array( |
|
63 | - * 'content_id' => 'some_unique_id_for_referencing_content', //just the string |
|
64 | - * 'content' => 'html/text content for the qtip', |
|
65 | - * 'target' => '#target-element', //use the same schema as jQuery selectors. This will match what the |
|
66 | - * target is for the qTip in the dom (i.e. if class then '.some-class'). |
|
67 | - * 'options' => array() //use this to override any of the default options for this specific qtip. |
|
68 | - * ) |
|
69 | - * ); |
|
70 | - * |
|
71 | - * @abstract |
|
72 | - * @access protected |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - abstract protected function _set_tips_array(); |
|
58 | + /** |
|
59 | + * Children define this method and its purpose is to setup the $_qtipsa property. The format of this property is: |
|
60 | + * |
|
61 | + * $qtipsa = array( |
|
62 | + * 0 => array( |
|
63 | + * 'content_id' => 'some_unique_id_for_referencing_content', //just the string |
|
64 | + * 'content' => 'html/text content for the qtip', |
|
65 | + * 'target' => '#target-element', //use the same schema as jQuery selectors. This will match what the |
|
66 | + * target is for the qTip in the dom (i.e. if class then '.some-class'). |
|
67 | + * 'options' => array() //use this to override any of the default options for this specific qtip. |
|
68 | + * ) |
|
69 | + * ); |
|
70 | + * |
|
71 | + * @abstract |
|
72 | + * @access protected |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + abstract protected function _set_tips_array(); |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * all the default options for the qtip js are defined here. Children class can override the defaults for all the |
|
80 | - * qtips defined in their config OR just leave it and have the parent default options apply. |
|
81 | - * |
|
82 | - * commented out options are there for reference so you know which can be defined by the child. |
|
83 | - * |
|
84 | - * Note: children do NOT have to define all these options. Just define the ones to override. |
|
85 | - * |
|
86 | - * @link http://qtip2.com/options |
|
87 | - * |
|
88 | - * @access protected |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - protected function _set_default_options() |
|
92 | - { |
|
93 | - $this->_default_options = array( |
|
94 | - // 'id' => 'unique_id_referncing_qtip_instance', |
|
95 | - 'prerender' => false, |
|
96 | - // increases page load if true, |
|
97 | - 'suppress' => true, |
|
98 | - // whether default browser tooltips are suppressed. |
|
99 | - 'content' => array( |
|
100 | - 'button' => false, |
|
101 | - // what you want for the close button text/link. |
|
102 | - 'title' => true, |
|
103 | - // Options: "string", true. If TRUE then the title attribute of the target will be used (if available). If "string" then we'll use that as the title. |
|
104 | - 'clone' => true, |
|
105 | - // Options: true|false. if true then the text will be cloned from the content instead of removed from the dom. |
|
106 | - ), |
|
107 | - 'show_only_once' => false, |
|
108 | - // this is NOT a qtip2 library option, but is something added for EE specific use. If set to true, this means that this particular tooltip will only show ONCE for the user and then a cookie will be saved so that it doesn't show again (after exit). |
|
109 | - 'position' => array( |
|
110 | - 'my' => 'top left', |
|
111 | - // top left || top center || top right || right top || right center || right bottom || bottom right || bottom center || bottom left || left bottom || left center || left top |
|
112 | - 'at' => 'bottom right', |
|
113 | - // same options as above. |
|
114 | - 'target' => 'event', |
|
115 | - // if u use jQuery::#selector, js will parse to a jQuery selector || 'mouse' (at mouse cursor position) || 'event' (position at target that triggered the tooltip), or an array containing an absolute x/y position on page. |
|
116 | - 'container' => false, |
|
117 | - // what HTML element the tooltip is appended to (it's containing element). jquery object. Use 'jQuery::#selector' and js will parse' |
|
118 | - 'viewport' => true, |
|
119 | - // @link http://qtip2.com/plugins#viewport |
|
120 | - 'adjust' => array( |
|
121 | - 'x' => 0, |
|
122 | - // adjust position on x axis by 0 pixels. |
|
123 | - 'y' => 0, |
|
124 | - // adjust position on y axis by 0 pixels. |
|
125 | - 'mouse' => true, |
|
126 | - // when position['target'] is set to 'mouse', tooltip will follow mouse when hovering over the target. False, stops following. |
|
127 | - 'resize' => true, |
|
128 | - // adjust tooltip position when window is resized. |
|
129 | - 'scroll' => true, |
|
130 | - // position of tooltip adjusted when window (or position.container) is scrolled. |
|
131 | - 'method' => 'flipinvert', |
|
132 | - // @link http://qtip2.com/plugins#viewport |
|
133 | - ), |
|
134 | - ), |
|
135 | - 'show' => array( |
|
136 | - 'event' => 'mouseenter', |
|
137 | - // what event triggers tooltip to be shown. Any jQuery standard event or custom events can be used. space separated events provide multiple triggers. |
|
138 | - 'target' => false, |
|
139 | - // options jQuery::#selector|false. Used to indicate which html element will trigger show event. When false, the element the qtip() method was called upon is used. |
|
140 | - 'delay' => 90, |
|
141 | - // time in millisecons by which to delay showing of tooltip. |
|
142 | - 'solo' => false, |
|
143 | - // determines whether tooltip will hid all others when triggered. Options: true (hide all) || false (ignore) || string (parent selector for which qtips get hidden) |
|
144 | - 'modal' => array( |
|
145 | - 'on' => false, // does tooltip trigger modal? |
|
146 | - 'blur' => true, // does clicking on the dimmed background hide the tooltip and remove the dim? |
|
147 | - 'escape' => true, // hitting escape key hide the tooltip and cancel modal |
|
148 | - 'stealfocus' => true, // can users focus on inputs and elelments outside of tooltip when modal on? |
|
149 | - ), |
|
150 | - ), |
|
151 | - 'hide' => array( |
|
152 | - 'event' => 'mouseleave', |
|
153 | - // similar as what you do for show.event. |
|
154 | - 'target' => false, |
|
155 | - // Options jQuery::#selector. which html element will trigger hide event. When false, the element the .qtip() method was called upon is used. |
|
156 | - 'delay' => 0, |
|
157 | - // set time in milliseconds for delaying the hide of the tooltip |
|
158 | - 'inactive' => false, |
|
159 | - // if integer, time in millisecons in which the tooltip should be hidden if remains inactive (not interacted with) |
|
160 | - 'fixed' => false, |
|
161 | - // when set to true, the tooltip will not hide if moused over. |
|
162 | - 'leave' => 'window', |
|
163 | - // specify whether the tooltip will hide when leaving the window it's conained within. |
|
164 | - 'distance' => false, |
|
165 | - // if integer, distance in pixels that the tooltip hides when the mouse is moved from the point it triggered the tooltip. |
|
166 | - ), |
|
167 | - 'style' => array( |
|
168 | - 'classes' => 'qtip-tipsy', |
|
169 | - // Options "string", false. A space separated string containing all class names which should be added ot the main qTip element. See options for styles in comment block at end of this class. |
|
170 | - 'def' => true, |
|
171 | - // set to false and the default qtip class does not get applied |
|
172 | - 'widget' => false, |
|
173 | - // whether ui-widget classes of the themeroller UI styles are applied to tooltip. |
|
174 | - 'width' => false, |
|
175 | - // Options: "string", integer, false. with this you can override all applied CSS width styles for tooltip. Can be any valid width CSS value. (does not override min/max width styles) |
|
176 | - 'height' => false, |
|
177 | - // same as above except applies to height. |
|
178 | - 'tip' => array( |
|
179 | - 'corner' => true, |
|
180 | - // where in relation to the tooltip the speech bubble tip is applied. Options: true, "corner string" (see position), false. true inherits |
|
181 | - 'mimic' => false, |
|
182 | - // see documentation @link http://qtip2.com/plugins#tips |
|
183 | - 'border' => true, |
|
184 | - // Options: true, integer. determines the width of the border that surrounds the tip element. True inherits from tooltip. |
|
185 | - 'width' => 6, |
|
186 | - // width of rendered tip in pixels in relation to the side of the tooltip the tip is on. |
|
187 | - 'height' => 6, |
|
188 | - // works the same as tip.width |
|
189 | - 'offset' => 0, |
|
190 | - // use to set the offset of the tip in relation to its corner position. |
|
191 | - ), |
|
192 | - ), |
|
78 | + /** |
|
79 | + * all the default options for the qtip js are defined here. Children class can override the defaults for all the |
|
80 | + * qtips defined in their config OR just leave it and have the parent default options apply. |
|
81 | + * |
|
82 | + * commented out options are there for reference so you know which can be defined by the child. |
|
83 | + * |
|
84 | + * Note: children do NOT have to define all these options. Just define the ones to override. |
|
85 | + * |
|
86 | + * @link http://qtip2.com/options |
|
87 | + * |
|
88 | + * @access protected |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + protected function _set_default_options() |
|
92 | + { |
|
93 | + $this->_default_options = array( |
|
94 | + // 'id' => 'unique_id_referncing_qtip_instance', |
|
95 | + 'prerender' => false, |
|
96 | + // increases page load if true, |
|
97 | + 'suppress' => true, |
|
98 | + // whether default browser tooltips are suppressed. |
|
99 | + 'content' => array( |
|
100 | + 'button' => false, |
|
101 | + // what you want for the close button text/link. |
|
102 | + 'title' => true, |
|
103 | + // Options: "string", true. If TRUE then the title attribute of the target will be used (if available). If "string" then we'll use that as the title. |
|
104 | + 'clone' => true, |
|
105 | + // Options: true|false. if true then the text will be cloned from the content instead of removed from the dom. |
|
106 | + ), |
|
107 | + 'show_only_once' => false, |
|
108 | + // this is NOT a qtip2 library option, but is something added for EE specific use. If set to true, this means that this particular tooltip will only show ONCE for the user and then a cookie will be saved so that it doesn't show again (after exit). |
|
109 | + 'position' => array( |
|
110 | + 'my' => 'top left', |
|
111 | + // top left || top center || top right || right top || right center || right bottom || bottom right || bottom center || bottom left || left bottom || left center || left top |
|
112 | + 'at' => 'bottom right', |
|
113 | + // same options as above. |
|
114 | + 'target' => 'event', |
|
115 | + // if u use jQuery::#selector, js will parse to a jQuery selector || 'mouse' (at mouse cursor position) || 'event' (position at target that triggered the tooltip), or an array containing an absolute x/y position on page. |
|
116 | + 'container' => false, |
|
117 | + // what HTML element the tooltip is appended to (it's containing element). jquery object. Use 'jQuery::#selector' and js will parse' |
|
118 | + 'viewport' => true, |
|
119 | + // @link http://qtip2.com/plugins#viewport |
|
120 | + 'adjust' => array( |
|
121 | + 'x' => 0, |
|
122 | + // adjust position on x axis by 0 pixels. |
|
123 | + 'y' => 0, |
|
124 | + // adjust position on y axis by 0 pixels. |
|
125 | + 'mouse' => true, |
|
126 | + // when position['target'] is set to 'mouse', tooltip will follow mouse when hovering over the target. False, stops following. |
|
127 | + 'resize' => true, |
|
128 | + // adjust tooltip position when window is resized. |
|
129 | + 'scroll' => true, |
|
130 | + // position of tooltip adjusted when window (or position.container) is scrolled. |
|
131 | + 'method' => 'flipinvert', |
|
132 | + // @link http://qtip2.com/plugins#viewport |
|
133 | + ), |
|
134 | + ), |
|
135 | + 'show' => array( |
|
136 | + 'event' => 'mouseenter', |
|
137 | + // what event triggers tooltip to be shown. Any jQuery standard event or custom events can be used. space separated events provide multiple triggers. |
|
138 | + 'target' => false, |
|
139 | + // options jQuery::#selector|false. Used to indicate which html element will trigger show event. When false, the element the qtip() method was called upon is used. |
|
140 | + 'delay' => 90, |
|
141 | + // time in millisecons by which to delay showing of tooltip. |
|
142 | + 'solo' => false, |
|
143 | + // determines whether tooltip will hid all others when triggered. Options: true (hide all) || false (ignore) || string (parent selector for which qtips get hidden) |
|
144 | + 'modal' => array( |
|
145 | + 'on' => false, // does tooltip trigger modal? |
|
146 | + 'blur' => true, // does clicking on the dimmed background hide the tooltip and remove the dim? |
|
147 | + 'escape' => true, // hitting escape key hide the tooltip and cancel modal |
|
148 | + 'stealfocus' => true, // can users focus on inputs and elelments outside of tooltip when modal on? |
|
149 | + ), |
|
150 | + ), |
|
151 | + 'hide' => array( |
|
152 | + 'event' => 'mouseleave', |
|
153 | + // similar as what you do for show.event. |
|
154 | + 'target' => false, |
|
155 | + // Options jQuery::#selector. which html element will trigger hide event. When false, the element the .qtip() method was called upon is used. |
|
156 | + 'delay' => 0, |
|
157 | + // set time in milliseconds for delaying the hide of the tooltip |
|
158 | + 'inactive' => false, |
|
159 | + // if integer, time in millisecons in which the tooltip should be hidden if remains inactive (not interacted with) |
|
160 | + 'fixed' => false, |
|
161 | + // when set to true, the tooltip will not hide if moused over. |
|
162 | + 'leave' => 'window', |
|
163 | + // specify whether the tooltip will hide when leaving the window it's conained within. |
|
164 | + 'distance' => false, |
|
165 | + // if integer, distance in pixels that the tooltip hides when the mouse is moved from the point it triggered the tooltip. |
|
166 | + ), |
|
167 | + 'style' => array( |
|
168 | + 'classes' => 'qtip-tipsy', |
|
169 | + // Options "string", false. A space separated string containing all class names which should be added ot the main qTip element. See options for styles in comment block at end of this class. |
|
170 | + 'def' => true, |
|
171 | + // set to false and the default qtip class does not get applied |
|
172 | + 'widget' => false, |
|
173 | + // whether ui-widget classes of the themeroller UI styles are applied to tooltip. |
|
174 | + 'width' => false, |
|
175 | + // Options: "string", integer, false. with this you can override all applied CSS width styles for tooltip. Can be any valid width CSS value. (does not override min/max width styles) |
|
176 | + 'height' => false, |
|
177 | + // same as above except applies to height. |
|
178 | + 'tip' => array( |
|
179 | + 'corner' => true, |
|
180 | + // where in relation to the tooltip the speech bubble tip is applied. Options: true, "corner string" (see position), false. true inherits |
|
181 | + 'mimic' => false, |
|
182 | + // see documentation @link http://qtip2.com/plugins#tips |
|
183 | + 'border' => true, |
|
184 | + // Options: true, integer. determines the width of the border that surrounds the tip element. True inherits from tooltip. |
|
185 | + 'width' => 6, |
|
186 | + // width of rendered tip in pixels in relation to the side of the tooltip the tip is on. |
|
187 | + 'height' => 6, |
|
188 | + // works the same as tip.width |
|
189 | + 'offset' => 0, |
|
190 | + // use to set the offset of the tip in relation to its corner position. |
|
191 | + ), |
|
192 | + ), |
|
193 | 193 | |
194 | - ); |
|
195 | - } |
|
194 | + ); |
|
195 | + } |
|
196 | 196 | |
197 | 197 | |
198 | - /** |
|
199 | - * This takes the set $_qtipsa array property and loops through it to set the EE_Qtip objects and assign them to |
|
200 | - * the $_qtips property |
|
201 | - * |
|
202 | - * @access protected |
|
203 | - * @return void |
|
204 | - */ |
|
205 | - protected function _construct_tips() |
|
206 | - { |
|
207 | - foreach ($this->_qtipsa as $qt) { |
|
208 | - // make sure we have what we need. |
|
209 | - if (! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) { |
|
210 | - throw new EE_Error( |
|
211 | - sprintf( |
|
212 | - esc_html__( |
|
213 | - 'There is something wrong with the _qtipsa property setup for the %s qtip config class. The dump of the current array index is: %s.<br /><br />Please check that it is setup correctly.', |
|
214 | - 'event_espresso' |
|
215 | - ), |
|
216 | - get_class($this), |
|
217 | - var_export($qt, true) |
|
218 | - ) |
|
219 | - ); |
|
220 | - } |
|
198 | + /** |
|
199 | + * This takes the set $_qtipsa array property and loops through it to set the EE_Qtip objects and assign them to |
|
200 | + * the $_qtips property |
|
201 | + * |
|
202 | + * @access protected |
|
203 | + * @return void |
|
204 | + */ |
|
205 | + protected function _construct_tips() |
|
206 | + { |
|
207 | + foreach ($this->_qtipsa as $qt) { |
|
208 | + // make sure we have what we need. |
|
209 | + if (! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) { |
|
210 | + throw new EE_Error( |
|
211 | + sprintf( |
|
212 | + esc_html__( |
|
213 | + 'There is something wrong with the _qtipsa property setup for the %s qtip config class. The dump of the current array index is: %s.<br /><br />Please check that it is setup correctly.', |
|
214 | + 'event_espresso' |
|
215 | + ), |
|
216 | + get_class($this), |
|
217 | + var_export($qt, true) |
|
218 | + ) |
|
219 | + ); |
|
220 | + } |
|
221 | 221 | |
222 | - // make sure the options include defaults and just override via set config. |
|
223 | - $options_override = isset($qt['options']) ? (array) $qt['options'] : array(); |
|
224 | - $options = array_merge($this->_default_options, $options_override); |
|
225 | - $setup = array( |
|
226 | - 'content_id' => $qt['content_id'], |
|
227 | - 'options' => $options, |
|
228 | - 'target' => $qt['target'], |
|
229 | - 'content' => $qt['content'], |
|
230 | - ); |
|
231 | - $this->_qtips[] = new EE_Qtip($setup); |
|
232 | - } |
|
233 | - } |
|
222 | + // make sure the options include defaults and just override via set config. |
|
223 | + $options_override = isset($qt['options']) ? (array) $qt['options'] : array(); |
|
224 | + $options = array_merge($this->_default_options, $options_override); |
|
225 | + $setup = array( |
|
226 | + 'content_id' => $qt['content_id'], |
|
227 | + 'options' => $options, |
|
228 | + 'target' => $qt['target'], |
|
229 | + 'content' => $qt['content'], |
|
230 | + ); |
|
231 | + $this->_qtips[] = new EE_Qtip($setup); |
|
232 | + } |
|
233 | + } |
|
234 | 234 | |
235 | 235 | |
236 | - /** |
|
237 | - * return the _qtips property contents |
|
238 | - * |
|
239 | - * @access public |
|
240 | - * @return EE_Qtip[] |
|
241 | - */ |
|
242 | - public function get_tips() |
|
243 | - { |
|
244 | - return $this->_qtips; |
|
245 | - } |
|
236 | + /** |
|
237 | + * return the _qtips property contents |
|
238 | + * |
|
239 | + * @access public |
|
240 | + * @return EE_Qtip[] |
|
241 | + */ |
|
242 | + public function get_tips() |
|
243 | + { |
|
244 | + return $this->_qtips; |
|
245 | + } |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | // class names you can use for tooltip styles |
@@ -294,17 +294,17 @@ discard block |
||
294 | 294 | */ |
295 | 295 | class EE_Qtip extends EE_Base |
296 | 296 | { |
297 | - public $content_id; |
|
298 | - public $options; |
|
299 | - public $target; |
|
300 | - public $content; |
|
297 | + public $content_id; |
|
298 | + public $options; |
|
299 | + public $target; |
|
300 | + public $content; |
|
301 | 301 | |
302 | - public function __construct($setup_array) |
|
303 | - { |
|
304 | - foreach ($setup_array as $prop => $value) { |
|
305 | - if (EEH_Class_Tools::has_property($this, $prop)) { |
|
306 | - $this->{$prop} = $value; |
|
307 | - } |
|
308 | - } |
|
309 | - } |
|
302 | + public function __construct($setup_array) |
|
303 | + { |
|
304 | + foreach ($setup_array as $prop => $value) { |
|
305 | + if (EEH_Class_Tools::has_property($this, $prop)) { |
|
306 | + $this->{$prop} = $value; |
|
307 | + } |
|
308 | + } |
|
309 | + } |
|
310 | 310 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function __construct() |
73 | 73 | { |
74 | - if (! $this->_model_name_extended) { |
|
74 | + if ( ! $this->_model_name_extended) { |
|
75 | 75 | throw new EE_Error( |
76 | 76 | esc_html__( |
77 | 77 | "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ) |
80 | 80 | ); |
81 | 81 | } |
82 | - $construct_end_action = 'AHEE__EEM_' . $this->_model_name_extended . '__construct__end'; |
|
82 | + $construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end'; |
|
83 | 83 | if (did_action($construct_end_action)) { |
84 | 84 | throw new EE_Error( |
85 | 85 | sprintf( |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | ); |
95 | 95 | } |
96 | 96 | add_filter( |
97 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables', |
|
97 | + 'FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', |
|
98 | 98 | array($this, 'add_extra_tables_on_filter') |
99 | 99 | ); |
100 | 100 | add_filter( |
101 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields', |
|
101 | + 'FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', |
|
102 | 102 | array($this, 'add_extra_fields_on_filter') |
103 | 103 | ); |
104 | 104 | add_filter( |
105 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations', |
|
105 | + 'FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', |
|
106 | 106 | array($this, 'add_extra_relations_on_filter') |
107 | 107 | ); |
108 | 108 | $this->_register_extending_methods(); |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | { |
128 | 128 | if ($this->_extra_fields) { |
129 | 129 | foreach ($this->_extra_fields as $table_alias => $fields) { |
130 | - if (! isset($existing_fields[ $table_alias ])) { |
|
131 | - $existing_fields[ $table_alias ] = array(); |
|
130 | + if ( ! isset($existing_fields[$table_alias])) { |
|
131 | + $existing_fields[$table_alias] = array(); |
|
132 | 132 | } |
133 | - $existing_fields[ $table_alias ] = array_merge( |
|
134 | - (array) $existing_fields[ $table_alias ], |
|
135 | - $this->_extra_fields[ $table_alias ] |
|
133 | + $existing_fields[$table_alias] = array_merge( |
|
134 | + (array) $existing_fields[$table_alias], |
|
135 | + $this->_extra_fields[$table_alias] |
|
136 | 136 | ); |
137 | 137 | } |
138 | 138 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
164 | 164 | add_filter( |
165 | 165 | $callback_name, |
166 | - array($this, self::dynamic_callback_method_prefix . $method_name_on_model), |
|
166 | + array($this, self::dynamic_callback_method_prefix.$method_name_on_model), |
|
167 | 167 | 10, |
168 | 168 | 10 |
169 | 169 | ); |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | public function deregister() |
179 | 179 | { |
180 | 180 | remove_filter( |
181 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables', |
|
181 | + 'FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', |
|
182 | 182 | array($this, 'add_extra_tables_on_filter') |
183 | 183 | ); |
184 | 184 | remove_filter( |
185 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields', |
|
185 | + 'FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', |
|
186 | 186 | array($this, 'add_extra_fields_on_filter') |
187 | 187 | ); |
188 | 188 | remove_filter( |
189 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations', |
|
189 | + 'FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', |
|
190 | 190 | array($this, 'add_extra_relations_on_filter') |
191 | 191 | ); |
192 | 192 | $all_methods = get_class_methods(get_class($this)); |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
197 | 197 | remove_filter( |
198 | 198 | $callback_name, |
199 | - array($this, self::dynamic_callback_method_prefix . $method_name_on_model), |
|
199 | + array($this, self::dynamic_callback_method_prefix.$method_name_on_model), |
|
200 | 200 | 10 |
201 | 201 | ); |
202 | 202 | } |
203 | 203 | } |
204 | 204 | /** @var EEM_Base $model_to_reset */ |
205 | - $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
205 | + $model_to_reset = 'EEM_'.$this->_model_name_extended; |
|
206 | 206 | if (class_exists($model_to_reset)) { |
207 | 207 | $model_to_reset::reset(); |
208 | 208 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | // phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction |
225 | 225 | $this->_ = $model_called; |
226 | 226 | // phpcs:enable |
227 | - $extending_method = self::extending_method_prefix . $method_called_on_model; |
|
227 | + $extending_method = self::extending_method_prefix.$method_called_on_model; |
|
228 | 228 | if (method_exists($this, $extending_method)) { |
229 | 229 | return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model); |
230 | 230 | } else { |
@@ -43,211 +43,211 @@ |
||
43 | 43 | */ |
44 | 44 | abstract class EEME_Base |
45 | 45 | { |
46 | - const extending_method_prefix = 'ext_'; |
|
47 | - const dynamic_callback_method_prefix = 'dynamic_callback_method_'; |
|
48 | - |
|
49 | - protected $_extra_tables = array(); |
|
50 | - protected $_extra_fields = array(); |
|
51 | - protected $_extra_relations = array(); |
|
52 | - |
|
53 | - /** |
|
54 | - * The model name that is extended (not classname) |
|
55 | - * |
|
56 | - * @var string |
|
57 | - */ |
|
58 | - protected $_model_name_extended = null; |
|
59 | - |
|
60 | - /** |
|
61 | - * The model this extends |
|
62 | - * |
|
63 | - * @var EEM_Base |
|
64 | - */ |
|
65 | - protected $_ = null; |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * @throws \EE_Error |
|
70 | - */ |
|
71 | - public function __construct() |
|
72 | - { |
|
73 | - if (! $this->_model_name_extended) { |
|
74 | - throw new EE_Error( |
|
75 | - esc_html__( |
|
76 | - "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
77 | - "event_espresso" |
|
78 | - ) |
|
79 | - ); |
|
80 | - } |
|
81 | - $construct_end_action = 'AHEE__EEM_' . $this->_model_name_extended . '__construct__end'; |
|
82 | - if (did_action($construct_end_action)) { |
|
83 | - throw new EE_Error( |
|
84 | - sprintf( |
|
85 | - esc_html__( |
|
86 | - "Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", |
|
87 | - "event_espresso" |
|
88 | - ), |
|
89 | - get_class($this), |
|
90 | - $this->_model_name_extended, |
|
91 | - $construct_end_action |
|
92 | - ) |
|
93 | - ); |
|
94 | - } |
|
95 | - add_filter( |
|
96 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables', |
|
97 | - array($this, 'add_extra_tables_on_filter') |
|
98 | - ); |
|
99 | - add_filter( |
|
100 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields', |
|
101 | - array($this, 'add_extra_fields_on_filter') |
|
102 | - ); |
|
103 | - add_filter( |
|
104 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations', |
|
105 | - array($this, 'add_extra_relations_on_filter') |
|
106 | - ); |
|
107 | - $this->_register_extending_methods(); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @param array $existing_tables |
|
113 | - * @return array |
|
114 | - */ |
|
115 | - public function add_extra_tables_on_filter($existing_tables) |
|
116 | - { |
|
117 | - return array_merge((array) $existing_tables, $this->_extra_tables); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * @param array $existing_fields |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function add_extra_fields_on_filter($existing_fields) |
|
126 | - { |
|
127 | - if ($this->_extra_fields) { |
|
128 | - foreach ($this->_extra_fields as $table_alias => $fields) { |
|
129 | - if (! isset($existing_fields[ $table_alias ])) { |
|
130 | - $existing_fields[ $table_alias ] = array(); |
|
131 | - } |
|
132 | - $existing_fields[ $table_alias ] = array_merge( |
|
133 | - (array) $existing_fields[ $table_alias ], |
|
134 | - $this->_extra_fields[ $table_alias ] |
|
135 | - ); |
|
136 | - } |
|
137 | - } |
|
138 | - return $existing_fields; |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @param array $existing_relations |
|
144 | - * @return array |
|
145 | - */ |
|
146 | - public function add_extra_relations_on_filter($existing_relations) |
|
147 | - { |
|
148 | - return array_merge((array) $existing_relations, $this->_extra_relations); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the |
|
154 | - * model extended. (Internally uses filters, and the __call magic method) |
|
155 | - */ |
|
156 | - protected function _register_extending_methods() |
|
157 | - { |
|
158 | - $all_methods = get_class_methods(get_class($this)); |
|
159 | - foreach ($all_methods as $method_name) { |
|
160 | - if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
161 | - $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
|
162 | - $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
|
163 | - add_filter( |
|
164 | - $callback_name, |
|
165 | - array($this, self::dynamic_callback_method_prefix . $method_name_on_model), |
|
166 | - 10, |
|
167 | - 10 |
|
168 | - ); |
|
169 | - } |
|
170 | - } |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the |
|
175 | - * model extended. (Internally uses filters, and the __call magic method) |
|
176 | - */ |
|
177 | - public function deregister() |
|
178 | - { |
|
179 | - remove_filter( |
|
180 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables', |
|
181 | - array($this, 'add_extra_tables_on_filter') |
|
182 | - ); |
|
183 | - remove_filter( |
|
184 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields', |
|
185 | - array($this, 'add_extra_fields_on_filter') |
|
186 | - ); |
|
187 | - remove_filter( |
|
188 | - 'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations', |
|
189 | - array($this, 'add_extra_relations_on_filter') |
|
190 | - ); |
|
191 | - $all_methods = get_class_methods(get_class($this)); |
|
192 | - foreach ($all_methods as $method_name) { |
|
193 | - if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
194 | - $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
|
195 | - $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
|
196 | - remove_filter( |
|
197 | - $callback_name, |
|
198 | - array($this, self::dynamic_callback_method_prefix . $method_name_on_model), |
|
199 | - 10 |
|
200 | - ); |
|
201 | - } |
|
202 | - } |
|
203 | - /** @var EEM_Base $model_to_reset */ |
|
204 | - $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
205 | - if (class_exists($model_to_reset)) { |
|
206 | - $model_to_reset::reset(); |
|
207 | - } |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * @param string $callback_method_name |
|
213 | - * @param array $args |
|
214 | - * @return mixed |
|
215 | - * @throws EE_Error |
|
216 | - */ |
|
217 | - public function __call($callback_method_name, $args) |
|
218 | - { |
|
219 | - if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) { |
|
220 | - // it's a dynamic callback for a method name |
|
221 | - $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name); |
|
222 | - list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args; |
|
223 | - // phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction |
|
224 | - $this->_ = $model_called; |
|
225 | - // phpcs:enable |
|
226 | - $extending_method = self::extending_method_prefix . $method_called_on_model; |
|
227 | - if (method_exists($this, $extending_method)) { |
|
228 | - return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model); |
|
229 | - } else { |
|
230 | - throw new EE_Error( |
|
231 | - sprintf( |
|
232 | - esc_html__( |
|
233 | - "An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", |
|
234 | - "event_espresso" |
|
235 | - ), |
|
236 | - $this->_model_name_extended, |
|
237 | - get_class($this), |
|
238 | - $extending_method, |
|
239 | - $extending_method |
|
240 | - ) |
|
241 | - ); |
|
242 | - } |
|
243 | - } else { |
|
244 | - throw new EE_Error( |
|
245 | - sprintf( |
|
246 | - esc_html__("There is no method named '%s' on '%s'", "event_espresso"), |
|
247 | - $callback_method_name, |
|
248 | - get_class($this) |
|
249 | - ) |
|
250 | - ); |
|
251 | - } |
|
252 | - } |
|
46 | + const extending_method_prefix = 'ext_'; |
|
47 | + const dynamic_callback_method_prefix = 'dynamic_callback_method_'; |
|
48 | + |
|
49 | + protected $_extra_tables = array(); |
|
50 | + protected $_extra_fields = array(); |
|
51 | + protected $_extra_relations = array(); |
|
52 | + |
|
53 | + /** |
|
54 | + * The model name that is extended (not classname) |
|
55 | + * |
|
56 | + * @var string |
|
57 | + */ |
|
58 | + protected $_model_name_extended = null; |
|
59 | + |
|
60 | + /** |
|
61 | + * The model this extends |
|
62 | + * |
|
63 | + * @var EEM_Base |
|
64 | + */ |
|
65 | + protected $_ = null; |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * @throws \EE_Error |
|
70 | + */ |
|
71 | + public function __construct() |
|
72 | + { |
|
73 | + if (! $this->_model_name_extended) { |
|
74 | + throw new EE_Error( |
|
75 | + esc_html__( |
|
76 | + "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
77 | + "event_espresso" |
|
78 | + ) |
|
79 | + ); |
|
80 | + } |
|
81 | + $construct_end_action = 'AHEE__EEM_' . $this->_model_name_extended . '__construct__end'; |
|
82 | + if (did_action($construct_end_action)) { |
|
83 | + throw new EE_Error( |
|
84 | + sprintf( |
|
85 | + esc_html__( |
|
86 | + "Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", |
|
87 | + "event_espresso" |
|
88 | + ), |
|
89 | + get_class($this), |
|
90 | + $this->_model_name_extended, |
|
91 | + $construct_end_action |
|
92 | + ) |
|
93 | + ); |
|
94 | + } |
|
95 | + add_filter( |
|
96 | + 'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables', |
|
97 | + array($this, 'add_extra_tables_on_filter') |
|
98 | + ); |
|
99 | + add_filter( |
|
100 | + 'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields', |
|
101 | + array($this, 'add_extra_fields_on_filter') |
|
102 | + ); |
|
103 | + add_filter( |
|
104 | + 'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations', |
|
105 | + array($this, 'add_extra_relations_on_filter') |
|
106 | + ); |
|
107 | + $this->_register_extending_methods(); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @param array $existing_tables |
|
113 | + * @return array |
|
114 | + */ |
|
115 | + public function add_extra_tables_on_filter($existing_tables) |
|
116 | + { |
|
117 | + return array_merge((array) $existing_tables, $this->_extra_tables); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * @param array $existing_fields |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function add_extra_fields_on_filter($existing_fields) |
|
126 | + { |
|
127 | + if ($this->_extra_fields) { |
|
128 | + foreach ($this->_extra_fields as $table_alias => $fields) { |
|
129 | + if (! isset($existing_fields[ $table_alias ])) { |
|
130 | + $existing_fields[ $table_alias ] = array(); |
|
131 | + } |
|
132 | + $existing_fields[ $table_alias ] = array_merge( |
|
133 | + (array) $existing_fields[ $table_alias ], |
|
134 | + $this->_extra_fields[ $table_alias ] |
|
135 | + ); |
|
136 | + } |
|
137 | + } |
|
138 | + return $existing_fields; |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @param array $existing_relations |
|
144 | + * @return array |
|
145 | + */ |
|
146 | + public function add_extra_relations_on_filter($existing_relations) |
|
147 | + { |
|
148 | + return array_merge((array) $existing_relations, $this->_extra_relations); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the |
|
154 | + * model extended. (Internally uses filters, and the __call magic method) |
|
155 | + */ |
|
156 | + protected function _register_extending_methods() |
|
157 | + { |
|
158 | + $all_methods = get_class_methods(get_class($this)); |
|
159 | + foreach ($all_methods as $method_name) { |
|
160 | + if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
161 | + $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
|
162 | + $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
|
163 | + add_filter( |
|
164 | + $callback_name, |
|
165 | + array($this, self::dynamic_callback_method_prefix . $method_name_on_model), |
|
166 | + 10, |
|
167 | + 10 |
|
168 | + ); |
|
169 | + } |
|
170 | + } |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the |
|
175 | + * model extended. (Internally uses filters, and the __call magic method) |
|
176 | + */ |
|
177 | + public function deregister() |
|
178 | + { |
|
179 | + remove_filter( |
|
180 | + 'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables', |
|
181 | + array($this, 'add_extra_tables_on_filter') |
|
182 | + ); |
|
183 | + remove_filter( |
|
184 | + 'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields', |
|
185 | + array($this, 'add_extra_fields_on_filter') |
|
186 | + ); |
|
187 | + remove_filter( |
|
188 | + 'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations', |
|
189 | + array($this, 'add_extra_relations_on_filter') |
|
190 | + ); |
|
191 | + $all_methods = get_class_methods(get_class($this)); |
|
192 | + foreach ($all_methods as $method_name) { |
|
193 | + if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
194 | + $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
|
195 | + $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
|
196 | + remove_filter( |
|
197 | + $callback_name, |
|
198 | + array($this, self::dynamic_callback_method_prefix . $method_name_on_model), |
|
199 | + 10 |
|
200 | + ); |
|
201 | + } |
|
202 | + } |
|
203 | + /** @var EEM_Base $model_to_reset */ |
|
204 | + $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
205 | + if (class_exists($model_to_reset)) { |
|
206 | + $model_to_reset::reset(); |
|
207 | + } |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * @param string $callback_method_name |
|
213 | + * @param array $args |
|
214 | + * @return mixed |
|
215 | + * @throws EE_Error |
|
216 | + */ |
|
217 | + public function __call($callback_method_name, $args) |
|
218 | + { |
|
219 | + if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) { |
|
220 | + // it's a dynamic callback for a method name |
|
221 | + $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name); |
|
222 | + list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args; |
|
223 | + // phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction |
|
224 | + $this->_ = $model_called; |
|
225 | + // phpcs:enable |
|
226 | + $extending_method = self::extending_method_prefix . $method_called_on_model; |
|
227 | + if (method_exists($this, $extending_method)) { |
|
228 | + return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model); |
|
229 | + } else { |
|
230 | + throw new EE_Error( |
|
231 | + sprintf( |
|
232 | + esc_html__( |
|
233 | + "An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", |
|
234 | + "event_espresso" |
|
235 | + ), |
|
236 | + $this->_model_name_extended, |
|
237 | + get_class($this), |
|
238 | + $extending_method, |
|
239 | + $extending_method |
|
240 | + ) |
|
241 | + ); |
|
242 | + } |
|
243 | + } else { |
|
244 | + throw new EE_Error( |
|
245 | + sprintf( |
|
246 | + esc_html__("There is no method named '%s' on '%s'", "event_espresso"), |
|
247 | + $callback_method_name, |
|
248 | + get_class($this) |
|
249 | + ) |
|
250 | + ); |
|
251 | + } |
|
252 | + } |
|
253 | 253 | } |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | 'Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults. Attributes that are available are:', |
30 | 30 | 'event_espresso' |
31 | 31 | ) |
32 | - . '<p><ul>' . |
|
33 | - '<li><strong>no_payments</strong>:' . sprintf( |
|
32 | + . '<p><ul>'. |
|
33 | + '<li><strong>no_payments</strong>:'.sprintf( |
|
34 | 34 | esc_html__( |
35 | 35 | 'Indicate with this attribute what will be used if there are no payments present. Default is: "%sNo approved payments have been received.%s"', |
36 | 36 | 'event_espresso' |
37 | 37 | ), |
38 | 38 | htmlspecialchars('<td class="aln-cntr" colspan="6">'), |
39 | 39 | htmlspecialchars('</td>') |
40 | - ) . '</li>' . |
|
40 | + ).'</li>'. |
|
41 | 41 | '</ul></p>', |
42 | 42 | ); |
43 | 43 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->_validate_list_requirements(); |
68 | 68 | |
69 | 69 | |
70 | - if (! $this->_data['data'] instanceof EE_Messages_Addressee) { |
|
70 | + if ( ! $this->_data['data'] instanceof EE_Messages_Addressee) { |
|
71 | 71 | return ''; |
72 | 72 | } |
73 | 73 |
@@ -18,87 +18,87 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Payment_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - protected function _init_props() |
|
22 | - { |
|
23 | - $this->label = esc_html__('Payment List Shortcodes', 'event_espresso'); |
|
24 | - $this->description = esc_html__('All shortcodes specific to payment lists', 'event_espresso'); |
|
25 | - $this->_shortcodes = array( |
|
26 | - '[PAYMENT_LIST_*]' => esc_html__( |
|
27 | - 'Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults. Attributes that are available are:', |
|
28 | - 'event_espresso' |
|
29 | - ) |
|
30 | - . '<p><ul>' . |
|
31 | - '<li><strong>no_payments</strong>:' . sprintf( |
|
32 | - esc_html__( |
|
33 | - 'Indicate with this attribute what will be used if there are no payments present. Default is: "%sNo approved payments have been received.%s"', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - htmlspecialchars('<td class="aln-cntr" colspan="6">'), |
|
37 | - htmlspecialchars('</td>') |
|
38 | - ) . '</li>' . |
|
39 | - '</ul></p>', |
|
40 | - ); |
|
41 | - } |
|
21 | + protected function _init_props() |
|
22 | + { |
|
23 | + $this->label = esc_html__('Payment List Shortcodes', 'event_espresso'); |
|
24 | + $this->description = esc_html__('All shortcodes specific to payment lists', 'event_espresso'); |
|
25 | + $this->_shortcodes = array( |
|
26 | + '[PAYMENT_LIST_*]' => esc_html__( |
|
27 | + 'Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults. Attributes that are available are:', |
|
28 | + 'event_espresso' |
|
29 | + ) |
|
30 | + . '<p><ul>' . |
|
31 | + '<li><strong>no_payments</strong>:' . sprintf( |
|
32 | + esc_html__( |
|
33 | + 'Indicate with this attribute what will be used if there are no payments present. Default is: "%sNo approved payments have been received.%s"', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + htmlspecialchars('<td class="aln-cntr" colspan="6">'), |
|
37 | + htmlspecialchars('</td>') |
|
38 | + ) . '</li>' . |
|
39 | + '</ul></p>', |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - protected function _parser($shortcode) |
|
45 | - { |
|
46 | - if (strpos($shortcode, '[PAYMENT_LIST_*') !== false) { |
|
47 | - return $this->_get_payment_list($shortcode); |
|
48 | - } |
|
49 | - return ''; |
|
50 | - } |
|
44 | + protected function _parser($shortcode) |
|
45 | + { |
|
46 | + if (strpos($shortcode, '[PAYMENT_LIST_*') !== false) { |
|
47 | + return $this->_get_payment_list($shortcode); |
|
48 | + } |
|
49 | + return ''; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * verify incoming data contains what is needed for retrieving and parsing each payment for transaction. |
|
55 | - * |
|
56 | - * @since 4.5.0 |
|
57 | - * |
|
58 | - * @param string $shortcode The incoming shortcode. |
|
59 | - * |
|
60 | - * @return string parsed ticket line item list. |
|
61 | - */ |
|
62 | - private function _get_payment_list($shortcode) |
|
63 | - { |
|
64 | - $this->_validate_list_requirements(); |
|
53 | + /** |
|
54 | + * verify incoming data contains what is needed for retrieving and parsing each payment for transaction. |
|
55 | + * |
|
56 | + * @since 4.5.0 |
|
57 | + * |
|
58 | + * @param string $shortcode The incoming shortcode. |
|
59 | + * |
|
60 | + * @return string parsed ticket line item list. |
|
61 | + */ |
|
62 | + private function _get_payment_list($shortcode) |
|
63 | + { |
|
64 | + $this->_validate_list_requirements(); |
|
65 | 65 | |
66 | 66 | |
67 | - if (! $this->_data['data'] instanceof EE_Messages_Addressee) { |
|
68 | - return ''; |
|
69 | - } |
|
67 | + if (! $this->_data['data'] instanceof EE_Messages_Addressee) { |
|
68 | + return ''; |
|
69 | + } |
|
70 | 70 | |
71 | - $valid_shortcodes = array('payment'); |
|
71 | + $valid_shortcodes = array('payment'); |
|
72 | 72 | |
73 | - $addressee_obj = $this->_data['data']; |
|
74 | - $templates = $this->_extra_data['template']; |
|
75 | - $payments = apply_filters( |
|
76 | - 'FHEE__Payment_List_Shortcodes___get_payments_list__payments', |
|
77 | - $addressee_obj->payments |
|
78 | - ); |
|
73 | + $addressee_obj = $this->_data['data']; |
|
74 | + $templates = $this->_extra_data['template']; |
|
75 | + $payments = apply_filters( |
|
76 | + 'FHEE__Payment_List_Shortcodes___get_payments_list__payments', |
|
77 | + $addressee_obj->payments |
|
78 | + ); |
|
79 | 79 | |
80 | - // let's get any attributes that may be present and set the defaults. |
|
81 | - $atts = $this->_get_shortcode_attrs($shortcode); |
|
80 | + // let's get any attributes that may be present and set the defaults. |
|
81 | + $atts = $this->_get_shortcode_attrs($shortcode); |
|
82 | 82 | |
83 | - $no_payments_msg = empty($atts['no_payments']) ? esc_html__( |
|
84 | - 'No approved payments have been received.', |
|
85 | - 'event_espresso' |
|
86 | - ) : $atts['no_payments']; |
|
83 | + $no_payments_msg = empty($atts['no_payments']) ? esc_html__( |
|
84 | + 'No approved payments have been received.', |
|
85 | + 'event_espresso' |
|
86 | + ) : $atts['no_payments']; |
|
87 | 87 | |
88 | - // made it here so we have an array of paymnets, so we should have what we need. |
|
89 | - $payment_content = empty($payments) ? $no_payments_msg : ''; |
|
88 | + // made it here so we have an array of paymnets, so we should have what we need. |
|
89 | + $payment_content = empty($payments) ? $no_payments_msg : ''; |
|
90 | 90 | |
91 | - $payments = (array) $payments; |
|
91 | + $payments = (array) $payments; |
|
92 | 92 | |
93 | - foreach ($payments as $payment) { |
|
94 | - $payment_content .= $this->_shortcode_helper->parse_payment_list_template( |
|
95 | - $templates['payment_list'], |
|
96 | - $payment, |
|
97 | - $valid_shortcodes, |
|
98 | - $this->_extra_data |
|
99 | - ); |
|
100 | - } |
|
93 | + foreach ($payments as $payment) { |
|
94 | + $payment_content .= $this->_shortcode_helper->parse_payment_list_template( |
|
95 | + $templates['payment_list'], |
|
96 | + $payment, |
|
97 | + $valid_shortcodes, |
|
98 | + $this->_extra_data |
|
99 | + ); |
|
100 | + } |
|
101 | 101 | |
102 | - return $payment_content; |
|
103 | - } |
|
102 | + return $payment_content; |
|
103 | + } |
|
104 | 104 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function getModelVersionInfo() |
52 | 52 | { |
53 | - if (! $this->model_version_info) { |
|
53 | + if ( ! $this->model_version_info) { |
|
54 | 54 | throw new EE_Error( |
55 | 55 | sprintf( |
56 | 56 | esc_html__( |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function validateModel($model_name) |
97 | 97 | { |
98 | - if (! $this->getModelVersionInfo()->isModelNameInThisVersion($model_name)) { |
|
98 | + if ( ! $this->getModelVersionInfo()->isModelNameInThisVersion($model_name)) { |
|
99 | 99 | throw new RestException( |
100 | 100 | 'endpoint_parsing_error', |
101 | 101 | sprintf( |
@@ -18,95 +18,95 @@ |
||
18 | 18 | */ |
19 | 19 | class Base extends Controller_Base |
20 | 20 | { |
21 | - /** |
|
22 | - * Holds reference to the model version info, which knows the requested version |
|
23 | - * |
|
24 | - * @var ModelVersionInfo |
|
25 | - */ |
|
26 | - protected $model_version_info; |
|
21 | + /** |
|
22 | + * Holds reference to the model version info, which knows the requested version |
|
23 | + * |
|
24 | + * @var ModelVersionInfo |
|
25 | + */ |
|
26 | + protected $model_version_info; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * Sets the version the user requested |
|
32 | - * |
|
33 | - * @param string $version eg '4.8' |
|
34 | - */ |
|
35 | - public function setRequestedVersion(string $version) |
|
36 | - { |
|
37 | - parent::setRequestedVersion($version); |
|
38 | - $this->model_version_info = new ModelVersionInfo($version); |
|
39 | - } |
|
30 | + /** |
|
31 | + * Sets the version the user requested |
|
32 | + * |
|
33 | + * @param string $version eg '4.8' |
|
34 | + */ |
|
35 | + public function setRequestedVersion(string $version) |
|
36 | + { |
|
37 | + parent::setRequestedVersion($version); |
|
38 | + $this->model_version_info = new ModelVersionInfo($version); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * Gets the object that should be used for getting any info from the models, |
|
45 | - * because it's takes the requested and current core version into account |
|
46 | - * |
|
47 | - * @return ModelVersionInfo |
|
48 | - * @throws EE_Error |
|
49 | - */ |
|
50 | - public function getModelVersionInfo() |
|
51 | - { |
|
52 | - if (! $this->model_version_info) { |
|
53 | - throw new EE_Error( |
|
54 | - sprintf( |
|
55 | - esc_html__( |
|
56 | - 'Cannot use model version info before setting the requested version in the controller', |
|
57 | - 'event_espresso' |
|
58 | - ) |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
62 | - return $this->model_version_info; |
|
63 | - } |
|
43 | + /** |
|
44 | + * Gets the object that should be used for getting any info from the models, |
|
45 | + * because it's takes the requested and current core version into account |
|
46 | + * |
|
47 | + * @return ModelVersionInfo |
|
48 | + * @throws EE_Error |
|
49 | + */ |
|
50 | + public function getModelVersionInfo() |
|
51 | + { |
|
52 | + if (! $this->model_version_info) { |
|
53 | + throw new EE_Error( |
|
54 | + sprintf( |
|
55 | + esc_html__( |
|
56 | + 'Cannot use model version info before setting the requested version in the controller', |
|
57 | + 'event_espresso' |
|
58 | + ) |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | + return $this->model_version_info; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * Determines if $object is of one of the classes of $classes. Similar to |
|
69 | - * in_array(), except this checks if $object is a subclass of the classnames provided |
|
70 | - * in $classnames |
|
71 | - * |
|
72 | - * @param object $object |
|
73 | - * @param array $classnames |
|
74 | - * @return boolean |
|
75 | - */ |
|
76 | - public function isSubclassOfOne($object, $classnames) |
|
77 | - { |
|
78 | - foreach ($classnames as $classname) { |
|
79 | - if (is_a($object, $classname)) { |
|
80 | - return true; |
|
81 | - } |
|
82 | - } |
|
83 | - return false; |
|
84 | - } |
|
67 | + /** |
|
68 | + * Determines if $object is of one of the classes of $classes. Similar to |
|
69 | + * in_array(), except this checks if $object is a subclass of the classnames provided |
|
70 | + * in $classnames |
|
71 | + * |
|
72 | + * @param object $object |
|
73 | + * @param array $classnames |
|
74 | + * @return boolean |
|
75 | + */ |
|
76 | + public function isSubclassOfOne($object, $classnames) |
|
77 | + { |
|
78 | + foreach ($classnames as $classname) { |
|
79 | + if (is_a($object, $classname)) { |
|
80 | + return true; |
|
81 | + } |
|
82 | + } |
|
83 | + return false; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Verifies the model name provided was valid. If so, returns the model (as an object). Otherwise, throws an |
|
88 | - * exception. Must be called after `setRequestedVersion()`. |
|
89 | - * @since 4.9.76.p |
|
90 | - * @param $model_name |
|
91 | - * @return EEM_Base |
|
92 | - * @throws EE_Error |
|
93 | - * @throws RestException |
|
94 | - */ |
|
95 | - protected function validateModel($model_name) |
|
96 | - { |
|
97 | - if (! $this->getModelVersionInfo()->isModelNameInThisVersion($model_name)) { |
|
98 | - throw new RestException( |
|
99 | - 'endpoint_parsing_error', |
|
100 | - sprintf( |
|
101 | - esc_html__( |
|
102 | - 'There is no model for endpoint %s. Please contact event espresso support', |
|
103 | - 'event_espresso' |
|
104 | - ), |
|
105 | - $model_name |
|
106 | - ) |
|
107 | - ); |
|
108 | - } |
|
109 | - return $this->getModelVersionInfo()->loadModel($model_name); |
|
110 | - } |
|
86 | + /** |
|
87 | + * Verifies the model name provided was valid. If so, returns the model (as an object). Otherwise, throws an |
|
88 | + * exception. Must be called after `setRequestedVersion()`. |
|
89 | + * @since 4.9.76.p |
|
90 | + * @param $model_name |
|
91 | + * @return EEM_Base |
|
92 | + * @throws EE_Error |
|
93 | + * @throws RestException |
|
94 | + */ |
|
95 | + protected function validateModel($model_name) |
|
96 | + { |
|
97 | + if (! $this->getModelVersionInfo()->isModelNameInThisVersion($model_name)) { |
|
98 | + throw new RestException( |
|
99 | + 'endpoint_parsing_error', |
|
100 | + sprintf( |
|
101 | + esc_html__( |
|
102 | + 'There is no model for endpoint %s. Please contact event espresso support', |
|
103 | + 'event_espresso' |
|
104 | + ), |
|
105 | + $model_name |
|
106 | + ) |
|
107 | + ); |
|
108 | + } |
|
109 | + return $this->getModelVersionInfo()->loadModel($model_name); |
|
110 | + } |
|
111 | 111 | } |
112 | 112 | // End of file Base.php |
@@ -37,74 +37,74 @@ |
||
37 | 37 | abstract class ChangesInBase |
38 | 38 | { |
39 | 39 | |
40 | - /** |
|
41 | - * The version that these changes happened |
|
42 | - * |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - protected $version = null; |
|
40 | + /** |
|
41 | + * The version that these changes happened |
|
42 | + * |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + protected $version = null; |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Called when an EE4 REST API request is made to an earlier version than |
|
50 | - * what is indicated in this class' name. |
|
51 | - * Uses WordPress' add_filter and add_action to modify the EE4 REST API's response |
|
52 | - * so that regardless of what version of EE4 core is running, API clients |
|
53 | - * will have a consistent response |
|
54 | - * |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - abstract public function setHooks(); |
|
48 | + /** |
|
49 | + * Called when an EE4 REST API request is made to an earlier version than |
|
50 | + * what is indicated in this class' name. |
|
51 | + * Uses WordPress' add_filter and add_action to modify the EE4 REST API's response |
|
52 | + * so that regardless of what version of EE4 core is running, API clients |
|
53 | + * will have a consistent response |
|
54 | + * |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + abstract public function setHooks(); |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Returns whether or not this class' name indicates its hooks should |
|
62 | - * apply when a request comes in for $requested_version. A class can use |
|
63 | - * other conditions when determining whether to perform their callbacks or not, |
|
64 | - * but this will typically be enough |
|
65 | - * |
|
66 | - * @param string $requested_version eg "4.8.33" |
|
67 | - * @return boolean true: this class' name indicates its filters and actions |
|
68 | - * should take effect. False: this class' name indicates it shouldn't do anything |
|
69 | - */ |
|
70 | - public function appliesToVersion($requested_version) |
|
71 | - { |
|
72 | - if ($this->version() > $requested_version) { |
|
73 | - return true; |
|
74 | - } |
|
75 | - return false; |
|
76 | - } |
|
60 | + /** |
|
61 | + * Returns whether or not this class' name indicates its hooks should |
|
62 | + * apply when a request comes in for $requested_version. A class can use |
|
63 | + * other conditions when determining whether to perform their callbacks or not, |
|
64 | + * but this will typically be enough |
|
65 | + * |
|
66 | + * @param string $requested_version eg "4.8.33" |
|
67 | + * @return boolean true: this class' name indicates its filters and actions |
|
68 | + * should take effect. False: this class' name indicates it shouldn't do anything |
|
69 | + */ |
|
70 | + public function appliesToVersion($requested_version) |
|
71 | + { |
|
72 | + if ($this->version() > $requested_version) { |
|
73 | + return true; |
|
74 | + } |
|
75 | + return false; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * Gets the EE core version when this changes were made to the rest api. |
|
81 | - * Any requests to earlier versions should have modifications made to them |
|
82 | - * by the callbacks of this class. |
|
83 | - * |
|
84 | - * @return string eg "4.8.33" |
|
85 | - * @throws EE_Error |
|
86 | - */ |
|
87 | - public function version() |
|
88 | - { |
|
89 | - if ($this->version === null) { |
|
90 | - $matches = array(); |
|
91 | - $regex = '~ChangesIn(\d)(\d\d)(\d\d)$~'; |
|
92 | - $success = preg_match( |
|
93 | - $regex, |
|
94 | - get_class($this), |
|
95 | - $matches |
|
96 | - ); |
|
97 | - if (! $success) { |
|
98 | - throw new EE_Error( |
|
99 | - sprintf( |
|
100 | - esc_html__('The class %1$s was misnamed. It name should match the regex "%2$s"', 'event_espresso'), |
|
101 | - get_class($this), |
|
102 | - $regex |
|
103 | - ) |
|
104 | - ); |
|
105 | - } |
|
106 | - $this->version = (int) $matches[1] . '.' . (int) $matches[2] . '.' . (int) $matches[3]; |
|
107 | - } |
|
108 | - return $this->version; |
|
109 | - } |
|
79 | + /** |
|
80 | + * Gets the EE core version when this changes were made to the rest api. |
|
81 | + * Any requests to earlier versions should have modifications made to them |
|
82 | + * by the callbacks of this class. |
|
83 | + * |
|
84 | + * @return string eg "4.8.33" |
|
85 | + * @throws EE_Error |
|
86 | + */ |
|
87 | + public function version() |
|
88 | + { |
|
89 | + if ($this->version === null) { |
|
90 | + $matches = array(); |
|
91 | + $regex = '~ChangesIn(\d)(\d\d)(\d\d)$~'; |
|
92 | + $success = preg_match( |
|
93 | + $regex, |
|
94 | + get_class($this), |
|
95 | + $matches |
|
96 | + ); |
|
97 | + if (! $success) { |
|
98 | + throw new EE_Error( |
|
99 | + sprintf( |
|
100 | + esc_html__('The class %1$s was misnamed. It name should match the regex "%2$s"', 'event_espresso'), |
|
101 | + get_class($this), |
|
102 | + $regex |
|
103 | + ) |
|
104 | + ); |
|
105 | + } |
|
106 | + $this->version = (int) $matches[1] . '.' . (int) $matches[2] . '.' . (int) $matches[3]; |
|
107 | + } |
|
108 | + return $this->version; |
|
109 | + } |
|
110 | 110 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | get_class($this), |
95 | 95 | $matches |
96 | 96 | ); |
97 | - if (! $success) { |
|
97 | + if ( ! $success) { |
|
98 | 98 | throw new EE_Error( |
99 | 99 | sprintf( |
100 | 100 | esc_html__('The class %1$s was misnamed. It name should match the regex "%2$s"', 'event_espresso'), |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ) |
104 | 104 | ); |
105 | 105 | } |
106 | - $this->version = (int) $matches[1] . '.' . (int) $matches[2] . '.' . (int) $matches[3]; |
|
106 | + $this->version = (int) $matches[1].'.'.(int) $matches[2].'.'.(int) $matches[3]; |
|
107 | 107 | } |
108 | 108 | return $this->version; |
109 | 109 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function registrationsCheckedInCount($wpdb_row, $request, $controller) |
89 | 89 | { |
90 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
90 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
91 | 91 | throw new EE_Error( |
92 | 92 | sprintf( |
93 | 93 | esc_html__( |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
123 | 123 | { |
124 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
124 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
125 | 125 | throw new EE_Error( |
126 | 126 | sprintf( |
127 | 127 | esc_html__( |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
158 | 158 | { |
159 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
159 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
160 | 160 | throw new EE_Error( |
161 | 161 | sprintf( |
162 | 162 | esc_html__( |
@@ -18,214 +18,214 @@ |
||
18 | 18 | |
19 | 19 | class Datetime extends DatetimeCalculationBase |
20 | 20 | { |
21 | - /** |
|
22 | - * @var EEM_Datetime |
|
23 | - */ |
|
24 | - protected $datetime_model; |
|
21 | + /** |
|
22 | + * @var EEM_Datetime |
|
23 | + */ |
|
24 | + protected $datetime_model; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var EEM_Registration |
|
28 | - */ |
|
29 | - protected $registration_model; |
|
30 | - public function __construct(EEM_Datetime $datetime_model, EEM_Registration $registration_model) |
|
31 | - { |
|
32 | - $this->datetime_model = $datetime_model; |
|
33 | - $this->registration_model = $registration_model; |
|
34 | - } |
|
26 | + /** |
|
27 | + * @var EEM_Registration |
|
28 | + */ |
|
29 | + protected $registration_model; |
|
30 | + public function __construct(EEM_Datetime $datetime_model, EEM_Registration $registration_model) |
|
31 | + { |
|
32 | + $this->datetime_model = $datetime_model; |
|
33 | + $this->registration_model = $registration_model; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * Calculates the total spaces available on the datetime, taking into account |
|
38 | - * ticket limits too. |
|
39 | - * |
|
40 | - * @see EE_Datetime::spaces_remaining( true ) |
|
41 | - * @param array $wpdb_row |
|
42 | - * @param WP_REST_Request $request |
|
43 | - * @param DatetimeControllerBase $controller |
|
44 | - * @return int |
|
45 | - * @throws EE_Error |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @throws InvalidInterfaceException |
|
48 | - * @throws InvalidArgumentException |
|
49 | - * @throws ReflectionException |
|
50 | - */ |
|
51 | - public function spacesRemainingConsideringTickets($wpdb_row, $request, $controller) |
|
52 | - { |
|
53 | - if (is_array($wpdb_row) && isset($wpdb_row['Datetime.DTT_ID'])) { |
|
54 | - $dtt_obj = $this->datetime_model->get_one_by_ID($wpdb_row['Datetime.DTT_ID']); |
|
55 | - } else { |
|
56 | - $dtt_obj = null; |
|
57 | - } |
|
58 | - if ($dtt_obj instanceof EE_Datetime) { |
|
59 | - return $dtt_obj->spaces_remaining(true); |
|
60 | - } |
|
61 | - throw new EE_Error( |
|
62 | - sprintf( |
|
63 | - esc_html__( |
|
64 | - // @codingStandardsIgnoreStart |
|
65 | - 'Cannot calculate spaces_remaining_considering_tickets because the datetime with ID %1$s (from database row %2$s) was not found', |
|
66 | - // @codingStandardsIgnoreEnd |
|
67 | - 'event_espresso' |
|
68 | - ), |
|
69 | - $wpdb_row['Datetime.DTT_ID'], |
|
70 | - print_r($wpdb_row, true) |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
36 | + /** |
|
37 | + * Calculates the total spaces available on the datetime, taking into account |
|
38 | + * ticket limits too. |
|
39 | + * |
|
40 | + * @see EE_Datetime::spaces_remaining( true ) |
|
41 | + * @param array $wpdb_row |
|
42 | + * @param WP_REST_Request $request |
|
43 | + * @param DatetimeControllerBase $controller |
|
44 | + * @return int |
|
45 | + * @throws EE_Error |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @throws InvalidInterfaceException |
|
48 | + * @throws InvalidArgumentException |
|
49 | + * @throws ReflectionException |
|
50 | + */ |
|
51 | + public function spacesRemainingConsideringTickets($wpdb_row, $request, $controller) |
|
52 | + { |
|
53 | + if (is_array($wpdb_row) && isset($wpdb_row['Datetime.DTT_ID'])) { |
|
54 | + $dtt_obj = $this->datetime_model->get_one_by_ID($wpdb_row['Datetime.DTT_ID']); |
|
55 | + } else { |
|
56 | + $dtt_obj = null; |
|
57 | + } |
|
58 | + if ($dtt_obj instanceof EE_Datetime) { |
|
59 | + return $dtt_obj->spaces_remaining(true); |
|
60 | + } |
|
61 | + throw new EE_Error( |
|
62 | + sprintf( |
|
63 | + esc_html__( |
|
64 | + // @codingStandardsIgnoreStart |
|
65 | + 'Cannot calculate spaces_remaining_considering_tickets because the datetime with ID %1$s (from database row %2$s) was not found', |
|
66 | + // @codingStandardsIgnoreEnd |
|
67 | + 'event_espresso' |
|
68 | + ), |
|
69 | + $wpdb_row['Datetime.DTT_ID'], |
|
70 | + print_r($wpdb_row, true) |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * Counts registrations who have checked into this datetime |
|
78 | - * |
|
79 | - * @param array $wpdb_row |
|
80 | - * @param WP_REST_Request $request |
|
81 | - * @param DatetimeControllerBase $controller |
|
82 | - * @return int |
|
83 | - * @throws EE_Error |
|
84 | - * @throws InvalidArgumentException |
|
85 | - * @throws InvalidDataTypeException |
|
86 | - * @throws InvalidInterfaceException |
|
87 | - * @throws RestException |
|
88 | - */ |
|
89 | - public function registrationsCheckedInCount($wpdb_row, $request, $controller) |
|
90 | - { |
|
91 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
92 | - throw new EE_Error( |
|
93 | - sprintf( |
|
94 | - esc_html__( |
|
95 | - // @codingStandardsIgnoreStart |
|
96 | - 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
97 | - // @codingStandardsIgnoreEnd |
|
98 | - 'event_espresso' |
|
99 | - ), |
|
100 | - print_r($wpdb_row, true) |
|
101 | - ) |
|
102 | - ); |
|
103 | - } |
|
104 | - $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count'); |
|
105 | - return $this->registration_model |
|
106 | - ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], true); |
|
107 | - } |
|
76 | + /** |
|
77 | + * Counts registrations who have checked into this datetime |
|
78 | + * |
|
79 | + * @param array $wpdb_row |
|
80 | + * @param WP_REST_Request $request |
|
81 | + * @param DatetimeControllerBase $controller |
|
82 | + * @return int |
|
83 | + * @throws EE_Error |
|
84 | + * @throws InvalidArgumentException |
|
85 | + * @throws InvalidDataTypeException |
|
86 | + * @throws InvalidInterfaceException |
|
87 | + * @throws RestException |
|
88 | + */ |
|
89 | + public function registrationsCheckedInCount($wpdb_row, $request, $controller) |
|
90 | + { |
|
91 | + if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
92 | + throw new EE_Error( |
|
93 | + sprintf( |
|
94 | + esc_html__( |
|
95 | + // @codingStandardsIgnoreStart |
|
96 | + 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
97 | + // @codingStandardsIgnoreEnd |
|
98 | + 'event_espresso' |
|
99 | + ), |
|
100 | + print_r($wpdb_row, true) |
|
101 | + ) |
|
102 | + ); |
|
103 | + } |
|
104 | + $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count'); |
|
105 | + return $this->registration_model |
|
106 | + ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], true); |
|
107 | + } |
|
108 | 108 | |
109 | 109 | |
110 | - /** |
|
111 | - * Counts registrations who have checked out of this datetime |
|
112 | - * |
|
113 | - * @param array $wpdb_row |
|
114 | - * @param WP_REST_Request $request |
|
115 | - * @param DatetimeControllerBase $controller |
|
116 | - * @return int |
|
117 | - * @throws EE_Error |
|
118 | - * @throws InvalidArgumentException |
|
119 | - * @throws InvalidDataTypeException |
|
120 | - * @throws InvalidInterfaceException |
|
121 | - * @throws RestException |
|
122 | - */ |
|
123 | - public function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
|
124 | - { |
|
125 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
126 | - throw new EE_Error( |
|
127 | - sprintf( |
|
128 | - esc_html__( |
|
129 | - // @codingStandardsIgnoreStart |
|
130 | - 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
131 | - // @codingStandardsIgnoreEnd |
|
132 | - 'event_espresso' |
|
133 | - ), |
|
134 | - print_r($wpdb_row, true) |
|
135 | - ) |
|
136 | - ); |
|
137 | - } |
|
138 | - $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count'); |
|
139 | - return $this->registration_model |
|
140 | - ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], false); |
|
141 | - } |
|
110 | + /** |
|
111 | + * Counts registrations who have checked out of this datetime |
|
112 | + * |
|
113 | + * @param array $wpdb_row |
|
114 | + * @param WP_REST_Request $request |
|
115 | + * @param DatetimeControllerBase $controller |
|
116 | + * @return int |
|
117 | + * @throws EE_Error |
|
118 | + * @throws InvalidArgumentException |
|
119 | + * @throws InvalidDataTypeException |
|
120 | + * @throws InvalidInterfaceException |
|
121 | + * @throws RestException |
|
122 | + */ |
|
123 | + public function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
|
124 | + { |
|
125 | + if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
126 | + throw new EE_Error( |
|
127 | + sprintf( |
|
128 | + esc_html__( |
|
129 | + // @codingStandardsIgnoreStart |
|
130 | + 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
131 | + // @codingStandardsIgnoreEnd |
|
132 | + 'event_espresso' |
|
133 | + ), |
|
134 | + print_r($wpdb_row, true) |
|
135 | + ) |
|
136 | + ); |
|
137 | + } |
|
138 | + $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count'); |
|
139 | + return $this->registration_model |
|
140 | + ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], false); |
|
141 | + } |
|
142 | 142 | |
143 | 143 | |
144 | - /** |
|
145 | - * Counts the number of pending-payment registrations for this event (regardless |
|
146 | - * of how many datetimes each registrations' ticket purchase is for) |
|
147 | - * |
|
148 | - * @param array $wpdb_row |
|
149 | - * @param WP_REST_Request $request |
|
150 | - * @param DatetimeControllerBase $controller |
|
151 | - * @return int |
|
152 | - * @throws EE_Error |
|
153 | - * @throws InvalidArgumentException |
|
154 | - * @throws InvalidDataTypeException |
|
155 | - * @throws InvalidInterfaceException |
|
156 | - * @throws RestException |
|
157 | - */ |
|
158 | - public function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
|
159 | - { |
|
160 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
161 | - throw new EE_Error( |
|
162 | - sprintf( |
|
163 | - esc_html__( |
|
164 | - // @codingStandardsIgnoreStart |
|
165 | - 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
166 | - // @codingStandardsIgnoreEnd |
|
167 | - 'event_espresso' |
|
168 | - ), |
|
169 | - print_r($wpdb_row, true) |
|
170 | - ) |
|
171 | - ); |
|
172 | - } |
|
173 | - $this->verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment'); |
|
174 | - return $this->registration_model->count( |
|
175 | - array( |
|
176 | - array( |
|
177 | - 'Ticket.Datetime.DTT_ID' => $wpdb_row['Datetime.DTT_ID'], |
|
178 | - 'STS_ID' => RegStatus::PENDING_PAYMENT, |
|
179 | - ), |
|
180 | - ), |
|
181 | - 'REG_ID', |
|
182 | - true |
|
183 | - ); |
|
184 | - } |
|
144 | + /** |
|
145 | + * Counts the number of pending-payment registrations for this event (regardless |
|
146 | + * of how many datetimes each registrations' ticket purchase is for) |
|
147 | + * |
|
148 | + * @param array $wpdb_row |
|
149 | + * @param WP_REST_Request $request |
|
150 | + * @param DatetimeControllerBase $controller |
|
151 | + * @return int |
|
152 | + * @throws EE_Error |
|
153 | + * @throws InvalidArgumentException |
|
154 | + * @throws InvalidDataTypeException |
|
155 | + * @throws InvalidInterfaceException |
|
156 | + * @throws RestException |
|
157 | + */ |
|
158 | + public function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
|
159 | + { |
|
160 | + if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
161 | + throw new EE_Error( |
|
162 | + sprintf( |
|
163 | + esc_html__( |
|
164 | + // @codingStandardsIgnoreStart |
|
165 | + 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
166 | + // @codingStandardsIgnoreEnd |
|
167 | + 'event_espresso' |
|
168 | + ), |
|
169 | + print_r($wpdb_row, true) |
|
170 | + ) |
|
171 | + ); |
|
172 | + } |
|
173 | + $this->verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment'); |
|
174 | + return $this->registration_model->count( |
|
175 | + array( |
|
176 | + array( |
|
177 | + 'Ticket.Datetime.DTT_ID' => $wpdb_row['Datetime.DTT_ID'], |
|
178 | + 'STS_ID' => RegStatus::PENDING_PAYMENT, |
|
179 | + ), |
|
180 | + ), |
|
181 | + 'REG_ID', |
|
182 | + true |
|
183 | + ); |
|
184 | + } |
|
185 | 185 | |
186 | 186 | |
187 | - /** |
|
188 | - * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
189 | - * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
190 | - * |
|
191 | - * @since 4.9.68.p |
|
192 | - * @return array |
|
193 | - */ |
|
194 | - public function schemaForCalculations() |
|
195 | - { |
|
196 | - return array( |
|
197 | - 'spaces_remaining_considering_tickets' => array( |
|
198 | - 'description' => esc_html__( |
|
199 | - 'Calculates the total spaces available on the datetime, taking into account ticket limits too.', |
|
200 | - 'event_espresso' |
|
201 | - ), |
|
202 | - 'type' => 'number', |
|
203 | - 'protected' => true, |
|
204 | - ), |
|
205 | - 'registrations_checked_in_count' => array( |
|
206 | - 'description' => esc_html__( |
|
207 | - 'Counts registrations who have checked into this datetime.', |
|
208 | - 'event_espresso' |
|
209 | - ), |
|
210 | - 'type' => 'number', |
|
211 | - 'protected' => true, |
|
212 | - ), |
|
213 | - 'registrations_checked_out_count' => array( |
|
214 | - 'description' => esc_html__( |
|
215 | - 'Counts registrations who have checked out of this datetime.', |
|
216 | - 'event_espresso' |
|
217 | - ), |
|
218 | - 'type' => 'number', |
|
219 | - 'protected' => true, |
|
220 | - ), |
|
221 | - 'spots_taken_pending_payment' => array( |
|
222 | - 'description' => esc_html__( |
|
223 | - 'The count of pending-payment registrations for this event (regardless of how many datetimes each registration\'s ticket purchase is for', |
|
224 | - 'event_espresso' |
|
225 | - ), |
|
226 | - 'type' => 'number', |
|
227 | - 'protected' => true, |
|
228 | - ), |
|
229 | - ); |
|
230 | - } |
|
187 | + /** |
|
188 | + * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
189 | + * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
190 | + * |
|
191 | + * @since 4.9.68.p |
|
192 | + * @return array |
|
193 | + */ |
|
194 | + public function schemaForCalculations() |
|
195 | + { |
|
196 | + return array( |
|
197 | + 'spaces_remaining_considering_tickets' => array( |
|
198 | + 'description' => esc_html__( |
|
199 | + 'Calculates the total spaces available on the datetime, taking into account ticket limits too.', |
|
200 | + 'event_espresso' |
|
201 | + ), |
|
202 | + 'type' => 'number', |
|
203 | + 'protected' => true, |
|
204 | + ), |
|
205 | + 'registrations_checked_in_count' => array( |
|
206 | + 'description' => esc_html__( |
|
207 | + 'Counts registrations who have checked into this datetime.', |
|
208 | + 'event_espresso' |
|
209 | + ), |
|
210 | + 'type' => 'number', |
|
211 | + 'protected' => true, |
|
212 | + ), |
|
213 | + 'registrations_checked_out_count' => array( |
|
214 | + 'description' => esc_html__( |
|
215 | + 'Counts registrations who have checked out of this datetime.', |
|
216 | + 'event_espresso' |
|
217 | + ), |
|
218 | + 'type' => 'number', |
|
219 | + 'protected' => true, |
|
220 | + ), |
|
221 | + 'spots_taken_pending_payment' => array( |
|
222 | + 'description' => esc_html__( |
|
223 | + 'The count of pending-payment registrations for this event (regardless of how many datetimes each registration\'s ticket purchase is for', |
|
224 | + 'event_espresso' |
|
225 | + ), |
|
226 | + 'type' => 'number', |
|
227 | + 'protected' => true, |
|
228 | + ), |
|
229 | + ); |
|
230 | + } |
|
231 | 231 | } |