@@ -46,7 +46,7 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function get_key($classname, $data) |
| 48 | 48 | { |
| 49 | - return md5($classname . serialize($data)); |
|
| 49 | + return md5($classname.serialize($data)); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -9,69 +9,69 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_Messages_Data_Handler_Collection extends EE_Object_Collection |
| 11 | 11 | { |
| 12 | - public function __construct() |
|
| 13 | - { |
|
| 14 | - $this->interface = 'EE_Messages_incoming_data'; |
|
| 15 | - } |
|
| 12 | + public function __construct() |
|
| 13 | + { |
|
| 14 | + $this->interface = 'EE_Messages_incoming_data'; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * This adds the EE_Messages_incoming_data data handler object to the collection. |
|
| 20 | - * |
|
| 21 | - * @param EE_Messages_incoming_data $data_handler |
|
| 22 | - * @param mixed $data Usually an array of data used in combination with the $data_handler |
|
| 23 | - * classname to create an alternative index for retrieving data_handlers. |
|
| 24 | - * @return bool |
|
| 25 | - */ |
|
| 26 | - public function add($data_handler, $data = ''): bool |
|
| 27 | - { |
|
| 28 | - $data = $data === null ? array() : (array) $data; |
|
| 29 | - $info['key'] = $this->get_key(get_class($data_handler), $data); |
|
| 30 | - return parent::add($data_handler, $info); |
|
| 31 | - } |
|
| 18 | + /** |
|
| 19 | + * This adds the EE_Messages_incoming_data data handler object to the collection. |
|
| 20 | + * |
|
| 21 | + * @param EE_Messages_incoming_data $data_handler |
|
| 22 | + * @param mixed $data Usually an array of data used in combination with the $data_handler |
|
| 23 | + * classname to create an alternative index for retrieving data_handlers. |
|
| 24 | + * @return bool |
|
| 25 | + */ |
|
| 26 | + public function add($data_handler, $data = ''): bool |
|
| 27 | + { |
|
| 28 | + $data = $data === null ? array() : (array) $data; |
|
| 29 | + $info['key'] = $this->get_key(get_class($data_handler), $data); |
|
| 30 | + return parent::add($data_handler, $info); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * This returns a key for retrieving data for the given references used to generate the key. |
|
| 39 | - * Data handlers are cached to the repository along with a md5() generated key using known references. |
|
| 40 | - * @param string $classname The classname of the datahandler being checked for. |
|
| 41 | - * @param mixed $data The data that was used to instantiate the data_handler. |
|
| 42 | - * |
|
| 43 | - * @return string md5 hash using provided info. |
|
| 44 | - */ |
|
| 45 | - public function get_key($classname, $data) |
|
| 46 | - { |
|
| 47 | - return md5($classname . serialize($data)); |
|
| 48 | - } |
|
| 37 | + /** |
|
| 38 | + * This returns a key for retrieving data for the given references used to generate the key. |
|
| 39 | + * Data handlers are cached to the repository along with a md5() generated key using known references. |
|
| 40 | + * @param string $classname The classname of the datahandler being checked for. |
|
| 41 | + * @param mixed $data The data that was used to instantiate the data_handler. |
|
| 42 | + * |
|
| 43 | + * @return string md5 hash using provided info. |
|
| 44 | + */ |
|
| 45 | + public function get_key($classname, $data) |
|
| 46 | + { |
|
| 47 | + return md5($classname . serialize($data)); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * This returns a saved EE_Messages_incoming_data object if there is one in the repository indexed by a key matching |
|
| 57 | - * the given string. |
|
| 58 | - * |
|
| 59 | - * @param string $key @see EE_Messages_Data_Handler_Collection::get_key() to setup a key formatted for searching. |
|
| 60 | - * |
|
| 61 | - * @return null|EE_Messages_incoming_data |
|
| 62 | - */ |
|
| 63 | - public function get_by_key($key) |
|
| 64 | - { |
|
| 65 | - $this->rewind(); |
|
| 66 | - while ($this->valid()) { |
|
| 67 | - $data = $this->getInfo(); |
|
| 68 | - if (isset($data['key']) && $data['key'] === $key) { |
|
| 69 | - $handler = $this->current(); |
|
| 70 | - $this->rewind(); |
|
| 71 | - return $handler; |
|
| 72 | - } |
|
| 73 | - $this->next(); |
|
| 74 | - } |
|
| 75 | - return null; |
|
| 76 | - } |
|
| 55 | + /** |
|
| 56 | + * This returns a saved EE_Messages_incoming_data object if there is one in the repository indexed by a key matching |
|
| 57 | + * the given string. |
|
| 58 | + * |
|
| 59 | + * @param string $key @see EE_Messages_Data_Handler_Collection::get_key() to setup a key formatted for searching. |
|
| 60 | + * |
|
| 61 | + * @return null|EE_Messages_incoming_data |
|
| 62 | + */ |
|
| 63 | + public function get_by_key($key) |
|
| 64 | + { |
|
| 65 | + $this->rewind(); |
|
| 66 | + while ($this->valid()) { |
|
| 67 | + $data = $this->getInfo(); |
|
| 68 | + if (isset($data['key']) && $data['key'] === $key) { |
|
| 69 | + $handler = $this->current(); |
|
| 70 | + $this->rewind(); |
|
| 71 | + return $handler; |
|
| 72 | + } |
|
| 73 | + $this->next(); |
|
| 74 | + } |
|
| 75 | + return null; |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | protected function _set_admin_pages() |
| 54 | 54 | { |
| 55 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
| 55 | + $this->admin_registered_pages = array('events_edit' => true); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | protected function _set_with_messengers() |
| 68 | 68 | { |
| 69 | 69 | $this->_with_messengers = array( |
| 70 | - 'html' => array( 'pdf' ) |
|
| 70 | + 'html' => array('pdf') |
|
| 71 | 71 | ); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | // receipt message type data handler is 'Gateways' and it expects a transaction object. |
| 79 | 79 | $transaction = $registration->transaction(); |
| 80 | 80 | if ($transaction instanceof EE_Transaction) { |
| 81 | - return array( $transaction ); |
|
| 81 | + return array($transaction); |
|
| 82 | 82 | } |
| 83 | 83 | return array(); |
| 84 | 84 | } |
@@ -12,123 +12,123 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class EE_Invoice_message_type extends EE_message_type |
| 14 | 14 | { |
| 15 | - public function __construct() |
|
| 16 | - { |
|
| 17 | - $this->name = 'invoice'; |
|
| 18 | - $this->description = esc_html__('The invoice message type is triggered via a url on the thank you page and via at url generated by the [INVOICE_URL] or [INVOICE_LINK] shortcode.', 'event_espresso'); |
|
| 19 | - $this->label = array( |
|
| 20 | - 'singular' => esc_html__('invoice', 'event_espresso'), |
|
| 21 | - 'plural' => esc_html__('invoices', 'event_espresso') |
|
| 22 | - ); |
|
| 23 | - $this->_master_templates = array(); |
|
| 24 | - parent::__construct(); |
|
| 25 | - } |
|
| 15 | + public function __construct() |
|
| 16 | + { |
|
| 17 | + $this->name = 'invoice'; |
|
| 18 | + $this->description = esc_html__('The invoice message type is triggered via a url on the thank you page and via at url generated by the [INVOICE_URL] or [INVOICE_LINK] shortcode.', 'event_espresso'); |
|
| 19 | + $this->label = array( |
|
| 20 | + 'singular' => esc_html__('invoice', 'event_espresso'), |
|
| 21 | + 'plural' => esc_html__('invoices', 'event_espresso') |
|
| 22 | + ); |
|
| 23 | + $this->_master_templates = array(); |
|
| 24 | + parent::__construct(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @see parent::get_priority() for documentation. |
|
| 31 | - * @return int |
|
| 32 | - */ |
|
| 33 | - public function get_priority() |
|
| 34 | - { |
|
| 35 | - return EEM_Message::priority_high; |
|
| 36 | - } |
|
| 29 | + /** |
|
| 30 | + * @see parent::get_priority() for documentation. |
|
| 31 | + * @return int |
|
| 32 | + */ |
|
| 33 | + public function get_priority() |
|
| 34 | + { |
|
| 35 | + return EEM_Message::priority_high; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * This method returns whether this message type should always generate a new copy |
|
| 41 | - * when requested, or if links can be to the already generated copy. |
|
| 42 | - * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
| 43 | - * Invoices always generate. |
|
| 44 | - * @return bool false means can link to generated EE_Message. true must regenerate. |
|
| 45 | - */ |
|
| 46 | - public function always_generate() |
|
| 47 | - { |
|
| 48 | - return true; |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * This method returns whether this message type should always generate a new copy |
|
| 41 | + * when requested, or if links can be to the already generated copy. |
|
| 42 | + * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
| 43 | + * Invoices always generate. |
|
| 44 | + * @return bool false means can link to generated EE_Message. true must regenerate. |
|
| 45 | + */ |
|
| 46 | + public function always_generate() |
|
| 47 | + { |
|
| 48 | + return true; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | - protected function _set_admin_pages() |
|
| 53 | - { |
|
| 54 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
| 55 | - } |
|
| 52 | + protected function _set_admin_pages() |
|
| 53 | + { |
|
| 54 | + $this->admin_registered_pages = array( 'events_edit' => true ); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | |
| 59 | - protected function _set_data_handler() |
|
| 60 | - { |
|
| 61 | - $this->_data_handler = 'Gateways'; |
|
| 62 | - } |
|
| 59 | + protected function _set_data_handler() |
|
| 60 | + { |
|
| 61 | + $this->_data_handler = 'Gateways'; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | |
| 66 | - protected function _set_with_messengers() |
|
| 67 | - { |
|
| 68 | - $this->_with_messengers = array( |
|
| 69 | - 'html' => array( 'pdf' ) |
|
| 70 | - ); |
|
| 71 | - } |
|
| 66 | + protected function _set_with_messengers() |
|
| 67 | + { |
|
| 68 | + $this->_with_messengers = array( |
|
| 69 | + 'html' => array( 'pdf' ) |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | |
| 75 | - protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
| 76 | - { |
|
| 77 | - // receipt message type data handler is 'Gateways' and it expects a transaction object. |
|
| 78 | - $transaction = $registration->transaction(); |
|
| 79 | - if ($transaction instanceof EE_Transaction) { |
|
| 80 | - return array( $transaction ); |
|
| 81 | - } |
|
| 82 | - return array(); |
|
| 83 | - } |
|
| 75 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
| 76 | + { |
|
| 77 | + // receipt message type data handler is 'Gateways' and it expects a transaction object. |
|
| 78 | + $transaction = $registration->transaction(); |
|
| 79 | + if ($transaction instanceof EE_Transaction) { |
|
| 80 | + return array( $transaction ); |
|
| 81 | + } |
|
| 82 | + return array(); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | |
| 87 | - protected function _set_admin_settings_fields() |
|
| 88 | - { |
|
| 89 | - $this->_admin_settings_fields = array(); |
|
| 90 | - } |
|
| 87 | + protected function _set_admin_settings_fields() |
|
| 88 | + { |
|
| 89 | + $this->_admin_settings_fields = array(); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | |
| 93 | 93 | |
| 94 | - protected function _set_contexts() |
|
| 95 | - { |
|
| 96 | - $this->_context_label = array( |
|
| 97 | - 'label' => esc_html__('recipient', 'event_espresso'), |
|
| 98 | - 'plural' => esc_html__('recipients', 'event_espresso'), |
|
| 99 | - 'description' => esc_html__('Recipient\'s are who will view the invoice.', 'event_espresso') |
|
| 100 | - ); |
|
| 94 | + protected function _set_contexts() |
|
| 95 | + { |
|
| 96 | + $this->_context_label = array( |
|
| 97 | + 'label' => esc_html__('recipient', 'event_espresso'), |
|
| 98 | + 'plural' => esc_html__('recipients', 'event_espresso'), |
|
| 99 | + 'description' => esc_html__('Recipient\'s are who will view the invoice.', 'event_espresso') |
|
| 100 | + ); |
|
| 101 | 101 | |
| 102 | - $this->_contexts = array( |
|
| 103 | - 'purchaser' => array( |
|
| 104 | - 'label' => esc_html__('Purchaser', 'event_espresso'), |
|
| 105 | - 'description' => esc_html__('This template goes to the person who conducted the transaction.', 'event_espresso') |
|
| 106 | - ) |
|
| 107 | - ); |
|
| 108 | - } |
|
| 102 | + $this->_contexts = array( |
|
| 103 | + 'purchaser' => array( |
|
| 104 | + 'label' => esc_html__('Purchaser', 'event_espresso'), |
|
| 105 | + 'description' => esc_html__('This template goes to the person who conducted the transaction.', 'event_espresso') |
|
| 106 | + ) |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * used to set the valid shortcodes for the receipt message type |
|
| 115 | - * |
|
| 116 | - * @since 4.5.0 |
|
| 117 | - * |
|
| 118 | - * @return void |
|
| 119 | - */ |
|
| 120 | - protected function _set_valid_shortcodes() |
|
| 121 | - { |
|
| 122 | - $this->_valid_shortcodes['purchaser'] = array( |
|
| 123 | - 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event', 'event_meta', 'messenger', 'organization', 'primary_registration_list', 'primary_registration_details', 'ticket_list', 'ticket', 'transaction', 'venue', 'line_item_list', 'payment_list', 'line_item', 'payment' |
|
| 124 | - ); |
|
| 125 | - } |
|
| 113 | + /** |
|
| 114 | + * used to set the valid shortcodes for the receipt message type |
|
| 115 | + * |
|
| 116 | + * @since 4.5.0 |
|
| 117 | + * |
|
| 118 | + * @return void |
|
| 119 | + */ |
|
| 120 | + protected function _set_valid_shortcodes() |
|
| 121 | + { |
|
| 122 | + $this->_valid_shortcodes['purchaser'] = array( |
|
| 123 | + 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event', 'event_meta', 'messenger', 'organization', 'primary_registration_list', 'primary_registration_details', 'ticket_list', 'ticket', 'transaction', 'venue', 'line_item_list', 'payment_list', 'line_item', 'payment' |
|
| 124 | + ); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | |
| 130 | - protected function _purchaser_addressees() |
|
| 131 | - { |
|
| 132 | - return parent::_primary_attendee_addressees(); |
|
| 133 | - } |
|
| 130 | + protected function _purchaser_addressees() |
|
| 131 | + { |
|
| 132 | + return parent::_primary_attendee_addressees(); |
|
| 133 | + } |
|
| 134 | 134 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | protected function _set_admin_pages() |
| 55 | 55 | { |
| 56 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
| 56 | + $this->admin_registered_pages = array('events_edit' => true); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | protected function _set_with_messengers() |
| 69 | 69 | { |
| 70 | 70 | $this->_with_messengers = array( |
| 71 | - 'html' => array( 'pdf' ) |
|
| 71 | + 'html' => array('pdf') |
|
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // receipt message type data handler is 'Gateways' and it expects a transaction object. |
| 80 | 80 | $transaction = $registration->transaction(); |
| 81 | 81 | if ($transaction instanceof EE_Transaction) { |
| 82 | - return array( $transaction ); |
|
| 82 | + return array($transaction); |
|
| 83 | 83 | } |
| 84 | 84 | return array(); |
| 85 | 85 | } |
@@ -12,142 +12,142 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class EE_Receipt_message_type extends EE_message_type |
| 14 | 14 | { |
| 15 | - public function __construct() |
|
| 16 | - { |
|
| 17 | - $this->name = 'receipt'; |
|
| 18 | - $this->description = esc_html__('The receipt message type is triggered via a url on the thank you page and via at url generated by the [RECEIPT_URL] shortcode.', 'event_espresso'); |
|
| 19 | - $this->label = array( |
|
| 20 | - 'singular' => esc_html__('receipt', 'event_espresso'), |
|
| 21 | - 'plural' => esc_html__('receipts', 'event_espresso') |
|
| 22 | - ); |
|
| 23 | - $this->_master_templates = array(); |
|
| 24 | - parent::__construct(); |
|
| 25 | - } |
|
| 15 | + public function __construct() |
|
| 16 | + { |
|
| 17 | + $this->name = 'receipt'; |
|
| 18 | + $this->description = esc_html__('The receipt message type is triggered via a url on the thank you page and via at url generated by the [RECEIPT_URL] shortcode.', 'event_espresso'); |
|
| 19 | + $this->label = array( |
|
| 20 | + 'singular' => esc_html__('receipt', 'event_espresso'), |
|
| 21 | + 'plural' => esc_html__('receipts', 'event_espresso') |
|
| 22 | + ); |
|
| 23 | + $this->_master_templates = array(); |
|
| 24 | + parent::__construct(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @see parent::get_priority() for documentation. |
|
| 31 | - * @return int |
|
| 32 | - */ |
|
| 33 | - public function get_priority() |
|
| 34 | - { |
|
| 35 | - return EEM_Message::priority_high; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * This method returns whether this message type should always generate a new copy |
|
| 42 | - * when requested, or if links can be to the already generated copy. |
|
| 43 | - * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
| 44 | - * Receipts always generate |
|
| 45 | - * @return bool false means can link to generated EE_Message. true must regenerate. |
|
| 46 | - */ |
|
| 47 | - public function always_generate() |
|
| 48 | - { |
|
| 49 | - return true; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - protected function _set_admin_pages() |
|
| 54 | - { |
|
| 55 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - protected function _set_data_handler() |
|
| 61 | - { |
|
| 62 | - $this->_data_handler = 'Gateways'; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - protected function _set_with_messengers() |
|
| 68 | - { |
|
| 69 | - $this->_with_messengers = array( |
|
| 70 | - 'html' => array( 'pdf' ) |
|
| 71 | - ); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
| 77 | - { |
|
| 78 | - // receipt message type data handler is 'Gateways' and it expects a transaction object. |
|
| 79 | - $transaction = $registration->transaction(); |
|
| 80 | - if ($transaction instanceof EE_Transaction) { |
|
| 81 | - return array( $transaction ); |
|
| 82 | - } |
|
| 83 | - return array(); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - protected function _set_admin_settings_fields() |
|
| 89 | - { |
|
| 90 | - $this->_admin_settings_fields = array(); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - protected function _set_contexts() |
|
| 96 | - { |
|
| 97 | - $this->_context_label = array( |
|
| 98 | - 'label' => esc_html__('recipient', 'event_espresso'), |
|
| 99 | - 'plural' => esc_html__('recipients', 'event_espresso'), |
|
| 100 | - 'description' => esc_html__('Recipient\'s are who will view the receipt.', 'event_espresso') |
|
| 101 | - ); |
|
| 102 | - |
|
| 103 | - $this->_contexts = array( |
|
| 104 | - 'purchaser' => array( |
|
| 105 | - 'label' => esc_html__('Purchaser', 'event_espresso'), |
|
| 106 | - 'description' => esc_html__('This template goes to the person who conducted the transaction.', 'event_espresso') |
|
| 107 | - ) |
|
| 108 | - ); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * used to set the valid shortcodes for the receipt message type |
|
| 116 | - * |
|
| 117 | - * @since 4.5.0 |
|
| 118 | - * |
|
| 119 | - * @return void |
|
| 120 | - */ |
|
| 121 | - protected function _set_valid_shortcodes() |
|
| 122 | - { |
|
| 123 | - $this->_valid_shortcodes['purchaser'] = array( |
|
| 124 | - 'attendee_list', |
|
| 125 | - 'attendee', |
|
| 126 | - 'datetime_list', |
|
| 127 | - 'datetime', |
|
| 128 | - 'event_list', |
|
| 129 | - 'event', |
|
| 130 | - 'event_meta', |
|
| 131 | - 'messenger', |
|
| 132 | - 'organization', |
|
| 133 | - 'primary_registration_list', |
|
| 134 | - 'primary_registration_details', |
|
| 135 | - 'ticket_list', |
|
| 136 | - 'ticket', |
|
| 137 | - 'transaction', |
|
| 138 | - 'venue', |
|
| 139 | - 'line_item_list', |
|
| 140 | - 'payment_list', |
|
| 141 | - 'line_item', |
|
| 142 | - 'payment' |
|
| 143 | - ); |
|
| 144 | - } |
|
| 145 | - |
|
| 29 | + /** |
|
| 30 | + * @see parent::get_priority() for documentation. |
|
| 31 | + * @return int |
|
| 32 | + */ |
|
| 33 | + public function get_priority() |
|
| 34 | + { |
|
| 35 | + return EEM_Message::priority_high; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * This method returns whether this message type should always generate a new copy |
|
| 42 | + * when requested, or if links can be to the already generated copy. |
|
| 43 | + * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table. |
|
| 44 | + * Receipts always generate |
|
| 45 | + * @return bool false means can link to generated EE_Message. true must regenerate. |
|
| 46 | + */ |
|
| 47 | + public function always_generate() |
|
| 48 | + { |
|
| 49 | + return true; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + protected function _set_admin_pages() |
|
| 54 | + { |
|
| 55 | + $this->admin_registered_pages = array( 'events_edit' => true ); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + protected function _set_data_handler() |
|
| 61 | + { |
|
| 62 | + $this->_data_handler = 'Gateways'; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + protected function _set_with_messengers() |
|
| 68 | + { |
|
| 69 | + $this->_with_messengers = array( |
|
| 70 | + 'html' => array( 'pdf' ) |
|
| 71 | + ); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
| 77 | + { |
|
| 78 | + // receipt message type data handler is 'Gateways' and it expects a transaction object. |
|
| 79 | + $transaction = $registration->transaction(); |
|
| 80 | + if ($transaction instanceof EE_Transaction) { |
|
| 81 | + return array( $transaction ); |
|
| 82 | + } |
|
| 83 | + return array(); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + protected function _set_admin_settings_fields() |
|
| 89 | + { |
|
| 90 | + $this->_admin_settings_fields = array(); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + protected function _set_contexts() |
|
| 96 | + { |
|
| 97 | + $this->_context_label = array( |
|
| 98 | + 'label' => esc_html__('recipient', 'event_espresso'), |
|
| 99 | + 'plural' => esc_html__('recipients', 'event_espresso'), |
|
| 100 | + 'description' => esc_html__('Recipient\'s are who will view the receipt.', 'event_espresso') |
|
| 101 | + ); |
|
| 102 | + |
|
| 103 | + $this->_contexts = array( |
|
| 104 | + 'purchaser' => array( |
|
| 105 | + 'label' => esc_html__('Purchaser', 'event_espresso'), |
|
| 106 | + 'description' => esc_html__('This template goes to the person who conducted the transaction.', 'event_espresso') |
|
| 107 | + ) |
|
| 108 | + ); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * used to set the valid shortcodes for the receipt message type |
|
| 116 | + * |
|
| 117 | + * @since 4.5.0 |
|
| 118 | + * |
|
| 119 | + * @return void |
|
| 120 | + */ |
|
| 121 | + protected function _set_valid_shortcodes() |
|
| 122 | + { |
|
| 123 | + $this->_valid_shortcodes['purchaser'] = array( |
|
| 124 | + 'attendee_list', |
|
| 125 | + 'attendee', |
|
| 126 | + 'datetime_list', |
|
| 127 | + 'datetime', |
|
| 128 | + 'event_list', |
|
| 129 | + 'event', |
|
| 130 | + 'event_meta', |
|
| 131 | + 'messenger', |
|
| 132 | + 'organization', |
|
| 133 | + 'primary_registration_list', |
|
| 134 | + 'primary_registration_details', |
|
| 135 | + 'ticket_list', |
|
| 136 | + 'ticket', |
|
| 137 | + 'transaction', |
|
| 138 | + 'venue', |
|
| 139 | + 'line_item_list', |
|
| 140 | + 'payment_list', |
|
| 141 | + 'line_item', |
|
| 142 | + 'payment' |
|
| 143 | + ); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | |
| 149 | - protected function _purchaser_addressees() |
|
| 150 | - { |
|
| 151 | - return parent::_primary_attendee_addressees(); |
|
| 152 | - } |
|
| 149 | + protected function _purchaser_addressees() |
|
| 150 | + { |
|
| 151 | + return parent::_primary_attendee_addressees(); |
|
| 152 | + } |
|
| 153 | 153 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | */ |
| 63 | 63 | protected function _get_subject($custom_subject = '') |
| 64 | 64 | { |
| 65 | - if (! empty($custom_subject)) { |
|
| 65 | + if ( ! empty($custom_subject)) { |
|
| 66 | 66 | return $custom_subject; |
| 67 | 67 | } |
| 68 | 68 | $this->queue->get_message_repository()->rewind(); |
@@ -12,90 +12,90 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class EE_Message_To_Generate_From_Queue extends EE_Message_To_Generate |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Will hold an EE_Messages_Queue object |
|
| 17 | - * @type EE_Messages_Queue |
|
| 18 | - */ |
|
| 19 | - public $queue = array(); |
|
| 15 | + /** |
|
| 16 | + * Will hold an EE_Messages_Queue object |
|
| 17 | + * @type EE_Messages_Queue |
|
| 18 | + */ |
|
| 19 | + public $queue = array(); |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $messenger_name The messenger being used to send the message |
|
| 23 | - * @param string $message_type_name The message type being used to grab variations etc. |
|
| 24 | - * @param EE_Messages_Queue $queue |
|
| 25 | - * @param string $custom_subject Used if a custom subject is desired for the generated aggregate EE_Message object |
|
| 26 | - */ |
|
| 27 | - public function __construct($messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '') |
|
| 28 | - { |
|
| 29 | - $this->queue = $queue; |
|
| 30 | - parent::__construct($messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle); |
|
| 31 | - if ($this->valid()) { |
|
| 32 | - $this->_message->set_content($this->_get_content()); |
|
| 33 | - $this->_message->set_subject($this->_get_subject($custom_subject)); |
|
| 34 | - $this->_message->set_GRP_ID($this->getGroupIdFromMessageRepo()); |
|
| 35 | - } |
|
| 36 | - } |
|
| 21 | + /** |
|
| 22 | + * @param string $messenger_name The messenger being used to send the message |
|
| 23 | + * @param string $message_type_name The message type being used to grab variations etc. |
|
| 24 | + * @param EE_Messages_Queue $queue |
|
| 25 | + * @param string $custom_subject Used if a custom subject is desired for the generated aggregate EE_Message object |
|
| 26 | + */ |
|
| 27 | + public function __construct($messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '') |
|
| 28 | + { |
|
| 29 | + $this->queue = $queue; |
|
| 30 | + parent::__construct($messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle); |
|
| 31 | + if ($this->valid()) { |
|
| 32 | + $this->_message->set_content($this->_get_content()); |
|
| 33 | + $this->_message->set_subject($this->_get_subject($custom_subject)); |
|
| 34 | + $this->_message->set_GRP_ID($this->getGroupIdFromMessageRepo()); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Uses the EE_Messages_Queue currently set on this object to generate the content |
|
| 42 | - * for the single EE_Message aggregate object returned by get_EE_Message |
|
| 43 | - * @return string; |
|
| 44 | - */ |
|
| 45 | - protected function _get_content() |
|
| 46 | - { |
|
| 47 | - $content = ''; |
|
| 48 | - $this->queue->get_message_repository()->rewind(); |
|
| 49 | - while ($this->queue->get_message_repository()->valid()) { |
|
| 50 | - $content .= $this->queue->get_message_repository()->current()->content(); |
|
| 51 | - $this->queue->get_message_repository()->next(); |
|
| 52 | - } |
|
| 53 | - return $content; |
|
| 54 | - } |
|
| 40 | + /** |
|
| 41 | + * Uses the EE_Messages_Queue currently set on this object to generate the content |
|
| 42 | + * for the single EE_Message aggregate object returned by get_EE_Message |
|
| 43 | + * @return string; |
|
| 44 | + */ |
|
| 45 | + protected function _get_content() |
|
| 46 | + { |
|
| 47 | + $content = ''; |
|
| 48 | + $this->queue->get_message_repository()->rewind(); |
|
| 49 | + while ($this->queue->get_message_repository()->valid()) { |
|
| 50 | + $content .= $this->queue->get_message_repository()->current()->content(); |
|
| 51 | + $this->queue->get_message_repository()->next(); |
|
| 52 | + } |
|
| 53 | + return $content; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Return a subject string to use for `MSG_Subject` in the aggregate EE_Message object. |
|
| 59 | - * @param string $custom_subject |
|
| 60 | - * |
|
| 61 | - * @return string |
|
| 62 | - */ |
|
| 63 | - protected function _get_subject($custom_subject = '') |
|
| 64 | - { |
|
| 65 | - if (! empty($custom_subject)) { |
|
| 66 | - return $custom_subject; |
|
| 67 | - } |
|
| 68 | - $this->queue->get_message_repository()->rewind(); |
|
| 69 | - $count_of_items = $this->queue->get_message_repository()->count(); |
|
| 57 | + /** |
|
| 58 | + * Return a subject string to use for `MSG_Subject` in the aggregate EE_Message object. |
|
| 59 | + * @param string $custom_subject |
|
| 60 | + * |
|
| 61 | + * @return string |
|
| 62 | + */ |
|
| 63 | + protected function _get_subject($custom_subject = '') |
|
| 64 | + { |
|
| 65 | + if (! empty($custom_subject)) { |
|
| 66 | + return $custom_subject; |
|
| 67 | + } |
|
| 68 | + $this->queue->get_message_repository()->rewind(); |
|
| 69 | + $count_of_items = $this->queue->get_message_repository()->count(); |
|
| 70 | 70 | |
| 71 | - // if $count of items in queue == 1, then let's just return the subject for that item. |
|
| 72 | - if ($count_of_items === 1) { |
|
| 73 | - return $this->queue->get_message_repository()->current()->subject(); |
|
| 74 | - } |
|
| 75 | - // phpcs:disable WordPress.WP.I18n.MissingSingularPlaceholder |
|
| 76 | - return sprintf( |
|
| 77 | - _n( |
|
| 78 | - 'Showing Aggregate output for 1 result', |
|
| 79 | - 'Showing Aggregate output for %d items', |
|
| 80 | - $count_of_items, |
|
| 81 | - 'event_espresso' |
|
| 82 | - ), |
|
| 83 | - $count_of_items |
|
| 84 | - ); |
|
| 85 | - // phpcs:enable |
|
| 86 | - } |
|
| 71 | + // if $count of items in queue == 1, then let's just return the subject for that item. |
|
| 72 | + if ($count_of_items === 1) { |
|
| 73 | + return $this->queue->get_message_repository()->current()->subject(); |
|
| 74 | + } |
|
| 75 | + // phpcs:disable WordPress.WP.I18n.MissingSingularPlaceholder |
|
| 76 | + return sprintf( |
|
| 77 | + _n( |
|
| 78 | + 'Showing Aggregate output for 1 result', |
|
| 79 | + 'Showing Aggregate output for %d items', |
|
| 80 | + $count_of_items, |
|
| 81 | + 'event_espresso' |
|
| 82 | + ), |
|
| 83 | + $count_of_items |
|
| 84 | + ); |
|
| 85 | + // phpcs:enable |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Uses the EE_Messages_Queue currently set on this object to set the GRP_ID |
|
| 91 | - * for the single EE_Message aggregate object returned by get_EE_Message |
|
| 92 | - * @return int; |
|
| 93 | - */ |
|
| 94 | - protected function getGroupIdFromMessageRepo() |
|
| 95 | - { |
|
| 96 | - $this->queue->get_message_repository()->rewind(); |
|
| 97 | - if ($this->queue->get_message_repository()->valid()) { |
|
| 98 | - return $this->queue->get_message_repository()->current()->GRP_ID(); |
|
| 99 | - } |
|
| 100 | - } |
|
| 89 | + /** |
|
| 90 | + * Uses the EE_Messages_Queue currently set on this object to set the GRP_ID |
|
| 91 | + * for the single EE_Message aggregate object returned by get_EE_Message |
|
| 92 | + * @return int; |
|
| 93 | + */ |
|
| 94 | + protected function getGroupIdFromMessageRepo() |
|
| 95 | + { |
|
| 96 | + $this->queue->get_message_repository()->rewind(); |
|
| 97 | + if ($this->queue->get_message_repository()->valid()) { |
|
| 98 | + return $this->queue->get_message_repository()->current()->GRP_ID(); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | $this->_venue = $this->_get_venue(); |
| 90 | 90 | // If there is no venue object by now then get out. |
| 91 | - if (! $this->_venue instanceof EE_Venue) { |
|
| 91 | + if ( ! $this->_venue instanceof EE_Venue) { |
|
| 92 | 92 | return ''; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | // if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the |
| 186 | 186 | // reg_obj instead. |
| 187 | - if (! $this->_event instanceof EE_Event) { |
|
| 187 | + if ( ! $this->_event instanceof EE_Event) { |
|
| 188 | 188 | $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
| 189 | 189 | $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
| 190 | 190 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $this->_event = ! $this->_event instanceof EE_Event |
| 197 | 197 | && $this->_data instanceof EE_Ticket |
| 198 | 198 | && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
| 199 | - ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
| 199 | + ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event'] |
|
| 200 | 200 | : $this->_event; |
| 201 | 201 | |
| 202 | 202 | // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | private function _venue($field) |
| 226 | 226 | { |
| 227 | 227 | |
| 228 | - if (! $this->_venue instanceof EE_Venue) { |
|
| 228 | + if ( ! $this->_venue instanceof EE_Venue) { |
|
| 229 | 229 | return ''; |
| 230 | 230 | } //no venue so get out. |
| 231 | 231 | |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | break; |
| 249 | 249 | |
| 250 | 250 | case 'image': |
| 251 | - return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
| 252 | - . '" alt="' . sprintf( |
|
| 251 | + return '<img src="'.$this->_venue->feature_image_url(array(200, 200,)) |
|
| 252 | + . '" alt="'.sprintf( |
|
| 253 | 253 | esc_attr__('%s Feature Image', 'event_espresso'), |
| 254 | 254 | $this->_venue->get('VNU_name') |
| 255 | - ) . '" />'; |
|
| 255 | + ).'" />'; |
|
| 256 | 256 | break; |
| 257 | 257 | |
| 258 | 258 | case 'phone': |
@@ -15,299 +15,299 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class EE_Venue_Shortcodes extends EE_Shortcodes |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Will hold the EE_Event if available |
|
| 20 | - * |
|
| 21 | - * @var EE_Event |
|
| 22 | - */ |
|
| 23 | - protected $_event; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Will hold the EE_Venue if available |
|
| 27 | - * |
|
| 28 | - * @var EE_Venue |
|
| 29 | - */ |
|
| 30 | - protected $_venue; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Initialize properties |
|
| 35 | - */ |
|
| 36 | - protected function _init_props() |
|
| 37 | - { |
|
| 38 | - $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
| 39 | - $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
| 40 | - $this->_shortcodes = array( |
|
| 41 | - '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
| 42 | - '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
| 43 | - '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
| 44 | - '[VENUE_DETAILS_URL]' => sprintf( |
|
| 45 | - esc_html__( |
|
| 46 | - 'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.', |
|
| 47 | - 'event_espresso' |
|
| 48 | - ), |
|
| 49 | - '[VENUE_URL]' |
|
| 50 | - ), |
|
| 51 | - '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
| 52 | - '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
| 53 | - '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
| 54 | - '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
| 55 | - '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
| 56 | - '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
| 57 | - '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
| 58 | - '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
| 59 | - 'This just outputs the venue address in a semantic address format.', |
|
| 60 | - 'event_espresso' |
|
| 61 | - ), |
|
| 62 | - '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
| 63 | - '[VENUE_META_*]' => esc_html__( |
|
| 64 | - 'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the venue then it will be output in place of this shortcode.', |
|
| 65 | - 'event_espresso' |
|
| 66 | - ), |
|
| 67 | - '[GOOGLE_MAP_URL]' => esc_html__( |
|
| 68 | - 'URL for the google map associated with the venue.', |
|
| 69 | - 'event_espresso' |
|
| 70 | - ), |
|
| 71 | - '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
| 72 | - '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
| 73 | - ); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Parse incoming shortcode |
|
| 79 | - * |
|
| 80 | - * @param string $shortcode |
|
| 81 | - * @return string |
|
| 82 | - * @throws EE_Error |
|
| 83 | - * @throws EntityNotFoundException |
|
| 84 | - */ |
|
| 85 | - protected function _parser($shortcode) |
|
| 86 | - { |
|
| 87 | - $this->_venue = $this->_get_venue(); |
|
| 88 | - // If there is no venue object by now then get out. |
|
| 89 | - if (! $this->_venue instanceof EE_Venue) { |
|
| 90 | - return ''; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - switch ($shortcode) { |
|
| 94 | - case '[VENUE_TITLE]': |
|
| 95 | - return $this->_venue('title'); |
|
| 96 | - |
|
| 97 | - case '[VENUE_DESCRIPTION]': |
|
| 98 | - return $this->_venue('description'); |
|
| 99 | - |
|
| 100 | - case '[VENUE_URL]': |
|
| 101 | - return $this->_venue('url'); |
|
| 102 | - |
|
| 103 | - case '[VENUE_IMAGE]': |
|
| 104 | - return $this->_venue('image'); |
|
| 105 | - |
|
| 106 | - case '[VENUE_PHONE]': |
|
| 107 | - return $this->_venue('phone'); |
|
| 108 | - |
|
| 109 | - case '[VENUE_ADDRESS]': |
|
| 110 | - return $this->_venue('address'); |
|
| 111 | - |
|
| 112 | - case '[VENUE_ADDRESS2]': |
|
| 113 | - return $this->_venue('address2'); |
|
| 114 | - |
|
| 115 | - case '[VENUE_CITY]': |
|
| 116 | - return $this->_venue('city'); |
|
| 117 | - |
|
| 118 | - case '[VENUE_COUNTRY]': |
|
| 119 | - return $this->_venue('country'); |
|
| 120 | - |
|
| 121 | - case '[VENUE_STATE]': |
|
| 122 | - return $this->_venue('state'); |
|
| 123 | - |
|
| 124 | - case '[VENUE_ZIP]': |
|
| 125 | - return $this->_venue('zip'); |
|
| 126 | - |
|
| 127 | - case '[VENUE_FORMATTED_ADDRESS]': |
|
| 128 | - return $this->_venue('formatted_address'); |
|
| 129 | - |
|
| 130 | - case '[GOOGLE_MAP_URL]': |
|
| 131 | - return $this->_venue('gmap_url'); |
|
| 132 | - |
|
| 133 | - case '[GOOGLE_MAP_LINK]': |
|
| 134 | - return $this->_venue('gmap_link'); |
|
| 135 | - |
|
| 136 | - case '[GOOGLE_MAP_IMAGE]': |
|
| 137 | - return $this->_venue('gmap_link_img'); |
|
| 138 | - |
|
| 139 | - case '[VENUE_DETAILS_URL]': |
|
| 140 | - return $this->_venue('permalink'); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - if (strpos($shortcode, '[VENUE_META_*') !== false) { |
|
| 144 | - $shortcode = str_replace('[VENUE_META_*', '', $shortcode); |
|
| 145 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
| 146 | - |
|
| 147 | - // pull the meta value from the venue post |
|
| 148 | - $venue_meta = $this->_venue->get_post_meta($shortcode, true); |
|
| 149 | - |
|
| 150 | - return ! empty($venue_meta) ? $venue_meta : ''; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * This retrieves the EE_Venue from the available data object. |
|
| 156 | - * |
|
| 157 | - * @return EE_Venue|null |
|
| 158 | - * @throws EE_Error |
|
| 159 | - * @throws EntityNotFoundException |
|
| 160 | - */ |
|
| 161 | - private function _get_venue() |
|
| 162 | - { |
|
| 163 | - |
|
| 164 | - // we need the EE_Event object to get the venue. |
|
| 165 | - $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
| 166 | - |
|
| 167 | - // if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the |
|
| 168 | - // reg_obj instead. |
|
| 169 | - if (! $this->_event instanceof EE_Event) { |
|
| 170 | - $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
| 171 | - $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
| 172 | - |
|
| 173 | - $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
| 174 | - ? $aee->reg_obj->event() |
|
| 175 | - : null; |
|
| 176 | - |
|
| 177 | - // if still empty do we have a ticket data item? |
|
| 178 | - $this->_event = ! $this->_event instanceof EE_Event |
|
| 179 | - && $this->_data instanceof EE_Ticket |
|
| 180 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
| 181 | - ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
| 182 | - : $this->_event; |
|
| 183 | - |
|
| 184 | - // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
|
| 185 | - // and use that. |
|
| 186 | - $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee |
|
| 187 | - ? reset($aee->events) |
|
| 188 | - : $this->_event; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - // If we have an event object use it to pull the venue. |
|
| 192 | - if ($this->_event instanceof EE_Event) { |
|
| 193 | - return $this->_event->get_first_related('Venue'); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - return null; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * This retrieves the specified venue information |
|
| 201 | - * |
|
| 202 | - * @param string $field What Venue field to retrieve |
|
| 203 | - * @return string What was retrieved! |
|
| 204 | - * @throws EE_Error |
|
| 205 | - * @throws EntityNotFoundException |
|
| 206 | - */ |
|
| 207 | - private function _venue($field) |
|
| 208 | - { |
|
| 209 | - |
|
| 210 | - if (! $this->_venue instanceof EE_Venue) { |
|
| 211 | - return ''; |
|
| 212 | - } //no venue so get out. |
|
| 213 | - |
|
| 214 | - switch ($field) { |
|
| 215 | - case 'title': |
|
| 216 | - return $this->_venue->get('VNU_name'); |
|
| 217 | - break; |
|
| 218 | - |
|
| 219 | - case 'description': |
|
| 220 | - return $this->_venue->get('VNU_desc'); |
|
| 221 | - break; |
|
| 222 | - |
|
| 223 | - case 'url': |
|
| 224 | - $url = $this->_venue->get('VNU_url'); |
|
| 225 | - return empty($url) ? $this->_venue->get_permalink() : $url; |
|
| 226 | - break; |
|
| 227 | - |
|
| 228 | - case 'permalink': |
|
| 229 | - return $this->_venue->get_permalink(); |
|
| 230 | - break; |
|
| 231 | - |
|
| 232 | - case 'image': |
|
| 233 | - return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
| 234 | - . '" alt="' . sprintf( |
|
| 235 | - esc_attr__('%s Feature Image', 'event_espresso'), |
|
| 236 | - $this->_venue->get('VNU_name') |
|
| 237 | - ) . '" />'; |
|
| 238 | - break; |
|
| 239 | - |
|
| 240 | - case 'phone': |
|
| 241 | - return $this->_venue->get('VNU_phone'); |
|
| 242 | - break; |
|
| 243 | - |
|
| 244 | - case 'address': |
|
| 245 | - return $this->_venue->get('VNU_address'); |
|
| 246 | - break; |
|
| 247 | - |
|
| 248 | - case 'address2': |
|
| 249 | - return $this->_venue->get('VNU_address2'); |
|
| 250 | - break; |
|
| 251 | - |
|
| 252 | - case 'city': |
|
| 253 | - return $this->_venue->get('VNU_city'); |
|
| 254 | - break; |
|
| 255 | - |
|
| 256 | - case 'state': |
|
| 257 | - $state = $this->_venue->state_obj(); |
|
| 258 | - return is_object($state) ? $state->get('STA_name') : ''; |
|
| 259 | - break; |
|
| 260 | - |
|
| 261 | - case 'country': |
|
| 262 | - $country = $this->_venue->country_obj(); |
|
| 263 | - return is_object($country) ? $country->get('CNT_name') : ''; |
|
| 264 | - break; |
|
| 265 | - |
|
| 266 | - case 'zip': |
|
| 267 | - return $this->_venue->get('VNU_zip'); |
|
| 268 | - break; |
|
| 269 | - |
|
| 270 | - case 'formatted_address': |
|
| 271 | - return EEH_Address::format($this->_venue); |
|
| 272 | - break; |
|
| 273 | - |
|
| 274 | - case 'gmap_link': |
|
| 275 | - case 'gmap_url': |
|
| 276 | - case 'gmap_link_img': |
|
| 277 | - $atts = $this->get_map_attributes($this->_venue, $field); |
|
| 278 | - return EEH_Maps::google_map_link($atts); |
|
| 279 | - break; |
|
| 280 | - } |
|
| 281 | - return ''; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * Generates the attributes for retrieving a google_map artifact. |
|
| 287 | - * |
|
| 288 | - * @param EE_Venue $venue |
|
| 289 | - * @param string $field |
|
| 290 | - * @return array |
|
| 291 | - * @throws EE_Error |
|
| 292 | - */ |
|
| 293 | - protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
| 294 | - { |
|
| 295 | - $state = $venue->state_obj(); |
|
| 296 | - $country = $venue->country_obj(); |
|
| 297 | - $atts = array( |
|
| 298 | - 'id' => $venue->ID(), |
|
| 299 | - 'address' => $venue->get('VNU_address'), |
|
| 300 | - 'city' => $venue->get('VNU_city'), |
|
| 301 | - 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
| 302 | - 'zip' => $venue->get('VNU_zip'), |
|
| 303 | - 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
| 304 | - 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
| 305 | - 'map_w' => 200, |
|
| 306 | - 'map_h' => 200, |
|
| 307 | - ); |
|
| 308 | - if ($field === 'gmap_url') { |
|
| 309 | - $atts['type'] = 'url_only'; |
|
| 310 | - } |
|
| 311 | - return $atts; |
|
| 312 | - } |
|
| 18 | + /** |
|
| 19 | + * Will hold the EE_Event if available |
|
| 20 | + * |
|
| 21 | + * @var EE_Event |
|
| 22 | + */ |
|
| 23 | + protected $_event; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Will hold the EE_Venue if available |
|
| 27 | + * |
|
| 28 | + * @var EE_Venue |
|
| 29 | + */ |
|
| 30 | + protected $_venue; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Initialize properties |
|
| 35 | + */ |
|
| 36 | + protected function _init_props() |
|
| 37 | + { |
|
| 38 | + $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
| 39 | + $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
| 40 | + $this->_shortcodes = array( |
|
| 41 | + '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
| 42 | + '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
| 43 | + '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
| 44 | + '[VENUE_DETAILS_URL]' => sprintf( |
|
| 45 | + esc_html__( |
|
| 46 | + 'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.', |
|
| 47 | + 'event_espresso' |
|
| 48 | + ), |
|
| 49 | + '[VENUE_URL]' |
|
| 50 | + ), |
|
| 51 | + '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
| 52 | + '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
| 53 | + '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
| 54 | + '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
| 55 | + '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
| 56 | + '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
| 57 | + '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
| 58 | + '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
| 59 | + 'This just outputs the venue address in a semantic address format.', |
|
| 60 | + 'event_espresso' |
|
| 61 | + ), |
|
| 62 | + '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
| 63 | + '[VENUE_META_*]' => esc_html__( |
|
| 64 | + 'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the venue then it will be output in place of this shortcode.', |
|
| 65 | + 'event_espresso' |
|
| 66 | + ), |
|
| 67 | + '[GOOGLE_MAP_URL]' => esc_html__( |
|
| 68 | + 'URL for the google map associated with the venue.', |
|
| 69 | + 'event_espresso' |
|
| 70 | + ), |
|
| 71 | + '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
| 72 | + '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Parse incoming shortcode |
|
| 79 | + * |
|
| 80 | + * @param string $shortcode |
|
| 81 | + * @return string |
|
| 82 | + * @throws EE_Error |
|
| 83 | + * @throws EntityNotFoundException |
|
| 84 | + */ |
|
| 85 | + protected function _parser($shortcode) |
|
| 86 | + { |
|
| 87 | + $this->_venue = $this->_get_venue(); |
|
| 88 | + // If there is no venue object by now then get out. |
|
| 89 | + if (! $this->_venue instanceof EE_Venue) { |
|
| 90 | + return ''; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + switch ($shortcode) { |
|
| 94 | + case '[VENUE_TITLE]': |
|
| 95 | + return $this->_venue('title'); |
|
| 96 | + |
|
| 97 | + case '[VENUE_DESCRIPTION]': |
|
| 98 | + return $this->_venue('description'); |
|
| 99 | + |
|
| 100 | + case '[VENUE_URL]': |
|
| 101 | + return $this->_venue('url'); |
|
| 102 | + |
|
| 103 | + case '[VENUE_IMAGE]': |
|
| 104 | + return $this->_venue('image'); |
|
| 105 | + |
|
| 106 | + case '[VENUE_PHONE]': |
|
| 107 | + return $this->_venue('phone'); |
|
| 108 | + |
|
| 109 | + case '[VENUE_ADDRESS]': |
|
| 110 | + return $this->_venue('address'); |
|
| 111 | + |
|
| 112 | + case '[VENUE_ADDRESS2]': |
|
| 113 | + return $this->_venue('address2'); |
|
| 114 | + |
|
| 115 | + case '[VENUE_CITY]': |
|
| 116 | + return $this->_venue('city'); |
|
| 117 | + |
|
| 118 | + case '[VENUE_COUNTRY]': |
|
| 119 | + return $this->_venue('country'); |
|
| 120 | + |
|
| 121 | + case '[VENUE_STATE]': |
|
| 122 | + return $this->_venue('state'); |
|
| 123 | + |
|
| 124 | + case '[VENUE_ZIP]': |
|
| 125 | + return $this->_venue('zip'); |
|
| 126 | + |
|
| 127 | + case '[VENUE_FORMATTED_ADDRESS]': |
|
| 128 | + return $this->_venue('formatted_address'); |
|
| 129 | + |
|
| 130 | + case '[GOOGLE_MAP_URL]': |
|
| 131 | + return $this->_venue('gmap_url'); |
|
| 132 | + |
|
| 133 | + case '[GOOGLE_MAP_LINK]': |
|
| 134 | + return $this->_venue('gmap_link'); |
|
| 135 | + |
|
| 136 | + case '[GOOGLE_MAP_IMAGE]': |
|
| 137 | + return $this->_venue('gmap_link_img'); |
|
| 138 | + |
|
| 139 | + case '[VENUE_DETAILS_URL]': |
|
| 140 | + return $this->_venue('permalink'); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + if (strpos($shortcode, '[VENUE_META_*') !== false) { |
|
| 144 | + $shortcode = str_replace('[VENUE_META_*', '', $shortcode); |
|
| 145 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
| 146 | + |
|
| 147 | + // pull the meta value from the venue post |
|
| 148 | + $venue_meta = $this->_venue->get_post_meta($shortcode, true); |
|
| 149 | + |
|
| 150 | + return ! empty($venue_meta) ? $venue_meta : ''; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * This retrieves the EE_Venue from the available data object. |
|
| 156 | + * |
|
| 157 | + * @return EE_Venue|null |
|
| 158 | + * @throws EE_Error |
|
| 159 | + * @throws EntityNotFoundException |
|
| 160 | + */ |
|
| 161 | + private function _get_venue() |
|
| 162 | + { |
|
| 163 | + |
|
| 164 | + // we need the EE_Event object to get the venue. |
|
| 165 | + $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
| 166 | + |
|
| 167 | + // if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the |
|
| 168 | + // reg_obj instead. |
|
| 169 | + if (! $this->_event instanceof EE_Event) { |
|
| 170 | + $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
| 171 | + $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
| 172 | + |
|
| 173 | + $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
| 174 | + ? $aee->reg_obj->event() |
|
| 175 | + : null; |
|
| 176 | + |
|
| 177 | + // if still empty do we have a ticket data item? |
|
| 178 | + $this->_event = ! $this->_event instanceof EE_Event |
|
| 179 | + && $this->_data instanceof EE_Ticket |
|
| 180 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
| 181 | + ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
| 182 | + : $this->_event; |
|
| 183 | + |
|
| 184 | + // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
|
| 185 | + // and use that. |
|
| 186 | + $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee |
|
| 187 | + ? reset($aee->events) |
|
| 188 | + : $this->_event; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + // If we have an event object use it to pull the venue. |
|
| 192 | + if ($this->_event instanceof EE_Event) { |
|
| 193 | + return $this->_event->get_first_related('Venue'); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + return null; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * This retrieves the specified venue information |
|
| 201 | + * |
|
| 202 | + * @param string $field What Venue field to retrieve |
|
| 203 | + * @return string What was retrieved! |
|
| 204 | + * @throws EE_Error |
|
| 205 | + * @throws EntityNotFoundException |
|
| 206 | + */ |
|
| 207 | + private function _venue($field) |
|
| 208 | + { |
|
| 209 | + |
|
| 210 | + if (! $this->_venue instanceof EE_Venue) { |
|
| 211 | + return ''; |
|
| 212 | + } //no venue so get out. |
|
| 213 | + |
|
| 214 | + switch ($field) { |
|
| 215 | + case 'title': |
|
| 216 | + return $this->_venue->get('VNU_name'); |
|
| 217 | + break; |
|
| 218 | + |
|
| 219 | + case 'description': |
|
| 220 | + return $this->_venue->get('VNU_desc'); |
|
| 221 | + break; |
|
| 222 | + |
|
| 223 | + case 'url': |
|
| 224 | + $url = $this->_venue->get('VNU_url'); |
|
| 225 | + return empty($url) ? $this->_venue->get_permalink() : $url; |
|
| 226 | + break; |
|
| 227 | + |
|
| 228 | + case 'permalink': |
|
| 229 | + return $this->_venue->get_permalink(); |
|
| 230 | + break; |
|
| 231 | + |
|
| 232 | + case 'image': |
|
| 233 | + return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
| 234 | + . '" alt="' . sprintf( |
|
| 235 | + esc_attr__('%s Feature Image', 'event_espresso'), |
|
| 236 | + $this->_venue->get('VNU_name') |
|
| 237 | + ) . '" />'; |
|
| 238 | + break; |
|
| 239 | + |
|
| 240 | + case 'phone': |
|
| 241 | + return $this->_venue->get('VNU_phone'); |
|
| 242 | + break; |
|
| 243 | + |
|
| 244 | + case 'address': |
|
| 245 | + return $this->_venue->get('VNU_address'); |
|
| 246 | + break; |
|
| 247 | + |
|
| 248 | + case 'address2': |
|
| 249 | + return $this->_venue->get('VNU_address2'); |
|
| 250 | + break; |
|
| 251 | + |
|
| 252 | + case 'city': |
|
| 253 | + return $this->_venue->get('VNU_city'); |
|
| 254 | + break; |
|
| 255 | + |
|
| 256 | + case 'state': |
|
| 257 | + $state = $this->_venue->state_obj(); |
|
| 258 | + return is_object($state) ? $state->get('STA_name') : ''; |
|
| 259 | + break; |
|
| 260 | + |
|
| 261 | + case 'country': |
|
| 262 | + $country = $this->_venue->country_obj(); |
|
| 263 | + return is_object($country) ? $country->get('CNT_name') : ''; |
|
| 264 | + break; |
|
| 265 | + |
|
| 266 | + case 'zip': |
|
| 267 | + return $this->_venue->get('VNU_zip'); |
|
| 268 | + break; |
|
| 269 | + |
|
| 270 | + case 'formatted_address': |
|
| 271 | + return EEH_Address::format($this->_venue); |
|
| 272 | + break; |
|
| 273 | + |
|
| 274 | + case 'gmap_link': |
|
| 275 | + case 'gmap_url': |
|
| 276 | + case 'gmap_link_img': |
|
| 277 | + $atts = $this->get_map_attributes($this->_venue, $field); |
|
| 278 | + return EEH_Maps::google_map_link($atts); |
|
| 279 | + break; |
|
| 280 | + } |
|
| 281 | + return ''; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * Generates the attributes for retrieving a google_map artifact. |
|
| 287 | + * |
|
| 288 | + * @param EE_Venue $venue |
|
| 289 | + * @param string $field |
|
| 290 | + * @return array |
|
| 291 | + * @throws EE_Error |
|
| 292 | + */ |
|
| 293 | + protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
| 294 | + { |
|
| 295 | + $state = $venue->state_obj(); |
|
| 296 | + $country = $venue->country_obj(); |
|
| 297 | + $atts = array( |
|
| 298 | + 'id' => $venue->ID(), |
|
| 299 | + 'address' => $venue->get('VNU_address'), |
|
| 300 | + 'city' => $venue->get('VNU_city'), |
|
| 301 | + 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
| 302 | + 'zip' => $venue->get('VNU_zip'), |
|
| 303 | + 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
| 304 | + 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
| 305 | + 'map_w' => 200, |
|
| 306 | + 'map_h' => 200, |
|
| 307 | + ); |
|
| 308 | + if ($field === 'gmap_url') { |
|
| 309 | + $atts['type'] = 'url_only'; |
|
| 310 | + } |
|
| 311 | + return $atts; |
|
| 312 | + } |
|
| 313 | 313 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | protected function _parser($shortcode) |
| 50 | 50 | { |
| 51 | 51 | // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
| 52 | - if (! $this->_data instanceof EE_Payment) { |
|
| 52 | + if ( ! $this->_data instanceof EE_Payment) { |
|
| 53 | 53 | return ''; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -16,87 +16,87 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class EE_Payment_Shortcodes extends EE_Shortcodes |
| 18 | 18 | { |
| 19 | - protected function _init_props() |
|
| 20 | - { |
|
| 21 | - $this->label = esc_html__('Payment Shortcodes', 'event_espresso'); |
|
| 22 | - $this->description = esc_html__('All shortcodes specific to payments.', 'event_espresso'); |
|
| 23 | - $this->_shortcodes = array( |
|
| 24 | - '[PAYMENT_TIMESTAMP]' => esc_html__( |
|
| 25 | - 'Outputs the date of the payment (using the default date format).', |
|
| 26 | - 'event_espresso' |
|
| 27 | - ), |
|
| 28 | - '[PAYMENT_METHOD]' => esc_html__('Outputs a the payment method.', 'event_espresso'), |
|
| 29 | - '[PAYMENT_AMOUNT]' => esc_html__('Outputs the payment amount (with currency symbol).', 'event_espresso'), |
|
| 30 | - '[PAYMENT_GATEWAY]' => esc_html__('Outputs the gateway used for the payment.', 'event_espresso'), |
|
| 31 | - '[PAYMENT_GATEWAY_RESPONSE]' => esc_html__('Outputs the payment gateway response.', 'event_espresso'), |
|
| 32 | - '[PAYMENT_GATEWAY_TXN_ID]' => esc_html__( |
|
| 33 | - 'This will either be the gateway transaction ID, or the manual ID added with payment applied via the admin.', |
|
| 34 | - 'event_espresso' |
|
| 35 | - ), |
|
| 36 | - '[PAYMENT_PO_NUMBER]' => esc_html__('Purchase Order number (if present)', 'event_espresso'), |
|
| 37 | - '[PAYMENT_EXTRA_ACCOUNTING]' => esc_html__( |
|
| 38 | - 'Any extra accounting messages. Typically added with payments made via the admin.', |
|
| 39 | - 'event_espresso' |
|
| 40 | - ), |
|
| 41 | - '[PAYMENT_STATUS]' => esc_html__('The status of the payment.', 'event_espresso'), |
|
| 42 | - // '[PAYMENT_STATUS_WITH_ICONS]' => esc_html__('The status of the payment including icons representing the status.', 'event_espresso') |
|
| 43 | - ); |
|
| 44 | - } |
|
| 19 | + protected function _init_props() |
|
| 20 | + { |
|
| 21 | + $this->label = esc_html__('Payment Shortcodes', 'event_espresso'); |
|
| 22 | + $this->description = esc_html__('All shortcodes specific to payments.', 'event_espresso'); |
|
| 23 | + $this->_shortcodes = array( |
|
| 24 | + '[PAYMENT_TIMESTAMP]' => esc_html__( |
|
| 25 | + 'Outputs the date of the payment (using the default date format).', |
|
| 26 | + 'event_espresso' |
|
| 27 | + ), |
|
| 28 | + '[PAYMENT_METHOD]' => esc_html__('Outputs a the payment method.', 'event_espresso'), |
|
| 29 | + '[PAYMENT_AMOUNT]' => esc_html__('Outputs the payment amount (with currency symbol).', 'event_espresso'), |
|
| 30 | + '[PAYMENT_GATEWAY]' => esc_html__('Outputs the gateway used for the payment.', 'event_espresso'), |
|
| 31 | + '[PAYMENT_GATEWAY_RESPONSE]' => esc_html__('Outputs the payment gateway response.', 'event_espresso'), |
|
| 32 | + '[PAYMENT_GATEWAY_TXN_ID]' => esc_html__( |
|
| 33 | + 'This will either be the gateway transaction ID, or the manual ID added with payment applied via the admin.', |
|
| 34 | + 'event_espresso' |
|
| 35 | + ), |
|
| 36 | + '[PAYMENT_PO_NUMBER]' => esc_html__('Purchase Order number (if present)', 'event_espresso'), |
|
| 37 | + '[PAYMENT_EXTRA_ACCOUNTING]' => esc_html__( |
|
| 38 | + 'Any extra accounting messages. Typically added with payments made via the admin.', |
|
| 39 | + 'event_espresso' |
|
| 40 | + ), |
|
| 41 | + '[PAYMENT_STATUS]' => esc_html__('The status of the payment.', 'event_espresso'), |
|
| 42 | + // '[PAYMENT_STATUS_WITH_ICONS]' => esc_html__('The status of the payment including icons representing the status.', 'event_espresso') |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @param string $shortcode |
|
| 49 | - * @throws EE_Error |
|
| 50 | - * @throws ReflectionException |
|
| 51 | - */ |
|
| 52 | - protected function _parser($shortcode) |
|
| 53 | - { |
|
| 54 | - // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
| 55 | - if (! $this->_data instanceof EE_Payment) { |
|
| 56 | - return ''; |
|
| 57 | - } |
|
| 47 | + /** |
|
| 48 | + * @param string $shortcode |
|
| 49 | + * @throws EE_Error |
|
| 50 | + * @throws ReflectionException |
|
| 51 | + */ |
|
| 52 | + protected function _parser($shortcode) |
|
| 53 | + { |
|
| 54 | + // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
| 55 | + if (! $this->_data instanceof EE_Payment) { |
|
| 56 | + return ''; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $payment = $this->_data; |
|
| 59 | + $payment = $this->_data; |
|
| 60 | 60 | |
| 61 | - switch ($shortcode) { |
|
| 62 | - case '[PAYMENT_TIMESTAMP]': |
|
| 63 | - return $payment->timestamp(); |
|
| 61 | + switch ($shortcode) { |
|
| 62 | + case '[PAYMENT_TIMESTAMP]': |
|
| 63 | + return $payment->timestamp(); |
|
| 64 | 64 | |
| 65 | - case '[PAYMENT_METHOD]': |
|
| 66 | - // previously the column 'PAY_source' was known as 'PAY_method' |
|
| 67 | - return $payment->source(); |
|
| 65 | + case '[PAYMENT_METHOD]': |
|
| 66 | + // previously the column 'PAY_source' was known as 'PAY_method' |
|
| 67 | + return $payment->source(); |
|
| 68 | 68 | |
| 69 | - case '[PAYMENT_AMOUNT]': |
|
| 70 | - return $payment->amount_no_code(); |
|
| 69 | + case '[PAYMENT_AMOUNT]': |
|
| 70 | + return $payment->amount_no_code(); |
|
| 71 | 71 | |
| 72 | - case '[PAYMENT_GATEWAY]': |
|
| 73 | - // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
| 74 | - if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
| 75 | - return $payment->payment_method()->name(); |
|
| 76 | - } else { |
|
| 77 | - return esc_html__('Unknown', 'event_espresso'); |
|
| 78 | - } |
|
| 72 | + case '[PAYMENT_GATEWAY]': |
|
| 73 | + // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
| 74 | + if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
| 75 | + return $payment->payment_method()->name(); |
|
| 76 | + } else { |
|
| 77 | + return esc_html__('Unknown', 'event_espresso'); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - case '[PAYMENT_GATEWAY_RESPONSE]': |
|
| 81 | - return $payment->gateway_response(); |
|
| 80 | + case '[PAYMENT_GATEWAY_RESPONSE]': |
|
| 81 | + return $payment->gateway_response(); |
|
| 82 | 82 | |
| 83 | - case '[PAYMENT_GATEWAY_TXN_ID]': |
|
| 84 | - return $payment->txn_id_chq_nmbr(); |
|
| 83 | + case '[PAYMENT_GATEWAY_TXN_ID]': |
|
| 84 | + return $payment->txn_id_chq_nmbr(); |
|
| 85 | 85 | |
| 86 | - case '[PAYMENT_PO_NUMBER]': |
|
| 87 | - return $payment->po_number(); |
|
| 86 | + case '[PAYMENT_PO_NUMBER]': |
|
| 87 | + return $payment->po_number(); |
|
| 88 | 88 | |
| 89 | - case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
| 90 | - return $payment->extra_accntng(); |
|
| 89 | + case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
| 90 | + return $payment->extra_accntng(); |
|
| 91 | 91 | |
| 92 | - case '[PAYMENT_STATUS]': |
|
| 93 | - return $payment->pretty_status(); |
|
| 92 | + case '[PAYMENT_STATUS]': |
|
| 93 | + return $payment->pretty_status(); |
|
| 94 | 94 | |
| 95 | - case '[PAYMENT_STATUS_WITH_ICONS]': |
|
| 96 | - return $payment->pretty_status(true); |
|
| 95 | + case '[PAYMENT_STATUS_WITH_ICONS]': |
|
| 96 | + return $payment->pretty_status(true); |
|
| 97 | 97 | |
| 98 | - default: |
|
| 99 | - return ''; |
|
| 100 | - } |
|
| 101 | - } |
|
| 98 | + default: |
|
| 99 | + return ''; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | } |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | $key_begin_range = $january_is_month_1 ? 1 : 0; |
| 20 | 20 | $key_range = range($key_begin_range, $key_begin_range + 11); |
| 21 | 21 | if ($leading_zero) { |
| 22 | - array_walk($key_range, array( $this, '_zero_pad' )); |
|
| 22 | + array_walk($key_range, array($this, '_zero_pad')); |
|
| 23 | 23 | } |
| 24 | 24 | $value_range = range(1, 12); |
| 25 | - array_walk($value_range, array( $this, '_zero_pad' )); |
|
| 25 | + array_walk($value_range, array($this, '_zero_pad')); |
|
| 26 | 26 | parent::__construct( |
| 27 | 27 | array_combine( |
| 28 | 28 | $key_range, |
@@ -9,36 +9,36 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_Month_Input extends EE_Select_Input |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * @param bool $leading_zero |
|
| 14 | - * @param array $input_settings |
|
| 15 | - * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0 |
|
| 16 | - */ |
|
| 17 | - public function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true) |
|
| 18 | - { |
|
| 19 | - $key_begin_range = $january_is_month_1 ? 1 : 0; |
|
| 20 | - $key_range = range($key_begin_range, $key_begin_range + 11); |
|
| 21 | - if ($leading_zero) { |
|
| 22 | - array_walk($key_range, array( $this, '_zero_pad' )); |
|
| 23 | - } |
|
| 24 | - $value_range = range(1, 12); |
|
| 25 | - array_walk($value_range, array( $this, '_zero_pad' )); |
|
| 26 | - parent::__construct( |
|
| 27 | - array_combine( |
|
| 28 | - $key_range, |
|
| 29 | - $value_range |
|
| 30 | - ), |
|
| 31 | - $input_settings |
|
| 32 | - ); |
|
| 33 | - } |
|
| 12 | + /** |
|
| 13 | + * @param bool $leading_zero |
|
| 14 | + * @param array $input_settings |
|
| 15 | + * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0 |
|
| 16 | + */ |
|
| 17 | + public function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true) |
|
| 18 | + { |
|
| 19 | + $key_begin_range = $january_is_month_1 ? 1 : 0; |
|
| 20 | + $key_range = range($key_begin_range, $key_begin_range + 11); |
|
| 21 | + if ($leading_zero) { |
|
| 22 | + array_walk($key_range, array( $this, '_zero_pad' )); |
|
| 23 | + } |
|
| 24 | + $value_range = range(1, 12); |
|
| 25 | + array_walk($value_range, array( $this, '_zero_pad' )); |
|
| 26 | + parent::__construct( |
|
| 27 | + array_combine( |
|
| 28 | + $key_range, |
|
| 29 | + $value_range |
|
| 30 | + ), |
|
| 31 | + $input_settings |
|
| 32 | + ); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Changes int 1 to 01, etc. Useful with array_walk |
|
| 37 | - * @param int $input |
|
| 38 | - * @param mixed $key |
|
| 39 | - */ |
|
| 40 | - protected function _zero_pad(&$input, $key) |
|
| 41 | - { |
|
| 42 | - $input = str_pad($input, 2, '0', STR_PAD_LEFT); |
|
| 43 | - } |
|
| 35 | + /** |
|
| 36 | + * Changes int 1 to 01, etc. Useful with array_walk |
|
| 37 | + * @param int $input |
|
| 38 | + * @param mixed $key |
|
| 39 | + */ |
|
| 40 | + protected function _zero_pad(&$input, $key) |
|
| 41 | + { |
|
| 42 | + $input = str_pad($input, 2, '0', STR_PAD_LEFT); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -55,11 +55,11 @@ |
||
| 55 | 55 | $select_options = array(); |
| 56 | 56 | foreach ($answer_options as $model_obj) { |
| 57 | 57 | if ($this->_naming_method) { |
| 58 | - $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
| 58 | + $display_value = call_user_func(array($model_obj, $this->_naming_method)); |
|
| 59 | 59 | } else { |
| 60 | 60 | $display_value = $model_obj->name(); |
| 61 | 61 | } |
| 62 | - $select_options[ $model_obj->ID() ] = $display_value; |
|
| 62 | + $select_options[$model_obj->ID()] = $display_value; |
|
| 63 | 63 | } |
| 64 | 64 | parent::set_select_options($select_options); |
| 65 | 65 | } |
@@ -11,75 +11,75 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class EE_Select_Multi_Model_Input extends EE_Select_Multiple_Input |
| 13 | 13 | { |
| 14 | - protected $_naming_method; |
|
| 14 | + protected $_naming_method; |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * |
|
| 20 | - * @param EE_Base_Class[] $answer_options |
|
| 21 | - * @param array $input_settings { |
|
| 22 | - * @var EE_Base_Class[] or array $default |
|
| 23 | - * @var string $naming_method function name on the class which will be used for getting the displayed-name. |
|
| 24 | - * example: if the class were an EE_Event, this could be slug(), description(), name() (default) |
|
| 25 | - * } |
|
| 26 | - */ |
|
| 27 | - public function __construct($answer_options = array(), $input_settings = array()) |
|
| 28 | - { |
|
| 29 | - if (isset($input_settings['naming_method'])) { |
|
| 30 | - $this->set_option_naming_method($input_settings['naming_method']); |
|
| 31 | - } |
|
| 32 | - parent::__construct($answer_options, $input_settings); |
|
| 33 | - } |
|
| 18 | + /** |
|
| 19 | + * |
|
| 20 | + * @param EE_Base_Class[] $answer_options |
|
| 21 | + * @param array $input_settings { |
|
| 22 | + * @var EE_Base_Class[] or array $default |
|
| 23 | + * @var string $naming_method function name on the class which will be used for getting the displayed-name. |
|
| 24 | + * example: if the class were an EE_Event, this could be slug(), description(), name() (default) |
|
| 25 | + * } |
|
| 26 | + */ |
|
| 27 | + public function __construct($answer_options = array(), $input_settings = array()) |
|
| 28 | + { |
|
| 29 | + if (isset($input_settings['naming_method'])) { |
|
| 30 | + $this->set_option_naming_method($input_settings['naming_method']); |
|
| 31 | + } |
|
| 32 | + parent::__construct($answer_options, $input_settings); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Sets the method name which will be called when outputting the options list |
|
| 37 | - * @param string $method |
|
| 38 | - */ |
|
| 39 | - public function set_option_naming_method($method) |
|
| 40 | - { |
|
| 41 | - $this->_naming_method = $method; |
|
| 42 | - } |
|
| 35 | + /** |
|
| 36 | + * Sets the method name which will be called when outputting the options list |
|
| 37 | + * @param string $method |
|
| 38 | + */ |
|
| 39 | + public function set_option_naming_method($method) |
|
| 40 | + { |
|
| 41 | + $this->_naming_method = $method; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * You CAN pass an array of model objects instead of simple values for teh options |
|
| 48 | - * @param EE_Base_Class[] $answer_options |
|
| 49 | - * @return null|void |
|
| 50 | - */ |
|
| 51 | - public function set_select_options($answer_options = array()) |
|
| 52 | - { |
|
| 53 | - // convert the model objects to select from into normal select options |
|
| 54 | - $select_options = array(); |
|
| 55 | - foreach ($answer_options as $model_obj) { |
|
| 56 | - if ($this->_naming_method) { |
|
| 57 | - $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
| 58 | - } else { |
|
| 59 | - $display_value = $model_obj->name(); |
|
| 60 | - } |
|
| 61 | - $select_options[ $model_obj->ID() ] = $display_value; |
|
| 62 | - } |
|
| 63 | - parent::set_select_options($select_options); |
|
| 64 | - } |
|
| 46 | + /** |
|
| 47 | + * You CAN pass an array of model objects instead of simple values for teh options |
|
| 48 | + * @param EE_Base_Class[] $answer_options |
|
| 49 | + * @return null|void |
|
| 50 | + */ |
|
| 51 | + public function set_select_options($answer_options = array()) |
|
| 52 | + { |
|
| 53 | + // convert the model objects to select from into normal select options |
|
| 54 | + $select_options = array(); |
|
| 55 | + foreach ($answer_options as $model_obj) { |
|
| 56 | + if ($this->_naming_method) { |
|
| 57 | + $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
| 58 | + } else { |
|
| 59 | + $display_value = $model_obj->name(); |
|
| 60 | + } |
|
| 61 | + $select_options[ $model_obj->ID() ] = $display_value; |
|
| 62 | + } |
|
| 63 | + parent::set_select_options($select_options); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * if they passed in an array of model objects for the default, convert it |
|
| 70 | - * into the format EE_Select_Multiple expects |
|
| 71 | - * @param EE_Base_Class[]|array $values |
|
| 72 | - */ |
|
| 73 | - public function set_default($values) |
|
| 74 | - { |
|
| 75 | - $defaults_as_simple_ids = array(); |
|
| 76 | - foreach ($values as $key => $value) { |
|
| 77 | - if ($value instanceof EE_Base_Class) { |
|
| 78 | - $defaults_as_simple_ids[] = $value->ID(); |
|
| 79 | - } else { |
|
| 80 | - $defaults_as_simple_ids[] = $value; |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - parent::set_default($defaults_as_simple_ids); |
|
| 84 | - } |
|
| 68 | + /** |
|
| 69 | + * if they passed in an array of model objects for the default, convert it |
|
| 70 | + * into the format EE_Select_Multiple expects |
|
| 71 | + * @param EE_Base_Class[]|array $values |
|
| 72 | + */ |
|
| 73 | + public function set_default($values) |
|
| 74 | + { |
|
| 75 | + $defaults_as_simple_ids = array(); |
|
| 76 | + foreach ($values as $key => $value) { |
|
| 77 | + if ($value instanceof EE_Base_Class) { |
|
| 78 | + $defaults_as_simple_ids[] = $value->ID(); |
|
| 79 | + } else { |
|
| 80 | + $defaults_as_simple_ids[] = $value; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + parent::set_default($defaults_as_simple_ids); |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | public function __construct($answer_options, $input_settings = array()) |
| 17 | 17 | { |
| 18 | 18 | $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
| 19 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
| 19 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null)))); |
|
| 20 | 20 | $this->_multiple_selections = true; |
| 21 | 21 | parent::__construct($answer_options, $input_settings); |
| 22 | 22 | } |
@@ -9,15 +9,15 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_Select_Multiple_Input extends EE_Form_Input_With_Options_Base |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * @param array | EE_Question_Option[] $answer_options |
|
| 14 | - * @param array $input_settings |
|
| 15 | - */ |
|
| 16 | - public function __construct($answer_options, $input_settings = array()) |
|
| 17 | - { |
|
| 18 | - $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
|
| 19 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
| 20 | - $this->_multiple_selections = true; |
|
| 21 | - parent::__construct($answer_options, $input_settings); |
|
| 22 | - } |
|
| 12 | + /** |
|
| 13 | + * @param array | EE_Question_Option[] $answer_options |
|
| 14 | + * @param array $input_settings |
|
| 15 | + */ |
|
| 16 | + public function __construct($answer_options, $input_settings = array()) |
|
| 17 | + { |
|
| 18 | + $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
|
| 19 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
| 20 | + $this->_multiple_selections = true; |
|
| 21 | + parent::__construct($answer_options, $input_settings); |
|
| 22 | + } |
|
| 23 | 23 | } |