@@ -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 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | protected function _parser($shortcode) |
43 | 43 | { |
44 | 44 | // ensure that the incoming object IS a line item. If it isn't then bail early. |
45 | - if (! $this->_data instanceof EE_Line_Item) { |
|
45 | + if ( ! $this->_data instanceof EE_Line_Item) { |
|
46 | 46 | return ''; |
47 | 47 | } |
48 | 48 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | break; |
63 | 63 | |
64 | 64 | case '[LINE_ITEM_AMOUNT]': |
65 | - return $line_item->is_percent() ? $line_item->percent() . '%' : $line_item->unit_price_no_code(); |
|
65 | + return $line_item->is_percent() ? $line_item->percent().'%' : $line_item->unit_price_no_code(); |
|
66 | 66 | break; |
67 | 67 | |
68 | 68 | case '[LINE_ITEM_TOTAL]': |
@@ -16,65 +16,65 @@ |
||
16 | 16 | */ |
17 | 17 | class EE_Line_Item_Shortcodes extends EE_Shortcodes |
18 | 18 | { |
19 | - protected function _init_props() |
|
20 | - { |
|
21 | - $this->label = esc_html__('Line Item Shortcodes', 'event_espresso'); |
|
22 | - $this->description = esc_html__('All shortcodes specific to line items', 'event_espresso'); |
|
23 | - $this->_shortcodes = array( |
|
24 | - '[LINE_ITEM_NAME]' => esc_html__('Outputs the line item name.', 'event_espresso'), |
|
25 | - '[LINE_ITEM_DESCRIPTION]' => esc_html__('Outputs a the description for the line item.', 'event_espresso'), |
|
26 | - '[LINE_ITEM_QUANTITY]' => esc_html__('Outputs the quantity for this line item.', 'event_espresso'), |
|
27 | - '[LINE_ITEM_AMOUNT]' => esc_html__( |
|
28 | - 'This will either output the unit price for a line item if its not a percent, or the percent of the line item (if it is percent).', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - '[LINE_ITEM_TOTAL]' => esc_html__('This outputs the line item total.', 'event_espresso'), |
|
32 | - '[LINE_ITEM_TAXABLE_*]' => esc_html__( |
|
33 | - 'This attribute type shortcode allows users to indicate what to output if a line item is taxable or not. One can use the key "symbol=" with the shortcode to indicate what they\'d like to represent a taxable line item. So doing something like <code>[LINE_ITEM_TAXABLE_* symbol="*"]</code> means that when the line item is parsed, if it\'s taxable the "*" symbol will be returned. The default symbol if no attribute is included is the "*" symbol.', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - ); |
|
37 | - } |
|
19 | + protected function _init_props() |
|
20 | + { |
|
21 | + $this->label = esc_html__('Line Item Shortcodes', 'event_espresso'); |
|
22 | + $this->description = esc_html__('All shortcodes specific to line items', 'event_espresso'); |
|
23 | + $this->_shortcodes = array( |
|
24 | + '[LINE_ITEM_NAME]' => esc_html__('Outputs the line item name.', 'event_espresso'), |
|
25 | + '[LINE_ITEM_DESCRIPTION]' => esc_html__('Outputs a the description for the line item.', 'event_espresso'), |
|
26 | + '[LINE_ITEM_QUANTITY]' => esc_html__('Outputs the quantity for this line item.', 'event_espresso'), |
|
27 | + '[LINE_ITEM_AMOUNT]' => esc_html__( |
|
28 | + 'This will either output the unit price for a line item if its not a percent, or the percent of the line item (if it is percent).', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + '[LINE_ITEM_TOTAL]' => esc_html__('This outputs the line item total.', 'event_espresso'), |
|
32 | + '[LINE_ITEM_TAXABLE_*]' => esc_html__( |
|
33 | + 'This attribute type shortcode allows users to indicate what to output if a line item is taxable or not. One can use the key "symbol=" with the shortcode to indicate what they\'d like to represent a taxable line item. So doing something like <code>[LINE_ITEM_TAXABLE_* symbol="*"]</code> means that when the line item is parsed, if it\'s taxable the "*" symbol will be returned. The default symbol if no attribute is included is the "*" symbol.', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + ); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - protected function _parser($shortcode) |
|
41 | - { |
|
42 | - // ensure that the incoming object IS a line item. If it isn't then bail early. |
|
43 | - if (! $this->_data instanceof EE_Line_Item) { |
|
44 | - return ''; |
|
45 | - } |
|
40 | + protected function _parser($shortcode) |
|
41 | + { |
|
42 | + // ensure that the incoming object IS a line item. If it isn't then bail early. |
|
43 | + if (! $this->_data instanceof EE_Line_Item) { |
|
44 | + return ''; |
|
45 | + } |
|
46 | 46 | |
47 | - $line_item = $this->_data; |
|
47 | + $line_item = $this->_data; |
|
48 | 48 | |
49 | - switch ($shortcode) { |
|
50 | - case '[LINE_ITEM_NAME]': |
|
51 | - return $line_item->name(); |
|
52 | - break; |
|
49 | + switch ($shortcode) { |
|
50 | + case '[LINE_ITEM_NAME]': |
|
51 | + return $line_item->name(); |
|
52 | + break; |
|
53 | 53 | |
54 | - case '[LINE_ITEM_DESCRIPTION]': |
|
55 | - return $line_item->desc(); |
|
56 | - break; |
|
54 | + case '[LINE_ITEM_DESCRIPTION]': |
|
55 | + return $line_item->desc(); |
|
56 | + break; |
|
57 | 57 | |
58 | - case '[LINE_ITEM_QUANTITY]': |
|
59 | - return $line_item->quantity(); |
|
60 | - break; |
|
58 | + case '[LINE_ITEM_QUANTITY]': |
|
59 | + return $line_item->quantity(); |
|
60 | + break; |
|
61 | 61 | |
62 | - case '[LINE_ITEM_AMOUNT]': |
|
63 | - return $line_item->is_percent() ? $line_item->percent() . '%' : $line_item->unit_price_no_code(); |
|
64 | - break; |
|
62 | + case '[LINE_ITEM_AMOUNT]': |
|
63 | + return $line_item->is_percent() ? $line_item->percent() . '%' : $line_item->unit_price_no_code(); |
|
64 | + break; |
|
65 | 65 | |
66 | - case '[LINE_ITEM_TOTAL]': |
|
67 | - return $line_item->total_no_code(); |
|
68 | - break; |
|
69 | - } |
|
66 | + case '[LINE_ITEM_TOTAL]': |
|
67 | + return $line_item->total_no_code(); |
|
68 | + break; |
|
69 | + } |
|
70 | 70 | |
71 | - if (strpos($shortcode, '[LINE_ITEM_TAXABLE_*') !== false) { |
|
72 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
73 | - if ($line_item->is_taxable()) { |
|
74 | - return ! empty($attrs['symbol']) ? $attrs['symbol'] : '*'; |
|
75 | - } |
|
76 | - } |
|
71 | + if (strpos($shortcode, '[LINE_ITEM_TAXABLE_*') !== false) { |
|
72 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
73 | + if ($line_item->is_taxable()) { |
|
74 | + return ! empty($attrs['symbol']) ? $attrs['symbol'] : '*'; |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - return ''; |
|
79 | - } |
|
78 | + return ''; |
|
79 | + } |
|
80 | 80 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | protected function _parser($shortcode) |
55 | 55 | { |
56 | 56 | |
57 | - if (! $this->_data instanceof EE_Datetime) { |
|
57 | + if ( ! $this->_data instanceof EE_Datetime) { |
|
58 | 58 | return ''; // get out cause we can only parse with the datetime object. |
59 | 59 | } |
60 | 60 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | $URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $this->_data->ID()), site_url()); |
94 | 94 | |
95 | - return '<a class="ee-ical" href="' . $URL . '">' . $link_text . '</a>'; |
|
95 | + return '<a class="ee-ical" href="'.$URL.'">'.$link_text.'</a>'; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return ''; |
@@ -15,77 +15,77 @@ |
||
15 | 15 | */ |
16 | 16 | class EE_Datetime_Shortcodes extends EE_Shortcodes |
17 | 17 | { |
18 | - /** |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - protected function _init_props() |
|
22 | - { |
|
23 | - $this->label = esc_html__('Datetime Shortcodes', 'event_espresso'); |
|
24 | - $this->description = esc_html__('All shortcodes specific to datetime related data', 'event_espresso'); |
|
25 | - $this->_shortcodes = array( |
|
26 | - '[DATETIME_START]' => esc_html__('The start date and time.', 'event_espresso'), |
|
27 | - '[DATETIME_END]' => esc_html__('The end date and time.', 'event_espresso'), |
|
28 | - '[DATETIME_TIMEZONE]' => esc_html__('The timezone for the date and time', 'event_espresso'), |
|
29 | - '[DATE_START]' => esc_html__('The datetime start date.', 'event_espresso'), |
|
30 | - '[DATE_END]' => esc_html__('The datetime end date.', 'event_espresso'), |
|
31 | - '[TIME_START]' => esc_html__('The datetime start time.', 'event_espresso'), |
|
32 | - '[TIME_END]' => esc_html__('The datetime end time.', 'event_espresso'), |
|
33 | - '[ICAL_LINK_*]' => esc_html__( |
|
34 | - 'The datetime iCal link. The optional "link_text" attribute can be used to set custom text within the link (Default is "Add to iCal Calendar").', |
|
35 | - 'event_espresso' |
|
36 | - ), |
|
37 | - ); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $shortcode |
|
43 | - * @return string |
|
44 | - * @throws EE_Error |
|
45 | - * @throws ReflectionException |
|
46 | - */ |
|
47 | - protected function _parser($shortcode) |
|
48 | - { |
|
49 | - |
|
50 | - if (! $this->_data instanceof EE_Datetime) { |
|
51 | - return ''; // get out cause we can only parse with the datetime object. |
|
52 | - } |
|
53 | - |
|
54 | - switch ($shortcode) { |
|
55 | - case '[DATETIME_START]': |
|
56 | - return $this->_data->get_i18n_datetime('DTT_EVT_start'); |
|
57 | - |
|
58 | - case '[DATETIME_END]': |
|
59 | - return $this->_data->get_i18n_datetime('DTT_EVT_end'); |
|
60 | - |
|
61 | - case '[DATETIME_TIMEZONE]': |
|
62 | - return $this->_data->get_timezone(); |
|
63 | - |
|
64 | - case '[DATE_START]': |
|
65 | - return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('date_format')); |
|
66 | - |
|
67 | - case '[DATE_END]': |
|
68 | - return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('date_format')); |
|
69 | - |
|
70 | - case '[TIME_START]': |
|
71 | - return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('time_format')); |
|
72 | - |
|
73 | - case '[TIME_END]': |
|
74 | - return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('time_format')); |
|
75 | - |
|
76 | - } |
|
77 | - |
|
78 | - if (strpos($shortcode, '[ICAL_LINK_*') !== false) { |
|
79 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
80 | - |
|
81 | - $link_text = empty($attrs['link_text']) ? esc_html__('Add to iCal Calendar', 'event_espresso') |
|
82 | - : $attrs['link_text']; |
|
83 | - |
|
84 | - $URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $this->_data->ID()), site_url()); |
|
85 | - |
|
86 | - return '<a class="ee-ical" href="' . $URL . '">' . $link_text . '</a>'; |
|
87 | - } |
|
88 | - |
|
89 | - return ''; |
|
90 | - } |
|
18 | + /** |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + protected function _init_props() |
|
22 | + { |
|
23 | + $this->label = esc_html__('Datetime Shortcodes', 'event_espresso'); |
|
24 | + $this->description = esc_html__('All shortcodes specific to datetime related data', 'event_espresso'); |
|
25 | + $this->_shortcodes = array( |
|
26 | + '[DATETIME_START]' => esc_html__('The start date and time.', 'event_espresso'), |
|
27 | + '[DATETIME_END]' => esc_html__('The end date and time.', 'event_espresso'), |
|
28 | + '[DATETIME_TIMEZONE]' => esc_html__('The timezone for the date and time', 'event_espresso'), |
|
29 | + '[DATE_START]' => esc_html__('The datetime start date.', 'event_espresso'), |
|
30 | + '[DATE_END]' => esc_html__('The datetime end date.', 'event_espresso'), |
|
31 | + '[TIME_START]' => esc_html__('The datetime start time.', 'event_espresso'), |
|
32 | + '[TIME_END]' => esc_html__('The datetime end time.', 'event_espresso'), |
|
33 | + '[ICAL_LINK_*]' => esc_html__( |
|
34 | + 'The datetime iCal link. The optional "link_text" attribute can be used to set custom text within the link (Default is "Add to iCal Calendar").', |
|
35 | + 'event_espresso' |
|
36 | + ), |
|
37 | + ); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $shortcode |
|
43 | + * @return string |
|
44 | + * @throws EE_Error |
|
45 | + * @throws ReflectionException |
|
46 | + */ |
|
47 | + protected function _parser($shortcode) |
|
48 | + { |
|
49 | + |
|
50 | + if (! $this->_data instanceof EE_Datetime) { |
|
51 | + return ''; // get out cause we can only parse with the datetime object. |
|
52 | + } |
|
53 | + |
|
54 | + switch ($shortcode) { |
|
55 | + case '[DATETIME_START]': |
|
56 | + return $this->_data->get_i18n_datetime('DTT_EVT_start'); |
|
57 | + |
|
58 | + case '[DATETIME_END]': |
|
59 | + return $this->_data->get_i18n_datetime('DTT_EVT_end'); |
|
60 | + |
|
61 | + case '[DATETIME_TIMEZONE]': |
|
62 | + return $this->_data->get_timezone(); |
|
63 | + |
|
64 | + case '[DATE_START]': |
|
65 | + return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('date_format')); |
|
66 | + |
|
67 | + case '[DATE_END]': |
|
68 | + return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('date_format')); |
|
69 | + |
|
70 | + case '[TIME_START]': |
|
71 | + return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('time_format')); |
|
72 | + |
|
73 | + case '[TIME_END]': |
|
74 | + return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('time_format')); |
|
75 | + |
|
76 | + } |
|
77 | + |
|
78 | + if (strpos($shortcode, '[ICAL_LINK_*') !== false) { |
|
79 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
80 | + |
|
81 | + $link_text = empty($attrs['link_text']) ? esc_html__('Add to iCal Calendar', 'event_espresso') |
|
82 | + : $attrs['link_text']; |
|
83 | + |
|
84 | + $URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $this->_data->ID()), site_url()); |
|
85 | + |
|
86 | + return '<a class="ee-ical" href="' . $URL . '">' . $link_text . '</a>'; |
|
87 | + } |
|
88 | + |
|
89 | + return ''; |
|
90 | + } |
|
91 | 91 | } |
@@ -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,315 +15,315 @@ |
||
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 | - break; |
|
97 | - |
|
98 | - case '[VENUE_DESCRIPTION]': |
|
99 | - return $this->_venue('description'); |
|
100 | - break; |
|
101 | - |
|
102 | - case '[VENUE_URL]': |
|
103 | - return $this->_venue('url'); |
|
104 | - break; |
|
105 | - |
|
106 | - case '[VENUE_IMAGE]': |
|
107 | - return $this->_venue('image'); |
|
108 | - break; |
|
109 | - |
|
110 | - case '[VENUE_PHONE]': |
|
111 | - return $this->_venue('phone'); |
|
112 | - break; |
|
113 | - |
|
114 | - case '[VENUE_ADDRESS]': |
|
115 | - return $this->_venue('address'); |
|
116 | - break; |
|
117 | - |
|
118 | - case '[VENUE_ADDRESS2]': |
|
119 | - return $this->_venue('address2'); |
|
120 | - break; |
|
121 | - |
|
122 | - case '[VENUE_CITY]': |
|
123 | - return $this->_venue('city'); |
|
124 | - break; |
|
125 | - |
|
126 | - case '[VENUE_COUNTRY]': |
|
127 | - return $this->_venue('country'); |
|
128 | - break; |
|
129 | - |
|
130 | - case '[VENUE_STATE]': |
|
131 | - return $this->_venue('state'); |
|
132 | - break; |
|
133 | - |
|
134 | - case '[VENUE_ZIP]': |
|
135 | - return $this->_venue('zip'); |
|
136 | - break; |
|
137 | - |
|
138 | - case '[VENUE_FORMATTED_ADDRESS]': |
|
139 | - return $this->_venue('formatted_address'); |
|
140 | - break; |
|
141 | - |
|
142 | - case '[GOOGLE_MAP_URL]': |
|
143 | - return $this->_venue('gmap_url'); |
|
144 | - break; |
|
145 | - |
|
146 | - case '[GOOGLE_MAP_LINK]': |
|
147 | - return $this->_venue('gmap_link'); |
|
148 | - break; |
|
149 | - |
|
150 | - case '[GOOGLE_MAP_IMAGE]': |
|
151 | - return $this->_venue('gmap_link_img'); |
|
152 | - break; |
|
153 | - |
|
154 | - case '[VENUE_DETAILS_URL]': |
|
155 | - return $this->_venue('permalink'); |
|
156 | - break; |
|
157 | - } |
|
158 | - |
|
159 | - if (strpos($shortcode, '[VENUE_META_*') !== false) { |
|
160 | - $shortcode = str_replace('[VENUE_META_*', '', $shortcode); |
|
161 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
162 | - |
|
163 | - // pull the meta value from the venue post |
|
164 | - $venue_meta = $this->_venue->get_post_meta($shortcode, true); |
|
165 | - |
|
166 | - return ! empty($venue_meta) ? $venue_meta : ''; |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * This retrieves the EE_Venue from the available data object. |
|
172 | - * |
|
173 | - * @return EE_Venue|null |
|
174 | - * @throws EE_Error |
|
175 | - * @throws EntityNotFoundException |
|
176 | - */ |
|
177 | - private function _get_venue() |
|
178 | - { |
|
179 | - |
|
180 | - // we need the EE_Event object to get the venue. |
|
181 | - $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
182 | - |
|
183 | - // 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 |
|
184 | - // reg_obj instead. |
|
185 | - if (! $this->_event instanceof EE_Event) { |
|
186 | - $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
187 | - $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
188 | - |
|
189 | - $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
190 | - ? $aee->reg_obj->event() |
|
191 | - : null; |
|
192 | - |
|
193 | - // if still empty do we have a ticket data item? |
|
194 | - $this->_event = ! $this->_event instanceof EE_Event |
|
195 | - && $this->_data instanceof EE_Ticket |
|
196 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
197 | - ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
198 | - : $this->_event; |
|
199 | - |
|
200 | - // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
|
201 | - // and use that. |
|
202 | - $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee |
|
203 | - ? reset($aee->events) |
|
204 | - : $this->_event; |
|
205 | - } |
|
206 | - |
|
207 | - // If we have an event object use it to pull the venue. |
|
208 | - if ($this->_event instanceof EE_Event) { |
|
209 | - return $this->_event->get_first_related('Venue'); |
|
210 | - } |
|
211 | - |
|
212 | - return null; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * This retrieves the specified venue information |
|
217 | - * |
|
218 | - * @param string $field What Venue field to retrieve |
|
219 | - * @return string What was retrieved! |
|
220 | - * @throws EE_Error |
|
221 | - * @throws EntityNotFoundException |
|
222 | - */ |
|
223 | - private function _venue($field) |
|
224 | - { |
|
225 | - |
|
226 | - if (! $this->_venue instanceof EE_Venue) { |
|
227 | - return ''; |
|
228 | - } //no venue so get out. |
|
229 | - |
|
230 | - switch ($field) { |
|
231 | - case 'title': |
|
232 | - return $this->_venue->get('VNU_name'); |
|
233 | - break; |
|
234 | - |
|
235 | - case 'description': |
|
236 | - return $this->_venue->get('VNU_desc'); |
|
237 | - break; |
|
238 | - |
|
239 | - case 'url': |
|
240 | - $url = $this->_venue->get('VNU_url'); |
|
241 | - return empty($url) ? $this->_venue->get_permalink() : $url; |
|
242 | - break; |
|
243 | - |
|
244 | - case 'permalink': |
|
245 | - return $this->_venue->get_permalink(); |
|
246 | - break; |
|
247 | - |
|
248 | - case 'image': |
|
249 | - return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
250 | - . '" alt="' . sprintf( |
|
251 | - esc_attr__('%s Feature Image', 'event_espresso'), |
|
252 | - $this->_venue->get('VNU_name') |
|
253 | - ) . '" />'; |
|
254 | - break; |
|
255 | - |
|
256 | - case 'phone': |
|
257 | - return $this->_venue->get('VNU_phone'); |
|
258 | - break; |
|
259 | - |
|
260 | - case 'address': |
|
261 | - return $this->_venue->get('VNU_address'); |
|
262 | - break; |
|
263 | - |
|
264 | - case 'address2': |
|
265 | - return $this->_venue->get('VNU_address2'); |
|
266 | - break; |
|
267 | - |
|
268 | - case 'city': |
|
269 | - return $this->_venue->get('VNU_city'); |
|
270 | - break; |
|
271 | - |
|
272 | - case 'state': |
|
273 | - $state = $this->_venue->state_obj(); |
|
274 | - return is_object($state) ? $state->get('STA_name') : ''; |
|
275 | - break; |
|
276 | - |
|
277 | - case 'country': |
|
278 | - $country = $this->_venue->country_obj(); |
|
279 | - return is_object($country) ? $country->get('CNT_name') : ''; |
|
280 | - break; |
|
281 | - |
|
282 | - case 'zip': |
|
283 | - return $this->_venue->get('VNU_zip'); |
|
284 | - break; |
|
285 | - |
|
286 | - case 'formatted_address': |
|
287 | - return EEH_Address::format($this->_venue); |
|
288 | - break; |
|
289 | - |
|
290 | - case 'gmap_link': |
|
291 | - case 'gmap_url': |
|
292 | - case 'gmap_link_img': |
|
293 | - $atts = $this->get_map_attributes($this->_venue, $field); |
|
294 | - return EEH_Maps::google_map_link($atts); |
|
295 | - break; |
|
296 | - } |
|
297 | - return ''; |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * Generates the attributes for retrieving a google_map artifact. |
|
303 | - * |
|
304 | - * @param EE_Venue $venue |
|
305 | - * @param string $field |
|
306 | - * @return array |
|
307 | - * @throws EE_Error |
|
308 | - */ |
|
309 | - protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
310 | - { |
|
311 | - $state = $venue->state_obj(); |
|
312 | - $country = $venue->country_obj(); |
|
313 | - $atts = array( |
|
314 | - 'id' => $venue->ID(), |
|
315 | - 'address' => $venue->get('VNU_address'), |
|
316 | - 'city' => $venue->get('VNU_city'), |
|
317 | - 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
318 | - 'zip' => $venue->get('VNU_zip'), |
|
319 | - 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
320 | - 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
321 | - 'map_w' => 200, |
|
322 | - 'map_h' => 200, |
|
323 | - ); |
|
324 | - if ($field === 'gmap_url') { |
|
325 | - $atts['type'] = 'url_only'; |
|
326 | - } |
|
327 | - return $atts; |
|
328 | - } |
|
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 | + break; |
|
97 | + |
|
98 | + case '[VENUE_DESCRIPTION]': |
|
99 | + return $this->_venue('description'); |
|
100 | + break; |
|
101 | + |
|
102 | + case '[VENUE_URL]': |
|
103 | + return $this->_venue('url'); |
|
104 | + break; |
|
105 | + |
|
106 | + case '[VENUE_IMAGE]': |
|
107 | + return $this->_venue('image'); |
|
108 | + break; |
|
109 | + |
|
110 | + case '[VENUE_PHONE]': |
|
111 | + return $this->_venue('phone'); |
|
112 | + break; |
|
113 | + |
|
114 | + case '[VENUE_ADDRESS]': |
|
115 | + return $this->_venue('address'); |
|
116 | + break; |
|
117 | + |
|
118 | + case '[VENUE_ADDRESS2]': |
|
119 | + return $this->_venue('address2'); |
|
120 | + break; |
|
121 | + |
|
122 | + case '[VENUE_CITY]': |
|
123 | + return $this->_venue('city'); |
|
124 | + break; |
|
125 | + |
|
126 | + case '[VENUE_COUNTRY]': |
|
127 | + return $this->_venue('country'); |
|
128 | + break; |
|
129 | + |
|
130 | + case '[VENUE_STATE]': |
|
131 | + return $this->_venue('state'); |
|
132 | + break; |
|
133 | + |
|
134 | + case '[VENUE_ZIP]': |
|
135 | + return $this->_venue('zip'); |
|
136 | + break; |
|
137 | + |
|
138 | + case '[VENUE_FORMATTED_ADDRESS]': |
|
139 | + return $this->_venue('formatted_address'); |
|
140 | + break; |
|
141 | + |
|
142 | + case '[GOOGLE_MAP_URL]': |
|
143 | + return $this->_venue('gmap_url'); |
|
144 | + break; |
|
145 | + |
|
146 | + case '[GOOGLE_MAP_LINK]': |
|
147 | + return $this->_venue('gmap_link'); |
|
148 | + break; |
|
149 | + |
|
150 | + case '[GOOGLE_MAP_IMAGE]': |
|
151 | + return $this->_venue('gmap_link_img'); |
|
152 | + break; |
|
153 | + |
|
154 | + case '[VENUE_DETAILS_URL]': |
|
155 | + return $this->_venue('permalink'); |
|
156 | + break; |
|
157 | + } |
|
158 | + |
|
159 | + if (strpos($shortcode, '[VENUE_META_*') !== false) { |
|
160 | + $shortcode = str_replace('[VENUE_META_*', '', $shortcode); |
|
161 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
162 | + |
|
163 | + // pull the meta value from the venue post |
|
164 | + $venue_meta = $this->_venue->get_post_meta($shortcode, true); |
|
165 | + |
|
166 | + return ! empty($venue_meta) ? $venue_meta : ''; |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * This retrieves the EE_Venue from the available data object. |
|
172 | + * |
|
173 | + * @return EE_Venue|null |
|
174 | + * @throws EE_Error |
|
175 | + * @throws EntityNotFoundException |
|
176 | + */ |
|
177 | + private function _get_venue() |
|
178 | + { |
|
179 | + |
|
180 | + // we need the EE_Event object to get the venue. |
|
181 | + $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
182 | + |
|
183 | + // 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 |
|
184 | + // reg_obj instead. |
|
185 | + if (! $this->_event instanceof EE_Event) { |
|
186 | + $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
187 | + $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
188 | + |
|
189 | + $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
190 | + ? $aee->reg_obj->event() |
|
191 | + : null; |
|
192 | + |
|
193 | + // if still empty do we have a ticket data item? |
|
194 | + $this->_event = ! $this->_event instanceof EE_Event |
|
195 | + && $this->_data instanceof EE_Ticket |
|
196 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
197 | + ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
198 | + : $this->_event; |
|
199 | + |
|
200 | + // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
|
201 | + // and use that. |
|
202 | + $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee |
|
203 | + ? reset($aee->events) |
|
204 | + : $this->_event; |
|
205 | + } |
|
206 | + |
|
207 | + // If we have an event object use it to pull the venue. |
|
208 | + if ($this->_event instanceof EE_Event) { |
|
209 | + return $this->_event->get_first_related('Venue'); |
|
210 | + } |
|
211 | + |
|
212 | + return null; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * This retrieves the specified venue information |
|
217 | + * |
|
218 | + * @param string $field What Venue field to retrieve |
|
219 | + * @return string What was retrieved! |
|
220 | + * @throws EE_Error |
|
221 | + * @throws EntityNotFoundException |
|
222 | + */ |
|
223 | + private function _venue($field) |
|
224 | + { |
|
225 | + |
|
226 | + if (! $this->_venue instanceof EE_Venue) { |
|
227 | + return ''; |
|
228 | + } //no venue so get out. |
|
229 | + |
|
230 | + switch ($field) { |
|
231 | + case 'title': |
|
232 | + return $this->_venue->get('VNU_name'); |
|
233 | + break; |
|
234 | + |
|
235 | + case 'description': |
|
236 | + return $this->_venue->get('VNU_desc'); |
|
237 | + break; |
|
238 | + |
|
239 | + case 'url': |
|
240 | + $url = $this->_venue->get('VNU_url'); |
|
241 | + return empty($url) ? $this->_venue->get_permalink() : $url; |
|
242 | + break; |
|
243 | + |
|
244 | + case 'permalink': |
|
245 | + return $this->_venue->get_permalink(); |
|
246 | + break; |
|
247 | + |
|
248 | + case 'image': |
|
249 | + return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
250 | + . '" alt="' . sprintf( |
|
251 | + esc_attr__('%s Feature Image', 'event_espresso'), |
|
252 | + $this->_venue->get('VNU_name') |
|
253 | + ) . '" />'; |
|
254 | + break; |
|
255 | + |
|
256 | + case 'phone': |
|
257 | + return $this->_venue->get('VNU_phone'); |
|
258 | + break; |
|
259 | + |
|
260 | + case 'address': |
|
261 | + return $this->_venue->get('VNU_address'); |
|
262 | + break; |
|
263 | + |
|
264 | + case 'address2': |
|
265 | + return $this->_venue->get('VNU_address2'); |
|
266 | + break; |
|
267 | + |
|
268 | + case 'city': |
|
269 | + return $this->_venue->get('VNU_city'); |
|
270 | + break; |
|
271 | + |
|
272 | + case 'state': |
|
273 | + $state = $this->_venue->state_obj(); |
|
274 | + return is_object($state) ? $state->get('STA_name') : ''; |
|
275 | + break; |
|
276 | + |
|
277 | + case 'country': |
|
278 | + $country = $this->_venue->country_obj(); |
|
279 | + return is_object($country) ? $country->get('CNT_name') : ''; |
|
280 | + break; |
|
281 | + |
|
282 | + case 'zip': |
|
283 | + return $this->_venue->get('VNU_zip'); |
|
284 | + break; |
|
285 | + |
|
286 | + case 'formatted_address': |
|
287 | + return EEH_Address::format($this->_venue); |
|
288 | + break; |
|
289 | + |
|
290 | + case 'gmap_link': |
|
291 | + case 'gmap_url': |
|
292 | + case 'gmap_link_img': |
|
293 | + $atts = $this->get_map_attributes($this->_venue, $field); |
|
294 | + return EEH_Maps::google_map_link($atts); |
|
295 | + break; |
|
296 | + } |
|
297 | + return ''; |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * Generates the attributes for retrieving a google_map artifact. |
|
303 | + * |
|
304 | + * @param EE_Venue $venue |
|
305 | + * @param string $field |
|
306 | + * @return array |
|
307 | + * @throws EE_Error |
|
308 | + */ |
|
309 | + protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
310 | + { |
|
311 | + $state = $venue->state_obj(); |
|
312 | + $country = $venue->country_obj(); |
|
313 | + $atts = array( |
|
314 | + 'id' => $venue->ID(), |
|
315 | + 'address' => $venue->get('VNU_address'), |
|
316 | + 'city' => $venue->get('VNU_city'), |
|
317 | + 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
318 | + 'zip' => $venue->get('VNU_zip'), |
|
319 | + 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
320 | + 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
321 | + 'map_w' => 200, |
|
322 | + 'map_h' => 200, |
|
323 | + ); |
|
324 | + if ($field === 'gmap_url') { |
|
325 | + $atts['type'] = 'url_only'; |
|
326 | + } |
|
327 | + return $atts; |
|
328 | + } |
|
329 | 329 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return '<img src="' |
105 | 105 | . EE_Registry::instance()->CFG->organization->get_pretty( |
106 | 106 | 'logo_url' |
107 | - ) . '" id="headerImage" />'; |
|
107 | + ).'" id="headerImage" />'; |
|
108 | 108 | break; |
109 | 109 | |
110 | 110 | case '[CO_LOGO_URL]': |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | // set custom attrs if present (or default) |
151 | 151 | $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
152 | - return $prefix . $tax_number; |
|
152 | + return $prefix.$tax_number; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | return ''; |
@@ -17,139 +17,139 @@ |
||
17 | 17 | */ |
18 | 18 | class EE_Organization_Shortcodes extends EE_Shortcodes |
19 | 19 | { |
20 | - public function __construct() |
|
21 | - { |
|
22 | - parent::__construct(); |
|
23 | - } |
|
24 | - |
|
25 | - |
|
26 | - protected function _init_props() |
|
27 | - { |
|
28 | - $this->label = esc_html__('Organization Shortcodes', 'event_espresso'); |
|
29 | - $this->description = esc_html__('All shortcodes specific to organization related data', 'event_espresso'); |
|
30 | - $this->_shortcodes = array( |
|
31 | - '[COMPANY]' => esc_html__('Event organization name', 'event_espresso'), |
|
32 | - '[CO_ADD1]' => esc_html__('Address 1 value for the organization', 'event_espresso'), |
|
33 | - '[CO_ADD2]' => esc_html__('Address 2 value for the organization', 'event_espresso'), |
|
34 | - '[CO_CITY]' => esc_html__('City the organization is in', 'event_espresso'), |
|
35 | - '[CO_STATE]' => esc_html__('State the organization is located in', 'event_espresso'), |
|
36 | - '[CO_ZIP]' => esc_html__('The zip code for the organization', 'event_espresso'), |
|
37 | - '[CO_LOGO]' => esc_html__('The logo image for the organization', 'event_espresso'), |
|
38 | - '[CO_EMAIL]' => esc_html__('The primary email address for the organization', 'event_espresso'), |
|
39 | - '[CO_PHONE]' => esc_html__('The phone number for the organization', 'event_espresso'), |
|
40 | - '[CO_LOGO_URL]' => esc_html__( |
|
41 | - 'Just the link to the image used as the logo for the organization', |
|
42 | - 'event_espresso' |
|
43 | - ), |
|
44 | - '[CO_FACEBOOK_URL]' => esc_html__('Link to organization Facebook page', 'event_espresso'), |
|
45 | - '[CO_TWITTER_URL]' => esc_html__('Link to organization Twitter page', 'event_espresso'), |
|
46 | - '[CO_PINTEREST_URL]' => esc_html__('Link to organization Pinterest page', 'event_espresso'), |
|
47 | - '[CO_GOOGLE_URL]' => esc_html__('Link to organization Google page', 'event_espresso'), |
|
48 | - '[CO_LINKEDIN_URL]' => esc_html__('Link to organization LinkedIn page', 'event_espresso'), |
|
49 | - '[CO_INSTAGRAM_URL]' => esc_html__('Link to organization Instagram page', 'event_espresso'), |
|
50 | - '[CO_TAX_NUMBER_*]' => sprintf( |
|
51 | - esc_html__( |
|
52 | - 'This is the shortcode used for displaying any tax number for the company. %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56. Also take note that if you have NO number in your settings, the prefix is not output either.', |
|
53 | - 'event_espresso' |
|
54 | - ), |
|
55 | - '<strong>', |
|
56 | - '</strong>' |
|
57 | - ), |
|
58 | - ); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - protected function _parser($shortcode) |
|
63 | - { |
|
64 | - |
|
65 | - switch ($shortcode) { |
|
66 | - case '[COMPANY]': |
|
67 | - return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
68 | - break; |
|
69 | - |
|
70 | - case '[CO_ADD1]': |
|
71 | - return EE_Registry::instance()->CFG->organization->get_pretty('address_1'); |
|
72 | - break; |
|
73 | - |
|
74 | - case '[CO_ADD2]': |
|
75 | - return EE_Registry::instance()->CFG->organization->get_pretty('address_2'); |
|
76 | - break; |
|
77 | - |
|
78 | - case '[CO_CITY]': |
|
79 | - return EE_Registry::instance()->CFG->organization->get_pretty('city'); |
|
80 | - break; |
|
81 | - |
|
82 | - case '[CO_STATE]': |
|
83 | - $state = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
|
84 | - EE_Registry::instance()->CFG->organization->STA_ID |
|
85 | - ); |
|
86 | - return $state instanceof EE_State ? $state->name() : ''; |
|
87 | - break; |
|
88 | - |
|
89 | - case '[CO_ZIP]': |
|
90 | - return EE_Registry::instance()->CFG->organization->get_pretty('zip'); |
|
91 | - break; |
|
92 | - |
|
93 | - case '[CO_EMAIL]': |
|
94 | - return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
95 | - break; |
|
96 | - |
|
97 | - case '[CO_PHONE]': |
|
98 | - return EE_Registry::instance()->CFG->organization->get_pretty('phone'); |
|
99 | - break; |
|
100 | - |
|
101 | - case '[CO_LOGO]': |
|
102 | - return '<img src="' |
|
103 | - . EE_Registry::instance()->CFG->organization->get_pretty( |
|
104 | - 'logo_url' |
|
105 | - ) . '" id="headerImage" />'; |
|
106 | - break; |
|
107 | - |
|
108 | - case '[CO_LOGO_URL]': |
|
109 | - return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
110 | - break; |
|
111 | - |
|
112 | - case '[CO_FACEBOOK_URL]': |
|
113 | - return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
114 | - break; |
|
115 | - |
|
116 | - case '[CO_TWITTER_URL]': |
|
117 | - return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
118 | - break; |
|
119 | - |
|
120 | - case '[CO_PINTEREST_URL]': |
|
121 | - return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
122 | - break; |
|
123 | - |
|
124 | - case '[CO_LINKEDIN_URL]': |
|
125 | - return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
126 | - break; |
|
127 | - |
|
128 | - case '[CO_GOOGLE_URL]': |
|
129 | - return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
130 | - break; |
|
131 | - |
|
132 | - case '[CO_INSTAGRAM_URL]': |
|
133 | - return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
134 | - break; |
|
135 | - } |
|
136 | - |
|
137 | - // also allow for parameter shortcode |
|
138 | - if (strpos($shortcode, '[CO_TAX_NUMBER_*') !== false) { |
|
139 | - // first see if there is any company tax number set and bail early if not |
|
140 | - $tax_number = EE_Registry::instance()->CFG->organization->vat; |
|
141 | - if (empty($tax_number)) { |
|
142 | - return ''; |
|
143 | - } |
|
144 | - |
|
145 | - // see if there are any attributes. |
|
146 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
147 | - |
|
148 | - // set custom attrs if present (or default) |
|
149 | - $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
150 | - return $prefix . $tax_number; |
|
151 | - } |
|
152 | - |
|
153 | - return ''; |
|
154 | - } |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + parent::__construct(); |
|
23 | + } |
|
24 | + |
|
25 | + |
|
26 | + protected function _init_props() |
|
27 | + { |
|
28 | + $this->label = esc_html__('Organization Shortcodes', 'event_espresso'); |
|
29 | + $this->description = esc_html__('All shortcodes specific to organization related data', 'event_espresso'); |
|
30 | + $this->_shortcodes = array( |
|
31 | + '[COMPANY]' => esc_html__('Event organization name', 'event_espresso'), |
|
32 | + '[CO_ADD1]' => esc_html__('Address 1 value for the organization', 'event_espresso'), |
|
33 | + '[CO_ADD2]' => esc_html__('Address 2 value for the organization', 'event_espresso'), |
|
34 | + '[CO_CITY]' => esc_html__('City the organization is in', 'event_espresso'), |
|
35 | + '[CO_STATE]' => esc_html__('State the organization is located in', 'event_espresso'), |
|
36 | + '[CO_ZIP]' => esc_html__('The zip code for the organization', 'event_espresso'), |
|
37 | + '[CO_LOGO]' => esc_html__('The logo image for the organization', 'event_espresso'), |
|
38 | + '[CO_EMAIL]' => esc_html__('The primary email address for the organization', 'event_espresso'), |
|
39 | + '[CO_PHONE]' => esc_html__('The phone number for the organization', 'event_espresso'), |
|
40 | + '[CO_LOGO_URL]' => esc_html__( |
|
41 | + 'Just the link to the image used as the logo for the organization', |
|
42 | + 'event_espresso' |
|
43 | + ), |
|
44 | + '[CO_FACEBOOK_URL]' => esc_html__('Link to organization Facebook page', 'event_espresso'), |
|
45 | + '[CO_TWITTER_URL]' => esc_html__('Link to organization Twitter page', 'event_espresso'), |
|
46 | + '[CO_PINTEREST_URL]' => esc_html__('Link to organization Pinterest page', 'event_espresso'), |
|
47 | + '[CO_GOOGLE_URL]' => esc_html__('Link to organization Google page', 'event_espresso'), |
|
48 | + '[CO_LINKEDIN_URL]' => esc_html__('Link to organization LinkedIn page', 'event_espresso'), |
|
49 | + '[CO_INSTAGRAM_URL]' => esc_html__('Link to organization Instagram page', 'event_espresso'), |
|
50 | + '[CO_TAX_NUMBER_*]' => sprintf( |
|
51 | + esc_html__( |
|
52 | + 'This is the shortcode used for displaying any tax number for the company. %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56. Also take note that if you have NO number in your settings, the prefix is not output either.', |
|
53 | + 'event_espresso' |
|
54 | + ), |
|
55 | + '<strong>', |
|
56 | + '</strong>' |
|
57 | + ), |
|
58 | + ); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + protected function _parser($shortcode) |
|
63 | + { |
|
64 | + |
|
65 | + switch ($shortcode) { |
|
66 | + case '[COMPANY]': |
|
67 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
68 | + break; |
|
69 | + |
|
70 | + case '[CO_ADD1]': |
|
71 | + return EE_Registry::instance()->CFG->organization->get_pretty('address_1'); |
|
72 | + break; |
|
73 | + |
|
74 | + case '[CO_ADD2]': |
|
75 | + return EE_Registry::instance()->CFG->organization->get_pretty('address_2'); |
|
76 | + break; |
|
77 | + |
|
78 | + case '[CO_CITY]': |
|
79 | + return EE_Registry::instance()->CFG->organization->get_pretty('city'); |
|
80 | + break; |
|
81 | + |
|
82 | + case '[CO_STATE]': |
|
83 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
|
84 | + EE_Registry::instance()->CFG->organization->STA_ID |
|
85 | + ); |
|
86 | + return $state instanceof EE_State ? $state->name() : ''; |
|
87 | + break; |
|
88 | + |
|
89 | + case '[CO_ZIP]': |
|
90 | + return EE_Registry::instance()->CFG->organization->get_pretty('zip'); |
|
91 | + break; |
|
92 | + |
|
93 | + case '[CO_EMAIL]': |
|
94 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
95 | + break; |
|
96 | + |
|
97 | + case '[CO_PHONE]': |
|
98 | + return EE_Registry::instance()->CFG->organization->get_pretty('phone'); |
|
99 | + break; |
|
100 | + |
|
101 | + case '[CO_LOGO]': |
|
102 | + return '<img src="' |
|
103 | + . EE_Registry::instance()->CFG->organization->get_pretty( |
|
104 | + 'logo_url' |
|
105 | + ) . '" id="headerImage" />'; |
|
106 | + break; |
|
107 | + |
|
108 | + case '[CO_LOGO_URL]': |
|
109 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
110 | + break; |
|
111 | + |
|
112 | + case '[CO_FACEBOOK_URL]': |
|
113 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
114 | + break; |
|
115 | + |
|
116 | + case '[CO_TWITTER_URL]': |
|
117 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
118 | + break; |
|
119 | + |
|
120 | + case '[CO_PINTEREST_URL]': |
|
121 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
122 | + break; |
|
123 | + |
|
124 | + case '[CO_LINKEDIN_URL]': |
|
125 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
126 | + break; |
|
127 | + |
|
128 | + case '[CO_GOOGLE_URL]': |
|
129 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
130 | + break; |
|
131 | + |
|
132 | + case '[CO_INSTAGRAM_URL]': |
|
133 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
134 | + break; |
|
135 | + } |
|
136 | + |
|
137 | + // also allow for parameter shortcode |
|
138 | + if (strpos($shortcode, '[CO_TAX_NUMBER_*') !== false) { |
|
139 | + // first see if there is any company tax number set and bail early if not |
|
140 | + $tax_number = EE_Registry::instance()->CFG->organization->vat; |
|
141 | + if (empty($tax_number)) { |
|
142 | + return ''; |
|
143 | + } |
|
144 | + |
|
145 | + // see if there are any attributes. |
|
146 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
147 | + |
|
148 | + // set custom attrs if present (or default) |
|
149 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
150 | + return $prefix . $tax_number; |
|
151 | + } |
|
152 | + |
|
153 | + return ''; |
|
154 | + } |
|
155 | 155 | } |
@@ -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,93 +16,93 @@ |
||
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 | - protected function _parser($shortcode) |
|
48 | - { |
|
49 | - // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
50 | - if (! $this->_data instanceof EE_Payment) { |
|
51 | - return ''; |
|
52 | - } |
|
47 | + protected function _parser($shortcode) |
|
48 | + { |
|
49 | + // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
50 | + if (! $this->_data instanceof EE_Payment) { |
|
51 | + return ''; |
|
52 | + } |
|
53 | 53 | |
54 | - $payment = $this->_data; |
|
54 | + $payment = $this->_data; |
|
55 | 55 | |
56 | - switch ($shortcode) { |
|
57 | - case '[PAYMENT_TIMESTAMP]': |
|
58 | - return $payment->timestamp(); |
|
59 | - break; |
|
56 | + switch ($shortcode) { |
|
57 | + case '[PAYMENT_TIMESTAMP]': |
|
58 | + return $payment->timestamp(); |
|
59 | + break; |
|
60 | 60 | |
61 | - case '[PAYMENT_METHOD]': |
|
62 | - // previously the column 'PAY_source' was known as 'PAY_method' |
|
63 | - return $payment->source(); |
|
64 | - break; |
|
61 | + case '[PAYMENT_METHOD]': |
|
62 | + // previously the column 'PAY_source' was known as 'PAY_method' |
|
63 | + return $payment->source(); |
|
64 | + break; |
|
65 | 65 | |
66 | - case '[PAYMENT_AMOUNT]': |
|
67 | - return $payment->amount_no_code(); |
|
68 | - break; |
|
66 | + case '[PAYMENT_AMOUNT]': |
|
67 | + return $payment->amount_no_code(); |
|
68 | + break; |
|
69 | 69 | |
70 | - case '[PAYMENT_GATEWAY]': |
|
71 | - // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
72 | - if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
73 | - return $payment->payment_method()->name(); |
|
74 | - } else { |
|
75 | - return esc_html__('Unknown', 'event_espresso'); |
|
76 | - } |
|
77 | - break; |
|
70 | + case '[PAYMENT_GATEWAY]': |
|
71 | + // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
72 | + if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
73 | + return $payment->payment_method()->name(); |
|
74 | + } else { |
|
75 | + return esc_html__('Unknown', 'event_espresso'); |
|
76 | + } |
|
77 | + break; |
|
78 | 78 | |
79 | - case '[PAYMENT_GATEWAY_RESPONSE]': |
|
80 | - return $payment->gateway_response(); |
|
81 | - break; |
|
79 | + case '[PAYMENT_GATEWAY_RESPONSE]': |
|
80 | + return $payment->gateway_response(); |
|
81 | + break; |
|
82 | 82 | |
83 | - case '[PAYMENT_GATEWAY_TXN_ID]': |
|
84 | - return $payment->txn_id_chq_nmbr(); |
|
85 | - break; |
|
83 | + case '[PAYMENT_GATEWAY_TXN_ID]': |
|
84 | + return $payment->txn_id_chq_nmbr(); |
|
85 | + break; |
|
86 | 86 | |
87 | - case '[PAYMENT_PO_NUMBER]': |
|
88 | - return $payment->po_number(); |
|
89 | - break; |
|
87 | + case '[PAYMENT_PO_NUMBER]': |
|
88 | + return $payment->po_number(); |
|
89 | + break; |
|
90 | 90 | |
91 | - case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
92 | - return $payment->extra_accntng(); |
|
93 | - break; |
|
91 | + case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
92 | + return $payment->extra_accntng(); |
|
93 | + break; |
|
94 | 94 | |
95 | - case '[PAYMENT_STATUS]': |
|
96 | - return $payment->pretty_status(); |
|
97 | - break; |
|
95 | + case '[PAYMENT_STATUS]': |
|
96 | + return $payment->pretty_status(); |
|
97 | + break; |
|
98 | 98 | |
99 | - case '[PAYMENT_STATUS_WITH_ICONS]': |
|
100 | - return $payment->pretty_status(true); |
|
101 | - break; |
|
99 | + case '[PAYMENT_STATUS_WITH_ICONS]': |
|
100 | + return $payment->pretty_status(true); |
|
101 | + break; |
|
102 | 102 | |
103 | - default: |
|
104 | - return ''; |
|
105 | - break; |
|
106 | - } |
|
107 | - } |
|
103 | + default: |
|
104 | + return ''; |
|
105 | + break; |
|
106 | + } |
|
107 | + } |
|
108 | 108 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // now it's possible that $recipient is not an instance of EE_Messages_Addressee in which case we need to see if $this->_data is an instance of $event. |
60 | 60 | $event = $this->_data instanceof EE_Event ? $this->_data : null; |
61 | 61 | |
62 | - if (! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
62 | + if ( ! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
63 | 63 | return ''; |
64 | 64 | } |
65 | 65 | |
@@ -83,22 +83,22 @@ discard block |
||
83 | 83 | break; |
84 | 84 | |
85 | 85 | case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
86 | - if (! empty($recipient)) { |
|
86 | + if ( ! empty($recipient)) { |
|
87 | 87 | $email = ! empty($recipient->fname) |
88 | - ? $recipient->fname . ' ' . $recipient->lname . '<' . $recipient->admin_email . '>' |
|
88 | + ? $recipient->fname.' '.$recipient->lname.'<'.$recipient->admin_email.'>' |
|
89 | 89 | : EE_Registry::instance()->CFG->organization->get_pretty( |
90 | 90 | 'name' |
91 | - ) . '<' . $recipient->admin_email . '>'; |
|
91 | + ).'<'.$recipient->admin_email.'>'; |
|
92 | 92 | } else { |
93 | 93 | $email = null; |
94 | 94 | } |
95 | 95 | if (empty($email) && ! empty($event)) { |
96 | 96 | $user = $this->_get_author_for_event($event); |
97 | 97 | $email = ! empty($user->first_name) |
98 | - ? $user->first_name . ' ' . $user->last_name . '<' . $user->user_email . '>' |
|
98 | + ? $user->first_name.' '.$user->last_name.'<'.$user->user_email.'>' |
|
99 | 99 | : EE_Registry::instance()->CFG->organization->get_pretty( |
100 | 100 | 'name' |
101 | - ) . '<' . $user->user_email . '>'; |
|
101 | + ).'<'.$user->user_email.'>'; |
|
102 | 102 | } |
103 | 103 | return $email; |
104 | 104 | break; |
@@ -19,116 +19,116 @@ |
||
19 | 19 | */ |
20 | 20 | class EE_Event_Author_Shortcodes extends EE_Shortcodes |
21 | 21 | { |
22 | - public function __construct() |
|
23 | - { |
|
24 | - parent::__construct(); |
|
25 | - } |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + parent::__construct(); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - protected function _init_props() |
|
29 | - { |
|
30 | - $this->label = esc_html__('Event Author Details Shortcodes', 'event_espresso'); |
|
31 | - $this->description = esc_html__('All shortcodes specific to event_author data', 'event_espresso'); |
|
32 | - $this->_shortcodes = array( |
|
33 | - '[EVENT_AUTHOR_FNAME]' => esc_html__('Parses to the first name of the event author.', 'event_espresso'), |
|
34 | - '[EVENT_AUTHOR_LNAME]' => esc_html__('Parses to the last name of the event author.', 'event_espresso'), |
|
35 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' => esc_html__( |
|
36 | - 'Parses to a formatted email address of the event author (fname lname <[email protected]>). <strong>NOTE:</strong> If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
37 | - 'event_espresso' |
|
38 | - ), |
|
39 | - '[EVENT_AUTHOR_EMAIL]' => esc_html__( |
|
40 | - 'Parses to the unformatted email address of the event author', |
|
41 | - 'event_espresso' |
|
42 | - ), |
|
43 | - ); |
|
44 | - } |
|
28 | + protected function _init_props() |
|
29 | + { |
|
30 | + $this->label = esc_html__('Event Author Details Shortcodes', 'event_espresso'); |
|
31 | + $this->description = esc_html__('All shortcodes specific to event_author data', 'event_espresso'); |
|
32 | + $this->_shortcodes = array( |
|
33 | + '[EVENT_AUTHOR_FNAME]' => esc_html__('Parses to the first name of the event author.', 'event_espresso'), |
|
34 | + '[EVENT_AUTHOR_LNAME]' => esc_html__('Parses to the last name of the event author.', 'event_espresso'), |
|
35 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' => esc_html__( |
|
36 | + 'Parses to a formatted email address of the event author (fname lname <[email protected]>). <strong>NOTE:</strong> If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
37 | + 'event_espresso' |
|
38 | + ), |
|
39 | + '[EVENT_AUTHOR_EMAIL]' => esc_html__( |
|
40 | + 'Parses to the unformatted email address of the event author', |
|
41 | + 'event_espresso' |
|
42 | + ), |
|
43 | + ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - protected function _parser($shortcode) |
|
48 | - { |
|
49 | - // make sure we end up with a copy of the EE_Messages_Addressee object |
|
50 | - $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
51 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array( |
|
52 | - $this->_data |
|
53 | - ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] |
|
54 | - : $recipient; |
|
55 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
56 | - ? $this->_extra_data['data'] : $recipient; |
|
47 | + protected function _parser($shortcode) |
|
48 | + { |
|
49 | + // make sure we end up with a copy of the EE_Messages_Addressee object |
|
50 | + $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
51 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array( |
|
52 | + $this->_data |
|
53 | + ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] |
|
54 | + : $recipient; |
|
55 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
56 | + ? $this->_extra_data['data'] : $recipient; |
|
57 | 57 | |
58 | - // now it's possible that $recipient is not an instance of EE_Messages_Addressee in which case we need to see if $this->_data is an instance of $event. |
|
59 | - $event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
58 | + // now it's possible that $recipient is not an instance of EE_Messages_Addressee in which case we need to see if $this->_data is an instance of $event. |
|
59 | + $event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
60 | 60 | |
61 | - if (! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
62 | - return ''; |
|
63 | - } |
|
61 | + if (! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
62 | + return ''; |
|
63 | + } |
|
64 | 64 | |
65 | - switch ($shortcode) { |
|
66 | - case '[EVENT_AUTHOR_FNAME]': |
|
67 | - $fname = ! empty($recipient) ? $recipient->fname : null; |
|
68 | - if (empty($fname) && ! empty($event)) { |
|
69 | - $user = $this->_get_author_for_event($event); |
|
70 | - $fname = $user->first_name; |
|
71 | - } |
|
72 | - return $fname; |
|
73 | - break; |
|
65 | + switch ($shortcode) { |
|
66 | + case '[EVENT_AUTHOR_FNAME]': |
|
67 | + $fname = ! empty($recipient) ? $recipient->fname : null; |
|
68 | + if (empty($fname) && ! empty($event)) { |
|
69 | + $user = $this->_get_author_for_event($event); |
|
70 | + $fname = $user->first_name; |
|
71 | + } |
|
72 | + return $fname; |
|
73 | + break; |
|
74 | 74 | |
75 | - case '[EVENT_AUTHOR_LNAME]': |
|
76 | - $lname = ! empty($recipient) ? $recipient->lname : null; |
|
77 | - if (empty($lname) && ! empty($event)) { |
|
78 | - $user = $this->_get_author_for_event($event); |
|
79 | - $lname = $user->last_name; |
|
80 | - } |
|
81 | - return $lname; |
|
82 | - break; |
|
75 | + case '[EVENT_AUTHOR_LNAME]': |
|
76 | + $lname = ! empty($recipient) ? $recipient->lname : null; |
|
77 | + if (empty($lname) && ! empty($event)) { |
|
78 | + $user = $this->_get_author_for_event($event); |
|
79 | + $lname = $user->last_name; |
|
80 | + } |
|
81 | + return $lname; |
|
82 | + break; |
|
83 | 83 | |
84 | - case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
85 | - if (! empty($recipient)) { |
|
86 | - $email = ! empty($recipient->fname) |
|
87 | - ? $recipient->fname . ' ' . $recipient->lname . '<' . $recipient->admin_email . '>' |
|
88 | - : EE_Registry::instance()->CFG->organization->get_pretty( |
|
89 | - 'name' |
|
90 | - ) . '<' . $recipient->admin_email . '>'; |
|
91 | - } else { |
|
92 | - $email = null; |
|
93 | - } |
|
94 | - if (empty($email) && ! empty($event)) { |
|
95 | - $user = $this->_get_author_for_event($event); |
|
96 | - $email = ! empty($user->first_name) |
|
97 | - ? $user->first_name . ' ' . $user->last_name . '<' . $user->user_email . '>' |
|
98 | - : EE_Registry::instance()->CFG->organization->get_pretty( |
|
99 | - 'name' |
|
100 | - ) . '<' . $user->user_email . '>'; |
|
101 | - } |
|
102 | - return $email; |
|
103 | - break; |
|
84 | + case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
85 | + if (! empty($recipient)) { |
|
86 | + $email = ! empty($recipient->fname) |
|
87 | + ? $recipient->fname . ' ' . $recipient->lname . '<' . $recipient->admin_email . '>' |
|
88 | + : EE_Registry::instance()->CFG->organization->get_pretty( |
|
89 | + 'name' |
|
90 | + ) . '<' . $recipient->admin_email . '>'; |
|
91 | + } else { |
|
92 | + $email = null; |
|
93 | + } |
|
94 | + if (empty($email) && ! empty($event)) { |
|
95 | + $user = $this->_get_author_for_event($event); |
|
96 | + $email = ! empty($user->first_name) |
|
97 | + ? $user->first_name . ' ' . $user->last_name . '<' . $user->user_email . '>' |
|
98 | + : EE_Registry::instance()->CFG->organization->get_pretty( |
|
99 | + 'name' |
|
100 | + ) . '<' . $user->user_email . '>'; |
|
101 | + } |
|
102 | + return $email; |
|
103 | + break; |
|
104 | 104 | |
105 | - case '[EVENT_AUTHOR_EMAIL]': |
|
106 | - $email = ! empty($recipient) ? $recipient->admin_email : null; |
|
107 | - if (empty($email) && ! empty($event)) { |
|
108 | - $user = $this->_get_author_for_event($event); |
|
109 | - $email = $user->user_email; |
|
110 | - } |
|
111 | - return $email; |
|
112 | - break; |
|
105 | + case '[EVENT_AUTHOR_EMAIL]': |
|
106 | + $email = ! empty($recipient) ? $recipient->admin_email : null; |
|
107 | + if (empty($email) && ! empty($event)) { |
|
108 | + $user = $this->_get_author_for_event($event); |
|
109 | + $email = $user->user_email; |
|
110 | + } |
|
111 | + return $email; |
|
112 | + break; |
|
113 | 113 | |
114 | - default: |
|
115 | - return ''; |
|
116 | - break; |
|
117 | - } |
|
118 | - } |
|
114 | + default: |
|
115 | + return ''; |
|
116 | + break; |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | - /** |
|
122 | - * Helper method to return the user object for the author of the given EE_Event |
|
123 | - * |
|
124 | - * @param EE_Event $event |
|
125 | - * |
|
126 | - * @return WP_User |
|
127 | - */ |
|
128 | - private function _get_author_for_event(EE_Event $event) |
|
129 | - { |
|
130 | - $author_id = $event->wp_user(); |
|
131 | - $user_data = get_userdata((int) $author_id); |
|
132 | - return $user_data; |
|
133 | - } |
|
121 | + /** |
|
122 | + * Helper method to return the user object for the author of the given EE_Event |
|
123 | + * |
|
124 | + * @param EE_Event $event |
|
125 | + * |
|
126 | + * @return WP_User |
|
127 | + */ |
|
128 | + private function _get_author_for_event(EE_Event $event) |
|
129 | + { |
|
130 | + $author_id = $event->wp_user(); |
|
131 | + $user_data = get_userdata((int) $author_id); |
|
132 | + return $user_data; |
|
133 | + } |
|
134 | 134 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | |
88 | 88 | case '[CO_FORMATTED_EMAIL]': |
89 | 89 | case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]': |
90 | - return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' |
|
91 | - . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>'; |
|
90 | + return EE_Registry::instance()->CFG->organization->get_pretty('name').' <' |
|
91 | + . EE_Registry::instance()->CFG->organization->get_pretty('email').'>'; |
|
92 | 92 | break; |
93 | 93 | |
94 | 94 | case '[CO_EMAIL]': |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | private function _get_event_admin_emails($fancy_headers = true) |
119 | 119 | { |
120 | 120 | |
121 | - if (! empty($this->_data->admin_email)) { |
|
122 | - if (! $fancy_headers) { |
|
121 | + if ( ! empty($this->_data->admin_email)) { |
|
122 | + if ( ! $fancy_headers) { |
|
123 | 123 | return $this->_data->admin_email; |
124 | 124 | } |
125 | 125 | return ! empty($this->_data->fname) |
126 | - ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' |
|
126 | + ? $this->_data->fname.' '.$this->_data->lname.' <'.$this->_data->admin_email.'>' |
|
127 | 127 | : EE_Registry::instance()->CFG->organization->get_pretty( |
128 | 128 | 'name' |
129 | - ) . ' <' . $this->_data->admin_email . '>'; |
|
129 | + ).' <'.$this->_data->admin_email.'>'; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | $cnt = 0; |
147 | 147 | foreach ($events as $event) { |
148 | 148 | $user = get_userdata($event->get('EVT_wp_user')); |
149 | - $admin_details[ $cnt ] = new stdClass(); |
|
150 | - $admin_details[ $cnt ]->email = $user->user_email; |
|
151 | - $admin_details[ $cnt ]->first_name = $user->user_firstname; |
|
152 | - $admin_details[ $cnt ]->last_name = $user->user_lastname; |
|
149 | + $admin_details[$cnt] = new stdClass(); |
|
150 | + $admin_details[$cnt]->email = $user->user_email; |
|
151 | + $admin_details[$cnt]->first_name = $user->user_firstname; |
|
152 | + $admin_details[$cnt]->last_name = $user->user_lastname; |
|
153 | 153 | $cnt++; |
154 | 154 | } |
155 | 155 | |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | |
172 | - if (! $fancy_headers) { |
|
172 | + if ( ! $fancy_headers) { |
|
173 | 173 | $admin_email[] = $admin->email; |
174 | 174 | continue; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $admin_email[] = ! empty($admin->first_name) |
178 | - ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' |
|
179 | - : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>'; |
|
178 | + ? $admin->first_name.' '.$admin->last_name.' <'.$admin->email.'>' |
|
179 | + : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$admin->email.'>'; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $admin_email = implode(',', $admin_email); |
@@ -17,167 +17,167 @@ |
||
17 | 17 | */ |
18 | 18 | class EE_Email_Shortcodes extends EE_Shortcodes |
19 | 19 | { |
20 | - public function __construct() |
|
21 | - { |
|
22 | - parent::__construct(); |
|
23 | - } |
|
24 | - |
|
25 | - |
|
26 | - protected function _init_props() |
|
27 | - { |
|
28 | - $this->label = esc_html__('Email Shortcodes', 'event_espresso'); |
|
29 | - $this->description = esc_html__('All shortcodes related to emails', 'event_espresso'); |
|
30 | - $this->_shortcodes = array( |
|
31 | - '[SITE_ADMIN_EMAIL]' => esc_html__( |
|
32 | - 'Will be replaced with the admin email for the site that Event Espresso is installed on', |
|
33 | - 'event_espresso' |
|
34 | - ), |
|
35 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' => sprintf( |
|
36 | - esc_html__( |
|
37 | - 'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - '<strong>', |
|
41 | - '</strong>' |
|
42 | - ), |
|
43 | - '[EVENT_AUTHOR_EMAIL]' => sprintf( |
|
44 | - esc_html__( |
|
45 | - 'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', |
|
46 | - 'event_espresso' |
|
47 | - ), |
|
48 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' |
|
49 | - ), |
|
50 | - '[CO_FORMATTED_EMAIL]' => esc_html__( |
|
51 | - 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
52 | - 'event_espresso' |
|
53 | - ), |
|
54 | - '[CO_EMAIL]' => esc_html__( |
|
55 | - 'This will parse to the email address only for the organization set in Your Organization Settings.', |
|
56 | - 'event_espresso' |
|
57 | - ), |
|
58 | - '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__( |
|
59 | - 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
60 | - 'event_espresso' |
|
61 | - ), |
|
62 | - '[ESPRESSO_ADMIN_EMAIL]' => esc_html__( |
|
63 | - 'This parses to the email address only for the organization set in Your Organization Settings page.', |
|
64 | - 'event_espresso' |
|
65 | - ), |
|
66 | - ); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - protected function _parser($shortcode) |
|
71 | - { |
|
72 | - |
|
73 | - switch ($shortcode) { |
|
74 | - case '[SITE_ADMIN_EMAIL]': |
|
75 | - return $this->_get_site_admin_email(); |
|
76 | - break; |
|
77 | - |
|
78 | - case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
79 | - return $this->_get_event_admin_emails(); |
|
80 | - break; |
|
81 | - |
|
82 | - case '[EVENT_AUTHOR_EMAIL]': |
|
83 | - return $this->_get_event_admin_emails(false); |
|
84 | - break; |
|
85 | - |
|
86 | - case '[CO_FORMATTED_EMAIL]': |
|
87 | - case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]': |
|
88 | - return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' |
|
89 | - . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>'; |
|
90 | - break; |
|
91 | - |
|
92 | - case '[CO_EMAIL]': |
|
93 | - case '[ESPRESSO_ADMIN_EMAIL]': |
|
94 | - return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
95 | - break; |
|
96 | - |
|
97 | - default: |
|
98 | - return ''; |
|
99 | - break; |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode) |
|
106 | - * |
|
107 | - * @access private |
|
108 | - * @return string email address of site admin |
|
109 | - */ |
|
110 | - private function _get_site_admin_email() |
|
111 | - { |
|
112 | - return get_bloginfo('admin_email'); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - private function _get_event_admin_emails($fancy_headers = true) |
|
117 | - { |
|
118 | - |
|
119 | - if (! empty($this->_data->admin_email)) { |
|
120 | - if (! $fancy_headers) { |
|
121 | - return $this->_data->admin_email; |
|
122 | - } |
|
123 | - return ! empty($this->_data->fname) |
|
124 | - ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' |
|
125 | - : EE_Registry::instance()->CFG->organization->get_pretty( |
|
126 | - 'name' |
|
127 | - ) . ' <' . $this->_data->admin_email . '>'; |
|
128 | - } |
|
129 | - |
|
130 | - // k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
|
131 | - |
|
132 | - $admin_email = array(); |
|
133 | - |
|
134 | - // loop through events and set the list of event_ids to retrieve so we can do ONE query. |
|
135 | - foreach ($this->_data->events as $event) { |
|
136 | - $ids[] = $event['ID']; |
|
137 | - } |
|
138 | - |
|
139 | - // get all the events |
|
140 | - $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids)))); |
|
141 | - |
|
142 | - // now loop through each event and setup the details |
|
143 | - $admin_details = array(); |
|
144 | - $cnt = 0; |
|
145 | - foreach ($events as $event) { |
|
146 | - $user = get_userdata($event->get('EVT_wp_user')); |
|
147 | - $admin_details[ $cnt ] = new stdClass(); |
|
148 | - $admin_details[ $cnt ]->email = $user->user_email; |
|
149 | - $admin_details[ $cnt ]->first_name = $user->user_firstname; |
|
150 | - $admin_details[ $cnt ]->last_name = $user->user_lastname; |
|
151 | - $cnt++; |
|
152 | - } |
|
153 | - |
|
154 | - // results? |
|
155 | - if (empty($admin_details) || ! is_array($admin_details)) { |
|
156 | - $msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso'); |
|
157 | - $msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql); |
|
158 | - $msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true)); |
|
159 | - $msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true)); |
|
160 | - $msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details)); |
|
161 | - do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser'); |
|
162 | - } |
|
163 | - |
|
164 | - foreach ($admin_details as $admin) { |
|
165 | - // only add an admin email if it is present. |
|
166 | - if (empty($admin->email) || $admin->email == '') { |
|
167 | - continue; |
|
168 | - } |
|
169 | - |
|
170 | - if (! $fancy_headers) { |
|
171 | - $admin_email[] = $admin->email; |
|
172 | - continue; |
|
173 | - } |
|
174 | - |
|
175 | - $admin_email[] = ! empty($admin->first_name) |
|
176 | - ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' |
|
177 | - : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>'; |
|
178 | - } |
|
179 | - |
|
180 | - $admin_email = implode(',', $admin_email); |
|
181 | - return $admin_email; |
|
182 | - } |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + parent::__construct(); |
|
23 | + } |
|
24 | + |
|
25 | + |
|
26 | + protected function _init_props() |
|
27 | + { |
|
28 | + $this->label = esc_html__('Email Shortcodes', 'event_espresso'); |
|
29 | + $this->description = esc_html__('All shortcodes related to emails', 'event_espresso'); |
|
30 | + $this->_shortcodes = array( |
|
31 | + '[SITE_ADMIN_EMAIL]' => esc_html__( |
|
32 | + 'Will be replaced with the admin email for the site that Event Espresso is installed on', |
|
33 | + 'event_espresso' |
|
34 | + ), |
|
35 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' => sprintf( |
|
36 | + esc_html__( |
|
37 | + 'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + '<strong>', |
|
41 | + '</strong>' |
|
42 | + ), |
|
43 | + '[EVENT_AUTHOR_EMAIL]' => sprintf( |
|
44 | + esc_html__( |
|
45 | + 'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', |
|
46 | + 'event_espresso' |
|
47 | + ), |
|
48 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' |
|
49 | + ), |
|
50 | + '[CO_FORMATTED_EMAIL]' => esc_html__( |
|
51 | + 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
52 | + 'event_espresso' |
|
53 | + ), |
|
54 | + '[CO_EMAIL]' => esc_html__( |
|
55 | + 'This will parse to the email address only for the organization set in Your Organization Settings.', |
|
56 | + 'event_espresso' |
|
57 | + ), |
|
58 | + '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__( |
|
59 | + 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
60 | + 'event_espresso' |
|
61 | + ), |
|
62 | + '[ESPRESSO_ADMIN_EMAIL]' => esc_html__( |
|
63 | + 'This parses to the email address only for the organization set in Your Organization Settings page.', |
|
64 | + 'event_espresso' |
|
65 | + ), |
|
66 | + ); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + protected function _parser($shortcode) |
|
71 | + { |
|
72 | + |
|
73 | + switch ($shortcode) { |
|
74 | + case '[SITE_ADMIN_EMAIL]': |
|
75 | + return $this->_get_site_admin_email(); |
|
76 | + break; |
|
77 | + |
|
78 | + case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
79 | + return $this->_get_event_admin_emails(); |
|
80 | + break; |
|
81 | + |
|
82 | + case '[EVENT_AUTHOR_EMAIL]': |
|
83 | + return $this->_get_event_admin_emails(false); |
|
84 | + break; |
|
85 | + |
|
86 | + case '[CO_FORMATTED_EMAIL]': |
|
87 | + case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]': |
|
88 | + return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' |
|
89 | + . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>'; |
|
90 | + break; |
|
91 | + |
|
92 | + case '[CO_EMAIL]': |
|
93 | + case '[ESPRESSO_ADMIN_EMAIL]': |
|
94 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
95 | + break; |
|
96 | + |
|
97 | + default: |
|
98 | + return ''; |
|
99 | + break; |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode) |
|
106 | + * |
|
107 | + * @access private |
|
108 | + * @return string email address of site admin |
|
109 | + */ |
|
110 | + private function _get_site_admin_email() |
|
111 | + { |
|
112 | + return get_bloginfo('admin_email'); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + private function _get_event_admin_emails($fancy_headers = true) |
|
117 | + { |
|
118 | + |
|
119 | + if (! empty($this->_data->admin_email)) { |
|
120 | + if (! $fancy_headers) { |
|
121 | + return $this->_data->admin_email; |
|
122 | + } |
|
123 | + return ! empty($this->_data->fname) |
|
124 | + ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' |
|
125 | + : EE_Registry::instance()->CFG->organization->get_pretty( |
|
126 | + 'name' |
|
127 | + ) . ' <' . $this->_data->admin_email . '>'; |
|
128 | + } |
|
129 | + |
|
130 | + // k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
|
131 | + |
|
132 | + $admin_email = array(); |
|
133 | + |
|
134 | + // loop through events and set the list of event_ids to retrieve so we can do ONE query. |
|
135 | + foreach ($this->_data->events as $event) { |
|
136 | + $ids[] = $event['ID']; |
|
137 | + } |
|
138 | + |
|
139 | + // get all the events |
|
140 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids)))); |
|
141 | + |
|
142 | + // now loop through each event and setup the details |
|
143 | + $admin_details = array(); |
|
144 | + $cnt = 0; |
|
145 | + foreach ($events as $event) { |
|
146 | + $user = get_userdata($event->get('EVT_wp_user')); |
|
147 | + $admin_details[ $cnt ] = new stdClass(); |
|
148 | + $admin_details[ $cnt ]->email = $user->user_email; |
|
149 | + $admin_details[ $cnt ]->first_name = $user->user_firstname; |
|
150 | + $admin_details[ $cnt ]->last_name = $user->user_lastname; |
|
151 | + $cnt++; |
|
152 | + } |
|
153 | + |
|
154 | + // results? |
|
155 | + if (empty($admin_details) || ! is_array($admin_details)) { |
|
156 | + $msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso'); |
|
157 | + $msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql); |
|
158 | + $msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true)); |
|
159 | + $msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true)); |
|
160 | + $msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details)); |
|
161 | + do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser'); |
|
162 | + } |
|
163 | + |
|
164 | + foreach ($admin_details as $admin) { |
|
165 | + // only add an admin email if it is present. |
|
166 | + if (empty($admin->email) || $admin->email == '') { |
|
167 | + continue; |
|
168 | + } |
|
169 | + |
|
170 | + if (! $fancy_headers) { |
|
171 | + $admin_email[] = $admin->email; |
|
172 | + continue; |
|
173 | + } |
|
174 | + |
|
175 | + $admin_email[] = ! empty($admin->first_name) |
|
176 | + ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' |
|
177 | + : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>'; |
|
178 | + } |
|
179 | + |
|
180 | + $admin_email = implode(',', $admin_email); |
|
181 | + return $admin_email; |
|
182 | + } |
|
183 | 183 | } |
@@ -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 | } |